From 3fb4424909d7627a273d3593b0ba57acc041aaff Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 20 Nov 2016 17:15:56 +0100 Subject: [PATCH 01/16] Changed: Improved formatting --HG-- branch : develop --- .../vertex_tree_paint.cpp | 1092 +++++++++-------- 1 file changed, 552 insertions(+), 540 deletions(-) diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp index a2465ba4c..045d8489d 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp @@ -2,11 +2,11 @@ *< FILE: vertex_tree_paint.cpp - DESCRIPTION: Modifier implementation + DESCRIPTION: Modifier implementation CREATED BY: Christer Janson, Nikolai Sander - HISTORY: + HISTORY: *> Copyright (c) 1997, All Rights Reserved. **********************************************************************/ @@ -14,19 +14,20 @@ #include "vertex_tree_paint.h" #include "meshdelta.h" -// flags: + // flags: #define VP_DISP_END_RESULT 0x01 static WNDPROC colorSwatchOriginalWndProc; static HIMAGELIST hButtonImages = NULL; -static void LoadImages() { +static void LoadImages() +{ if (hButtonImages) return; HBITMAP hBitmap, hMask; hButtonImages = ImageList_Create(15, 14, ILC_MASK, 2, 0); // 17 is kluge to center square. -SA - hBitmap = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_BUTTONS)); - hMask = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_BUTTON_MASK)); + hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTTONS)); + hMask = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTTON_MASK)); ImageList_Add(hButtonImages, hBitmap, hMask); DeleteObject(hBitmap); DeleteObject(hMask); @@ -35,282 +36,284 @@ static void LoadImages() { ClassDesc* GetVertexPaintDesc(); -class VertexPaintClassDesc:public ClassDesc { - public: - int IsPublic() {return 1;} - void * Create(BOOL loading = FALSE){return new VertexPaint();} - const TCHAR * ClassName() {return GetString(IDS_CLASS_NAME);} - SClass_ID SuperClassID() {return OSM_CLASS_ID;} - Class_ID ClassID() {return VERTEX_TREE_PAINT_CLASS_ID;} - const TCHAR* Category() {return GetString(IDS_CATEGORY);} +class VertexPaintClassDesc :public ClassDesc +{ +public: + int IsPublic() { return 1; } + void * Create(BOOL loading = FALSE) { return new VertexPaint(); } + const TCHAR * ClassName() { return GetString(IDS_CLASS_NAME); } + SClass_ID SuperClassID() { return OSM_CLASS_ID; } + Class_ID ClassID() { return VERTEX_TREE_PAINT_CLASS_ID; } + const TCHAR* Category() { return GetString(IDS_CATEGORY); } void ResetClassParams(BOOL fileReset) {} - }; +}; static VertexPaintClassDesc VertexPaintDesc; -ClassDesc* GetVertexPaintDesc() {return &VertexPaintDesc;} +ClassDesc* GetVertexPaintDesc() { return &VertexPaintDesc; } -static INT_PTR CALLBACK VertexPaintDlgProc( - HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) - { +static INT_PTR CALLBACK VertexPaintDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ int numPoints; - VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd,GWLP_USERDATA); - if (!mod && msg!=WM_INITDIALOG) return FALSE; + VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (!mod && msg != WM_INITDIALOG) return FALSE; int comboResult; - + // Manages Spinners. - if (((msg==CC_SPINNER_BUTTONUP) && HIWORD(wParam)) || - ((msg==CC_SPINNER_CHANGE) )) + if (((msg == CC_SPINNER_BUTTONUP) && HIWORD(wParam)) || + ((msg == CC_SPINNER_CHANGE))) { ISpinnerControl *spin; - spin = (ISpinnerControl *) lParam; - - switch (LOWORD(wParam)) + spin = (ISpinnerControl *)lParam; + + switch (LOWORD(wParam)) { case IDC_TINT_SPIN: if ((msg == CC_SPINNER_CHANGE)) { - mod->fTint = spin->GetFVal()/100; + mod->fTint = spin->GetFVal() / 100; } break; case IDC_BEND_SPIN: if ((msg == CC_SPINNER_CHANGE)) { - mod->fGradientBend = spin->GetFVal()/100; + mod->fGradientBend = spin->GetFVal() / 100; } break; } } - switch (msg) { - case WM_INITDIALOG: - LoadImages(); - mod = (VertexPaint*)lParam; - SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); - mod->hParams = hWnd; - mod->iPaintButton = GetICustButton(GetDlgItem(hWnd, IDC_PAINT)); - mod->iPaintButton->SetType(CBT_CHECK); - mod->iPaintButton->SetHighlightColor(GREEN_WASH); - mod->iPaintButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && - !((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); - mod->iPaintButton->SetImage(hButtonImages,0,0,0,0,15,14); - mod->iPaintButton->SetTooltip (TRUE, GetString (IDS_PAINT)); + switch (msg) + { + case WM_INITDIALOG: + LoadImages(); + mod = (VertexPaint*)lParam; + SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam); + mod->hParams = hWnd; + mod->iPaintButton = GetICustButton(GetDlgItem(hWnd, IDC_PAINT)); + mod->iPaintButton->SetType(CBT_CHECK); + mod->iPaintButton->SetHighlightColor(GREEN_WASH); + mod->iPaintButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && + !((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); + mod->iPaintButton->SetImage(hButtonImages, 0, 0, 0, 0, 15, 14); + mod->iPaintButton->SetTooltip(TRUE, GetString(IDS_PAINT)); - mod->iPickButton = GetICustButton(GetDlgItem(hWnd, IDC_PICK)); - mod->iPickButton->SetType(CBT_CHECK); - mod->iPickButton->SetHighlightColor(GREEN_WASH); - mod->iPickButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && - ((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); - mod->iPickButton->SetImage(hButtonImages,1,1,1,1,15,14); - mod->iPickButton->SetTooltip (TRUE, GetString (IDS_PICK)); + mod->iPickButton = GetICustButton(GetDlgItem(hWnd, IDC_PICK)); + mod->iPickButton->SetType(CBT_CHECK); + mod->iPickButton->SetHighlightColor(GREEN_WASH); + mod->iPickButton->SetCheck(mod->ip->GetCommandMode()->ID() == CID_PAINT && + ((PaintMouseProc *)mod->ip->GetCommandMode()->MouseProc(&numPoints))->GetPickMode()); + mod->iPickButton->SetImage(hButtonImages, 1, 1, 1, 1, 15, 14); + mod->iPickButton->SetTooltip(TRUE, GetString(IDS_PICK)); - mod->iColor = GetIColorSwatch(GetDlgItem(hWnd, IDC_COLOR)); - // change current Color according to editMode - mod->reloadBkupColor(); + mod->iColor = GetIColorSwatch(GetDlgItem(hWnd, IDC_COLOR)); + // change current Color according to editMode + mod->reloadBkupColor(); - // Get interface For ZGradient, reload bkuped colors - mod->iColorGradient[0] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD0)); - mod->iColorGradient[1] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD1)); - mod->iColorGradient[0]->SetColor(mod->lastGradientColor[0]); - mod->iColorGradient[1]->SetColor(mod->lastGradientColor[1]); + // Get interface For ZGradient, reload bkuped colors + mod->iColorGradient[0] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD0)); + mod->iColorGradient[1] = GetIColorSwatch(GetDlgItem(hWnd, IDC_PALETTE_GRAD1)); + mod->iColorGradient[0]->SetColor(mod->lastGradientColor[0]); + mod->iColorGradient[1]->SetColor(mod->lastGradientColor[1]); - - // Init comboBox - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Tree Weight"); - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 1"); - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 2"); - SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_SETCURSEL, mod->getEditionType(), 0); - // If paint mode at last edit. - if(mod->_LastPaintMode) - { - // ActivatePaint / check button. - mod->ActivatePaint(TRUE); - mod->iPaintButton->SetCheck(TRUE); - } + // Init comboBox + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Tree Weight"); + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 1"); + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)"Phase Level 2"); + SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_SETCURSEL, mod->getEditionType(), 0); - break; - - case WM_POSTINIT: - mod->InitPalettes(); - break; - - case CC_COLOR_CHANGE: - if (LOWORD(wParam) == IDC_COLOR) - { - IColorSwatch* iCol = (IColorSwatch*)lParam; - switch(mod->getEditionType()) - { - case 0: mod->lastWeightColor = iCol->GetColor(); break; - case 1: - case 2: - mod->lastPhaseColor = iCol->GetColor(); break; - } - } - break; - case WM_DESTROY: - mod->SavePalettes(); - mod->iPaintButton = NULL; - mod->iPickButton = NULL; - mod->iColor = NULL; - mod->iColorGradient[0] = NULL; - mod->iColorGradient[1] = NULL; - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDC_PAINT: - mod->ActivatePaint(mod->iPaintButton->IsChecked()); - break; - case IDC_PICK: - mod->ActivatePaint(mod->iPickButton->IsChecked(),TRUE); - break; - - case IDC_VC_ON: - mod->TurnVCOn(FALSE); - break; - case IDC_SHADED: - mod->TurnVCOn(TRUE); - break; - case IDC_COMBO_TYPE: - // Init default type. - comboResult= SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0); - mod->setEditionType(comboResult); - break; - case IDC_BUTTON_FILL: - mod->fillSelectionColor(); - break; - case IDC_BUTTON_GRADIENT: - mod->fillSelectionGradientColor(); - break; - case IDC_BUTTON_GRAD0: - mod->iColorGradient[0]->SetColor(RGB(0,0,0)); - mod->iColorGradient[1]->SetColor(RGB(85,85,85)); - break; - case IDC_BUTTON_GRAD1: - mod->iColorGradient[0]->SetColor(RGB(85,85,85)); - mod->iColorGradient[1]->SetColor(RGB(170,170,170)); - break; - case IDC_BUTTON_GRAD2: - mod->iColorGradient[0]->SetColor(RGB(170,170,170)); - mod->iColorGradient[1]->SetColor(RGB(255,255,255)); - break; - } - break; - - default: - return FALSE; + // If paint mode at last edit. + if (mod->_LastPaintMode) + { + // ActivatePaint / check button. + mod->ActivatePaint(TRUE); + mod->iPaintButton->SetCheck(TRUE); } + + break; + + case WM_POSTINIT: + mod->InitPalettes(); + break; + + case CC_COLOR_CHANGE: + if (LOWORD(wParam) == IDC_COLOR) + { + IColorSwatch* iCol = (IColorSwatch*)lParam; + switch (mod->getEditionType()) + { + case 0: mod->lastWeightColor = iCol->GetColor(); break; + case 1: + case 2: + mod->lastPhaseColor = iCol->GetColor(); break; + } + } + break; + case WM_DESTROY: + mod->SavePalettes(); + mod->iPaintButton = NULL; + mod->iPickButton = NULL; + mod->iColor = NULL; + mod->iColorGradient[0] = NULL; + mod->iColorGradient[1] = NULL; + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_PAINT: + mod->ActivatePaint(mod->iPaintButton->IsChecked()); + break; + case IDC_PICK: + mod->ActivatePaint(mod->iPickButton->IsChecked(), TRUE); + break; + + case IDC_VC_ON: + mod->TurnVCOn(FALSE); + break; + case IDC_SHADED: + mod->TurnVCOn(TRUE); + break; + case IDC_COMBO_TYPE: + // Init default type. + comboResult = SendDlgItemMessage(hWnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0); + mod->setEditionType(comboResult); + break; + case IDC_BUTTON_FILL: + mod->fillSelectionColor(); + break; + case IDC_BUTTON_GRADIENT: + mod->fillSelectionGradientColor(); + break; + case IDC_BUTTON_GRAD0: + mod->iColorGradient[0]->SetColor(RGB(0, 0, 0)); + mod->iColorGradient[1]->SetColor(RGB(85, 85, 85)); + break; + case IDC_BUTTON_GRAD1: + mod->iColorGradient[0]->SetColor(RGB(85, 85, 85)); + mod->iColorGradient[1]->SetColor(RGB(170, 170, 170)); + break; + case IDC_BUTTON_GRAD2: + mod->iColorGradient[0]->SetColor(RGB(170, 170, 170)); + mod->iColorGradient[1]->SetColor(RGB(255, 255, 255)); + break; + } + break; + + default: + return FALSE; + } return TRUE; - } +} // Subclass procedure -LRESULT APIENTRY colorSwatchSubclassWndProc( - HWND hwnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) +LRESULT APIENTRY colorSwatchSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_LBUTTONDBLCLK: { - HWND hPanel = GetParent(hwnd); - LONG_PTR mod = GetWindowLongPtr(hPanel,GWLP_USERDATA); - if (mod) { - ((VertexPaint*)mod)->PaletteButton(hwnd); - } - } - break; - case WM_DESTROY: - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) colorSwatchOriginalWndProc); - // Fallthrough... - default: - return CallWindowProc(colorSwatchOriginalWndProc, hwnd, uMsg, wParam, lParam); - break; + switch (uMsg) + { + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + { + HWND hPanel = GetParent(hwnd); + LONG_PTR mod = GetWindowLongPtr(hPanel, GWLP_USERDATA); + if (mod) + { + ((VertexPaint*)mod)->PaletteButton(hwnd); } - return 0; } - + break; + case WM_DESTROY: + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)colorSwatchOriginalWndProc); + // Fallthrough... + default: + return CallWindowProc(colorSwatchOriginalWndProc, hwnd, uMsg, wParam, lParam); + break; + } + return 0; +} -IObjParam *VertexPaint::ip = NULL; -HWND VertexPaint::hParams = NULL; -VertexPaint* VertexPaint::editMod = NULL; -ICustButton* VertexPaint::iPaintButton = NULL; -ICustButton* VertexPaint::iPickButton = NULL; -IColorSwatch* VertexPaint::iColor = NULL; -COLORREF VertexPaint::lastWeightColor = RGB(85,85,85); -COLORREF VertexPaint::lastPhaseColor = RGB(0,0,0); -COLORREF VertexPaint::palColors[] = { + +IObjParam *VertexPaint::ip = NULL; +HWND VertexPaint::hParams = NULL; +VertexPaint* VertexPaint::editMod = NULL; +ICustButton* VertexPaint::iPaintButton = NULL; +ICustButton* VertexPaint::iPickButton = NULL; +IColorSwatch* VertexPaint::iColor = NULL; +COLORREF VertexPaint::lastWeightColor = RGB(85, 85, 85); +COLORREF VertexPaint::lastPhaseColor = RGB(0, 0, 0); +COLORREF VertexPaint::palColors[] = +{ //RGB(32, 32, 32), RGB( 96,96,96), RGB( 160,160,160), RGB(224,224,224) }; - RGB(0, 0, 0), RGB( 85,85,85), RGB( 170,170,170), RGB(255,255,255), - RGB(42, 42, 42), RGB( 127, 127, 127), RGB( 212, 212, 212)}; + RGB(0, 0, 0), RGB(85,85,85), RGB(170,170,170), RGB(255,255,255), + RGB(42, 42, 42), RGB(127, 127, 127), RGB(212, 212, 212) }; -IColorSwatch* VertexPaint::iColorGradient[]= {NULL, NULL}; -COLORREF VertexPaint::lastGradientColor[] = {RGB(0, 0, 0), RGB(85, 85, 85)}; +IColorSwatch* VertexPaint::iColorGradient[] = { NULL, NULL }; +COLORREF VertexPaint::lastGradientColor[] = { RGB(0, 0, 0), RGB(85, 85, 85) }; //--- VertexPaint ------------------------------------------------------- VertexPaint::VertexPaint() : iTint(NULL), fTint(1.0f), iGradientBend(NULL), fGradientBend(0.0f) - { +{ flags = 0x0; - _EditType= 0; - _LastPaintMode= false; - } + _EditType = 0; + _LastPaintMode = false; +} VertexPaint::~VertexPaint() - { - } +{ +} Interval VertexPaint::LocalValidity(TimeValue t) - { +{ return FOREVER; - } +} BOOL VertexPaint::DependOnTopology(ModContext &mc) - { +{ return TRUE; - } +} RefTargetHandle VertexPaint::Clone(RemapDir& remap) - { - VertexPaint* newmod = new VertexPaint(); +{ + VertexPaint* newmod = new VertexPaint(); return(newmod); - } +} void VertexPaint::NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) - { +{ if (!mc->localData) return; ((VertexPaintData*)mc->localData)->FreeCache(); - } +} -void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) - { +void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) +{ if (!os->obj->IsSubClassOf(triObjectClassID)) return; - - os->obj->ReadyChannelsForMod(GEOM_CHANNEL|TOPO_CHANNEL|VERTCOLOR_CHANNEL|TEXMAP_CHANNEL); - + + os->obj->ReadyChannelsForMod(GEOM_CHANNEL | TOPO_CHANNEL | VERTCOLOR_CHANNEL | TEXMAP_CHANNEL); + TriObject *tobj = (TriObject*)os->obj; - VertexPaintData *d = (VertexPaintData*)mc.localData; - + VertexPaintData *d = (VertexPaintData*)mc.localData; + Mesh* mesh = &tobj->GetMesh(); - - if (mesh) + + if (mesh) { // We don't have any VColors yet, so we allocate the vcfaces // and set all vcolors to black (index 0) - if (!mesh->vcFace) + if (!mesh->vcFace) { mesh->setNumVCFaces(mesh->getNumFaces()); mesh->setNumVertCol(1); - - mesh->vertCol[0] = Color(0,0,0); - for (int f=0; fgetNumFaces(); f++) + mesh->vertCol[0] = Color(0, 0, 0); + + for (int f = 0; f < mesh->getNumFaces(); f++) { mesh->vcFace[f].t[0] = 0; mesh->vcFace[f].t[1] = 0; @@ -318,10 +321,10 @@ void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, IN } } - if (!d) mc.localData = d = new VertexPaintData(tobj->GetMesh()); - if (!d->GetMesh()) d->SetCache(*mesh); + if (!d) mc.localData = d = new VertexPaintData(tobj->GetMesh()); + if (!d->GetMesh()) d->SetCache(*mesh); + - { MeshDelta md(*mesh); //MeshDelta mdc; @@ -330,141 +333,139 @@ void VertexPaint::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, IN // If the incoming Mesh had no vertex colors, this will add a default map to start with. // The default map has the same topology as the Mesh (so one color per vertex), // with all colors set to white. - if (!mesh->mapSupport(0)) md.AddVertexColors (); + if (!mesh->mapSupport(0)) md.AddVertexColors(); //if (cache && !cache->mapSupport(0)) mdc.AddVertexColors (); - + // We used two routines -- VCreate to add new map vertices, and FRemap to make the // existing map faces use the new verts. frFlags tell FRemap which vertices on a face // should be "remapped", and the ww array contains the new locations. VertColor nvc; int j; - for (int v=0; v < d->GetNumColors(); v++) + for (int v = 0; v < d->GetNumColors(); v++) { ColorData cd = d->GetColorData(v); - + // Edition Mode ?? - if(editMod == this) + if (editMod == this) { - nvc= Color(cd.color); + nvc = Color(cd.color); // change color to view only monochromatic info for this channel; - switch(_EditType) + switch (_EditType) { - case 0: nvc.y= nvc.z= nvc.x; - nvc.y*= 0.7f; - nvc.z*= 0.7f; + case 0: nvc.y = nvc.z = nvc.x; + nvc.y *= 0.7f; + nvc.z *= 0.7f; break; - case 1: nvc.x= nvc.z= nvc.y; - nvc.x*= 0.7f; - nvc.z*= 0.7f; + case 1: nvc.x = nvc.z = nvc.y; + nvc.x *= 0.7f; + nvc.z *= 0.7f; break; - case 2: nvc.x= nvc.y= nvc.z; - nvc.x*= 0.7f; - nvc.y*= 0.7f; + case 2: nvc.x = nvc.y = nvc.z; + nvc.x *= 0.7f; + nvc.y *= 0.7f; break; } } else { // replace the VertexColor of the outgoing mesh - nvc= Color(cd.color); + nvc = Color(cd.color); } DWORD ww[3], frFlags; - - md.map->VCreate (&nvc); - + + md.map->VCreate(&nvc); + // increase the number of vcol's and set the vcfaces as well - for(int i = 0 ; i < d->GetNVert(v).faces.Count() ; i++) - { + for (int i = 0; i < d->GetNVert(v).faces.Count(); i++) + { j = d->GetNVert(v).whichVertex[i]; - frFlags = (1<outVNum()-1; + frFlags = (1 << j); + ww[j] = md.map->outVNum() - 1; md.map->FRemap(d->GetNVert(v).faces[i], frFlags, ww); - + } - } + } md.Apply(*mesh); } - + NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); - os->obj->UpdateValidity(VERT_COLOR_CHAN_NUM, Interval(t,t)); + os->obj->UpdateValidity(VERT_COLOR_CHAN_NUM, Interval(t, t)); } } static bool oldShowEnd; -void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) - { - +void VertexPaint::BeginEditParams(IObjParam *ip, ULONG flags, Animatable *prev) +{ + this->ip = ip; editMod = this; - if (!hParams) { - hParams = ip->AddRollupPage( - hInstance, - MAKEINTRESOURCE(IDD_PANEL), - VertexPaintDlgProc, - GetString(IDS_PARAMS), - (LPARAM)this); + if (!hParams) + { + hParams = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_PANEL), VertexPaintDlgProc, GetString(IDS_PARAMS), (LPARAM)this); // Subclass the palette controls - hPaletteWnd[ 0] = GetDlgItem(hParams, IDC_PALETTE_1); - hPaletteWnd[ 1] = GetDlgItem(hParams, IDC_PALETTE_2); - hPaletteWnd[ 2] = GetDlgItem(hParams, IDC_PALETTE_3); - hPaletteWnd[ 3] = GetDlgItem(hParams, IDC_PALETTE_4); - hPaletteWnd[ 4] = GetDlgItem(hParams, IDC_PALETTE_5); - hPaletteWnd[ 5] = GetDlgItem(hParams, IDC_PALETTE_6); - hPaletteWnd[ 6] = GetDlgItem(hParams, IDC_PALETTE_7); + hPaletteWnd[0] = GetDlgItem(hParams, IDC_PALETTE_1); + hPaletteWnd[1] = GetDlgItem(hParams, IDC_PALETTE_2); + hPaletteWnd[2] = GetDlgItem(hParams, IDC_PALETTE_3); + hPaletteWnd[3] = GetDlgItem(hParams, IDC_PALETTE_4); + hPaletteWnd[4] = GetDlgItem(hParams, IDC_PALETTE_5); + hPaletteWnd[5] = GetDlgItem(hParams, IDC_PALETTE_6); + hPaletteWnd[6] = GetDlgItem(hParams, IDC_PALETTE_7); int i; - for (i=0; iGetShowEndResult() ? TRUE : FALSE; - ip->SetShowEndResult (GetFlag (VP_DISP_END_RESULT)); + ip->SetShowEndResult(GetFlag(VP_DISP_END_RESULT)); // Force an eval to update caches. NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); } -void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) - { +void VertexPaint::EndEditParams(IObjParam *ip, ULONG flags, Animatable *next) +{ // Dsiable Painting. - bool lpm= _LastPaintMode; + bool lpm = _LastPaintMode; ActivatePaint(FALSE); // bkup lastPainMode - _LastPaintMode= lpm; - - ReleaseISpinner (iTint); - ReleaseISpinner (iGradientBend); - + _LastPaintMode = lpm; + + ReleaseISpinner(iTint); + ReleaseISpinner(iGradientBend); + ModContextList list; INodeTab nodes; - ip->GetModContexts(list,nodes); - for (int i=0; iGetModContexts(list, nodes); + for (int i = 0; i < list.Count(); i++) + { VertexPaintData *vd = (VertexPaintData*)list[i]->localData; if (vd) vd->FreeCache(); } nodes.DisposeTemporary(); // Reset show end result - SetFlag (VP_DISP_END_RESULT, ip->GetShowEndResult() ? TRUE : FALSE); + SetFlag(VP_DISP_END_RESULT, ip->GetShowEndResult() ? TRUE : FALSE); ip->SetShowEndResult(oldShowEnd); @@ -476,47 +477,45 @@ void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) ip->DeleteRollupPage(hParams); hParams = NULL; iTint = NULL; - iGradientBend= NULL; + iGradientBend = NULL; this->ip = NULL; - } +} //From ReferenceMaker -RefResult VertexPaint::NotifyRefChanged( - Interval changeInt, RefTargetHandle hTarget, - PartID& partID, RefMessage message) - { +RefResult VertexPaint::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) +{ return REF_SUCCEED; - } +} -int VertexPaint::NumRefs() - { +int VertexPaint::NumRefs() +{ return 0; - } +} -RefTargetHandle VertexPaint::GetReference(int i) - { +RefTargetHandle VertexPaint::GetReference(int i) +{ return NULL; - } +} void VertexPaint::SetReference(int i, RefTargetHandle rtarg) - { - } +{ +} -int VertexPaint::NumSubs() - { +int VertexPaint::NumSubs() +{ return 0; - } +} -Animatable* VertexPaint::SubAnim(int i) - { - return NULL; - } +Animatable* VertexPaint::SubAnim(int i) +{ + return NULL; +} -TSTR VertexPaint::SubAnimName(int i) - { +TSTR VertexPaint::SubAnimName(int i) +{ return _T(""); - } +} #define VERSION_CHUNKID 0x100 @@ -525,66 +524,70 @@ TSTR VertexPaint::SubAnimName(int i) static int currentVersion = 1; IOResult VertexPaint::Load(ILoad *iload) - { +{ IOResult res; ULONG nb; int version = 1; Modifier::Load(iload); - while (IO_OK==(res=iload->OpenChunk())) { - switch(iload->CurChunkID()) { - case VERSION_CHUNKID: - iload->Read (&version, sizeof(version), &nb); - break; - } - iload->CloseChunk(); - if (res!=IO_OK) return res; + while (IO_OK == (res = iload->OpenChunk())) + { + switch (iload->CurChunkID()) + { + case VERSION_CHUNKID: + iload->Read(&version, sizeof(version), &nb); + break; } - - return IO_OK; + iload->CloseChunk(); + if (res != IO_OK) return res; } + return IO_OK; +} + IOResult VertexPaint::Save(ISave *isave) - { +{ IOResult res; ULONG nb; Modifier::Save(isave); isave->BeginChunk(VERSION_CHUNKID); - res = isave->Write (¤tVersion, sizeof(int), &nb); + res = isave->Write(¤tVersion, sizeof(int), &nb); isave->EndChunk(); return IO_OK; - } +} IOResult VertexPaint::SaveLocalData(ISave *isave, LocalModData *ld) - { +{ VertexPaintData* d = (VertexPaintData*)ld; IOResult res; ULONG nb; int numColors; ColorData col; - + isave->BeginChunk(VERSION_CHUNKID); - res = isave->Write (¤tVersion, sizeof(int), &nb); + res = isave->Write(¤tVersion, sizeof(int), &nb); isave->EndChunk(); - + isave->BeginChunk(COLORLIST_CHUNKID); numColors = d->GetNumColors(); res = isave->Write(&numColors, sizeof(int), &nb); - for (int i=0; iGetColorData(i); - isave->Write(&col.color,sizeof(col.color),&nb); - } + isave->Write(&col.color, sizeof(col.color), &nb); + } isave->EndChunk(); return IO_OK; - } +} -IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) { +IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) +{ VertexPaintData *d = new VertexPaintData; - IOResult res; + IOResult res; ULONG nb; int version = 1; int numColors; @@ -592,74 +595,80 @@ IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) { *pld = d; - while (IO_OK==(res=iload->OpenChunk())) { - switch(iload->CurChunkID()) { + while (IO_OK == (res = iload->OpenChunk())) + { + switch (iload->CurChunkID()) + { case VERSION_CHUNKID: - iload->Read (&version, sizeof(version), &nb); - break; + iload->Read(&version, sizeof(version), &nb); + break; case COLORLIST_CHUNKID: - { - iload->Read(&numColors,sizeof(int), &nb); - d->AllocColorData(numColors); - for (int i=0; iRead(&col.color,sizeof(col.color), &nb); - d->SetColor(i, col); - } - } - break; + { + iload->Read(&numColors, sizeof(int), &nb); + d->AllocColorData(numColors); + for (int i = 0; i < numColors; i++) + { + iload->Read(&col.color, sizeof(col.color), &nb); + d->SetColor(i, col); } - iload->CloseChunk(); - if (res!=IO_OK) return res; } - return IO_OK; + break; + } + iload->CloseChunk(); + if (res != IO_OK) return res; } + return IO_OK; +} void VertexPaint::PaletteButton(HWND hWnd) - { +{ IColorSwatch* iPal = GetIColorSwatch(hWnd); - if (iPal && iColor) { + if (iPal && iColor) + { iColor->SetColor(iPal->GetColor(), TRUE); - } } +} void VertexPaint::InitPalettes() - { +{ IColorSwatch* c; - for (int i=0; iSetColor(palColors[i]); ReleaseIColorSwatch(c); - } } +} void VertexPaint::SavePalettes() - { +{ IColorSwatch* c; - for (int i=0; iGetColor(); ReleaseIColorSwatch(c); - } - // Save Gradient Palettes. - lastGradientColor[0]= iColorGradient[0]->GetColor(); - lastGradientColor[1]= iColorGradient[1]->GetColor(); } + // Save Gradient Palettes. + lastGradientColor[0] = iColorGradient[0]->GetColor(); + lastGradientColor[1] = iColorGradient[1]->GetColor(); +} void VertexPaint::TurnVCOn(BOOL shaded) { ModContextList list; INodeTab NodeTab; - - // Only the selected nodes will be affected - ip->GetModContexts(list,NodeTab); - for( int i = 0 ; i < NodeTab.Count() ; i++) + // Only the selected nodes will be affected + ip->GetModContexts(list, NodeTab); + + for (int i = 0; i < NodeTab.Count(); i++) { - if(shaded) + if (shaded) NodeTab[i]->SetShadeCVerts(!NodeTab[i]->GetShadeCVerts()); else - NodeTab[i]->SetCVertMode(!NodeTab[i]->GetCVertMode()); - + NodeTab[i]->SetCVertMode(!NodeTab[i]->GetCVertMode()); + } NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime()); @@ -669,37 +678,37 @@ void VertexPaint::TurnVCOn(BOOL shaded) // ***************************************************************** void VertexPaint::setEditionType(int editMode) { - if(editMode<0) editMode= 0; - if(editMode>2) editMode= 2; + if (editMode < 0) editMode = 0; + if (editMode > 2) editMode = 2; // backup current Color according to editMode backupCurrentColor(); - _EditType= editMode; + _EditType = editMode; NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); ip->RedrawViews(ip->GetTime()); // Change Color Swatch according to editMode. IColorSwatch* c; - for (int i=0; i=4) + if (i >= 4) { - if(editMode==0) - val= 42 + (i-4)*255 / (4-1); // 42, 127, 212 + if (editMode == 0) + val = 42 + (i - 4) * 255 / (4 - 1); // 42, 127, 212 else - val= 0; // Phase not used + val = 0; // Phase not used } // Setup Color - palColors[i]= RGB(val, val, val); + palColors[i] = RGB(val, val, val); c = GetIColorSwatch(hPaletteWnd[i]); @@ -714,7 +723,7 @@ void VertexPaint::setEditionType(int editMode) // ***************************************************************** void VertexPaint::backupCurrentColor() { - switch(getEditionType()) + switch (getEditionType()) { case 0: lastWeightColor = iColor->GetColor(); break; case 1: @@ -724,10 +733,10 @@ void VertexPaint::backupCurrentColor() void VertexPaint::reloadBkupColor() { // Change current color according to editMode. - switch(getEditionType()) + switch (getEditionType()) { case 0: iColor->SetColor(lastWeightColor); break; - case 1: + case 1: case 2: iColor->SetColor(lastPhaseColor); break; } } @@ -739,18 +748,18 @@ void VertexPaint::fillSelectionColor() int mci; // Put Data in Undo/Redo List. - if(!theHold.Holding()) + if (!theHold.Holding()) theHold.Begin(); - + ModContextList modContexts; INodeTab nodeTab; - + GetCOREInterface()->GetModContexts(modContexts, nodeTab); - - for (mci=0; mcilocalData) + if (mc && mc->localData) theHold.Put(new VertexPaintRestore((VertexPaintData*)mc->localData, this)); } @@ -759,42 +768,42 @@ void VertexPaint::fillSelectionColor() // Which Component to change?? VertexPaintData::TComponent whichComponent; - switch(getEditionType()) + switch (getEditionType()) { - case 0: whichComponent= VertexPaintData::Red; break; - case 1: whichComponent= VertexPaintData::Green; break; - case 2: whichComponent= VertexPaintData::Blue; break; + case 0: whichComponent = VertexPaintData::Red; break; + case 1: whichComponent = VertexPaintData::Green; break; + case 2: whichComponent = VertexPaintData::Blue; break; } // Modify all meshes. - for (mci=0; mcilocalData) + if (mc && mc->localData) { VertexPaintData* d = (VertexPaintData*)mc->localData; - Mesh* mesh = d->GetMesh(); - if (mesh && mesh->vertCol) + Mesh* mesh = d->GetMesh(); + if (mesh && mesh->vertCol) { // For all faces of the mesh - for(int fi=0; figetNumFaces(); fi++) + for (int fi = 0; fi < mesh->getNumFaces(); fi++) { Face* f = &mesh->faces[fi]; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { // Skip painting because not selected?? - if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] ) + if (mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]]) continue; - if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) + if (mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) continue; // Also skip if face is hidden. - if(f->Hidden()) + if (f->Hidden()) continue; // Apply painting - d->SetColor(f->v[i], 1, GetActiveColor(), whichComponent); + d->SetColor(f->v[i], 1, GetActiveColor(), whichComponent); } } } @@ -812,18 +821,18 @@ void VertexPaint::fillSelectionGradientColor() int mci; // Put Data in Undo/Redo List. - if(!theHold.Holding()) + if (!theHold.Holding()) theHold.Begin(); - + ModContextList modContexts; INodeTab nodeTab; - + GetCOREInterface()->GetModContexts(modContexts, nodeTab); - - for (mci=0; mcilocalData) + if (mc && mc->localData) theHold.Put(new VertexPaintRestore((VertexPaintData*)mc->localData, this)); } @@ -832,14 +841,14 @@ void VertexPaint::fillSelectionGradientColor() // Which Component to change?? VertexPaintData::TComponent whichComponent; - switch(getEditionType()) + switch (getEditionType()) { - case 0: whichComponent= VertexPaintData::Red; break; - case 1: whichComponent= VertexPaintData::Green; break; - case 2: whichComponent= VertexPaintData::Blue; break; + case 0: whichComponent = VertexPaintData::Red; break; + case 1: whichComponent = VertexPaintData::Green; break; + case 2: whichComponent = VertexPaintData::Blue; break; } - COLORREF grad0= iColorGradient[0]->GetColor(); - COLORREF grad1= iColorGradient[1]->GetColor(); + COLORREF grad0 = iColorGradient[0]->GetColor(); + COLORREF grad1 = iColorGradient[1]->GetColor(); // Get Matrix to viewport. @@ -853,72 +862,72 @@ void VertexPaint::fillSelectionGradientColor() // Modify all meshes. - for (mci=0; mcilocalData) + if (mc && mc->localData) { VertexPaintData* d = (VertexPaintData*)mc->localData; - Mesh* mesh = d->GetMesh(); - if (mesh && mesh->vertCol) + Mesh* mesh = d->GetMesh(); + if (mesh && mesh->vertCol) { - float yMini= FLT_MAX; - float yMaxi= -FLT_MAX; + float yMini = FLT_MAX; + float yMaxi = -FLT_MAX; // 1st, For all faces of the mesh, comute BBox of selection. int fi; - for(fi=0; figetNumFaces(); fi++) + for (fi = 0; fi < mesh->getNumFaces(); fi++) { Face* f = &mesh->faces[fi]; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { // Skip painting because not selected?? - if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] ) + if (mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]]) continue; - if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) + if (mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) continue; // Also skip if face is hidden. - if(f->Hidden()) + if (f->Hidden()) continue; // Transform to viewSpace. - Point3 p= viewMat*mesh->getVert(f->v[i]); + Point3 p = viewMat*mesh->getVert(f->v[i]); // extend bbox. - yMini= p.yyMaxi?p.y:yMaxi; + yMini = p.y < yMini ? p.y : yMini; + yMaxi = p.y > yMaxi ? p.y : yMaxi; } } // 2nd, For all faces of the mesh, fill with gradient - for(fi=0; figetNumFaces(); fi++) + for (fi = 0; fi < mesh->getNumFaces(); fi++) { Face* f = &mesh->faces[fi]; - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { // Skip painting because not selected?? - if(mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]] ) + if (mesh->selLevel == MESH_VERTEX && !mesh->VertSel()[f->v[i]]) continue; - if(mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) + if (mesh->selLevel == MESH_FACE && !mesh->FaceSel()[fi]) continue; // Also skip if face is hidden. - if(f->Hidden()) + if (f->Hidden()) continue; // Compute gradientValue. float gradValue; - Point3 p= viewMat*mesh->getVert(f->v[i]); - gradValue= (p.y-yMini)/(yMaxi-yMini); + Point3 p = viewMat*mesh->getVert(f->v[i]); + gradValue = (p.y - yMini) / (yMaxi - yMini); // Modifie with bendPower. 1->6. - float pow= 1 + fGradientBend * 5; - gradValue= powf(gradValue, pow); + float pow = 1 + fGradientBend * 5; + gradValue = powf(gradValue, pow); // Apply painting // Reset To 0. - d->SetColor(f->v[i], 1, grad0, whichComponent); + d->SetColor(f->v[i], 1, grad0, whichComponent); // Blend with gradientValue. - d->SetColor(f->v[i], gradValue, grad1, whichComponent); + d->SetColor(f->v[i], gradValue, grad1, whichComponent); } } @@ -933,34 +942,34 @@ void VertexPaint::fillSelectionGradientColor() // ***************************************************************** -VertexPaintData::VertexPaintData(Mesh& m) : mesh(NULL), colordata(NULL), nverts(NULL), +VertexPaintData::VertexPaintData(Mesh& m) : mesh(NULL), colordata(NULL), nverts(NULL), nvcverts(NULL), numColors(0), numnverts(0), numnvcverts(0) { SetCache(m); } -VertexPaintData::VertexPaintData() : mesh(NULL), colordata(NULL), nverts(NULL), +VertexPaintData::VertexPaintData() : mesh(NULL), colordata(NULL), nverts(NULL), nvcverts(NULL), numColors(0), numnverts(0), numnvcverts(0) { } VertexPaintData::~VertexPaintData() - { +{ FreeCache(); - if (colordata) delete [] colordata; - if(nverts) delete [] nverts; - if(nvcverts) delete [] nvcverts; + if (colordata) delete[] colordata; + if (nverts) delete[] nverts; + if (nvcverts) delete[] nvcverts; nverts = NULL; nvcverts = NULL; colordata = NULL; - + numColors = 0; numnverts = 0; numnvcverts = 0; - } +} void VertexPaintData::SetCache(Mesh& m) { @@ -968,31 +977,31 @@ void VertexPaintData::SetCache(Mesh& m) mesh = new Mesh(m); SynchVerts(m); AllocColorData(mesh->getNumVerts()); - + } void VertexPaintData::FreeCache() - { +{ if (mesh) delete mesh; - if(nverts) delete [] nverts; - if(nvcverts) delete [] nvcverts; + if (nverts) delete[] nverts; + if (nvcverts) delete[] nvcverts; mesh = NULL; nverts = NULL; nvcverts = NULL; numnverts = 0; numnvcverts = 0; - } +} Mesh* VertexPaintData::GetMesh() - { +{ return mesh; - } +} NVert& VertexPaintData::GetNVert(int i) { static NVert nv; - + if (numnverts > i) return nverts[i]; else @@ -1002,7 +1011,7 @@ NVert& VertexPaintData::GetNVert(int i) NVert& VertexPaintData::GetNVCVert(int i) { static NVert nv; - + if (numnvcverts > i) return nvcverts[i]; else @@ -1010,70 +1019,70 @@ NVert& VertexPaintData::GetNVCVert(int i) } COLORREF& VertexPaintData::GetColor(int i) - { - static COLORREF c = RGB(0,0,0); +{ + static COLORREF c = RGB(0, 0, 0); if (numColors > i) return colordata[i].color; else return c; - } +} ColorData& VertexPaintData::GetColorData(int i) - { +{ static ColorData c; if (numColors > i) return colordata[i]; else return c; - } +} void VertexPaintData::SetColor(int i, float bary, COLORREF c, TComponent whichComp) { - - if (colordata && numColors > i) + + if (colordata && numColors > i) { // change color. - COLORREF oldColor= colordata[i].color; + COLORREF oldColor = colordata[i].color; int oldVal; int editVal; int newVal; - + // Mask good component. - switch(whichComp) + switch (whichComp) { case Red: - oldVal= GetRValue(colordata[i].color); - editVal= GetRValue(c); + oldVal = GetRValue(colordata[i].color); + editVal = GetRValue(c); break; case Green: - oldVal= GetGValue(colordata[i].color); - editVal= GetGValue(c); + oldVal = GetGValue(colordata[i].color); + editVal = GetGValue(c); break; case Blue: - oldVal= GetBValue(colordata[i].color); - editVal= GetBValue(c); + oldVal = GetBValue(colordata[i].color); + editVal = GetBValue(c); break; } // Blend Color component // This color was set before ! - float alpha = (1.0f-bary); - + float alpha = (1.0f - bary); + // Compute new value - newVal= (int)(alpha*oldVal + bary*editVal); + newVal = (int)(alpha*oldVal + bary*editVal); // Mask good component. - switch(whichComp) + switch (whichComp) { case Red: - colordata[i].color= (RGB(newVal, 0, 0)) | (oldColor & RGB(0,255,255)); + colordata[i].color = (RGB(newVal, 0, 0)) | (oldColor & RGB(0, 255, 255)); break; case Green: - colordata[i].color= (RGB(0, newVal, 0)) | (oldColor & RGB(255,0,255)); + colordata[i].color = (RGB(0, newVal, 0)) | (oldColor & RGB(255, 0, 255)); break; case Blue: - colordata[i].color= (RGB(0, 0, newVal)) | (oldColor & RGB(255,255,0)); + colordata[i].color = (RGB(0, 0, newVal)) | (oldColor & RGB(255, 255, 0)); break; } @@ -1082,47 +1091,47 @@ void VertexPaintData::SetColor(int i, float bary, COLORREF c, TComponent whichCo void VertexPaintData::SetColor(int i, const ColorData &c) { - if (colordata && numColors > i) + if (colordata && numColors > i) { - colordata[i]= c; + colordata[i] = c; } } int VertexPaintData::GetNumColors() - { +{ return numColors; - } +} void VertexPaintData::AllocColorData(int numcols) - { +{ ColorData* newColorData; // Colors already exist. if (numColors == numcols) return; - - if (numColors > 0 ) + + if (numColors > 0) { // If the new number of colors is bigger than what we have in the colordata array - if(numcols > numColors) + if (numcols > numColors) { // Allocate a new color list and fill in as many as // we have from the previous set newColorData = new ColorData[numcols]; - - for (int i=0; icolordata = new ColorData[numColors]; d->numColors = numColors; - for (int i=0; icolordata[i] = colordata[i]; - } } - if(nverts) + } + if (nverts) { d->nverts = new NVert[numnverts]; - for(int i = 0 ; i < numnverts ; i++ ) { + for (int i = 0; i < numnverts; i++) + { d->nverts[i] = nverts[i]; } } - if(nvcverts) + if (nvcverts) { d->nvcverts = new NVert[numnvcverts]; - for(int i = 0 ; i < numnvcverts ; i++ ) { + for (int i = 0; i < numnvcverts; i++) + { d->nvcverts[i] = nvcverts[i]; } } return d; - } - +} void VertexPaintData::SynchVerts(Mesh &m) { @@ -1177,47 +1189,47 @@ void VertexPaintData::SynchVerts(Mesh &m) return; } - if(nverts) - delete [] nverts; - + if (nverts) + delete[] nverts; + numnverts = m.getNumVerts(); - + nverts = new NVert[numnverts]; - if(nvcverts) - delete [] nvcverts; - + if (nvcverts) + delete[] nvcverts; + numnvcverts = m.getNumVertCol(); nvcverts = new NVert[numnvcverts]; - - for(int i = 0 ; i < mesh->getNumFaces() ; i++) - { + + for (int i = 0; i < mesh->getNumFaces(); i++) + { // for each vertex of each face - for(int j = 0 ; j < 3 ; j++) - { + for (int j = 0; j < 3; j++) + { int iCur = nverts[mesh->faces[i].v[j]].faces.Count(); - + // Tell the vertex, which to which face it belongs and which // of the three face v-indices corresponds to the vertex - - nverts[mesh->faces[i].v[j]].faces.SetCount(iCur+1); - nverts[mesh->faces[i].v[j]].whichVertex.SetCount(iCur+1); + + nverts[mesh->faces[i].v[j]].faces.SetCount(iCur + 1); + nverts[mesh->faces[i].v[j]].whichVertex.SetCount(iCur + 1); nverts[mesh->faces[i].v[j]].faces[iCur] = i; nverts[mesh->faces[i].v[j]].whichVertex[iCur] = j; - - - if(mesh->vcFace) + + + if (mesh->vcFace) { // Do the same for texture vertices - iCur = nvcverts[mesh->vcFace[i].t[j]].faces.Count(); - - nvcverts[mesh->vcFace[i].t[j]].faces.SetCount(iCur+1); - nvcverts[mesh->vcFace[i].t[j]].whichVertex.SetCount(iCur+1); - - nvcverts[mesh->vcFace[i].t[j]].faces[iCur] = i; - nvcverts[mesh->vcFace[i].t[j]].whichVertex[iCur] = j; + iCur = nvcverts[mesh->vcFace[i].t[j]].faces.Count(); + + nvcverts[mesh->vcFace[i].t[j]].faces.SetCount(iCur + 1); + nvcverts[mesh->vcFace[i].t[j]].whichVertex.SetCount(iCur + 1); + + nvcverts[mesh->vcFace[i].t[j]].faces[iCur] = i; + nvcverts[mesh->vcFace[i].t[j]].whichVertex[iCur] = j; } else @@ -1269,11 +1281,11 @@ ColorData::ColorData() : color(0) //** //*************************************************************************** -VertexPaintRestore::VertexPaintRestore(VertexPaintData *pLocalData, VertexPaint *pVPaint) -: pMod(pVPaint), pPaintData(pLocalData), redoColordata(NULL) +VertexPaintRestore::VertexPaintRestore(VertexPaintData *pLocalData, VertexPaint *pVPaint) + : pMod(pVPaint), pPaintData(pLocalData), redoColordata(NULL) { colordata = new ColorData[pPaintData->numColors]; - for(int i = 0; i < pPaintData->numColors ; i++) + for (int i = 0; i < pPaintData->numColors; i++) { colordata[i] = pPaintData->colordata[i]; } @@ -1283,16 +1295,16 @@ VertexPaintRestore::VertexPaintRestore(VertexPaintData *pLocalData, VertexPaint VertexPaintRestore::~VertexPaintRestore() { - if(colordata) - delete [] colordata; - - if(redoColordata) - delete [] redoColordata; + if (colordata) + delete[] colordata; + + if (redoColordata) + delete[] redoColordata; } void VertexPaintRestore::Restore(int isUndo) { - if(isUndo) + if (isUndo) { nlassert(pPaintData->colordata); @@ -1303,7 +1315,7 @@ void VertexPaintRestore::Restore(int isUndo) pPaintData->numColors = numcolors; colordata = NULL; - + pMod->NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime()); } @@ -1312,28 +1324,28 @@ void VertexPaintRestore::Restore(int isUndo) void VertexPaintRestore::Redo() { nlassert(pPaintData->colordata); - + colordata = pPaintData->colordata; numcolors = pPaintData->numColors; - + pPaintData->colordata = redoColordata; pPaintData->numColors = redonumcolors; - + redoColordata = NULL; pMod->NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime()); - + } int VertexPaintRestore::Size() { int iSize = 0; - - if(colordata) + + if (colordata) iSize += sizeof(ColorData) * numcolors; - - if(redoColordata) + + if (redoColordata) iSize += sizeof(ColorData) * redonumcolors; return iSize; From 88bfa8ec70e82d28f98e58990a881e80de70b8f9 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 13:22:05 +0100 Subject: [PATCH 02/16] Fixed: Warnings --HG-- branch : develop --- code/ryzom/client/src/seven_zip/7zMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/seven_zip/7zMain.cpp b/code/ryzom/client/src/seven_zip/7zMain.cpp index 0e5417ad9..63b5a2bd7 100644 --- a/code/ryzom/client/src/seven_zip/7zMain.cpp +++ b/code/ryzom/client/src/seven_zip/7zMain.cpp @@ -323,7 +323,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s) UIntToStr_2(s, sec); s[2] = 0; } -void PrintError(char *sz) +void PrintError(const char *sz) { printf("\nERROR: %s\n", sz); } From 7afe10373b68421ac27b1c523dc86d8b10cc29fa Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 16:35:18 +0100 Subject: [PATCH 03/16] Fixed: Use default path for ryzom_installer.log is installation directory not defined --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index a2ea81f00..6adb87d83 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) bool res = config.load(); // init log - CLogHelper logHelper(config.getInstallationDirectory()); + CLogHelper logHelper(config.getInstallationDirectory().isEmpty() ? config.getNewInstallationDirectory():config.getInstallationDirectory()); nlinfo("Launched %s", Q2C(config.getInstallerCurrentFilePath())); From cc331d6295f18adf8915bed7cfc6907f429186b7 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 16:35:28 +0100 Subject: [PATCH 04/16] Fixed: Wrong variable --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 6adb87d83..0ab58302a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) OperationStep step = res ? config.getInstallNextStep():DisplayNoServerError; - if (res == DisplayNoServerError) + if (step == DisplayNoServerError) { QMessageBox::critical(NULL, QApplication::tr("Error"), QApplication::tr("Unable to find ryzom_installer.ini")); return 1; From 501e1d9d271499ef36448562b468332663bb4bb5 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 16:36:12 +0100 Subject: [PATCH 05/16] Fixed: Specify working directory for getVersionFromExecutable --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/configfile.cpp | 2 +- .../tools/client/ryzom_installer/src/profilesdialog.cpp | 5 +++-- code/ryzom/tools/client/ryzom_installer/src/utils.cpp | 3 ++- code/ryzom/tools/client/ryzom_installer/src/utils.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 99f1a54a8..7d14aa223 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -693,7 +693,7 @@ int CConfigFile::compareInstallersVersion() const // if installer not found in installation directory if (!QFile::exists(installerDst)) return 1; - QString installedVersion = getVersionFromExecutable(installerDst); + QString installedVersion = getVersionFromExecutable(installerDst, getInstallationDirectory()); // if unable to get version, copy it if (installedVersion.isEmpty()) return 1; diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index dee751b48..391e31eb9 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -226,20 +226,21 @@ void CProfilesDialog::updateExecutableVersion(int index) if (index < 0) return; const CProfile &profile = m_model->getProfiles()[index]; + const CServer &server = CConfigFile::getInstance()->getServer(profile.server); QString executable = profile.executable; // file empty, use default one if (executable.isEmpty()) { - executable += CConfigFile::getInstance()->getServer(profile.server).getClientFullPath(); + executable = server.getClientFullPath(); } // file doesn't exist if (executable.isEmpty() || !QFile::exists(executable)) return; // convert output to string - QString versionString = getVersionFromExecutable(executable); + QString versionString = getVersionFromExecutable(executable, server.getDirectory()); if (!versionString.isEmpty()) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index 5ec1413e8..e52081b72 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -406,7 +406,7 @@ QString appendShortcutExtension(const QString &shortcut) return shortcut + extension; } -QString getVersionFromExecutable(const QString &path) +QString getVersionFromExecutable(const QString &path, const QString &workingDirectory) { // check if file exists if (!QFile::exists(path)) @@ -426,6 +426,7 @@ QString getVersionFromExecutable(const QString &path) // launch executable with --version argument QProcess process; process.setProcessChannelMode(QProcess::MergedChannels); + process.setWorkingDirectory(workingDirectory); process.start(path, QStringList() << "--version", QIODevice::ReadOnly); if (!process.waitForStarted()) diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h index 980826a16..aec574387 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.h +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h @@ -76,7 +76,7 @@ bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &pa QString appendShortcutExtension(const QString &shortcut); // launch an executable with --version parameter and parse version string -QString getVersionFromExecutable(const QString &path); +QString getVersionFromExecutable(const QString &path, const QString &workingDirectory); // write a resource in QRC to disk bool writeResource(const QString &resource, const QString &path); From d7182af3992c8e1dc488eeaf689f7c4f61de8048 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 20:57:18 +0100 Subject: [PATCH 06/16] Changed: New join function to do the opposite work of explode --HG-- branch : develop --- code/nel/include/nel/misc/common.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 0617ad560..c677a01bf 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -478,6 +478,22 @@ template void explode (const T &src, const T &sep, std::vector &res while(pos != std::string::npos); } +/** Join a string (or ucstring) from a vector of strings with *sep* as separator. If sep can be more than 1 char, in this case, +* we find the entire sep to separator (it s not a set of possible separator) +*/ +template void join(const std::vector& strings, const U& separator, T &res) +{ + res.clear(); + + for (uint i = 0, len = strings.size(); i> with all NeL simple types (except for ucchar and ucstring) From f59cef10bd15a1226d9d580d0bb2704b34fec5ee Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 20:57:49 +0100 Subject: [PATCH 07/16] Changed: Removed flags not supported everywhere --HG-- branch : develop --- code/CMakeModules/nel.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 6d17643ee..819e260f4 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -869,9 +869,6 @@ MACRO(NL_SETUP_BUILD) ELSE() # Check wrong formats in printf-like functions ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security") - - # Don't display invalid or unused command lines arguments by default (often too verbose) - ADD_PLATFORM_FLAGS("-Wno-invalid-command-line-argument -Wno-unused-command-line-argument") ENDIF() IF(ANDROID) From 94d34401480bf68821162fc11ee8f38c8db6852a Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 22 Nov 2016 12:14:32 +0100 Subject: [PATCH 08/16] Fixed: Strict aliasing warnings --HG-- branch : develop --- code/nel/include/nel/gui/interface_property.h | 4 +-- code/nel/include/nel/misc/cdb_leaf.h | 22 +++++++-------- code/nel/src/gui/interface_property.cpp | 27 ++++++++++++++++--- code/ryzom/server/src/pd_lib/pd_messages.h | 6 +++-- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h index 4ed6e701e..b506ec7a9 100644 --- a/code/nel/include/nel/gui/interface_property.h +++ b/code/nel/include/nel/gui/interface_property.h @@ -72,8 +72,8 @@ namespace NLGUI bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); /// float operations - void setDouble (double value) {setSInt64((sint64&) value);} - double getDouble () const {sint64 i = getSInt64(); return (double &) i; } + void setDouble(double value); + double getDouble() const; void readDouble (const char* value, const std::string& id); /// sint32 operations diff --git a/code/nel/include/nel/misc/cdb_leaf.h b/code/nel/include/nel/misc/cdb_leaf.h index e3df6f8b3..c80ec903a 100644 --- a/code/nel/include/nel/misc/cdb_leaf.h +++ b/code/nel/include/nel/misc/cdb_leaf.h @@ -40,20 +40,20 @@ public: /// Return the value of the property. - inline sint64 getValue64() { return _Property; } + inline sint64 getValue64() const { return _Property; } /// Set the value of the property (set '_Changed' flag with 'true'). void setValue64 (sint64 prop); - inline sint32 getValue32() { return *((sint32*)&_Property); } + inline sint32 getValue32() const { return (sint32)(_Property & 0xffffffff); } void setValue32 (sint32 prop); - inline sint16 getValue16() { return *((sint16*)&_Property); } + inline sint16 getValue16() const { return (sint16)(_Property & 0xffff); } void setValue16 (sint16 prop); - inline sint8 getValue8() { return *((sint8*)&_Property); } + inline sint8 getValue8() const { return (sint8)(_Property & 0xff); } void setValue8 (sint8 prop); - inline bool getValueBool() { return (_Property!=(sint64)0 ); } + inline bool getValueBool() const { return (_Property!=(sint64)0 ); } void setValueBool (bool prop); - inline CRGBA getValueRGBA() + inline CRGBA getValueRGBA() const { CRGBA col; col.R = (uint8)(_Property&0xff); @@ -65,11 +65,11 @@ public: void setValueRGBA (const CRGBA &color); /// Return the value of the property before the database change - inline sint64 getOldValue64() { return _oldProperty; } - inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); } - inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); } - inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); } - inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); } + inline sint64 getOldValue64() const { return _oldProperty; } + inline sint32 getOldValue32() const { return (sint32)(_oldProperty & 0xffffffff); } + inline sint16 getOldValue16() const { return (sint16)(_oldProperty & 0xffff); } + inline sint8 getOldValue8() const { return (sint8)(_oldProperty & 0xff); } + inline bool getOldValueBool() const { return (_oldProperty!=(sint64)0 ); } /// Return the type of the property. diff --git a/code/nel/src/gui/interface_property.cpp b/code/nel/src/gui/interface_property.cpp index 694bd6c36..8715b0f2f 100644 --- a/code/nel/src/gui/interface_property.cpp +++ b/code/nel/src/gui/interface_property.cpp @@ -26,6 +26,12 @@ using namespace std; namespace NLGUI { + // helper to convert double <> sint64 + union C64BitsParts + { + sint64 i64; + double d; + }; bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode ) { @@ -66,6 +72,20 @@ namespace NLGUI } + void CInterfaceProperty::setDouble(double value) + { + C64BitsParts parts; + parts.d = value; + setSInt64(parts.i64); + } + + double CInterfaceProperty::getDouble() const + { + C64BitsParts parts; + parts.i64 = getSInt64(); + return parts.d; + } + // ***************** // sint64 operations // ***************** @@ -104,10 +124,9 @@ namespace NLGUI if ( isdigit(*ptr) || *ptr=='-') { _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - double buf; - fromString(ptr, buf); - sint64 i = *(sint64*)&buf; - _VolatileValue->setValue64( i ); + C64BitsParts buf; + fromString(ptr, buf.d); + _VolatileValue->setValue64(buf.i64); } else { diff --git a/code/ryzom/server/src/pd_lib/pd_messages.h b/code/ryzom/server/src/pd_lib/pd_messages.h index 25ea12c4b..41e2c2db2 100644 --- a/code/ryzom/server/src/pd_lib/pd_messages.h +++ b/code/ryzom/server/src/pd_lib/pd_messages.h @@ -578,8 +578,8 @@ public: sint16 asSint16() const { return (sint16)_Value1[0]; } sint32 asSint32() const { return (sint32)_Value2[0]; } sint64 asSint64() const { return (sint64)_Value3[0]; } - float asFloat() const { return *(float*)(&_Value2[0]); } - double asDouble() const { return *(double*)(&_Value3[0]); } + float asFloat() const { return (float)_ValueFloat[0]; } + double asDouble() const { return (double)_ValueDouble[0]; } const NLMISC::CSheetId& asSheetId() const { return *(NLMISC::CSheetId*)(&_Value2[0]); } const NLMISC::CEntityId& asEntityId() const { return *(NLMISC::CEntityId*)(&_Value3[0]); } @@ -668,6 +668,8 @@ private: uint16 _Value1[4]; uint32 _Value2[2]; uint64 _Value3[1]; + float _ValueFloat[2]; + double _ValueDouble[1]; }; bool _ObjectIdPresent; From a3262bb971583599ebbec4b9c258c3119df97b58 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 22 Nov 2016 12:22:17 +0100 Subject: [PATCH 09/16] Fixed: Warnings --HG-- branch : develop --- code/nel/include/nel/net/message_recorder.h | 2 +- code/nel/src/misc/eval_num_expr.cpp | 3 +++ code/nel/src/net/module_common.cpp | 4 ++-- code/nel/src/pipeline/database_config.cpp | 2 +- code/nel/src/pipeline/project_config.cpp | 4 ++-- .../3d/object_viewer/located_target_dlg.cpp | 2 +- .../tools/misc/log_analyser/PlugInSelector.cpp | 2 +- .../tools/misc/make_sheet_id/make_sheet_id.cpp | 4 ++-- code/ryzom/server/src/ai_share/16x16_layer.h | 1 + .../src/persistant_data_service/pds_database.h | 2 +- .../mission_compiler_lib/mission_compiler.cpp | 13 +++++++++++-- .../mission_compiler_lib/mission_compiler.h | 2 +- .../tools/leveldesign/mp_generator/main.cpp | 16 ++++++++++++---- .../named_items_2_csv/named_items_2_csv.cpp | 16 ++++++++++++++-- .../world_editor/world_editor/display.cpp | 2 +- .../world_editor/world_editor/resource.h | 2 +- .../world_editor/world_editor/world_editor.rc | 2 +- 17 files changed, 56 insertions(+), 23 deletions(-) diff --git a/code/nel/include/nel/net/message_recorder.h b/code/nel/include/nel/net/message_recorder.h index 5874aca4c..92fee29fa 100644 --- a/code/nel/include/nel/net/message_recorder.h +++ b/code/nel/include/nel/net/message_recorder.h @@ -61,7 +61,7 @@ struct TMessageRecord { nlassert( stream.stringMode() ); - uint32 len; + uint32 len = 0; std::string s_event; stream.serial( UpdateCounter ); if ( stream.isReading() ) diff --git a/code/nel/src/misc/eval_num_expr.cpp b/code/nel/src/misc/eval_num_expr.cpp index 1bfad17eb..42298c1fa 100644 --- a/code/nel/src/misc/eval_num_expr.cpp +++ b/code/nel/src/misc/eval_num_expr.cpp @@ -632,6 +632,9 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT TOperator resultUnaryOp[InternalOperator]; vector resultUnaryOpSup; + // init table + for (uint i = 0; i < (uint)InternalOperator; ++i) resultUnaryOp[i] = NotOperator; + // Current value double value; diff --git a/code/nel/src/net/module_common.cpp b/code/nel/src/net/module_common.cpp index 0133343dd..f16e1bfa9 100644 --- a/code/nel/src/net/module_common.cpp +++ b/code/nel/src/net/module_common.cpp @@ -212,8 +212,8 @@ namespace NLNET { // name is more deep, need to resurse parts.erase(parts.begin()); - CSString subName; - subName.join(reinterpret_cast(parts), "."); + std::string subName; + join(parts, ".", subName); sub->setParam(subName, value); } else diff --git a/code/nel/src/pipeline/database_config.cpp b/code/nel/src/pipeline/database_config.cpp index b326a2888..56369c902 100644 --- a/code/nel/src/pipeline/database_config.cpp +++ b/code/nel/src/pipeline/database_config.cpp @@ -53,7 +53,7 @@ bool CDatabaseConfig::init(const std::string &asset) TPathString configPath = rootPath + "/database.cfg"; while (!CFile::fileExists(configPath)) { - int sep = CFile::getLastSeparator(rootPath); + std::string::size_type sep = CFile::getLastSeparator(rootPath); if (sep == string::npos) return false; diff --git a/code/nel/src/pipeline/project_config.cpp b/code/nel/src/pipeline/project_config.cpp index 995f92fd4..b292f033c 100644 --- a/code/nel/src/pipeline/project_config.cpp +++ b/code/nel/src/pipeline/project_config.cpp @@ -65,7 +65,7 @@ bool CProjectConfig::init(const std::string &asset, Flags flags, bool partial) TPathString configPath = rootPath + "/nel.cfg"; while (!CFile::fileExists(configPath)) { - int sep = CFile::getLastSeparator(rootPath); + std::string::size_type sep = CFile::getLastSeparator(rootPath); if (sep == string::npos) return false; @@ -82,7 +82,7 @@ bool CProjectConfig::init(const std::string &asset, Flags flags, bool partial) std::vector configRootPaths; TPathString projectConfigPath; - uint32 projectConfigModification; + uint32 projectConfigModification = 0; std::string projectName; if (partial) { diff --git a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp index fb84877ad..7cb03426f 100644 --- a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp @@ -137,7 +137,7 @@ void CLocatedTargetDlg::OnRemoveTarget() m_Targets.DeleteString(indexs[k] - k); int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName())); - m_AvailableTargets.SetItemData(l, (DWORD) loc); + m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc); } UpdateData(FALSE); updateModifiedFlag(); diff --git a/code/nel/tools/misc/log_analyser/PlugInSelector.cpp b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp index 9a21a8df6..594942ddb 100644 --- a/code/nel/tools/misc/log_analyser/PlugInSelector.cpp +++ b/code/nel/tools/misc/log_analyser/PlugInSelector.cpp @@ -87,7 +87,7 @@ BOOL CPlugInSelector::OnInitDialog() } -int getLastSeparator (const string &filename) +std::string::size_type getLastSeparator (const string &filename) { string::size_type pos = filename.find_last_of ('/'); if (pos == string::npos) diff --git a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp index 5aefbcf4c..a8e095db3 100644 --- a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp +++ b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp @@ -529,9 +529,9 @@ int main( int argc, char ** argv ) readFormId( outputFileName ); // output path - sint lastSeparator = CFile::getLastSeparator(outputFileName); + std::string::size_type lastSeparator = CFile::getLastSeparator(outputFileName); string outputPath; - if( lastSeparator != -1 ) + if( lastSeparator != std::string::npos ) { outputPath = outputFileName.substr(0,lastSeparator+1); } diff --git a/code/ryzom/server/src/ai_share/16x16_layer.h b/code/ryzom/server/src/ai_share/16x16_layer.h index 49999a8fd..d8c3af912 100644 --- a/code/ryzom/server/src/ai_share/16x16_layer.h +++ b/code/ryzom/server/src/ai_share/16x16_layer.h @@ -77,6 +77,7 @@ typedef CFastBitField T1BitField; class I16x16Layer { public: + virtual ~I16x16Layer() {} /** * Get uncompressed value at i, j where i is y-like and j is x-like diff --git a/code/ryzom/server/src/persistant_data_service/pds_database.h b/code/ryzom/server/src/persistant_data_service/pds_database.h index fdd059c00..d6a26e6fe 100644 --- a/code/ryzom/server/src/persistant_data_service/pds_database.h +++ b/code/ryzom/server/src/persistant_data_service/pds_database.h @@ -74,7 +74,7 @@ public: /** * Destructor */ - ~CDatabase(); + virtual ~CDatabase(); /** diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp index 39354138d..bc5cb6ad8 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp @@ -875,17 +875,26 @@ bool CMissionCompiler::publishFiles(const std::string &serverPathPrim, const std return true; } -bool CMissionCompiler::includeText(const std::string filename, const std::string text) +bool CMissionCompiler::includeText(const std::string &filename, const std::string &text) { FILE *f = nlfopen(filename, "r+"); if (f == NULL) + { + nlwarning("Unable to open %s", filename.c_str()); return false; + } bool isIn = false; char buffer[1024]; // Check for UTF8 format - fread(buffer, 1, 3, f); + if (fread(buffer, 1, 3, f) != 3) + { + fclose(f); + nlwarning("Unable to read 3 bytes from %s", filename.c_str()); + return false; + } + if (buffer[0] != -17 || buffer[1] != -69 || buffer[2] != -65) fseek(f, 0, SEEK_SET); diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h index 46e0cc575..7016bd092 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h @@ -447,7 +447,7 @@ public: bool publishFiles(const std::string &serverPathPrim, const std::string &serverPathText, const std::string &localPathText); /// Search for text in the file : add it if it's not in - bool includeText(const std::string filename, const std::string text); + bool includeText(const std::string &filename, const std::string &text); /// Parse the pre requisite node of a mission. bool parsePreRequisite(CMissionData &md, NLLIGO::IPrimitive *preReq); diff --git a/code/ryzom/tools/leveldesign/mp_generator/main.cpp b/code/ryzom/tools/leveldesign/mp_generator/main.cpp index 15740d477..353642ac6 100644 --- a/code/ryzom/tools/leveldesign/mp_generator/main.cpp +++ b/code/ryzom/tools/leveldesign/mp_generator/main.cpp @@ -1279,15 +1279,23 @@ void ItemNamesSave() printf( "-- SAVING ITEM NAMES --\n"); CSString data, output; - FILE* file; - file = nlfopen( ITEM_WORDS_WK, "rb" ); + FILE *file = nlfopen( ITEM_WORDS_WK, "rb" ); char c; - fread( &c, 1, 1, file ); + if (fread(&c, 1, 1, file) != 1) + { + nlwarning("Unable to read 1 byte from %s", ITEM_WORDS_WK.c_str()); + return; + } + while ( !feof( file ) ) { data += toString( "%c", c ); - fread( &c, 1, 1, file ); + if (fread(&c, 1, 1, file) != 1) + { + nlwarning("Unable to read 1 byte from %s", ITEM_WORDS_WK.c_str()); + return; + } } fclose( file ); diff --git a/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp b/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp index d34e30c5a..c1c0c7aca 100644 --- a/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp +++ b/code/ryzom/tools/leveldesign/named_items_2_csv/named_items_2_csv.cpp @@ -199,7 +199,13 @@ int getNbItemFromFile(const char *filename) while (fgets(buffer, 1024, f)) { int n; - fscanf(f, "_Items#%d", &n); + if (fscanf(f, "_Items#%d", &n) != 1) + { + fclose(f); + nlerror("Unable to parse 1 item from %s", filename); + return max; + } + if (n > max) max = n; } @@ -247,7 +253,13 @@ int importCsv(const char *filename) // read fields name { - fgets(buffer, 1024, f); + if (fgets(buffer, 1024, f) != buffer) + { + fclose(f); + nlerror("Unable to read line from %s", filename); + return 1; + } + CSString s(buffer); s = s.strtok("\n"); 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 a1c1836a0..e25addbae 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp @@ -3400,7 +3400,7 @@ void CDisplay::updateCursor () // Moved with middle click ? case DragView: - cursor = theApp.LoadCursor (MAKEINTRESOURCE(IDC_HAND)); + cursor = theApp.LoadCursor (MAKEINTRESOURCE(IDC_HAND1)); break; // Moved with left click ? diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h index ce7382e1d..2a294d748 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h @@ -65,7 +65,7 @@ #define IDI_LINE_HIDE 149 #define IDC_INSERT_POINT 149 #define IDI_ZONE_HIDE 150 -#define IDC_HAND 150 +#define IDC_HAND1 150 #define IDI_ZONE 151 #define IDI_ZONE_OPENED 151 #define IDD_LOADING 152 diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.rc b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.rc index e465953a6..ce46045e4 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.rc +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.rc @@ -934,7 +934,7 @@ IDC_COPY CURSOR DISCARDABLE "res\\copy.cur" IDC_SELECT CURSOR DISCARDABLE "res\\select.cur" IDC_SELECT_COPY CURSOR DISCARDABLE "res\\select_copy.cur" IDC_INSERT_POINT CURSOR DISCARDABLE "res\\insert_point.cur" -IDC_HAND CURSOR DISCARDABLE "res\\hand.cur" +IDC_HAND1 CURSOR DISCARDABLE "res\\hand.cur" IDC_ZOOM CURSOR DISCARDABLE "res\\zoom.cur" IDC_RADIUS CURSOR DISCARDABLE "res\\radius.cur" From b7ca1d224c1e3121081b712a2983be93290eed90 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 22 Nov 2016 12:39:44 +0100 Subject: [PATCH 10/16] Changed: Use _T macro and TCHAR to support UNICODE --HG-- branch : develop --- .../3d/object_viewer/particle_tree_ctrl.cpp | 4 +- .../plugin_max/nel_mesh_lib/export_script.cpp | 2 +- .../plugin_max/nel_patch_paint/paint_ui.cpp | 2 +- .../plugin_max/tile_utility/tile_utility.cpp | 56 +++++++------- code/nel/tools/3d/tile_edit/Browse.h | 18 ++--- code/nel/tools/3d/tile_edit/View.cpp | 4 +- .../tools/3d/tile_edit/choose_veget_set.cpp | 6 +- .../misc/branch_patcher/branch_patcherDlg.cpp | 2 +- .../leveldesign/georges_dll/dfn_dialog.cpp | 14 ++-- .../georges_dll/file_tree_view.cpp | 2 +- .../world_editor/builder_zone.cpp | 10 +-- .../world_editor/dialog_properties.cpp | 30 ++++---- .../world_editor/world_editor/export_dlg.cpp | 20 ++--- .../world_editor/file_dialog_ex.cpp | 6 +- .../world_editor/find_primitive_dlg.cpp | 2 +- .../world_editor/world_editor/world_editor.h | 2 +- .../plugin.cpp | 2 +- .../graph_plugin.cpp | 10 +-- .../DialogFlags.cpp | 74 +++++++++---------- .../entity_display_info.h | 4 +- .../memory_combo_box.cpp | 8 +- .../memory_combo_box.h | 2 +- .../plugin.cpp | 2 +- .../plugin.h | 2 +- 24 files changed, 142 insertions(+), 142 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 c392b1481..803f7548a 100644 --- a/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer/particle_tree_ctrl.cpp @@ -852,8 +852,8 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA nt = new CNodeType(nt->Loc, objIndex); _NodeTypes.push_back(nt); // insert the element in the tree - HTREEITEM root = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, "instance", PSIconLocatedInstance, PSIconLocatedInstance, 0, 0, (LPARAM) nt, GetSelectedItem(), TVI_LAST); - SetItemData(root, (DWORD) nt); + HTREEITEM root = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, _T("instance"), PSIconLocatedInstance, PSIconLocatedInstance, 0, 0, (LPARAM) nt, GetSelectedItem(), TVI_LAST); + SetItemData(root, (DWORD_PTR) nt); Invalidate(); } break; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp index a0971d587..3d99cee91 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp @@ -125,7 +125,7 @@ float CExportNel::getScriptAppData (Animatable *node, uint32 id, float def) // String to int float value = 0.f; - if (toFloatMax((const char*)ap->data, value)) + if (toFloatMax((const TCHAR*)ap->data, value)) return value; else return def; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp index 10554f8da..46b1ad1d7 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp @@ -242,7 +242,7 @@ void CTileSetCont::build (CTileBank& bank, uint tileSet) if (!dmwarn) { dmwarn = true; - MessageBox(NULL, "Tile bank not loaded, or bad tile bank. Missing a displacement tile. Use the tile bank utility to load the correct tilebank.", "NeL Patch Paint", MB_OK | MB_ICONWARNING); + MessageBox(NULL, _T("Tile bank not loaded, or bad tile bank. Missing a displacement tile. Use the tile bank utility to load the correct tilebank."), _T("NeL Patch Paint"), MB_OK | MB_ICONWARNING); } continue; // with next displace } diff --git a/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp b/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp index 7c4605b38..e11605b42 100644 --- a/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp +++ b/code/nel/tools/3d/plugin_max/tile_utility/tile_utility.cpp @@ -72,7 +72,7 @@ class Tile_utilityClassDesc:public ClassDesc2 { return &theTile_utility; } - const TCHAR * ClassName() {return "NeL Tile Bank";} + const TCHAR * ClassName() {return _T("NeL Tile Bank");} SClass_ID SuperClassID() {return UTILITY_CLASS_ID;} Class_ID ClassID() {return TILE_UTILITY_CLASS_ID;} const TCHAR* Category() {return _T("NeL Tools");} @@ -96,7 +96,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, if (hModule) { // Get module file name - char moduldeFileName[512]; + TCHAR moduldeFileName[512]; if (GetModuleFileName (hModule, moduldeFileName, 512)) { // Get version info size @@ -112,41 +112,41 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, { uint *versionTab; uint versionSize; - if (VerQueryValue (buffer, "\\", (void**)&versionTab, &versionSize)) + if (VerQueryValue (buffer, _T("\\"), (void**)&versionTab, &versionSize)) { // Get the pointer on the structure VS_FIXEDFILEINFO *info=(VS_FIXEDFILEINFO*)versionTab; if (info) { // Setup version number - char version[512]; - sprintf (version, "Version %d.%d.%d.%d", - info->dwFileVersionMS>>16, - info->dwFileVersionMS&0xffff, - info->dwFileVersionLS>>16, + TCHAR version[512]; + _tcprintf (version, "Version %d.%d.%d.%d", + info->dwFileVersionMS>>16, + info->dwFileVersionMS&0xffff, + info->dwFileVersionLS>>16, info->dwFileVersionLS&0xffff); SetWindowText (GetDlgItem (hWnd, IDC_VERSION), version); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VS_FIXEDFILEINFO * is NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VS_FIXEDFILEINFO * is NULL")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "VerQueryValue failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("VerQueryValue failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfo failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfo failed")); // Free the buffer delete [] buffer; } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetFileVersionInfoSize failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetFileVersionInfoSize failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "GetModuleFileName failed"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("GetModuleFileName failed")); } else - SetWindowText (GetDlgItem (hWnd, IDC_VERSION), "hInstance NULL"); + SetWindowText (GetDlgItem (hWnd, IDC_VERSION), _T("hInstance NULL")); theTile_utility.Init(hWnd); @@ -168,7 +168,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, { case IDC_BANK_PATH: { - static char sPath[256]; + static TCHAR sPath[256]; static bool bFirst=false; if (!bFirst) { @@ -178,7 +178,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, OPENFILENAME ofn; ofn.lStructSize=sizeof (ofn); ofn.hwndOwner=NULL; - ofn.lpstrFilter="Rykol bank files (*.bank)\0*.bank\0All Files (*.*)\0*.*\0"; + ofn.lpstrFilter = _T("Rykol bank files (*.bank)\0*.bank\0All Files (*.*)\0*.*\0"); ofn.lpstrCustomFilter=NULL; ofn.nMaxCustFilter=0; ofn.nFilterIndex=0; @@ -187,7 +187,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, ofn.lpstrFileTitle=NULL; ofn.nMaxFileTitle=NULL; ofn.lpstrInitialDir=NULL; - ofn.lpstrTitle="Choose a bank file"; + ofn.lpstrTitle = _T("Choose a bank file"); ofn.Flags=OFN_ENABLESIZING|OFN_FILEMUSTEXIST; ofn.nFileOffset=0; ofn.nFileExtension=0; @@ -223,7 +223,7 @@ static INT_PTR CALLBACK Tile_utilityDlgProc(HWND hWnd, UINT msg, WPARAM wParam, case IDC_SETUP: { if (!theTile_utility.SetupMaterial ()) - MessageBox (NULL, "Select some nel patch object..", "Rykol tile", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Select some nel patch object.."), _T("Rykol tile"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -382,18 +382,18 @@ void Tile_utility::SetupUI () SetWindowText (hwnd, sName); // Static text - char sTmp[256]; - sprintf (sTmp, "%d diffuse tiles.", Bank.getNumBitmap (CTile::diffuse)); + TCHAR sTmp[256]; + _tcprintf (sTmp, "%d diffuse tiles.", Bank.getNumBitmap (CTile::diffuse)); SetWindowText (hwndStatic1, sTmp); - sprintf (sTmp, "%d additive tiles.", Bank.getNumBitmap (CTile::additive)); + _tcprintf (sTmp, "%d additive tiles.", Bank.getNumBitmap (CTile::additive)); SetWindowText (hwndStatic2, sTmp); } else { - SetWindowText (hwnd, "Click to choose a bank.."); - SetWindowText (hwndStatic1, ""); - SetWindowText (hwndStatic2, ""); - SetWindowText (hwndStatic3, ""); + SetWindowText (hwnd, _T("Click to choose a bank..")); + SetWindowText (hwndStatic1, _T("")); + SetWindowText (hwndStatic2, _T("")); + SetWindowText (hwndStatic3, _T("")); } } } @@ -412,7 +412,7 @@ bool Tile_utility::SetupMaterial () const // Multi MultiMtl* multi=NewDefaultMultiMtl(); multi->SetNumSubMtls (Bank.getTileCount()+1); - multi->SetName ("Rykol Bank"); + multi->SetName (_T("Rykol Bank")); // Default mtl Mtl* firstMtl=multi->GetSubMtl (0); @@ -420,7 +420,7 @@ bool Tile_utility::SetupMaterial () const // Mtl param firstMtl->SetDiffuse (Color (0.5f,0.5f,0.5f), t); firstMtl->SetAmbient (Color (0,0,0), t); - firstMtl->SetName ("Rykol Tile Default"); + firstMtl->SetName (_T("Rykol Tile Default")); firstMtl->SetShininess (0.0, t); firstMtl->SetSpecular (Color (0,0,0), t); @@ -439,7 +439,7 @@ bool Tile_utility::SetupMaterial () const // Mtl param mtl->SetDiffuse (Color (1.f,1.f,1.f), t); mtl->SetAmbient (Color (0,0,0), t); - mtl->SetName ("Rykol Tile"); + mtl->SetName (_T("Rykol Tile")); mtl->SetShininess (0.0, t); mtl->SetSpecular (Color (0,0,0), t); diff --git a/code/nel/tools/3d/tile_edit/Browse.h b/code/nel/tools/3d/tile_edit/Browse.h index 3c1ce166c..70fd1c6ac 100644 --- a/code/nel/tools/3d/tile_edit/Browse.h +++ b/code/nel/tools/3d/tile_edit/Browse.h @@ -25,15 +25,15 @@ #include "SelectionTerritoire.h" #include "View.h" -#define REGKEY_TILEDIT "Software\\Nevrax\\Nel\\Tile_Edit" -#define REGKEY_BUTTONZOOM "Zoom button" -#define REGKEY_BUTTONVARIETY "Zoom variety" -#define REGKEY_BUTTONTEXTURE "Texture button" -#define REGKEY_BUTTONSORT "Sort button" -#define REGKEY_BUTTONTEXTINFO "Info button" -#define REGKEY_LISTCOMBOBOX "List type combo box" -#define REGKEY_WNDPL "Window placement" -#define REGKEY_LASTPATH "Last path" +#define REGKEY_TILEDIT _T("Software\\Nevrax\\Nel\\Tile_Edit") +#define REGKEY_BUTTONZOOM _T("Zoom button") +#define REGKEY_BUTTONVARIETY _T("Zoom variety") +#define REGKEY_BUTTONTEXTURE _T("Texture button") +#define REGKEY_BUTTONSORT _T("Sort button") +#define REGKEY_BUTTONTEXTINFO _T("Info button") +#define REGKEY_LISTCOMBOBOX _T("List type combo box") +#define REGKEY_WNDPL _T("Window placement") +#define REGKEY_LASTPATH _T("Last path") #define SCROLL_MAX 50000 diff --git a/code/nel/tools/3d/tile_edit/View.cpp b/code/nel/tools/3d/tile_edit/View.cpp index d6d24d47c..d0eecb229 100644 --- a/code/nel/tools/3d/tile_edit/View.cpp +++ b/code/nel/tools/3d/tile_edit/View.cpp @@ -438,14 +438,14 @@ int TileList::setDisplacement (int tile, const std::string& name) theListDisplacement[tile].loaded=0; if (!_LoadBitmap(tileBank2.getAbsPath() + troncated, &theListDisplacement[tile].BmpInfo, theListDisplacement[tile].Bits, NULL, 0)) - MessageBox (NULL, (tileBank2.getAbsPath() + troncated).c_str(), "Can't load file", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, (tileBank2.getAbsPath() + troncated).c_str(), _T("Can't load file"), MB_OK|MB_ICONEXCLAMATION); else { // Check the size if ((theListDisplacement[tile].BmpInfo.bmiHeader.biWidth!=32)||(-theListDisplacement[tile].BmpInfo.bmiHeader.biHeight!=32)) { // Error message - MessageBox (NULL, "Invalid size: displacement map must be 32x32 8 bits.", troncated.c_str(), + MessageBox (NULL, _T("Invalid size: displacement map must be 32x32 8 bits."), troncated.c_str(), MB_OK|MB_ICONEXCLAMATION); // Free the bitmap diff --git a/code/nel/tools/3d/tile_edit/choose_veget_set.cpp b/code/nel/tools/3d/tile_edit/choose_veget_set.cpp index 7afa0c1e0..a8aa6878c 100644 --- a/code/nel/tools/3d/tile_edit/choose_veget_set.cpp +++ b/code/nel/tools/3d/tile_edit/choose_veget_set.cpp @@ -61,10 +61,10 @@ END_MESSAGE_MAP() void CChooseVegetSet::OnBrowse() { // Select a veget set - static char BASED_CODE szFilter[] = "NeL VegetSet Files (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"; + static TCHAR BASED_CODE szFilter[] = _T("NeL VegetSet Files (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"); // Create a file dialog - CFileDialog dialog ( TRUE, "*.vegetset", "*.vegetset", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)Parent); + CFileDialog dialog ( TRUE, _T("*.vegetset"), _T("*.vegetset"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)Parent); if (dialog.DoModal() == IDOK) { // Get the file name @@ -80,7 +80,7 @@ BOOL CChooseVegetSet::OnInitDialog() if (!FileName.empty()) Name.SetWindowText (utf8ToTStr(FileName)); else - Name.SetWindowText ("Browse..."); + Name.SetWindowText (_T("Browse...")); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp b/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp index b3e65653c..c20a90d53 100644 --- a/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp +++ b/code/nel/tools/misc/branch_patcher/branch_patcherDlg.cpp @@ -669,7 +669,7 @@ void CBranch_patcherDlg::OnButtonExtractTokens() m_SrcDirLabel = "Enter Token 1"; m_TargetDirLabel = "Enter Token 2"; m_Filename = "The tokens above were extracted from the directories."; - ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( "Store Tokens" ); + ((CButton*)GetDlgItem( IDC_ButtonExtractTokens ))->SetWindowText( _T("Store Tokens") ); GetDlgItem( IDC_TopText )->ShowWindow( SW_HIDE ); GetDlgItem( IDC_ButtonClearTokens )->EnableWindow( FALSE ); GetDlgItem( IDC_ButtonPatch )->ShowWindow( SW_HIDE ); diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp index 38ed1ec9c..301a9d893 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp @@ -90,7 +90,7 @@ BOOL CDfnDialog::OnInitDialog() // Create the type combo setStaticSize (currentPos); - LabelParents.Create ("Parents:", WS_VISIBLE, currentPos, this); + LabelParents.Create (_T("Parents:"), WS_VISIBLE, currentPos, this); initWidget (LabelParents); getNextPosLabel (currentPos); @@ -105,7 +105,7 @@ BOOL CDfnDialog::OnInitDialog() // Create the type combo setStaticSize (currentPos); - LabelStruct.Create ("Structure:", WS_VISIBLE, currentPos, this); + LabelStruct.Create (_T("Structure:"), WS_VISIBLE, currentPos, this); initWidget (LabelStruct); getNextPosLabel (currentPos); @@ -210,10 +210,10 @@ void CDfnDialog::getFromDocument (const NLGEORGES::CFormDfn &dfn) Struct.ListCtrl.SetItemText (elm, 4, dfn.getEntry (elm).getFilenameExt ().c_str()); break; case UFormDfn::EntryDfn: - Struct.ListCtrl.SetItemText (elm, 1, dfn.getEntry (elm).getArrayFlag () ? "Dfn array" : "Dfn"); + Struct.ListCtrl.SetItemText (elm, 1, dfn.getEntry (elm).getArrayFlag () ? _T("Dfn array") : _T("Dfn")); break; case UFormDfn::EntryVirtualDfn: - Struct.ListCtrl.SetItemText (elm, 1, "Virtual Dfn"); + Struct.ListCtrl.SetItemText (elm, 1, _T("Virtual Dfn")); break; } Struct.ListCtrl.SetItemText (elm, 2, dfn.getEntry (elm).getFilename ().c_str()); @@ -435,15 +435,15 @@ void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultDfn.c_str ()); // Clear default value - Dialog->Struct.ListCtrl.SetItemText (item, 3, ""); + Dialog->Struct.ListCtrl.SetItemText (item, 3, _T("")); } else if (type == "Virtual Dfn") { // Clear the value - Dialog->Struct.ListCtrl.SetItemText (item, 2, ""); + Dialog->Struct.ListCtrl.SetItemText (item, 2, _T("")); // Clear default value - Dialog->Struct.ListCtrl.SetItemText (item, 3, ""); + Dialog->Struct.ListCtrl.SetItemText (item, 3, _T("")); } } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index 90b742860..43c71f240 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -51,7 +51,7 @@ bool CFileTreeCtrl::create( const RECT& rect, CWnd* pParentWnd, UINT nID ) LPCTSTR className = AfxRegisterWndClass( 0 ); // Create this window - if (CWnd::Create (className, "empty", WS_CHILD, rect, pParentWnd, nID )) + if (CWnd::Create (className, _T("empty"), WS_CHILD, rect, pParentWnd, nID )) #if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 80 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 ffdfe4d60..30b15cf8d 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 @@ -609,8 +609,7 @@ bool CBuilderZone::refresh () if ((sZone != STRING_UNUSED)&&(sZone != STRING_OUT_OF_BOUND)) { unload (_ZoneRegionSelected); - MessageBox (NULL, "Cannot add this zone because it overlaps existing ones", - "Error", MB_ICONERROR|MB_OK); + MessageBox (NULL, _T("Cannot add this zone because it overlaps existing ones"), _T("Error"), MB_ICONERROR|MB_OK); return false; } } @@ -1599,17 +1598,18 @@ void CBuilderZone::del (const CVector &worldPos) // --------------------------------------------------------------------------- bool CBuilderZone::initZoneBank (const string &sPathName) { - char sDirBackup[512]; + // TODO: replace by NeL methods + TCHAR sDirBackup[512]; GetCurrentDirectory (512, sDirBackup); SetCurrentDirectory (sPathName.c_str()); WIN32_FIND_DATA findData; HANDLE hFind; - hFind = FindFirstFile ("*.ligozone", &findData); + hFind = FindFirstFile (_T("*.ligozone"), &findData); while (hFind != INVALID_HANDLE_VALUE) { // If the name of the file is not . or .. then its a valid entry in the DataBase - if (!((strcmp (findData.cFileName, ".") == 0) || (strcmp (findData.cFileName, "..") == 0))) + if (!((_tcscmp (findData.cFileName, _T(".")) == 0) || (_tcscmp (findData.cFileName, _T("..")) == 0))) { string error; if (!_ZoneBank.addElement (findData.cFileName, error)) 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 8fa0266e7..bbd84578b 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 @@ -49,8 +49,8 @@ using namespace NLMISC; #define STRING_SELECT_COMBOBOX_ID 9 -#define DIFFERENT_VALUE_STRING "" -#define DIFFERENT_VALUE_MULTI_STRING "" +#define DIFFERENT_VALUE_STRING _T("") +#define DIFFERENT_VALUE_MULTI_STRING _T("") //CDialogProperties PropertyDialog; std::list PropertiesDialogs; @@ -327,12 +327,12 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, buttonRect.right = buttonRect.left + FILE_BUTTON_WIDTH; // Create an edit box - nlverify (widget.CheckBox.Create ("Select", BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); + nlverify (widget.CheckBox.Create (_T("Select"), BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); widget.CheckBox.SetFont (GetFont ()); } // Create the label - widget.Static.Create ("", WS_VISIBLE, widgetPos, &m_PropertyCont); + widget.Static.Create (_T(""), WS_VISIBLE, widgetPos, &m_PropertyCont); widget.Static.SetFont (GetFont ()); // Next position @@ -372,11 +372,11 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, // we insert an empty string in case of a default value if (!widget.Parameter.SortEntries) { - widget.ComboBox.InsertString( -1, ""); + widget.ComboBox.InsertString( -1, _T("")); } else { - widget.ComboBox.AddString(""); + widget.ComboBox.AddString(_T("")); } if (ite != widget.Parameter.ComboValues.end ()) { @@ -431,7 +431,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, widgetPos.bottom = widgetPos.top + EDIT_HEIGHT; // Create an edit box - nlverify (widget.EditBox.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|(enabled?0:ES_READONLY), widgetPos, &m_PropertyCont, id)); + nlverify (widget.EditBox.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|(enabled?0:ES_READONLY), widgetPos, &m_PropertyCont, id)); widget.EditBox.SetFont (GetFont ()); if (widget.Parameter.FileExtension != "") { @@ -440,7 +440,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, buttonRect.right = buttonRect.left + FILE_BUTTON_WIDTH; // Create an edit box - nlverify (widget.CheckBox.Create ("Open...", BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); + nlverify (widget.CheckBox.Create (_T("Open..."), BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); widget.CheckBox.SetFont (GetFont ()); } } @@ -452,12 +452,12 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, // Create an edit box if (widget.Parameter.DisplayHS) { - nlverify (widget.MultiLineEditBox.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", + nlverify (widget.MultiLineEditBox.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL|(enabled?0:ES_READONLY), widgetPos, &m_PropertyCont, id)); } else { - nlverify (widget.MultiLineEditBox.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", + nlverify (widget.MultiLineEditBox.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL|(enabled?0:ES_READONLY), widgetPos, &m_PropertyCont, id)); } @@ -478,7 +478,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, RECT buttonRect = widgetPos; // Create an edit box - nlverify (widget.CheckBox.Create ("Edit...", BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); + nlverify (widget.CheckBox.Create (_T("Edit..."), BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); widget.CheckBox.SetFont (GetFont ()); } } @@ -488,7 +488,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, widgetPos.bottom = widgetPos.top + widget.Parameter.WidgetHeight; // Create an edit box - nlverify (widget.ListEditBox.CreateEx (WS_EX_CLIENTEDGE, _T("LISTBOX"), "", WS_VSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|LBS_NOTIFY|(enabled?0:WS_DISABLED), widgetPos, &m_PropertyCont, id)); + nlverify (widget.ListEditBox.CreateEx (WS_EX_CLIENTEDGE, _T("LISTBOX"), _T(""), WS_VSCROLL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|LBS_NOTIFY|(enabled?0:WS_DISABLED), widgetPos, &m_PropertyCont, id)); // Resize the column RECT listRect; @@ -498,7 +498,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, widget.ListEditBox.StringSelectComboBox.ResetContent (); std::map::iterator ite = widget.Parameter.ComboValues.find (doc->getContext ().c_str()); // we insert an empty string in case of a default value - widget.ListEditBox.StringSelectComboBox.InsertString( -1, ""); + widget.ListEditBox.StringSelectComboBox.InsertString( -1, _T("")); if (ite != widget.Parameter.ComboValues.end ()) { vector PathList; @@ -565,7 +565,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, // Create an edit box //nlverify (widget.CheckBox.Create ("Open...", BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP, buttonRect, this, id)); - nlverify (widget.CheckBox.Create ("View...", BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); + nlverify (widget.CheckBox.Create (_T("View..."), BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), buttonRect, &m_PropertyCont, id)); widget.CheckBox.SetFont (GetFont ()); } @@ -661,7 +661,7 @@ BOOL CDialogProperties::OnInitDialog() // m_PropertyFrame.ClientToScreen(&contRect); // leave 16 px for the scroll bar contRect.right-=16; - m_PropertyCont.Create("", 0, contRect, &m_PropertyFrame); + m_PropertyCont.Create(_T(""), 0, contRect, &m_PropertyFrame); // m_PropertyCont.SetCursor() m_PropertyCont.ShowWindow(SW_SHOW); 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 b12f145a6..6460dc3f1 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 @@ -163,20 +163,20 @@ int CALLBACK expBrowseCallbackProc (HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) bool CExportDlg::callChoosePathDlg(CString &dest) const { 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 path"; + bi.lpszTitle = _T("Choose the path"); bi.ulFlags = 0; bi.lpfn = expBrowseCallbackProc; - char sDir[512]; - strcpy(sDir, (LPCSTR)RefZoneDir); + TCHAR sDir[512]; + _tcscpy(sDir, (LPCTSTR)RefZoneDir); bi.lParam = (LPARAM)sDir; bi.iImage = 0; @@ -218,7 +218,7 @@ void CExportDlg::OnButtonOutIGdir() // --------------------------------------------------------------------------- void CExportDlg::OnButtonTilebankfile() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "bank", true, "smallbank", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "SmallBank (*.smallbank)|*.smallbank||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("bank"), true, _T("smallbank"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("SmallBank (*.smallbank)|*.smallbank||"), this); if (dialog.DoModal() == IDOK) { TileBankFile = dialog.GetPathName (); @@ -229,7 +229,7 @@ void CExportDlg::OnButtonTilebankfile() // --------------------------------------------------------------------------- void CExportDlg::OnButtonColormapfile() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "image", true, "tga", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Tga Files (*.tga)|*.tga|All Files (*.*)|*.*||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), true, _T("tga"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Tga Files (*.tga)|*.tga|All Files (*.*)|*.*||"), this); if (dialog.DoModal() == IDOK) { ColorMapFile = dialog.GetPathName (); @@ -240,7 +240,7 @@ void CExportDlg::OnButtonColormapfile() // --------------------------------------------------------------------------- void CExportDlg::OnButtonHeightmapfile() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "image", true, "tga", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Grayscale Tga (*.tga)|*.tga||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), true, _T("tga"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Grayscale Tga (*.tga)|*.tga||"), this); if (dialog.DoModal() == IDOK) { HeightMapFile = dialog.GetPathName (); @@ -251,7 +251,7 @@ void CExportDlg::OnButtonHeightmapfile() // --------------------------------------------------------------------------- void CExportDlg::OnButtonHeightmapfile2() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "image", true, "tga", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Grayscale Tga (*.tga)|*.tga||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), true, _T("tga"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Grayscale Tga (*.tga)|*.tga||"), this); if (dialog.DoModal() == IDOK) { HeightMapFile2 = dialog.GetPathName (); @@ -299,7 +299,7 @@ void CExportDlg::OnButtonContinentsDir() // --------------------------------------------------------------------------- void CExportDlg::OnButtonContinentFile() { - CFileDialogEx dialog (BASE_REGISTRY_KEY, "continent", true, "continent", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Continent file (*.continent)|*.continent||", this); + CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("continent"), true, _T("continent"), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, _T("Continent file (*.continent)|*.continent||"), this); if (dialog.DoModal() == IDOK) { ContinentFile = dialog.GetPathName (); 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 781e78005..9ee63294a 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 @@ -54,7 +54,7 @@ END_MESSAGE_MAP() INT_PTR CFileDialogEx::DoModal () { // Get the path - char path[512]; + TCHAR path[512]; path[0] = 0; HKEY hKey; DWORD type = REG_SZ; @@ -122,7 +122,7 @@ BOOL CFileDialogEx::OnCommand( WPARAM wParam, LPARAM lParam ) ::GetDlgItemText (parent, edt1, s, MAX_PATH); // Replace with the directory name - ::SendMessage (parent, CDM_SETCONTROLTEXT, edt1, (LPARAM)(const char*)text); + ::SendMessage (parent, CDM_SETCONTROLTEXT, edt1, (LPARAM)(LPCTSTR)text); // Click on the OK button ::SendMessage (parent, WM_COMMAND, IDOK, 0); @@ -148,7 +148,7 @@ BOOL CFileDialogEx::OnInitDialog() combo.Attach (::GetDlgItem (*this, IDC_DIRLIST)); // Insert the strings - char text[512]; + TCHAR text[512]; text[0] = 0; HKEY hKey; DWORD type = REG_SZ; 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 87e5d553c..2cea6d8d8 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 @@ -175,7 +175,7 @@ void CFindPrimitiveDlg::OnFindNext() } else { - 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); // Init locator _Locator.getRoot (0); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.h index 38a17b6bb..d5e629353 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.h @@ -36,7 +36,7 @@ #include "nel/ligo/ligo_config.h" // Base registry key -#define BASE_REGISTRY_KEY "Software\\Nevrax\\NeL World Editor" +#define BASE_REGISTRY_KEY _T("Software\\Nevrax\\NeL World Editor") ///////////////////////////////////////////////////////////////////////////// // CWorldEditorApp: diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp index 9d59e797e..532d034d0 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp @@ -353,7 +353,7 @@ void CPlugin::postRender(CDisplay &display) // TODO nico This code is duplicated with world_editor_shard_monitor static bool createFailed = false; if (createFailed) return; - HRSRC rsc = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_FLAG_ICONS_TGA), "TGA"); + HRSRC rsc = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_FLAG_ICONS_TGA), _T("TGA")); if (rsc == NULL) { DWORD lastError = GetLastError(); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp index f21400421..06c5d4dd8 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp @@ -186,7 +186,7 @@ void CGraphPlugin::refreshPrimitives() //currently using output.png as the input file... if(!createBitmap(tmpPath)) - AfxMessageBox("BEWARE: the image couldn't be loaded."); + AfxMessageBox(_T("BEWARE: the image couldn't be loaded.")); } while (missionTreeRoot->getParent()!=NULL) @@ -268,7 +268,7 @@ void CGraphPlugin::refreshMachine() //currently using output.png as the input file... if(!createBitmap(tmpPath)) - AfxMessageBox("BEWARE: the image couldn't be loaded."); + AfxMessageBox(_T("BEWARE: the image couldn't be loaded.")); } while (missionTreeRoot->getParent()!=NULL) @@ -312,8 +312,8 @@ void CGraphPlugin::refreshMachine() //currently using output.png as the input file... if(!createBitmap(tmpPath)) - AfxMessageBox("BEWARE: the image couldn't be loaded."); - } + AfxMessageBox(_T("BEWARE: the image couldn't be loaded.")); + } while (missionTreeRoot->getParent()!=NULL) { @@ -323,7 +323,7 @@ void CGraphPlugin::refreshMachine() } else { - AfxMessageBox("The selected node could not be processed."); + AfxMessageBox(_T("The selected node could not be processed.")); } } 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 7fc7ddf65..223860403 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 @@ -73,18 +73,18 @@ CDialogFlags::CDialogFlags(CWnd* pParent /*=NULL*/) { CEntityDisplayInfo di[] = { - CEntityDisplayInfo(RYZOMID::building, "Building", NLMISC::CRGBA(192, 0, 0)), - CEntityDisplayInfo(RYZOMID::creature, "Creature", NLMISC::CRGBA(255, 127, 0), 2, 0), - CEntityDisplayInfo(RYZOMID::deposit, "Deposit", NLMISC::CRGBA(0, 255, 0)), - CEntityDisplayInfo(RYZOMID::flora, "Flora", NLMISC::CRGBA(255, 127, 0)), - CEntityDisplayInfo(RYZOMID::forageSource, "Forage Source", NLMISC::CRGBA(0, 255, 0)), - CEntityDisplayInfo(RYZOMID::mount, "Mount", NLMISC::CRGBA(127, 63, 0), 3, 0), - CEntityDisplayInfo(RYZOMID::npc, "NPC", NLMISC::CRGBA(255, 0, 0), 1, 0), - CEntityDisplayInfo(RYZOMID::object, "Object", NLMISC::CRGBA(192, 255, 255)), - CEntityDisplayInfo(RYZOMID::pack_animal, "Pack Animal", NLMISC::CRGBA(127, 63, 0), 3, 0), - CEntityDisplayInfo(RYZOMID::player, "Player", NLMISC::CRGBA(127, 127, 255), 0, 0), - CEntityDisplayInfo(RYZOMID::fx_entity, "FX Entity", NLMISC::CRGBA(0, 255, 0)), - CEntityDisplayInfo(RYZOMID::unknown, "Unknown", NLMISC::CRGBA(127, 127, 127)), + CEntityDisplayInfo(RYZOMID::building, _T("Building"), NLMISC::CRGBA(192, 0, 0)), + CEntityDisplayInfo(RYZOMID::creature, _T("Creature"), NLMISC::CRGBA(255, 127, 0), 2, 0), + CEntityDisplayInfo(RYZOMID::deposit, _T("Deposit"), NLMISC::CRGBA(0, 255, 0)), + CEntityDisplayInfo(RYZOMID::flora, _T("Flora"), NLMISC::CRGBA(255, 127, 0)), + CEntityDisplayInfo(RYZOMID::forageSource, _T("Forage Source"), NLMISC::CRGBA(0, 255, 0)), + CEntityDisplayInfo(RYZOMID::mount, _T("Mount"), NLMISC::CRGBA(127, 63, 0), 3, 0), + CEntityDisplayInfo(RYZOMID::npc, _T("NPC"), NLMISC::CRGBA(255, 0, 0), 1, 0), + CEntityDisplayInfo(RYZOMID::object, _T("Object"), NLMISC::CRGBA(192, 255, 255)), + CEntityDisplayInfo(RYZOMID::pack_animal, _T("Pack Animal"), NLMISC::CRGBA(127, 63, 0), 3, 0), + CEntityDisplayInfo(RYZOMID::player, _T("Player"), NLMISC::CRGBA(127, 127, 255), 0, 0), + CEntityDisplayInfo(RYZOMID::fx_entity, _T("FX Entity"), NLMISC::CRGBA(0, 255, 0)), + CEntityDisplayInfo(RYZOMID::unknown, _T("Unknown"), NLMISC::CRGBA(127, 127, 127)), }; initDisplayInfo(di, sizeofarray(di), _EntityDisplayInfo[EntityType]); } @@ -92,10 +92,10 @@ CDialogFlags::CDialogFlags(CWnd* pParent /*=NULL*/) { CEntityDisplayInfo di[] = { - CEntityDisplayInfo(0, "Dead", NLMISC::CRGBA(255, 0, 0)), - CEntityDisplayInfo(1, "Weak", NLMISC::CRGBA(255, 255, 0)), - CEntityDisplayInfo(2, "Full shape", NLMISC::CRGBA(0, 255, 0)), - CEntityDisplayInfo(3, "No Hit Points", NLMISC::CRGBA(127, 127, 127)), + CEntityDisplayInfo(0, _T("Dead"), NLMISC::CRGBA(255, 0, 0)), + CEntityDisplayInfo(1, _T("Weak"), NLMISC::CRGBA(255, 255, 0)), + CEntityDisplayInfo(2, _T("Full shape"), NLMISC::CRGBA(0, 255, 0)), + CEntityDisplayInfo(3, _T("No Hit Points"), NLMISC::CRGBA(127, 127, 127)), }; initDisplayInfo(di, sizeofarray(di), _EntityDisplayInfo[EntityHitPoints]); } @@ -103,9 +103,9 @@ CDialogFlags::CDialogFlags(CWnd* pParent /*=NULL*/) { CEntityDisplayInfo di[] = { - CEntityDisplayInfo(0, "Dead", NLMISC::CRGBA(255, 0, 0)), - CEntityDisplayInfo(1, "Alive", NLMISC::CRGBA(0, 0, 255)), - CEntityDisplayInfo(2, "No Hit Points", NLMISC::CRGBA(127, 127, 127)), + CEntityDisplayInfo(0, _T("Dead"), NLMISC::CRGBA(255, 0, 0)), + CEntityDisplayInfo(1, _T("Alive"), NLMISC::CRGBA(0, 0, 255)), + CEntityDisplayInfo(2, _T("No Hit Points"), NLMISC::CRGBA(127, 127, 127)), }; initDisplayInfo(di, sizeofarray(di), _EntityDisplayInfo[EntityAlive]); } @@ -113,19 +113,19 @@ CDialogFlags::CDialogFlags(CWnd* pParent /*=NULL*/) { CEntityDisplayInfo di[] = { - CEntityDisplayInfo(MBEHAV::UNKNOWN_MODE, "Unknown", NLMISC::CRGBA(127, 127, 127)), - CEntityDisplayInfo(MBEHAV::NORMAL, "Normal", NLMISC::CRGBA(255, 255, 255)), - CEntityDisplayInfo(MBEHAV::COMBAT_FLOAT, "Combat float", NLMISC::CRGBA(255, 0, 0), 0, 1), - CEntityDisplayInfo(MBEHAV::COMBAT, "Combat", NLMISC::CRGBA(255, 0, 0), 0, 1), - CEntityDisplayInfo(MBEHAV::SWIM, "Swim", NLMISC::CRGBA(0, 0, 255)), - CEntityDisplayInfo(MBEHAV::SIT, "Sit", NLMISC::CRGBA(0, 255, 255)), - CEntityDisplayInfo(MBEHAV::MOUNT_NORMAL, "Mount Normal", NLMISC::CRGBA(192, 128, 0)), - CEntityDisplayInfo(MBEHAV::MOUNT_SWIM, "Mount Swim", NLMISC::CRGBA(0, 0, 255)), - CEntityDisplayInfo(MBEHAV::EAT, "Eat", NLMISC::CRGBA(0, 255, 0)), - CEntityDisplayInfo(MBEHAV::ALERT, "Alert", NLMISC::CRGBA(255, 127, 0)), - CEntityDisplayInfo(MBEHAV::HUNGRY, "Hungry", NLMISC::CRGBA(255, 255, 0)), - CEntityDisplayInfo(MBEHAV::DEATH, "Death", NLMISC::CRGBA(0, 0, 0)), - CEntityDisplayInfo(MBEHAV::SWIM_DEATH, "SwimDeath", NLMISC::CRGBA(0, 0, 0)) + CEntityDisplayInfo(MBEHAV::UNKNOWN_MODE, _T("Unknown"), NLMISC::CRGBA(127, 127, 127)), + CEntityDisplayInfo(MBEHAV::NORMAL, _T("Normal"), NLMISC::CRGBA(255, 255, 255)), + CEntityDisplayInfo(MBEHAV::COMBAT_FLOAT, _T("Combat float"), NLMISC::CRGBA(255, 0, 0), 0, 1), + CEntityDisplayInfo(MBEHAV::COMBAT, _T("Combat"), NLMISC::CRGBA(255, 0, 0), 0, 1), + CEntityDisplayInfo(MBEHAV::SWIM, _T("Swim"), NLMISC::CRGBA(0, 0, 255)), + CEntityDisplayInfo(MBEHAV::SIT, _T("Sit"), NLMISC::CRGBA(0, 255, 255)), + CEntityDisplayInfo(MBEHAV::MOUNT_NORMAL, _T("Mount Normal"), NLMISC::CRGBA(192, 128, 0)), + CEntityDisplayInfo(MBEHAV::MOUNT_SWIM, _T("Mount Swim"), NLMISC::CRGBA(0, 0, 255)), + CEntityDisplayInfo(MBEHAV::EAT, _T("Eat"), NLMISC::CRGBA(0, 255, 0)), + CEntityDisplayInfo(MBEHAV::ALERT, _T("Alert"), NLMISC::CRGBA(255, 127, 0)), + CEntityDisplayInfo(MBEHAV::HUNGRY, _T("Hungry"), NLMISC::CRGBA(255, 255, 0)), + CEntityDisplayInfo(MBEHAV::DEATH, _T("Death"), NLMISC::CRGBA(0, 0, 0)), + CEntityDisplayInfo(MBEHAV::SWIM_DEATH, _T("SwimDeath"), NLMISC::CRGBA(0, 0, 0)) }; initDisplayInfo(di, sizeofarray(di), _EntityDisplayInfo[EntityMode]); } @@ -213,7 +213,7 @@ BOOL CDialogFlags::OnInitDialog() { CDialog::OnInitDialog(); - HRSRC rsc = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ENTITY_ICONS_TGA), "TGA"); + HRSRC rsc = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ENTITY_ICONS_TGA), _T("TGA")); if (rsc != NULL) { NLMISC::CBitmap bm; @@ -247,7 +247,7 @@ BOOL CDialogFlags::OnInitDialog() ::CRect shardListRect; GetDlgItem(IDC_SHARD_LIST_PLACEMENT)->GetWindowRect(shardListRect); ScreenToClient(&shardListRect); - ShardCtrl.create(WS_CHILD|WS_TABSTOP, shardListRect, this, 0, REGKEY_BASE_PATH "\\shard_list", 10); + ShardCtrl.create(WS_CHILD|WS_TABSTOP, shardListRect, this, 0, REGKEY_BASE_PATH _T("\\shard_list"), 10); ShardCtrl.ShowWindow (SW_SHOW); CFont* font = GetFont (); ShardCtrl.SetFont(font); @@ -295,7 +295,7 @@ void CDialogFlags::setCurrentEntityDisplayMode(TEntityDisplayMode edm) -#define REGKEY_ENTITY_DISPLAY_INFO REGKEY_BASE_PATH "\\entity_display_info\\" +#define REGKEY_ENTITY_DISPLAY_INFO REGKEY_BASE_PATH _T("\\entity_display_info\\") //****************************************************************************************************** void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos, const std::string ®Id) @@ -306,13 +306,13 @@ void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos DWORD index = 0; for(;;) { - char valueStr[256] = { 0 }; + TCHAR valueStr[256] = { 0 }; BYTE dataStr[256] = { 0 }; DWORD valueSize = sizeofarray(valueStr); DWORD dataSize = sizeofarray(dataStr); LONG result = RegEnumValue(hKey, index, valueStr, &valueSize, NULL, NULL, dataStr, &dataSize); if (result != ERROR_SUCCESS) break; - uint value = (uint) atoi(valueStr); + uint value = (uint) _ttoi(valueStr); for(uint k = 0; k < infos.size(); ++k) { if (infos[k].Value == value) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/entity_display_info.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/entity_display_info.h index 8c3afda74..b3d3e2fc2 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/entity_display_info.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/entity_display_info.h @@ -46,12 +46,12 @@ class CEntityDisplayInfo { public: uint Value; - const char *Name; + const TCHAR *Name; CEntityIcon Icon; NLMISC::CRGBA Color; bool Visible; CEntityDisplayInfo() {} - CEntityDisplayInfo(uint value, const char *name, NLMISC::CRGBA color, sint iconX = -1, sint iconY = -1) + CEntityDisplayInfo(uint value, const TCHAR *name, NLMISC::CRGBA color, sint iconX = -1, sint iconY = -1) : Value(value), Name(name), Color(color), Visible(true), Icon(iconX, iconY) {} }; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp index a6d4a909d..5788c2d72 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp @@ -43,7 +43,7 @@ CMemoryComboBox::~CMemoryComboBox() // *************************************************************************** -void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount) +void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const TCHAR *registerAdress, int memoryCount) { // Register a window Id = nId; @@ -52,7 +52,7 @@ void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT LPCTSTR clas = AfxRegisterWndClass (0); if (clas) { - if (Create (clas, "MemoryComboBox", style, rect, parent, nId)) + if (Create (clas, _T("MemoryComboBox"), style, rect, parent, nId)) { // Create the combo box RECT comboRect; @@ -582,12 +582,12 @@ LRESULT CMemoryComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) int curSel = _ComboBox.GetCurSel (); if ((curSel == -1) || ((uint)curSel Date: Tue, 22 Nov 2016 13:07:52 +0100 Subject: [PATCH 11/16] Changed: Convert CString and TCHAR* from/to std::string --HG-- branch : develop --- .../tools/3d/ligo/plugin_max/max_to_ligo.cpp | 2 +- .../tools/3d/object_viewer/editable_range.h | 10 ++--- .../3d/object_viewer/located_target_dlg.cpp | 8 ++-- code/nel/tools/3d/object_viewer/mesh_dlg.cpp | 2 +- .../tools/3d/object_viewer/multi_tex_dlg.cpp | 2 +- .../nel/tools/3d/object_viewer/pick_sound.cpp | 2 +- .../tools/3d/object_viewer/ps_mover_dlg.cpp | 4 +- .../3d/object_viewer/skeleton_scale_dlg.cpp | 8 ++-- .../tools/3d/object_viewer/vegetable_dlg.cpp | 28 ++++++------ .../3d/object_viewer/vegetable_edit_tools.cpp | 2 +- .../vegetable_noise_value_dlg.cpp | 6 +-- .../3d/object_viewer/vegetable_select_dlg.cpp | 2 +- .../3d/object_viewer/vegetable_wind_dlg.cpp | 20 +++------ .../3d/object_viewer/water_pool_editor.cpp | 21 +++++---- .../3d/plugin_max/nel_export/nel_export.cpp | 16 +++---- .../nel_export/nel_export_export.cpp | 2 +- .../nel_export/nel_export_node_properties.cpp | 12 ++--- .../plugin_max/nel_export/nel_export_view.cpp | 4 +- .../3d/plugin_max/nel_mesh_lib/calc_lm.cpp | 25 +++++------ .../3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp | 4 +- .../plugin_max/nel_mesh_lib/export_anim.cpp | 2 +- .../nel_mesh_lib/export_collision.cpp | 2 +- .../nel_mesh_lib/export_material.cpp | 2 +- .../plugin_max/nel_mesh_lib/export_mesh.cpp | 11 +++-- .../nel_mesh_lib/export_mesh_interface.cpp | 8 ++-- .../plugin_max/nel_mesh_lib/export_misc.cpp | 30 ++++++------- .../3d/plugin_max/nel_mesh_lib/export_nel.h | 4 +- .../nel_mesh_lib/export_particle_system.cpp | 4 +- .../nel_mesh_lib/export_radial_normal.cpp | 2 +- .../plugin_max/nel_mesh_lib/export_scene.cpp | 28 ++++-------- .../plugin_max/nel_mesh_lib/export_script.cpp | 2 +- .../nel_mesh_lib/export_skinning.cpp | 8 ++-- .../plugin_max/nel_patch_lib/nel_patch_mesh.h | 2 +- .../3d/plugin_max/nel_patch_lib/rpo2nel.cpp | 15 +++---- .../3d/plugin_max/nel_patch_paint/paint.cpp | 2 +- .../plugin_max/tile_utility/tile_utility.cpp | 16 +++---- code/nel/tools/3d/tile_edit/View.cpp | 5 +-- .../tools/3d/tile_edit/choose_veget_set.cpp | 4 +- .../leveldesign/georges_dll/dfn_dialog.cpp | 44 +++++++++---------- .../leveldesign/georges_dll/georges_edit.cpp | 4 +- .../mission_compiler_feDlg.cpp | 4 +- .../world_editor/builder_zone.cpp | 10 ++--- .../world_editor/file_dialog_ex.cpp | 26 +++++------ .../world_editor/world_editor/name_dlg.cpp | 6 +-- .../graph_plugin.cpp | 17 +++---- .../DialogFlags.cpp | 6 +-- .../memory_combo_box.cpp | 42 +++++++++--------- .../plugin.cpp | 12 ++--- .../world_editor_sound_plugin/DialogFlags.cpp | 15 ++++--- 49 files changed, 241 insertions(+), 272 deletions(-) diff --git a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp index 7de43f6b9..052eb04a0 100644 --- a/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/max_to_ligo.cpp @@ -139,7 +139,7 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di try { // Load the config file - config.readConfigFile (sModulePath, false); + config.readConfigFile (tStrToUtf8(sModulePath), false); // ok return true; diff --git a/code/nel/tools/3d/object_viewer/editable_range.h b/code/nel/tools/3d/object_viewer/editable_range.h index 05e52857b..65c633352 100644 --- a/code/nel/tools/3d/object_viewer/editable_range.h +++ b/code/nel/tools/3d/object_viewer/editable_range.h @@ -317,7 +317,7 @@ inline void CEditableRangeT::value2CString(float value, CString &dest) inline const TCHAR *CEditableRangeT::string2value(const CString &value, float &result) { - if (sscanf((LPCTSTR) value, "%f", &result) == 1) + if (NLMISC::fromString(tStrToUtf8(value), result)) { return NULL; } @@ -343,8 +343,8 @@ inline void CEditableRangeT::value2CString(uint32 value, CString &dest) inline const TCHAR *CEditableRangeT::string2value(const CString &value, uint32 &result) { - uint32 tmp; - if (sscanf((LPCTSTR) value, "%d", &tmp) == 1) + sint32 tmp; + if (NLMISC::fromString(tStrToUtf8(value), tmp)) { if (strchr((LPCTSTR) value, '-')) { @@ -379,8 +379,8 @@ inline void CEditableRangeT::value2CString(sint32 value, CString &dest) inline const TCHAR *CEditableRangeT::string2value(const CString &value, sint32 &result) { - uint32 tmp; - if (sscanf((LPCTSTR) value, "%d", &tmp) == 1) + sint32 tmp; + if (NLMISC::fromString(tStrToUtf8(value), tmp)) { result = tmp; return NULL; diff --git a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp index 7cb03426f..12c9de041 100644 --- a/code/nel/tools/3d/object_viewer/located_target_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/located_target_dlg.cpp @@ -159,8 +159,8 @@ BOOL CLocatedTargetDlg::OnInitDialog() // fill the box thta tells us what the target are for(k = 0; k < nbTarg; ++k) { - m_Targets.AddString(_LBTarget->getTarget(k)->getName().c_str() ); - m_Targets.SetItemData(k, (DWORD) _LBTarget->getTarget(k) ); + m_Targets.AddString(utf8ToTStr(_LBTarget->getTarget(k)->getName())); + m_Targets.SetItemData(k, (DWORD_PTR) _LBTarget->getTarget(k)); targetSet.insert(_LBTarget->getTarget(k)); }; @@ -179,8 +179,8 @@ BOOL CLocatedTargetDlg::OnInitDialog() { if (targetSet.find(loc) == targetSet.end()) { - int l = m_AvailableTargets.AddString(loc->getName().c_str() ); - m_AvailableTargets.SetItemData(l, (DWORD) loc ); + int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName())); + m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc); } } } diff --git a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp index de59b9c2a..991ae09f3 100644 --- a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp @@ -162,7 +162,7 @@ void CMeshDlg::updateForMorph() GetDlgItem(IDC_SHAPE_NAME)->EnableWindow(!enable); if (!enable) { - m_ShapeName = cm->getShape().c_str(); + m_ShapeName = utf8ToTStr(cm->getShape()); } else { diff --git a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp index fc0c294ca..58776b931 100644 --- a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp @@ -188,6 +188,7 @@ void CMultiTexDlg::readValues(bool alternate) } } + GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getBumpFactor()))); } @@ -206,7 +207,6 @@ void CMultiTexDlg::writeValues(bool alternate) TCHAR u1[10], u2[10], v1[10], v2[10]; NLMISC::CVector2f vs1, vs2; - if (!alternate) { GetDlgItem(IDC_U_SPEED_1)->GetWindowText(u1, 10); diff --git a/code/nel/tools/3d/object_viewer/pick_sound.cpp b/code/nel/tools/3d/object_viewer/pick_sound.cpp index 2f67147a8..0e6c175d0 100644 --- a/code/nel/tools/3d/object_viewer/pick_sound.cpp +++ b/code/nel/tools/3d/object_viewer/pick_sound.cpp @@ -159,7 +159,7 @@ void CPickSound::OnDblclkList() stopCurrSource(); CString sName; m_NameList.GetText(curSel, sName); - _CurrSource = CSoundSystem::create(std::string( (LPCTSTR) sName)); + _CurrSource = CSoundSystem::create(tStrToUtf8(sName)); } //======================================================================================== diff --git a/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp b/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp index a916cee6f..cdd88ea70 100644 --- a/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/ps_mover_dlg.cpp @@ -178,8 +178,8 @@ BOOL CPSMoverDlg::OnInitDialog() { if (dynamic_cast(_EditedLocated->getBoundObject(k))) { - uint insertedLine = m_SubComponentCtrl.AddString(_EditedLocated->getBoundObject(k)->getName().c_str()); - m_SubComponentCtrl.SetItemData(insertedLine, (DWORD) _EditedLocated->getBoundObject(k)); + uint insertedLine = m_SubComponentCtrl.AddString(utf8ToTStr(_EditedLocated->getBoundObject(k)->getName())); + m_SubComponentCtrl.SetItemData(insertedLine, (DWORD_PTR) _EditedLocated->getBoundObject(k)); ++nbCandidates; } } diff --git a/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp b/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp index a7d2b022a..42839e933 100644 --- a/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/skeleton_scale_dlg.cpp @@ -843,13 +843,13 @@ void CSkeletonScaleDlg::OnSsdButtonSaveas() return; // choose the file - CFileDialog fd(FALSE, "skel", _SkeletonFileName.c_str(), OFN_OVERWRITEPROMPT, "SkelFiles (*.skel)|*.skel|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save As Skeleton"; + CFileDialog fd(FALSE, _T("skel"), utf8ToTStr(_SkeletonFileName), OFN_OVERWRITEPROMPT, _T("SkelFiles (*.skel)|*.skel|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save As Skeleton"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { if(saveCurrentInStream(f)) { @@ -859,7 +859,7 @@ void CSkeletonScaleDlg::OnSsdButtonSaveas() } // bkup the valid fileName (new file edited) - _SkeletonFileName= (const char*)fd.GetPathName(); + _SkeletonFileName= tStrToUtf8(fd.GetPathName()); _StaticFileName= _SkeletonFileName.c_str(); UpdateData(FALSE); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp index 7611b543b..09a2079e5 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_dlg.cpp @@ -196,7 +196,7 @@ void CVegetableDlg::updateCurSelVegetableName() _Vegetables[id].updateVegetableName(); // replace name in the listBox: must delete, and re-insert VegetableList.DeleteString(id); - VegetableList.InsertString(id, _Vegetables[id].VegetableName.c_str()); + VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName)); VegetableList.SetCurSel(id); } } @@ -349,14 +349,14 @@ bool CVegetableDlg::loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const ok= true; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName()))) { try { // read the vegetable f.serial(vegetSet); // bkup fileName. - _LastVegetSetName= (const char*)fd.GetFileName(); + _LastVegetSetName = tStrToUtf8(fd.GetFileName()); } catch(const NLMISC::EStream &) { @@ -439,7 +439,7 @@ void CVegetableDlg::appendVegetableSet(NL3D::CTileVegetableDesc &vegetSet) _Vegetables[id].initVegetable(veget); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); } } } @@ -529,7 +529,7 @@ void CVegetableDlg::OnButtonVegetableAdd() _Vegetables[id].initDefaultVegetable(); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -559,7 +559,7 @@ void CVegetableDlg::OnButtonVegetableInsert() _Vegetables[id].initDefaultVegetable(); // update view - VegetableList.InsertString(id, _Vegetables[id].VegetableName.c_str()); + VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -611,7 +611,7 @@ void CVegetableDlg::OnButtonVegetableLoadDesc() { NLMISC::CIFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { NL3D::CVegetable veget; try @@ -624,7 +624,7 @@ void CVegetableDlg::OnButtonVegetableLoadDesc() _Vegetables[id].initVegetable(veget); // update view - VegetableList.AddString(_Vegetables[id].VegetableName.c_str()); + VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName)); // update 3D view refreshVegetableDisplay(); @@ -651,13 +651,13 @@ void CVegetableDlg::OnButtonVegetableSaveDesc() std::string fileName= _Vegetables[id].VegetableName + ".vegetdesc"; - CFileDialog fd(FALSE, "vegetdesc", fileName.c_str(), OFN_OVERWRITEPROMPT, "VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save Vegetable Descriptor"; + CFileDialog fd(FALSE, _T("vegetdesc"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, _T("VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save Vegetable Descriptor"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { try { @@ -722,13 +722,13 @@ void CVegetableDlg::OnButtonVegetableSaveSet() buildVegetableSet(vegetSet); // Then try to save it. - CFileDialog fd(FALSE, "vegetset", _LastVegetSetName.c_str(), OFN_OVERWRITEPROMPT, "VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||", this) ; - fd.m_ofn.lpstrTitle= "Save Vegetable Set"; + CFileDialog fd(FALSE, _T("vegetset"), utf8ToTStr(_LastVegetSetName), OFN_OVERWRITEPROMPT, _T("VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"), this) ; + fd.m_ofn.lpstrTitle = _T("Save Vegetable Set"); if (fd.DoModal() == IDOK) { NLMISC::COFile f; - if( f.open((const char*)fd.GetPathName()) ) + if( f.open(tStrToUtf8(fd.GetPathName())) ) { try { diff --git a/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp b/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp index 8d791a0fe..b0508cca9 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_edit_tools.cpp @@ -33,7 +33,7 @@ void CDirectEditableRangeFloat::init(uint32 x, uint32 y, CWnd *pParent) CRect rect; rect.SetRect(x, y+10, x+dx, y+25); - _StaticText.Create(_Title.c_str(), WS_CHILD | WS_VISIBLE, rect, pParent); + _StaticText.Create(utf8ToTStr(_Title), WS_CHILD | WS_VISIBLE, rect, pParent); _StaticText.SetFont(pParent->GetFont()); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp index fb9bf1a1e..12bfe4050 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_noise_value_dlg.cpp @@ -154,7 +154,7 @@ BOOL CVegetableNoiseValueDlg::OnInitDialog() // Set the name. - NoiseValueName.SetWindowText(_TitleName.c_str()); + NoiseValueName.SetWindowText(utf8ToTStr(_TitleName)); // if previously setuped, setup now the noiseValue. @@ -264,7 +264,5 @@ void CVegetableNoiseValueDlg::applyScaleSlider(sint scrollValue) _RandValue->updateValueFromReader(); // update marker text - char str[256]; - sprintf(str, "%d%%", (sint)(factor*100)); - StaticScaleMarker.SetWindowText(str); + StaticScaleMarker.SetWindowText(utf8ToTStr(NLMISC::toString("%d%%", (sint)(factor * 100)))); } diff --git a/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp index 51b4cdc5e..d7be7bcb3 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_select_dlg.cpp @@ -63,7 +63,7 @@ BOOL CVegetableSelectDlg::OnInitDialog() uint num= _VegetableDlg->getNumVegetables(); for(uint i=0; igetVegetableName(i).c_str()); + VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i))); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp b/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp index 5c6657167..0b2084863 100644 --- a/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/vegetable_wind_dlg.cpp @@ -70,26 +70,22 @@ END_MESSAGE_MAP() void CVegetableWindDlg::updateView() { float a; - char str[256]; // update Power. a= _ObjViewer->getVegetableWindPower(); - sprintf(str, "%.2f", a); - StaticPower.SetWindowText(str); + StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER); SliderPower.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_POWER)); // update BendStart. a= _ObjViewer->getVegetableWindBendStart(); - sprintf(str, "%.2f", a); - StaticBendStart.SetWindowText(str); + StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART); SliderBendStart.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART)); // update Frequency. a= _ObjViewer->getVegetableWindFrequency(); - sprintf(str, "%.2f", a); - StaticFrequency.SetWindowText(str); + StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY); SliderFrequency.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY)); @@ -129,28 +125,24 @@ void CVegetableWindDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBa && nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK) { float a; - char str[256]; if(sliderCtrl == &SliderPower) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_POWER / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindPower(a); - sprintf(str, "%.2f", a); - StaticPower.SetWindowText(str); + StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } else if(sliderCtrl == &SliderBendStart) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindBendStart(a); - sprintf(str, "%.2f", a); - StaticBendStart.SetWindowText(str); + StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } else if(sliderCtrl == &SliderFrequency) { a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE; _ObjViewer->setVegetableWindFrequency(a); - sprintf(str, "%.2f", a); - StaticFrequency.SetWindowText(str); + StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a))); } } else diff --git a/code/nel/tools/3d/object_viewer/water_pool_editor.cpp b/code/nel/tools/3d/object_viewer/water_pool_editor.cpp index 3b68ae0e5..bf6f461bf 100644 --- a/code/nel/tools/3d/object_viewer/water_pool_editor.cpp +++ b/code/nel/tools/3d/object_viewer/water_pool_editor.cpp @@ -165,9 +165,8 @@ BOOL CWaterPoolEditor::OnInitDialog() int CWaterPoolEditor::addPool(uint32 ID) { - char poolId[128]; - sprintf(poolId, "%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str()); - int index = m_PoolList.AddString(poolId); + std::string poolId = NLMISC::toString("%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str()); + int index = m_PoolList.AddString(utf8ToTStr(poolId)); nlassert(index != LB_ERR); m_PoolList.SetItemData(index, ID); return index; @@ -358,7 +357,7 @@ void CWaterPoolEditor::OnLoadPool() { NLMISC::CIXml iXml; NLMISC::CIFile iF; - if (iF.open((LPCTSTR) fileDlg.GetPathName())) + if (iF.open(tStrToUtf8(fileDlg.GetPathName()))) { if (iXml.init (iF)) { @@ -370,17 +369,17 @@ void CWaterPoolEditor::OnLoadPool() else { iF.close(); - MessageBox (("Unable to init xml stream from file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { - MessageBox (("Unable to open file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } catch (const NLMISC::Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -396,7 +395,7 @@ void CWaterPoolEditor::OnSavePool() { NLMISC::COXml oXml; NLMISC::COFile oF; - if (oF.open((LPCTSTR) fileDlg.GetPathName())) + if (oF.open(tStrToUtf8(fileDlg.GetPathName()))) { if (oXml.init (&oF)) { @@ -407,17 +406,17 @@ void CWaterPoolEditor::OnSavePool() else { oF.close(); - MessageBox (("Unable to init xml stream from file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } else { - MessageBox (("Unable to open file : " + std::string((LPCTSTR) fileDlg.GetPathName())).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } catch (const NLMISC::Exception& e) { - MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION); + MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION); } } diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp index 3a4722063..71bc61d0e 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export.cpp @@ -325,14 +325,14 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP // Name of the node char sNodeMsg[256]; - nlwarning (sNodeMsg, "Save %s model...", pNode->GetName()); + nlwarning (sNodeMsg, "Save %s model...", tStrToUtf8(pNode->GetName()).c_str()); // It is a zone ? if (RPO::isZone (*pNode, time)) { // Save path char sSavePath[256]; - strcpy (sSavePath, pNode->GetName()); + strcpy (sSavePath, tStrToUtf8(pNode->GetName()).c_str()); // Choose a file to export if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0)) @@ -342,24 +342,22 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP if (!theCNelExport.exportZone (sSavePath, *pNode, time)) { // Error message - char sErrorMsg[512]; - sprintf (sErrorMsg, "Error exporting the zone %s in the file\n%s", pNode->GetName(), sSavePath); - MessageBox (hWnd, sErrorMsg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string sErrorMsg = toString("Error exporting the zone %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath); + MessageBox (hWnd, utf8ToTStr(sErrorMsg), L"NeL export", MB_OK|MB_ICONEXCLAMATION); } } } else if (CExportNel::isVegetable (*pNode, time)) { // Save path - char sSavePath[256]; - strcpy (sSavePath, pNode->GetName()); + std::string sSavePath = tStrToUtf8(pNode->GetName()); // Choose a file to export if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0)) - if (theCNelExport.SelectFileForSave(hWnd, sNodeMsg, vegetableFilter, sSavePath)) + if (theCNelExport.SelectFileForSave(hWnd, sNodeMsg, vegetableFilter, sSavePath.c_str())) { // Export the mesh - if (!theCNelExport.exportVegetable (sSavePath, *pNode, time)) + if (!theCNelExport.exportVegetable (sSavePath.c_str(), *pNode, time)) { // Error message char sErrorMsg[512]; diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp index b26464f3a..4fbdde584 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_export.cpp @@ -99,7 +99,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time) { // Open a file COFile file; - if (file.open(tempFileName)) + if (file.open(tStrToUtf8(tempFileName))) { try { diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_node_properties.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_node_properties.cpp index 0eeebfa52..e7a82c878 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_node_properties.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_node_properties.cpp @@ -2338,24 +2338,24 @@ INT_PTR CALLBACK MiscDialogCallback ( currentParam->LigoSymmetry = SendMessage (GetDlgItem (hwndDlg, IDC_LIGO_SYMMETRY), BM_GETCHECK, 0, 0); TCHAR tmp[512]; GetWindowText (GetDlgItem (hwndDlg, IDC_LIGO_ROTATE), tmp, 512); - currentParam->LigoRotate = tmp; + currentParam->LigoRotate = tStrToUtf8(tmp); // SWT currentParam->SWT = SendMessage (GetDlgItem (hwndDlg, IDC_SWT), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_SWT_WEIGHT), tmp, 512); - currentParam->SWTWeight = tmp; + currentParam->SWTWeight = tStrToUtf8(tmp); // Radial normals for (uint smoothGroup=0; smoothGroupRadialNormals[smoothGroup]=tmp; + currentParam->RadialNormals[smoothGroup] = tStrToUtf8(tmp); } // mesh interfaces GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_FILE), tmp, 512); - currentParam->InterfaceFileName=tmp; + currentParam->InterfaceFileName = tStrToUtf8(tmp); GetWindowText (GetDlgItem (hwndDlg, IDC_EDIT_INTERFACE_THRESHOLD), tmp, 512); if (strlen(tmp) != 0) currentParam->InterfaceThreshold = toFloatMax(tmp); @@ -2365,7 +2365,7 @@ INT_PTR CALLBACK MiscDialogCallback ( // Skeleton Scale currentParam->ExportBoneScale= SendMessage( GetDlgItem(hwndDlg, IDC_EXPORT_BONE_SCALE), BM_GETCHECK, 0, 0); GetWindowText (GetDlgItem (hwndDlg, IDC_EXPORT_BONE_SCALE_NAME_EXT), tmp, 512); - currentParam->ExportBoneScaleNameExt = wideToUtf8(tmp); + currentParam->ExportBoneScaleNameExt = tStrToUtf8(tmp); // remanence currentParam->UseRemanence = SendMessage (GetDlgItem (hwndDlg, IDC_USE_REMANENCE), BM_GETCHECK, 0, 0); @@ -2373,7 +2373,7 @@ INT_PTR CALLBACK MiscDialogCallback ( GetWindowText (GetDlgItem (hwndDlg, IDC_REMANENCE_SLICE_NUMBER), tmp, 512); uint rsn; - if (sscanf(tmp, "%d", &rsn) == 1) + if (NLMISC::fromString(tStrToUtf8(tmp), rsn)) { currentParam->RemanenceSliceNumber = rsn; } diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp index 6a0587a22..3461f0e46 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp @@ -367,7 +367,7 @@ void CNelExport::viewMesh (TimeValue time) INode* pNode=_Ip->GetSelNode (nNode); string sTmp = "Object Name: "; - sTmp += pNode->GetName(); + sTmp += tStrToUtf8(pNode->GetName()); ProgBar.setLine (0, sTmp); sTmp.clear(); for (uint32 i = 1; i < 10; ++i) @@ -412,7 +412,7 @@ void CNelExport::viewMesh (TimeValue time) if (pShape) { // Add the shape in the view - uint instance = view->addMesh (pShape, pNode->GetName(), iteSkelShape->second.SkeletonInstance); + uint instance = view->addMesh (pShape, tStrToUtf8(pNode->GetName()).c_str(), iteSkelShape->second.SkeletonInstance); // Add tracks CAnimation *anim=new CAnimation; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp index ef84390a1..21d63b626 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp @@ -128,7 +128,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) if (maxLight->EvalLightState(tvTime, valid, &ls)!=REF_SUCCEED) return; - this->Name = node->GetName(); + this->Name = tStrToUtf8(node->GetName()); // Retrieve the correct light Group Name this->AnimatedLight = CExportNel::getAnimatedLight (node); @@ -295,7 +295,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) INode *exclNode = exclusionList[i]; if (exclNode) // Crashfix // FIXME: Why is this NULL? { - string tmp = exclNode->GetName(); + string tmp = tStrToUtf8(exclNode->GetName()); this->setExclusion.insert(tmp); } } @@ -1930,7 +1930,7 @@ void supprLightNoInteractOne( vector &vLights, CMesh::CMeshBuild* p { bool bInteract = false; - if( vLights[i].setExclusion.find( node.GetName() ) != vLights[i].setExclusion.end() ) + if( vLights[i].setExclusion.find(tStrToUtf8(node.GetName()) ) != vLights[i].setExclusion.end() ) { bInteract = false; } @@ -2005,7 +2005,7 @@ void CExportNel::deleteLM(INode& ZeNode) string sSaveName; sSaveName = _Options.sExportLighting; if( sSaveName[sSaveName.size()-1] != '\\' ) sSaveName += "\\"; - sSaveName += ZeNode.GetName(); + sSaveName += tStrToUtf8(ZeNode.GetName()); char tmp[32]; sprintf( tmp, "%d", i ); sSaveName += tmp; @@ -2276,7 +2276,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { string thetext; thetext = "Warning "; - thetext += ZeNode.GetName(); + thetext += tStrToUtf8(ZeNode.GetName()); thetext = "have all faces NOT mapped (UV2)"; if (gOptions.FeedBack != NULL) { @@ -2325,11 +2325,11 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { // Make an error message string sTmp = "Warning : "; - sTmp += ZeNode.GetName(); + sTmp += tStrToUtf8(ZeNode.GetName()); sTmp += " has mapping problem"; // Script trace - mprintf ((sTmp+"\n").c_str()); + mprintf (utf8ToTStr((sTmp+"\n"))); // Feedback is here ? if (gOptions.FeedBack != NULL) @@ -2525,12 +2525,12 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB // Get the name of the max project char projectName[512]; - _splitpath (_Ip->GetCurFileName(), NULL, NULL, projectName, NULL); + _wsplitpath (_Ip->GetCurFileName(), NULL, NULL, utf8ToTStr(projectName), NULL); // Add lightmap information in the lightmap log COFile outputLog; if (outputLightmapLog) - createLightmapLog (outputLog, gOptions.sExportLighting.c_str(), projectName, ZeNode.GetName()); + createLightmapLog (outputLog, gOptions.sExportLighting.c_str(), projectName, tStrToUtf8(ZeNode.GetName()).c_str()); // Update UV coords to Texture space PutFaceUV1InTextureCoord( LightMap.w, LightMap.h, AllFaces.begin(), AllFaces.size() ); @@ -2559,7 +2559,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { CTextureFile *pLightMap = new CTextureFile(); //string sSaveName = AllMeshBuilds[nNode].second->GetName(); - string sSaveName = ZeNode.GetName(); + string sSaveName = tStrToUtf8(ZeNode.GetName()); char tmp[32]; sSaveName += "_"; sprintf( tmp, "%d", nLightMapNb ); @@ -2632,9 +2632,8 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB { if (gOptions.FeedBack != NULL) { - char message[512]; - sprintf (message, "Can't write the file %s : %s", sSaveName, e.what()); - mprintf (message); + std::string message = toString("Can't write the file %s : %s", sSaveName.c_str(), e.what()); + mprintf (utf8ToTStr(message)); } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp index a0e6139b2..789c37b23 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm_rt.cpp @@ -113,7 +113,7 @@ void CRTWorld::build (vector &AllLights, CVector &trans, bool bExcl pLAP->create( 64 ); // width of each grid in number of square for( j = 0; j < vMB.size(); ++j ) { - if (rLight.setExclusion.find (vINode[j]->GetName()) != rLight.setExclusion.end()) + if (rLight.setExclusion.find (tStrToUtf8(vINode[j]->GetName())) != rLight.setExclusion.end()) continue; for (k = 0; k < vMB[j]->Faces.size(); ++k) @@ -142,7 +142,7 @@ void CRTWorld::build (vector &AllLights, CVector &trans, bool bExcl pLAD->create (64, rLight.rDirRadius/64.0f, rLight.Direction); for( j = 0; j < vMB.size(); ++j ) { - if (rLight.setExclusion.find (vINode[j]->GetName()) != rLight.setExclusion.end()) + if (rLight.setExclusion.find (tStrToUtf8(vINode[j]->GetName())) != rLight.setExclusion.end()) continue; for (k = 0; k < vMB[j]->Faces.size(); ++k) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_anim.cpp index 1416d287f..30389d809 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 @@ -605,7 +605,7 @@ void CExportNel::addMorphTracks (NL3D::CAnimation& animation, INode& node, const if (pNode == NULL) continue; std::string name = parentName; - name += pNode->GetName(); + name += tStrToUtf8(pNode->GetName()); name += "MorphFactor"; IParamBlock *pb = (IParamBlock*)(pMorphMod->SubAnim (i+1)); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp index d7db650cb..d9657cd68 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_collision.cpp @@ -73,7 +73,7 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector & { // get the mesh name uint meshId = rootMeshNames.size(); - rootMeshNames.push_back(nodes[node]->GetName()); + rootMeshNames.push_back(tStrToUtf8(nodes[node]->GetName())); bool collision = getScriptAppData (nodes[node], NEL3D_APPDATA_COLLISION, 0) != 0; bool exterior = getScriptAppData (nodes[node], NEL3D_APPDATA_COLLISION_EXTERIOR, 0) != 0; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp index afe64907b..d39d00cf7 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp @@ -1271,7 +1271,7 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC else // standard texture { srcTex = new CTextureFile; - std::string mapName = pBitmap->GetMapName(); + std::string mapName = tStrToUtf8(pBitmap->GetMapName()); static_cast(srcTex)->setFileName (ConvertTexFileName(mapName, _AbsolutePath)); } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh.cpp index 0a0d8c522..5f8fd2811 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 @@ -266,7 +266,7 @@ NL3D::IShape *CExportNel::buildShape (INode& node, TimeValue time, const TInodeP std::string nodeName=getScriptAppData (&node, NEL3D_APPDATA_LOD_NAME+lod, ""); // Get the node - INode *lodNode=_Ip->GetINodeByName(nodeName.c_str()); + INode *lodNode=_Ip->GetINodeByName(utf8ToTStr(nodeName)); if (lodNode) { // Index of the lod in the build structure @@ -611,7 +611,7 @@ void CExportNel::buildBaseMeshInterface (NL3D::CMeshBase::CMeshBaseBuild& buildM continue; // get factor here ! buildMesh.DefaultBSFactors.push_back(0.0f); - std::string sTemp = pNode->GetName(); + std::string sTemp = tStrToUtf8(pNode->GetName()); buildMesh.BSNames.push_back (sTemp); } @@ -1063,9 +1063,8 @@ void CExportNel::buildMeshInterface (TriObject &tri, CMesh::CMeshBuild& buildMes // Error code ? if (error!=NoError) { - char msg[512]; - sprintf (msg, "%s skin: %s", getName (node).c_str(), ErrorMessage[error]); - MessageBox (NULL, msg, "NeL export", MB_OK|MB_ICONEXCLAMATION); + std::string msg = toString("%s skin: %s", getName (node).c_str(), ErrorMessage[error]); + MessageBoxW (NULL, utf8ToTStr(msg), L"NeL export", MB_OK|MB_ICONEXCLAMATION); } else { @@ -1493,7 +1492,7 @@ void CExportNel::buildMeshMorph (CMesh::CMeshBuild& buildMesh, INode &node, Time continue; } - bs.Name = pNode->GetName(); + bs.Name = tStrToUtf8(pNode->GetName()); bool bIsDeltaPos = false; bs.deltaPos.resize (nNbVertVB, CVector::Null); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_mesh_interface.cpp index 899c28a28..0a2e95242 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 @@ -316,7 +316,7 @@ static void AddNodeToQuadGrid(const NLMISC::CAABBox &delimiter, TNodeFaceQG &des { if (delimiter.intersect(nodeBBox)) { - nldebug((std::string("Adding ") + node.GetName() + std::string(" to mesh interface quad grid")).c_str()); + nldebug("Adding %s to mesh interface quad grid", tStrToUtf8(node.GetName()).c_str()); // add this node tris ObjectState os = node.EvalWorldState(time); Object *obj = os.obj; @@ -581,7 +581,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); renameMap.insert (map::value_type (newName, originalName)); - (*lib)[i]->SetName (newName.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(newName)); } // Merge the interface project @@ -614,7 +614,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorGetName (); renameMap.insert (map::value_type (newName, originalName)); - (*lib)[i]->SetName (newName.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(newName)); } } @@ -627,7 +627,7 @@ static bool BuildMeshInterfaces(const char *cMaxFileName, std::vectorSetName (ite->second.c_str ()); + (*lib)[i]->SetName (utf8ToTStr(ite->second)); } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp index a745970eb..87bc96be6 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp @@ -265,7 +265,7 @@ Control* CExportNel::getControlerByName (Animatable& node, const char* sName) ParamDef& paramDef=param->GetParamDef(id); // Good name? - if (strcmp (paramDef.int_name, sName)==0) + if (strcmp (tStrToUtf8(paramDef.int_name).c_str(), sName)==0) { // ok, return this subanim #if MAX_VERSION_MAJOR >= 14 @@ -332,7 +332,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName ParamDef& paramDef=param->GetParamDef(id); // Good name? - if (strcmp (paramDef.int_name, sName)==0) + if (strcmp (tStrToUtf8(paramDef.int_name).c_str(), sName)==0) { // Check this value is good type ParamType2 paramType = param->GetParameterType(id); @@ -372,7 +372,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName break; case TYPE_FILENAME: case TYPE_STRING: - *(std::string*)pValue = param->GetStr (id, tvTime); + *(std::string*)pValue = tStrToUtf8(param->GetStr (id, tvTime)); bRes = TRUE; break; case TYPE_FILENAME_TAB: @@ -382,7 +382,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName uint total = param->Count (id); rTab.resize(total); for( uint i = 0; i < total; ++i ) - rTab[i] = param->GetStr (id, tvTime, i); + rTab[i] = tStrToUtf8(param->GetStr (id, tvTime, i)); bRes = TRUE; } break; @@ -511,8 +511,8 @@ std::string CExportNel::getName (MtlBase& mtl) std::string CExportNel::getName(INode& node) { // Return its name - MCHAR* name = node.GetName(); - return std::string(name); + const MCHAR* name = node.GetName(); + return tStrToUtf8(name); } // -------------------------------------------------- @@ -549,7 +549,7 @@ std::string CExportNel::getNelObjectName (INode& node) } else { - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else @@ -571,19 +571,19 @@ std::string CExportNel::getNelObjectName (INode& node) } else { - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else { // Extract the node name - return node.GetName(); + return tStrToUtf8(node.GetName()); } } else { // Extract the node name - return node.GetName(); + return tStrToUtf8(node.GetName()); } } } @@ -763,17 +763,17 @@ bool CExportNel::hasLightMap (INode& node, TimeValue time) // -------------------------------------------------- -void CExportNel::outputErrorMessage (const char *message) +void CExportNel::outputErrorMessage(const std::string &message) { if (_ErrorInDialog) { - MessageBox (_Ip->GetMAXHWnd(), message, _ErrorTitle.c_str(), MB_OK|MB_ICONEXCLAMATION); + MessageBoxW (_Ip->GetMAXHWnd(), utf8ToTStr(message), utf8ToTStr(_ErrorTitle), MB_OK|MB_ICONEXCLAMATION); } - mprintf (message); - mprintf ("\n"); + mprintf (utf8ToTStr(message)); + mprintf (_T("\n")); nlwarning ("Error in max file %s : ", _Ip->GetCurFilePath()); - nlwarning (message); + nlwarning (message.c_str()); } // -------------------------------------------------- diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h index 7421fad49..d9d8b6189 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_nel.h @@ -667,8 +667,8 @@ public: static void setScriptAppData (Animatable *node, uint32 id, NLMISC::CRGBA val); // Output error message - void outputErrorMessage (const char *message); - void outputWarningMessage (const char *message); + void outputErrorMessage (const std::string &message); + void outputWarningMessage(const std::string &message); // Get an appData VertexProgram WindTree (ensure same default values for all retrieve). diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp index b84eb738e..4b17b17d3 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp @@ -51,7 +51,7 @@ IShape* CExportNel::buildParticleSystem(INode& node, TimeValue time) iF.serial(ss); if (!dynamic_cast(ss.getShapePointer())) { - mprintf("Error : Object shape %s isn't a particle system", shapeName.c_str()); + mprintf(_T("Error : Object shape %s isn't a particle system"), utf8ToTStr(shapeName)); return NULL; } @@ -78,7 +78,7 @@ IShape* CExportNel::buildParticleSystem(INode& node, TimeValue time) } else { - mprintf("Error : Can't find %s while exporting a particle system \n", shapeName.c_str()); + mprintf(_T("Error : Can't find %s while exporting a particle system \n"), utf8ToTStr(shapeName)); return NULL; } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp index 541c0c152..d623b7269 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_radial_normal.cpp @@ -62,7 +62,7 @@ void CRadialVertices::init (INode *node, Mesh *mesh, TimeValue time, Interface & _SmoothingGroupMask |= (1<& vectNode, v resultInstanceNode[nNumIG] = pNode; if (aIGArray[nNumIG].InstanceName == "") // no instance name was set, takes the node name instead { - aIGArray[nNumIG].InstanceName = pNode->GetName(); + aIGArray[nNumIG].InstanceName = tStrToUtf8(pNode->GetName()); } // Visible? always true, but if special flag for camera collision @@ -236,10 +236,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v pMB->Vertices[pMB->Faces[j].Corner[2].Vertex]) ) { // ERROR : The volume is not convex !!! - char tam[256]; - sprintf(tam,"ERROR: The cluster %s is not convex.",vectNode[i]->GetName()); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The cluster %s is not convex.", tStrToUtf8(vectNode[i]->GetName()).c_str()); } } @@ -247,7 +244,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v clusterTemp.VisibleFromFather = bVisibleFromFather; clusterTemp.FatherAudible = bFatherAudible; clusterTemp.AudibleFromFather = bAudibleFromFather; - clusterTemp.Name = pNode->GetName(); + clusterTemp.Name = tStrToUtf8(pNode->GetName()); vClusters.push_back (clusterTemp); delete pMB; pMB = NULL; @@ -336,10 +333,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (!portalTemp.setPoly (polyv)) { // ERROR : Poly not convex, or set of vertices not plane - char tam[256]; - sprintf(tam,"ERROR: The portal %s is not convex.",vectNode[i]->GetName()); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The portal %s is not convex.", tStrToUtf8(vectNode[i]->GetName()).c_str()); } if (nAccelType&16) // is dynamic portal ? @@ -348,7 +342,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (!InstanceName.empty()) portalTemp.setName (InstanceName); else - portalTemp.setName (string(pNode->GetName())); + portalTemp.setName (tStrToUtf8(pNode->GetName())); } // Check if portal has 2 cluster @@ -368,10 +362,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (nNbCluster != 2) { // ERROR - char tam[256]; - sprintf(tam,"ERROR: The portal %s has not 2 clusters but %d",vectNode[i]->GetName(), nNbCluster); - //MessageBox(NULL,tam,"Error",MB_OK|MB_ICONERROR); - nlwarning(tam); + nlwarning("ERROR: The portal %s has not 2 clusters but %d", tStrToUtf8(vectNode[i]->GetName()).c_str(), nNbCluster); } @@ -513,10 +504,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (vClusters.size() > 0) if (aIGArray[nNumIG].Clusters.size() == 0) { - char tam[256]; - sprintf(tam,"ERROR: Object %s is not attached to any cluster\nbut his flag clusterize is set", pNode->GetName()); - //MessageBox(NULL, tam, "Warning", MB_OK); - nlwarning(tam); + nlwarning("ERROR: Object %s is not attached to any cluster\nbut his flag clusterize is set", tStrToUtf8(pNode->GetName()).c_str()); } // debug purpose : to remove @@ -712,7 +700,7 @@ void CExportNel::buildScene (NL3D::CScene &scene, NL3D::CShapeBank &shapeBank, I if ( (!pNode->IsHidden () || buildHidden) && (pNode->Selected () || !onlySelected) ) { string sTmp = "Object Name: "; - sTmp += pNode->GetName(); + sTmp += tStrToUtf8(pNode->GetName()); if (progress) progress->setLine (0, sTmp); sTmp.clear(); diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp index 3d99cee91..1e6304d18 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp @@ -36,7 +36,7 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT four_typed_value_locals(Parser* parser,Value* code,Value* result,StringStream* source); vl.parser = new Parser; - vl.source = new StringStream (const_cast(script)); + vl.source = new StringStream (utf8ToTStr(script)); vl.source->log_to(NULL); save_current_frames(); try diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp index 3708a0906..ec1bb1f92 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp @@ -114,7 +114,7 @@ INode *CExportNel::getNELScaleReferenceNode(INode &node) { std::string boneScaleName= getName(node) + boneScaleNameExt; // Get the reference node - referenceNode= _Ip->GetINodeByName(boneScaleName.c_str()); + referenceNode= _Ip->GetINodeByName(utf8ToTStr(boneScaleName)); } } @@ -455,7 +455,7 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt nlassert ((uint)ite->secondsecond] = ite->first->GetName(); + buildMesh.BonesNames[ite->second] = tStrToUtf8(ite->first->GetName()); // Next ite++; @@ -1306,7 +1306,7 @@ static sint getBoneSide(INode *bone, std::string &mirrorName) { sint side= 0; sint pos; - mirrorName= bone->GetName(); + mirrorName = tStrToUtf8(bone->GetName()); if((pos= mirrorName.find(" R "))!=std::string::npos) { @@ -1335,7 +1335,7 @@ static INode *getMirrorBone(const std::vector &skeletonNodes, INode *bon // find for(uint i=0;iGetName()) + if(mirrorName == tStrToUtf8(skeletonNodes[i]->GetName())) return skeletonNodes[i]; } } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h index e9f3b6b3f..d6c4bb522 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.h @@ -450,7 +450,7 @@ public: } catch (const NLMISC::EStream& excp) { - MessageBox (NULL, excp.what(), "Load error", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(excp.what()), _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } } return _bank; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp index 55e8a8c55..ea21e8fbe 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/rpo2nel.cpp @@ -193,7 +193,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo } catch (const EStream& e) { - MessageBox (NULL, stream.what(), _T("Error"), MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(e.what()), _T("Error"), MB_OK|MB_ICONEXCLAMATION); } } } @@ -253,25 +253,22 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo if (!patchError.empty()) { // Make an error message - char error[2098]; - smprintf (error, 2098, "Error: triple edge detected in "); + std::string error = "Error: triple edge detected in "; // For each error set::iterator ite=patchError.begin(); while (ite!=patchError.end()) { // Sub error message - char subError[512]; - smprintf (subError, 512, "patch %d ", (*ite)+1); - strcat (error, subError); + error += toString("patch %d ", (*ite)+1); // Next error ite++; } // Show the message - mprintf (error); - nlwarning (error); + mprintf (utf8ToTStr(error)); + nlwarning (error.c_str()); // Error return false; @@ -612,7 +609,7 @@ bool RPatchMesh::exportZone(INode* pNode, PatchMesh* pPM, NL3D::CZone& zone, CZo uint i; for (i=0; iSetAlphaSource (ALPHA_NONE); tex->SetAlphaAsMono (FALSE); tex->SetAlphaAsRGB (FALSE); - tex->SetMapName (const_cast((Bank.getAbsPath()+tile->getRelativeFileName(CTile::diffuse)).c_str())); + tex->SetMapName (utf8ToTStr(Bank.getAbsPath() + tile->getRelativeFileName(CTile::diffuse))); // Assign BitmapTex rgb->SetSubTexmap (0, tex); @@ -481,7 +479,7 @@ bool Tile_utility::SetupMaterial () const tex->SetAlphaSource (ALPHA_NONE); tex->SetAlphaAsMono (FALSE); tex->SetAlphaAsRGB (FALSE); - tex->SetMapName (const_cast((Bank.getAbsPath()+tile->getRelativeFileName(CTile::additive)).c_str())); + tex->SetMapName (utf8ToTStr(Bank.getAbsPath() + tile->getRelativeFileName(CTile::additive))); // Assign BitmapTex rgb->SetSubTexmap (1, tex); diff --git a/code/nel/tools/3d/tile_edit/View.cpp b/code/nel/tools/3d/tile_edit/View.cpp index d0eecb229..0cfe0719a 100644 --- a/code/nel/tools/3d/tile_edit/View.cpp +++ b/code/nel/tools/3d/tile_edit/View.cpp @@ -417,9 +417,8 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile: else { // Error: bitmap not in the absolute path.. - char msg[512]; - sprintf (msg, "The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); - MessageBox (NULL, msg, "Load error", MB_OK|MB_ICONEXCLAMATION); + std::string msg = NLMISC::toString("The bitmap %s is not in the absolute path %s.", name.c_str(), tileBank2.getAbsPath ().c_str()); + MessageBox (NULL, utf8ToTStr(msg), _T("Load error"), MB_OK|MB_ICONEXCLAMATION); } return 1; diff --git a/code/nel/tools/3d/tile_edit/choose_veget_set.cpp b/code/nel/tools/3d/tile_edit/choose_veget_set.cpp index a8aa6878c..e1ccf4f4f 100644 --- a/code/nel/tools/3d/tile_edit/choose_veget_set.cpp +++ b/code/nel/tools/3d/tile_edit/choose_veget_set.cpp @@ -68,8 +68,8 @@ void CChooseVegetSet::OnBrowse() if (dialog.DoModal() == IDOK) { // Get the file name - FileName = dialog.GetFileName (); - Name.SetWindowText (FileName.c_str()); + FileName = tStrToUtf8(dialog.GetFileName ()); + Name.SetWindowText (utf8ToTStr(FileName)); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp index 301a9d893..2e1cafce8 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp @@ -193,7 +193,7 @@ void CDfnDialog::getFromDocument (const NLGEORGES::CFormDfn &dfn) for (parent=0; parentmodify (new CActionStringVectorVector (IAction::DfnStructure, stringVector, *doc, doc->getLeftView ()->getCurrentSelectionId (), 0)); @@ -301,19 +301,19 @@ CEditListCtrl::TItemEdit CDfnEditListCtrl::getItemEditMode (uint item, uint subI return CEditListCtrl::EditFixedCombo; else if (subItem == 2) { - string type = ListCtrl.GetItemText (item, 1); + string type = tStrToUtf8(ListCtrl.GetItemText (item, 1)); if (type != "Virtual Dfn") return CEditListCtrl::EditMemCombo; } else if (subItem == 3) { - string type = ListCtrl.GetItemText (item, 1); + string type = tStrToUtf8(ListCtrl.GetItemText (item, 1)); if ((type == "Type") || (type == "Type array")) return CEditListCtrl::EditMemCombo; } else if (subItem == 4) { - string type = ListCtrl.GetItemText (item, 1); + string type = tStrToUtf8(ListCtrl.GetItemText (item, 1)); if ((type == "Type") || (type == "Type array")) return CEditListCtrl::EditMemCombo; } @@ -349,7 +349,7 @@ void CDfnEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string browse = true; // Get type string - string type = ListCtrl.GetItemText (item, 1); + string type = tStrToUtf8(ListCtrl.GetItemText (item, 1)); if ((type == "Type") || (type == "Type array")) regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type MemCombo"; else if ((type == "Dfn") || (type == "Dfn array")) @@ -390,7 +390,7 @@ void CDfnEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defE if (subItem == 2) { // Get type string - string type = ListCtrl.GetItemText (item, 1); + string type = tStrToUtf8(ListCtrl.GetItemText (item, 1)); if ((type == "Type") || (type == "Type array")) { filter = TypeFilter; @@ -415,7 +415,7 @@ void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) if (subItem == 1) { // Get type string - string type = ListCtrl.GetItemText (item, 1); + string type = tStrToUtf8(ListCtrl.GetItemText (item, 1)); if ((type == "Type") || (type == "Type array")) { CString str; @@ -470,16 +470,16 @@ void CDfnDialog::onOpenSelected () int nItem = Parents.ListCtrl.GetNextSelectedItem(pos); // Get the string - CString str = Parents.ListCtrl.GetItemText (nItem, 0); - if (str != "") + std::string str = tStrToUtf8(Parents.ListCtrl.GetItemText (nItem, 0)); + if (!str.empty()) { // Look for the file - string name = CPath::lookup ((const char*)str, false, false); + string name = CPath::lookup (str, false, false); if (name.empty ()) name = str; // Open the file - theApp.OpenDocumentFile (name.c_str ()); + theApp.OpenDocumentFile (utf8ToTStr(name)); } } } @@ -492,16 +492,16 @@ void CDfnDialog::onOpenSelected () int nItem = Struct.ListCtrl.GetNextSelectedItem(pos); // Get the string - CString str = Struct.ListCtrl.GetItemText (nItem, 2); - if (str != "") + std::string str = tStrToUtf8(Struct.ListCtrl.GetItemText (nItem, 2)); + if (!str.empty()) { // Look for the file - string name = CPath::lookup ((const char*)str, false, false); + string name = CPath::lookup (str, false, false); if (name.empty ()) name = str; // Open the file - theApp.OpenDocumentFile (name.c_str ()); + theApp.OpenDocumentFile (utf8ToTStr(name)); } } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index 549c953e4..e42408f3d 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -477,9 +477,9 @@ void CGeorgesEditApp::OnAppAbout() void CGeorgesEditApp::outputError (const char* message) { if (m_pMainWnd) - m_pMainWnd->MessageBox (message, "Georges Edit", MB_OK|MB_ICONEXCLAMATION); + m_pMainWnd->MessageBox (utf8ToTStr(message), _T("Georges Edit"), MB_OK|MB_ICONEXCLAMATION); else - MessageBox (NULL, message, "Georges Edit", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, utf8ToTStr(message), _T("Georges Edit"), MB_OK|MB_ICONEXCLAMATION); } void CGeorgesEditApp::getConfigFilePath (std::string &output) diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp index 1d7396ee0..d43277d6c 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp @@ -698,8 +698,8 @@ void CMissionCompilerFeDlg::OnSpecialRuncompilertest() catch(const EParseException &e) { string msg = "In primitive "; - msg += buildPrimPath(e.Primitive) +" : "+e.Why; - AfxMessageBox(msg.c_str()); + msg += buildPrimPath(e.Primitive) + ": " + e.Why; + AfxMessageBox(utf8ToTStr(msg)); } } 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 30b15cf8d..63b1d545f 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 @@ -130,7 +130,7 @@ bool CDataBase::init (const string &Path, CZoneBank &zb) string sDirBackup = NLMISC::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())); NLMISC::CPath::setCurrentPath(s2.c_str()); string ss = NLMISC::CPath::getFullPath(Path); NLMISC::CPath::setCurrentPath (ss.c_str()); @@ -622,8 +622,8 @@ bool CBuilderZone::refresh () if (!_ZoneRegions[_ZoneRegionSelected]->init (&_ZoneBank, this, error)) { unload (_ZoneRegionSelected); - MessageBox (NULL, ("Cannot add this zone :\n"+error).c_str(), - "Error", MB_ICONERROR|MB_OK); + std::string msg = NLMISC::toString("Cannot add this zone :\n%s", error.c_str()); + MessageBox (NULL, utf8ToTStr(msg), _T("Error"), MB_ICONERROR|MB_OK); return false; } @@ -1601,7 +1601,7 @@ bool CBuilderZone::initZoneBank (const string &sPathName) // TODO: replace by NeL methods TCHAR sDirBackup[512]; GetCurrentDirectory (512, sDirBackup); - SetCurrentDirectory (sPathName.c_str()); + SetCurrentDirectory (utf8ToTStr(sPathName)); WIN32_FIND_DATA findData; HANDLE hFind; hFind = FindFirstFile (_T("*.ligozone"), &findData); @@ -1612,7 +1612,7 @@ bool CBuilderZone::initZoneBank (const string &sPathName) if (!((_tcscmp (findData.cFileName, _T(".")) == 0) || (_tcscmp (findData.cFileName, _T("..")) == 0))) { string error; - if (!_ZoneBank.addElement (findData.cFileName, error)) + if (!_ZoneBank.addElement (tStrToUtf8(findData.cFileName), error)) theApp.errorMessage (error.c_str()); } if (FindNextFile (hFind, &findData) == 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 9ee63294a..706c4053e 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 @@ -37,9 +37,9 @@ CFileDialogEx::CFileDialogEx(LPCTSTR lpszRegistryPath, LPCTSTR lpszFileType,BOOL LPCTSTR lpszDefExt, LPCTSTR lpszFileName, DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) : CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd) { - _RegistryPath = lpszRegistryPath; + _RegistryPath = tStrToUtf8(lpszRegistryPath); _RegistryPath += "\\CFileDialogEx"; - _FileType = lpszFileType; + _FileType = tStrToUtf8(lpszFileType); } // *************************************************************************** @@ -58,10 +58,10 @@ INT_PTR CFileDialogEx::DoModal () path[0] = 0; HKEY hKey; DWORD type = REG_SZ; - DWORD size = 512; - if (RegCreateKey (HKEY_CURRENT_USER, _RegistryPath.c_str (), &hKey) == ERROR_SUCCESS) + DWORD size = 512 * sizeof(TCHAR); + if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(_RegistryPath), &hKey) == ERROR_SUCCESS) { - if (RegQueryValueEx (hKey, _FileType.c_str (), 0, &type, (LPBYTE)path, &size) == ERROR_SUCCESS) + if (RegQueryValueEx (hKey, utf8ToTStr(_FileType), 0, &type, (LPBYTE)path, &size) == ERROR_SUCCESS) m_ofn.lpstrInitialDir = path; } @@ -73,9 +73,9 @@ INT_PTR CFileDialogEx::DoModal () if ((result = CFileDialog::DoModal ()) == IDOK) { // Update the path - std::string newPath = (const char *)GetPathName (); + std::string newPath = tStrToUtf8(GetPathName ()); newPath = NLMISC::CFile::getPath (newPath); - RegSetValueEx (hKey, _FileType.c_str (), 0, REG_SZ, (LPBYTE)newPath.c_str (), newPath.size ()+1); + RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)newPath.c_str (), newPath.size ()+1); // Update the path list set oldPath; @@ -83,15 +83,15 @@ INT_PTR CFileDialogEx::DoModal () for (i=0; i::const_iterator ite = oldPath.begin (); uint index = 0; while (ite != oldPath.end ()) { - RegSetValueEx (hKey, toString (index).c_str (), 0, REG_SZ, (LPBYTE)ite->c_str (), ite->size ()+1); + RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)ite->c_str (), ite->size ()+1); ite++; index++; } @@ -153,13 +153,13 @@ BOOL CFileDialogEx::OnInitDialog() HKEY hKey; DWORD type = REG_SZ; DWORD size; - if (RegCreateKey (HKEY_CURRENT_USER, _RegistryPath.c_str (), &hKey) == ERROR_SUCCESS) + if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(_RegistryPath), &hKey) == ERROR_SUCCESS) { uint i; for (i=0; isetCurrentSelection(resSet); - - }catch(const exception &e){ - GraphDlg->MessageBox(e.what()); + } + catch(const exception &e) + { + GraphDlg->MessageBox(utf8ToTStr(e.what())); } } } \ No newline at end of file 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 223860403..54184c45a 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 @@ -301,7 +301,7 @@ void CDialogFlags::setCurrentEntityDisplayMode(TEntityDisplayMode edm) void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos, const std::string ®Id) { HKEY hKey; - if (RegOpenKeyEx(HKEY_CURRENT_USER, (REGKEY_ENTITY_DISPLAY_INFO + regId).c_str(), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + if (RegOpenKeyEx(HKEY_CURRENT_USER, utf8ToTStr(tStrToUtf8(REGKEY_ENTITY_DISPLAY_INFO) + regId), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { DWORD index = 0; for(;;) @@ -338,14 +338,14 @@ void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos void CDialogFlags::saveEntityDisplayInfoToRegistry(const TEntityDisplayInfoVect &infos, const std::string ®Id) { HKEY hKey; - if (RegCreateKeyEx(HKEY_CURRENT_USER, (REGKEY_ENTITY_DISPLAY_INFO + regId).c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) + if (RegCreateKeyEx(HKEY_CURRENT_USER, utf8ToTStr(tStrToUtf8(REGKEY_ENTITY_DISPLAY_INFO) + regId), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) { 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, toString((int) infos[k].Value).c_str(), 0, REG_SZ, (const BYTE *) colorStr, strlen(colorStr)); + LONG result = RegSetValueEx(hKey, utf8ToTStr(toString(infos[k].Value)), 0, REG_SZ, (const BYTE *) colorStr, strlen(colorStr)); 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_shard_monitor_plugin/memory_combo_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp index 5788c2d72..531b58e89 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp @@ -47,7 +47,7 @@ void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT { // Register a window Id = nId; - RegisterAdress = registerAdress; + RegisterAdress = tStrToUtf8(registerAdress); MemoryCount = memoryCount; LPCTSTR clas = AfxRegisterWndClass (0); if (clas) @@ -95,16 +95,16 @@ bool CMemoryComboBox::getMemory (int slot, std::string &ret) { // Open the key HKEY hKey; - if (RegOpenKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + if (RegOpenKey (HKEY_CURRENT_USER, utf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) { // Get the value char strSrc[512]; smprintf (strSrc, 512, "%d", slot); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + TCHAR str[512]; + long size = 512*sizeof(TCHAR); + if (RegQueryValue (hKey, utf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { - ret = str; + ret = tStrToUtf8(str); // Close RegCloseKey (hKey); @@ -124,7 +124,7 @@ void CMemoryComboBox::scrollDown (int start, int end) { // Open the key HKEY hKey; - if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) { // Scroll down the list for (int i=end-1; i>start; i--) @@ -132,14 +132,14 @@ void CMemoryComboBox::scrollDown (int start, int end) // Get the old value char strSrc[512]; smprintf (strSrc, 512, "%d", i-1); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + TCHAR str[512]; + long size = 512 * sizeof(TCHAR); + if (RegQueryValue (hKey, utf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { // Set the value char strDst[512]; smprintf (strDst, 512, "%d", i); - RegSetValue (hKey, strDst, REG_SZ, str, size); + RegSetValue (hKey, utf8ToTStr(strDst), REG_SZ, str, size); } } @@ -154,10 +154,10 @@ void CMemoryComboBox::writeStringInRegistry (const std::string &str) { // Open the key HKEY hKey; - if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) { // Set the value - RegSetValue (hKey, "0", REG_SZ, str.c_str (), str.size ()); + RegSetValue (hKey, _T("0"), REG_SZ, utf8ToTStr(str), str.size ()); // Close RegCloseKey (hKey); @@ -364,7 +364,7 @@ void CMemoryComboBox::pushString () { CString str; GetWindowText (str); - pushString((LPCTSTR) str); + pushString(tStrToUtf8(str)); } @@ -428,7 +428,7 @@ void CMemoryComboBox::pushString (const std::string &str) if (i == (int)(itemCount+Commands.size()+ StaticStrings.size())) { // Insert the sting - _ComboBox.InsertString (Commands.size()+ StaticStrings.size(), str.c_str()); + _ComboBox.InsertString (Commands.size()+ StaticStrings.size(), utf8ToTStr(str)); } } } @@ -449,7 +449,7 @@ void CMemoryComboBox::refreshStrings () int count = Commands.size(); for (i=0; iUpdateData (TRUE); - _SHost = (const char*)_DialogFlag->ShardCtrl.getCurrString(); + _SHost = tStrToUtf8(_DialogFlag->ShardCtrl.getCurrString()); _DialogFlag->ShardCtrl.onOK(); @@ -1189,7 +1189,7 @@ void CPlugin::updateConnectionState() // Change the text _DialogFlag->ConnectCtrl.SetWindowText (getStringRsc(IDS_DISCONNECT)); _DialogFlag->State = (LPCTSTR) (getStringRsc(IDS_CONNECTED_TO) + _SHost.c_str()); - _DialogFlag->Sent = (toString ((uint32)_Client->getBytesSent ()) + (LPCTSTR) getStringRsc(IDS_BYTE_SENT)).c_str(); + _DialogFlag->Sent = CString(utf8ToTStr(toString (_Client->getBytesSent ()))) + getStringRsc(IDS_BYTE_SENT); //_DialogFlag->Received = (toString ((uint32)_Client->getBytesReceived ()) + " bytes received").c_str(); _DialogFlag->Received = (toString("%.1f", bandwidth/1024.0) + " kB/s").c_str(); _DialogFlag->DownloadValue = (toString("%.1f kB/s", _DialogFlag->Download/1024.0)).c_str(); @@ -1198,12 +1198,12 @@ void CPlugin::updateConnectionState() break; case WaitingServerParams: _DialogFlag->ConnectCtrl.SetWindowText (getStringRsc(IDS_CANCEL_CONNECT)); - _DialogFlag->State = (LPCTSTR) (getStringRsc(IDS_WAITING_SERVER_PARAMS) + _SHost.c_str()); + _DialogFlag->State = getStringRsc(IDS_WAITING_SERVER_PARAMS) + utf8ToTStr(_SHost); break; case WaitingLoginConfirmation: { _DialogFlag->ConnectCtrl.SetWindowText (getStringRsc(IDS_CANCEL_CONNECT)); - std::string label = (LPCTSTR) getStringRsc(IDS_WAITING_LOGIN_CONFIRMATION) +_SHost; + std::string label = tStrToUtf8(getStringRsc(IDS_WAITING_LOGIN_CONFIRMATION)) + _SHost; switch((NLMISC::CTime::getLocalTime() / 200) % 4) { case 0: label+= "-"; break; 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 0d1e0cbe7..a83578c9f 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,19 +225,20 @@ void CDialogFlags::OnTimer(UINT_PTR nIDEvent) c = _SbList.GetItemCount(); for (i=0; i Date: Tue, 22 Nov 2016 19:04:02 +0100 Subject: [PATCH 12/16] Fixed: CSystemInfo::availableHDSpace implementation under Unix --HG-- branch : develop --- code/nel/src/misc/system_info.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index 9bea47e29..680329dcf 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -1387,13 +1387,10 @@ uint64 CSystemInfo::availableHDSpace (const string &filename) std::string path = CFile::getPath(filename); #ifdef NL_OS_UNIX - struct stat stst; struct statfs stfs; + if (::statfs(path.c_str(), &stfs) != 0) return 0; - if (::stat(path.c_str(), &stst) == -1) return 0; - if (::statfs(path.c_str(), &stfs) == -1) return 0; - - return (uint64)(stfs.f_bavail * stst.st_blksize); + return (uint64)(stfs.f_bavail * stfs.f_bsize); #else ULARGE_INTEGER freeSpace = {0}; BOOL bRes = ::GetDiskFreeSpaceExW(utf8ToWide(path), &freeSpace, NULL, NULL); From 033a337419a3c318fc5bcc91d4b33ab551f0044e Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 22 Nov 2016 19:34:43 +0100 Subject: [PATCH 13/16] Changed: Replace all _splitpath by NeL methods --HG-- branch : develop --- code/nel/tools/3d/ligo/plugin_max/script.cpp | 80 +++++++------------ .../3d/object_viewer/animation_set_dlg.cpp | 6 +- .../3d/object_viewer/edit_morph_mesh_dlg.cpp | 14 +--- code/nel/tools/3d/object_viewer/mesh_dlg.cpp | 17 ++-- .../plugin_max/nel_export/nel_export_view.cpp | 10 +-- .../nel_mesh_lib/export_material.cpp | 16 ---- .../plugin_max/nel_mesh_lib/export_misc.cpp | 7 +- .../3d/plugin_max/nel_patch_paint/paint.cpp | 10 +-- .../plugin_max/nel_patch_paint/paint_ui.cpp | 24 ++---- .../plugin_max/tile_utility/tile_utility.cpp | 17 ++-- code/nel/tools/3d/tile_edit/Browse.cpp | 26 +++--- .../3d/tile_edit/SelectionTerritoire.cpp | 18 ++--- code/nel/tools/3d/tile_edit/View.cpp | 26 +++--- .../leveldesign/georges_dll/dfn_dialog.cpp | 14 ++-- .../georges_dll/file_tree_view.cpp | 8 +- .../leveldesign/georges_dll/form_dialog.cpp | 4 +- .../leveldesign/georges_dll/georges_edit.cpp | 36 +++------ .../georges_dll/georges_edit_doc.cpp | 21 ++--- .../leveldesign/georges_dll/imagelist_ex.cpp | 12 +-- .../world_editor/imagelist_ex.cpp | 12 +-- 20 files changed, 126 insertions(+), 252 deletions(-) diff --git a/code/nel/tools/3d/ligo/plugin_max/script.cpp b/code/nel/tools/3d/ligo/plugin_max/script.cpp index d8f8123cd..b494f69ff 100644 --- a/code/nel/tools/3d/ligo/plugin_max/script.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/script.cpp @@ -151,7 +151,7 @@ Value* export_material_cf (Value** arg_list, int count) nlassert (node); // The second arg - const char *fileName = arg_list[1]->to_string(); + const std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The third arg bool checkOnly = (arg_list[2]->to_bool() != FALSE); @@ -204,12 +204,7 @@ Value* export_material_cf (Value** arg_list, int count) { // Make a name for the zone - char drive[512]; - char dir[512]; - char name[512]; - char path[512]; - _splitpath (fileName, drive, dir, name, NULL); - _makepath (path, drive, dir, name, ".zone"); + std::string path = CFile::getPath(fileName) + CFile::getFilenameWithoutExtension(fileName) + ".zone"; // Ok ? bool ok = true; @@ -322,7 +317,7 @@ Value* export_transition_cf (Value** arg_list, int count) nlassert (is_array(nodes)); // The second arg - const char *fileName = arg_list[1]->to_string(); + std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The second arg string matFilename[2]; @@ -505,10 +500,7 @@ Value* export_transition_cf (Value** arg_list, int count) for (zone=0; zoneSaved.AnimationFileName.size(); i++) { // Get the animation name - char name[512]; - _splitpath (object->Saved.AnimationFileName[i].c_str(), NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.AnimationFileName[i]); // Get the animation pointer CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name)); @@ -314,8 +313,7 @@ void CAnimationSetDlg::refresh (BOOL update) for (i=0; iSaved.SWTFileName.size(); i++) { // Get the animation name - char name[512]; - _splitpath (object->Saved.SWTFileName[i].c_str(), NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.SWTFileName[i]); // Get the animation pointer CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight (object->AnimationSet.getSkeletonWeightIdByName (name)); diff --git a/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp index afcc75e34..0c7def7e9 100644 --- a/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp @@ -84,21 +84,9 @@ bool CEditMorphMeshDlg::getShapeNameFromDlg(std::string &name) CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this); if (fd.DoModal() == IDOK) { - // Add to the path - /* - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - */ - - // Add search path for the texture /* - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())); */ name = tStrToUtf8(fd.GetPathName()); diff --git a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp index 991ae09f3..c81a1d92a 100644 --- a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp @@ -94,22 +94,17 @@ void CMeshDlg::OnBrowseShape() if (fd.DoModal() == IDOK) { // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - + std::string fullPath = tStrToUtf8(fd.GetPathName()); + std::string fname = NLMISC::CFile::getFilenameWithoutExtension(fullPath); + std::string ext = NLMISC::CFile::getExtension(fullPath); // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(fullPath)); try { - _ShapeParticle->setShape(std::string(fname) + ext); - m_ShapeName = (std::string(fname) + ext).c_str(); + _ShapeParticle->setShape(fname + "." + ext); + m_ShapeName = utf8ToTStr(fname + "." + ext); touchPSState(); } catch (const NLMISC::Exception &e) diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp index 3461f0e46..bff98becc 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp @@ -111,15 +111,13 @@ void regsiterOVPath () if (!hModule) { ::MessageBox(NULL, "'hModule' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } char sModulePath[256]; int res = GetModuleFileName(hModule, sModulePath, 256); - if (!res) { ::MessageBox(NULL, "'res' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } - char SDrive[512]; - char SDir[512]; - _splitpath (sModulePath, SDrive, SDir, NULL, NULL); - _makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); + if (!res) { ::MessageBox(NULL, _T("'res' failed at '") __FUNCTION__ _T("' in file '") __FILE__ _T(" on line ") NL_MACRO_TO_STR(__LINE__), _T("NeL Export"), MB_OK | MB_ICONERROR); return; } + + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "object_viewer.cfg"; // Load the config file CConfigFile cf; - cf.load (sModulePath); + cf.load (modulePath); try { diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp index d39d00cf7..8f7957175 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp @@ -1142,22 +1142,6 @@ int CExportNel::getVertMapChannel (Texmap& texmap, Matrix3& channelMatrix, TimeV // get the absolute or relative path from a texture filename static std::string ConvertTexFileName(const std::string &path, bool _AbsolutePath) { - /*// File name, maxlen 256 under windows - char sFileName[512]; - strcpy (sFileName, src); - - // Let absolute path ? - if (!_AbsolutePath) - { - // Decompose bitmap file name - char sName[256]; - char sExt[256]; - _splitpath (sFileName, NULL, NULL, sName, sExt); - - // Make the final path - _makepath (sFileName, NULL, NULL, sName, sExt); - } - return std::string(sFileName);*/ if (_AbsolutePath) { return path; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp index 87bc96be6..51b8aa367 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp @@ -561,13 +561,10 @@ std::string CExportNel::getNelObjectName (INode& node) ad = obj->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE); if (ad&&ad->data) { - if (::strlen((const char *) ad->data) != 0) + if (_tcslen((const TCHAR *) ad->data) != 0) { // get file name only - char fName[_MAX_FNAME]; - char ext[_MAX_FNAME]; - ::_splitpath((const char*)ad->data, NULL, NULL, fName, ext) ; - return std::string(fName + std::string(ext)); + return NLMISC::CFile::getFilename(tStrToUtf8((const TCHAR*)ad->data)); } else { diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp index 799f1012d..9f5c7b4cb 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp @@ -4058,20 +4058,18 @@ bool loadLigoConfigFile (CLigoConfig& config, Interface& it) if (hModule) { // Get the path - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); // Success ? if (res) { // Path - char sDrive[256]; - char sDir[256]; - _splitpath (sModulePath, sDrive, sDir, NULL, NULL); - _makepath (sModulePath, sDrive, sDir, "ligoscape", ".cfg"); + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)); + try { // Load the config file - config.readConfigFile (sModulePath, false); + config.readConfigFile (modulePath, false); // ok return true; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp index 46b1ad1d7..7f6fec25c 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp @@ -409,24 +409,17 @@ void LoadKeyCfg () HMODULE hModule = hInstance; if (hModule) { - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); if (res) { - // split path - char drive[256]; - char dir[256]; - _splitpath (sModulePath, drive, dir, NULL, NULL); - // Make a new path - char cgfPath[256]; - _makepath (cgfPath, drive, dir, "keys", ".cfg"); - + std::string cfgPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "keys.cfg"; CConfigFile cf; // Load and parse "test.txt" file - cf.load (cgfPath); + cf.load (cfgPath); // For each keys for (uint key=0; keygetTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive).empty()) { // Try to load a tile with a file name like /tiletransition0.tga - char sName2[256]; - char sFinal[256]; - sprintf (sName2, "%s%02d", sName, (int)transition); - _makepath (sFinal, sDrive, sPath, sName2, sExt); - FILE *pFile=fopen (sFinal, "rb"); + std::string sFinal = path + toString("%s%02d.%s", filename.c_str(), (int)transition, ext.c_str()); + + FILE *pFile = nlfopen (sFinal, "rb"); // Close the file and add the tile if opened if (pFile) diff --git a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp index a7493c62e..eb7738411 100644 --- a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp +++ b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp @@ -386,12 +386,8 @@ void SelectionTerritoire::OnSelect() list2->AddString(tileBank.getTileSet(i)->getName().c_str()); } - char drive[256],name[256],path[256],ext[256]; - _splitpath(temp,drive,path,name,ext); - MainFileName = name; - MainFileName += ext; - DefautPath = drive; - DefautPath += path; + MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); + DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp))); MainFileOk = 1; CButton *button = (CButton*)GetDlgItem(IDC_ADD_TERRITOIRE); @@ -468,12 +464,10 @@ void SelectionTerritoire::OnSaveAs() button->EnableWindow(true); // Create a file name - char drive[256],name[256],path[256],ext[256]; - _splitpath(sFile.GetPathName(), drive, path, name, ext); - MainFileName = name; - MainFileName += ext; - DefautPath = drive; - DefautPath += path; + std::string temp = tStrToUtf8(sFile.GetPathName()); + + MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); + DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp))); } } diff --git a/code/nel/tools/3d/tile_edit/View.cpp b/code/nel/tools/3d/tile_edit/View.cpp index 0cfe0719a..354f1e51d 100644 --- a/code/nel/tools/3d/tile_edit/View.cpp +++ b/code/nel/tools/3d/tile_edit/View.cpp @@ -1283,11 +1283,10 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) &*bits->begin(),bmpinf,DIB_RGB_COLORS,SRCCOPY); } - char temp[100]; - char Name[256]; Name[0] = 0; + std::string Name; if (InfoTexte==2) { - _splitpath(pth.c_str(),temp,temp,Name,temp); + Name = NLMISC::CFile::getFilenameWithoutExtension(pth); } else if (InfoTexte==3) { @@ -1295,12 +1294,20 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) } else if (InfoTexte==1) { - sprintf(Name,"%d",i->id); + Name = NLMISC::toString("%d", i->id); } rect_txt.top = pt.y + sizetile_y + spacing_tile_text; rect_txt.bottom += rect_txt.top + sizetext_y; rect_txt.left -= spacing_x; - pDC->DrawText(Name,(int)strlen(Name),&rect_txt,DT_CENTER | DT_SINGLELINE); + +#ifdef _UNICODE + ucstring tmp; + tmp.fromUtf8(Name); +#else + std::string tmp = Name; +#endif + + pDC->DrawText((LPCTSTR)tmp.c_str(), (int)tmp.length(), &rect_txt,DT_CENTER | DT_SINGLELINE); // Restore the device context pDC->SetBkColor( clrBk ); @@ -1537,15 +1544,12 @@ LRESULT CTView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { CString str = load.GetNextPathName(p); - char sDrive[256]; - char sPath[256]; - _splitpath (str, sDrive, sPath, NULL, NULL); - LastPath=string (sDrive)+string (sPath); + LastPath = NLMISC::CFile::getPath(tStrToUtf8(str)); - if (str!=CString("")) + if (!str.IsEmpty()) { int index=0; - const char *pathname = (LPCTSTR)str; + std::string pathname = tStrToUtf8(str); // Add mode, to the end of the list if (id==ID_MENU_ADD) diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp index 2e1cafce8..3c12eb254 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp @@ -420,19 +420,17 @@ void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) { CString str; str = Dialog->Struct.ListCtrl.GetItemText (item, 2); - char ext[MAX_PATH]; - _splitpath (str, NULL, NULL, NULL, ext); - if (stricmp (ext, ".typ") != 0) - Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultType.c_str ()); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str)); + if (ext == "typ") + Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultType)); } else if ((type == "Dfn") || (type == "Dfn array")) { CString str; str = Dialog->Struct.ListCtrl.GetItemText (item, 2); - char ext[MAX_PATH]; - _splitpath (str, NULL, NULL, NULL, ext); - if (stricmp (ext, ".dfn") != 0) - Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultDfn.c_str ()); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str)); + if (ext == "dfn") + Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultDfn)); // Clear default value Dialog->Struct.ListCtrl.SetItemText (item, 3, _T("")); diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index 43c71f240..fac4cb052 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -403,11 +403,9 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByType) { - char ext1[_MAX_EXT]; - _splitpath (pItemInfo1->displayName.c_str(), NULL, NULL, NULL, ext1); - char ext2[_MAX_EXT]; - _splitpath (pItemInfo2->displayName.c_str(), NULL, NULL, NULL, ext2); - int res = stricmp (ext1, ext2); + std::string ext1 = NLMISC::CFile::getExtension(pItemInfo1->displayName); + std::string ext2 = NLMISC::CFile::getExtension(pItemInfo2->displayName); + int res = stricmp (ext1.c_str(), ext2.c_str()); if ( res == 0) return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); else diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index 60a555797..76421972b 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -1173,9 +1173,7 @@ void CFormDialog::getDfnName (string &result) const { // Get the DFN filename CString str = doc->GetPathName (); - char extension[512]; - _splitpath (str, NULL, NULL, NULL, extension); - result = (*extension == '.') ? extension+1 : extension; + result NLMISC::CFile::getExtension(tStrToUtf8(str)); } else result.clear(); diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index e42408f3d..d11e33a5a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -485,12 +485,7 @@ void CGeorgesEditApp::outputError (const char* message) void CGeorgesEditApp::getConfigFilePath (std::string &output) { // Get the config file path - char sDrive[MAX_PATH]; - char sDir[MAX_PATH]; - char sPath[MAX_PATH]; - _splitpath (theApp.ExePath.c_str (), sDrive, sDir, NULL, NULL); - _makepath (sPath, sDrive, sDir, "georges", ".cfg"); - output = sPath; + output = NLMISC::CFile::getPath(theApp.ExePath) + "georges.cfg"; } bool CGeorgesEditApp::loadCfg () @@ -962,12 +957,7 @@ void CGeorgesEditApp::gotoURL (LPCTSTR url) void CGeorgesEditApp::WinHelp(DWORD dwData, UINT nCmd) { - char drive[512]; - char dir[512]; - char path[512]; - _splitpath (ExePath.c_str (), drive, dir, NULL, NULL); - _makepath (path, drive, dir, "georges_edit", ".html"); - gotoURL (path); + gotoURL(utf8ToTStr(NLMISC::CFile::getPath(ExePath) + "georges_edit.html")); } void CGeorgesEditApp::OnViewRefresh() @@ -1478,9 +1468,8 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) name = name.substr (6, name.size ()-8); // Get the extension - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, NULL, ext); - string dfnName = string (ext+1) + ".dfn"; + std::string ext = NLMISC::CFile::getExtension(name); + string dfnName = ext + ".dfn"; // Get the doc template CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ()); @@ -1541,18 +1530,15 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) name = name.substr (8, name.size ()-10); // Get the extension - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, NULL, ext); - string dfnName = string (ext+1) + ".dfn"; + std::string ext = NLMISC::CFile::getExtension(name); + string dfnName = ext + ".dfn"; // Create a document CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); if (doc) { - char nameFile[MAX_PATH]; - char extFile[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, nameFile, extFile); - doc->addParent ((string (nameFile) + extFile).c_str ()); + std::string nameFile = NLMISC::CFile::getFilename(name); + doc->addParent (nameFile.c_str()); doc->updateDocumentStructure (); doc->UpdateAllViews (NULL); } @@ -1570,11 +1556,7 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) name = name.substr (10, name.size ()-12); // Get the extension - char name2[MAX_PATH]; - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, name2, ext); - string dfnName = name2; - dfnName += ext; + std::string dfnName = NLMISC::CFile::getFilename(name); // Create a document CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp index 7ecae14db..941824e73 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp @@ -181,13 +181,9 @@ bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement) } // Set file name and title - char name[512]; - char ext[512]; - _splitpath (dfnName, NULL, NULL, name, ext); - string name2 = (const char*)(name); - name2 = strlwr (name2); - SetPathName ( ("*."+name2).c_str(), FALSE); - SetTitle ( ("New "+name2+" form").c_str() ); + std::string name2 = toLower(NLMISC::CFile::getFilenameWithoutExtension(dfnName)); + SetPathName (utf8ToTStr("*." + name2), FALSE); + SetTitle (utf8ToTStr("New " + name2 + " form")); // TMp if (newElement) @@ -547,9 +543,9 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) try { // Check form - char ext[MAX_PATH]; - _splitpath (lpszPathName, NULL, NULL, NULL, ext); - string extLower = strlwr (string (ext)); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(lpszPathName)); + string extLower = toLower(ext); + if (!extLower.empty ()) { string dfnName = extLower.substr (1, string::npos) + ".dfn"; @@ -1090,10 +1086,7 @@ void CGeorgesEditDoc::getDfnFilename (std::string &dfnName) // Get the DFN filename CString str = GetPathName (); - char extension[512]; - _splitpath (str, NULL, NULL, NULL, extension); - dfnName = extension+1; - dfnName += ".dfn"; + dfnName = NLMISC::CFile::getExtension(tStrToUtf8(str)) + ".dfn"; } // *************************************************************************** diff --git a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp index 195a44381..590e98a25 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp @@ -103,10 +103,8 @@ void CImageListEx::addResourceIcon (const char *filename) index = ImageList.Replace( index, handle); // Add in the map - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - _IconMapString.insert (std::map::value_type (llwr, index)); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(filename); + _IconMapString.insert (std::map::value_type (toLower(name), index)); // Release the icon DestroyIcon (handle); @@ -131,10 +129,8 @@ int CImageListEx::getImage (int resource) const int CImageListEx::getImage (const char *filename) const { - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - std::map::const_iterator ite = _IconMapString.find (llwr); + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::map::const_iterator ite = _IconMapString.find (name); if (ite == _IconMapString.end()) return -1; else 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 195a44381..90a917225 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 @@ -103,10 +103,8 @@ void CImageListEx::addResourceIcon (const char *filename) index = ImageList.Replace( index, handle); // Add in the map - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - _IconMapString.insert (std::map::value_type (llwr, index)); + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + _IconMapString.insert (std::map::value_type (name, index)); // Release the icon DestroyIcon (handle); @@ -131,10 +129,8 @@ int CImageListEx::getImage (int resource) const int CImageListEx::getImage (const char *filename) const { - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - std::map::const_iterator ite = _IconMapString.find (llwr); + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::map::const_iterator ite = _IconMapString.find (name); if (ite == _IconMapString.end()) return -1; else From c658afdece27becf6cbac2c50102e0c2be334981 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 23 Nov 2016 12:29:59 +0100 Subject: [PATCH 14/16] Changed: Formatting --HG-- branch : develop --- code/CMakeModules/PCHSupport.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index 01118650e..aa7468cb6 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -77,7 +77,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") ENDFOREACH() ENDIF() @@ -91,14 +91,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") ENDFOREACH() ENDIF() GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD}) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") ENDFOREACH() ENDIF() @@ -122,14 +122,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") ENDFOREACH() ENDIF() GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD}) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") + LIST(APPEND GLOBAL_DEFINITIONS "$<$:-D$>") ENDFOREACH() ENDIF() From 6a76fc83177f089756e3cc9468a37cb479237a62 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 23 Nov 2016 12:30:18 +0100 Subject: [PATCH 15/16] Fixed: Compilation with old CMake versions --HG-- branch : develop --- code/CMakeModules/PCHSupport.cmake | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index aa7468cb6..020fa98d3 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -176,10 +176,21 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() IF(CMAKE_VERSION VERSION_LESS "3.3.0") - GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) - GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) - LIST(APPEND _FLAGS ${_directory_flags}) - LIST(APPEND _FLAGS ${_directory_definitions}) + GET_DIRECTORY_PROPERTY(_DIRECTORY_FLAGS DEFINITIONS) + + IF(_DIRECTORY_FLAGS) + FOREACH(item ${_DIRECTORY_FLAGS}) + LIST(APPEND _FLAGS "$<$:-D$>") + ENDFOREACH() + ENDIF() + + GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) + + IF(_DIRECTORY_DEFINITIONS) + FOREACH(item ${_DIRECTORY_DEFINITIONS}) + LIST(APPEND _FLAGS "$<$:-D$>") + ENDFOREACH() + ENDIF() ENDIF() # Format definitions From c4b9d77eaacf70e4d5d287641d74aef610a0cb72 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Nov 2016 10:44:06 +0100 Subject: [PATCH 16/16] Changed: Added option ignore_free_disk_space_checks to ryzom_installer.ini --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 15 ++++++++++++++- .../tools/client/ryzom_installer/src/configfile.h | 4 ++++ .../client/ryzom_installer/src/downloader.cpp | 3 ++- .../client/ryzom_installer/src/installdialog.cpp | 2 +- .../client/ryzom_installer/src/migratedialog.cpp | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 7d14aa223..592b8e0a2 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -25,7 +25,8 @@ CConfigFile *CConfigFile::s_instance = NULL; CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1), - m_defaultServerIndex(0), m_defaultProfileIndex(0), m_installerCopied(false), m_use64BitsClient(false), m_shouldUninstallOldClient(true) + m_defaultServerIndex(0), m_defaultProfileIndex(0), m_installerCopied(false), m_use64BitsClient(false), + m_shouldUninstallOldClient(true), m_ignoreFreeDiskSpaceChecks(false) { s_instance = this; @@ -82,6 +83,7 @@ bool CConfigFile::load(const QString &filename) m_installationDirectory = settings.value("installation_directory").toString(); m_use64BitsClient = settings.value("use_64bits_client", true).toBool(); m_shouldUninstallOldClient = settings.value("should_uninstall_old_client", true).toBool(); + m_ignoreFreeDiskSpaceChecks = settings.value("ignore_free_disk_space_checks", false).toBool(); // fix problems when src directory doesn't exist anymore if (!m_srcDirectory.isEmpty() && QFile::exists(m_srcDirectory)) m_srcDirectory.clear(); @@ -175,6 +177,7 @@ bool CConfigFile::save() const settings.setValue("installation_directory", m_installationDirectory); settings.setValue("use_64bits_client", m_use64BitsClient); settings.setValue("should_uninstall_old_client", m_shouldUninstallOldClient); + settings.setValue("ignore_free_disk_space_checks", m_ignoreFreeDiskSpaceChecks); #if defined(Q_OS_WIN) settings.setValue("installer_filename_windows", m_installerFilename); @@ -441,6 +444,16 @@ void CConfigFile::setShouldUninstallOldClient(bool on) m_shouldUninstallOldClient = on; } +bool CConfigFile::ignoreFreeDiskSpaceChecks() const +{ + return m_ignoreFreeDiskSpaceChecks; +} + +void CConfigFile::setIgnoreFreeDiskSpaceChecks(bool on) +{ + m_ignoreFreeDiskSpaceChecks = on; +} + bool CConfigFile::uninstallingOldClient() const { return QFile::exists(getInstallationDirectory() + "/ryzom_installer_uninstalling_old_client"); diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index df13b7a51..baa815bd8 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -113,6 +113,9 @@ public: bool shouldUninstallOldClient() const; void setShouldUninstallOldClient(bool on); + bool ignoreFreeDiskSpaceChecks() const; + void setIgnoreFreeDiskSpaceChecks(bool on); + bool uninstallingOldClient() const; void setUninstallingOldClient(bool on) const; @@ -158,6 +161,7 @@ private: QString m_srcDirectory; bool m_use64BitsClient; bool m_shouldUninstallOldClient; + bool m_ignoreFreeDiskSpaceChecks; QString m_installerFilename; QString m_language; diff --git a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp index 2d497b31a..81fc7ecd3 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp @@ -18,6 +18,7 @@ #include "operation.h" #include "downloader.h" #include "utils.h" +#include "configfile.h" #include "nel/misc/system_info.h" #include "nel/misc/path.h" @@ -179,7 +180,7 @@ void CDownloader::getFileHead() void CDownloader::downloadFile() { - qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_fullPath.toUtf8().constData()); + qint64 freeSpace = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks() ? 0:NLMISC::CSystemInfo::availableHDSpace(m_fullPath.toUtf8().constData()); if (freeSpace == 0) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/installdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/installdialog.cpp index a41ebffff..d7f12be55 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/installdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/installdialog.cpp @@ -130,7 +130,7 @@ void CInstallDialog::updateDestinationText() void CInstallDialog::accept() { // check free disk space - qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); + qint64 freeSpace = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks() ? 0:NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); // shouldn't happen if (freeSpace == 0) diff --git a/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp index 1629ae670..d246701ea 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp @@ -123,7 +123,7 @@ void CMigrateDialog::updateDestinationText() void CMigrateDialog::accept() { // check free disk space - qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); + qint64 freeSpace = CConfigFile::getInstance()->ignoreFreeDiskSpaceChecks() ? 0:NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); // shouldn't happen if (freeSpace == 0)