diff --git a/.gitignore b/.gitignore index a45db8833..c9506601c 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,9 @@ aes_state.txt # intellij project folder .idea/ +# VSCode project folder +.vscode/ + # Python cache *.pyd *.pyc @@ -244,6 +247,9 @@ external_stlport nel_tools* ryzom_tools* +#personal projects +personal/ + # Dumps *.dmp diff --git a/CMakeLists.txt b/CMakeLists.txt index af8332fd4..92e923e30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,8 @@ ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) SET(NL_VERSION_MAJOR 1) -SET(NL_VERSION_MINOR 0) -SET(NL_VERSION_PATCH 2) +SET(NL_VERSION_MINOR 1) +SET(NL_VERSION_PATCH 0 CACHE STRING "Patch version") SET(YEAR "2001-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") diff --git a/code/nel/include/nel/misc/xml_macros.h b/code/nel/include/nel/misc/xml_macros.h deleted file mode 100644 index d25cd4c30..000000000 --- a/code/nel/include/nel/misc/xml_macros.h +++ /dev/null @@ -1,74 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#ifndef XML_MACROS_H -#define XML_MACROS_H - -// -// xmlNodePtr cur; -// CXMLAutoPtr prop; -// -// sint i; -// XML_READ_SINT(cur, "prop_name", i, -1); -// - -#define XML_READ_UINT(node, name, var, def) { \ - uint tmp; \ - prop = (char *) xmlGetProp(node, (xmlChar*)name); \ - if (prop && fromString((const char*)prop, tmp)) \ - var = tmp; \ - else \ - var = def; \ -} - -#define XML_READ_SINT(node, name, var, def) { \ - sint tmp; \ - prop = (char *) xmlGetProp(node, (xmlChar*)name); \ - if (prop && fromString((const char*)prop, tmp)) \ - var = tmp; \ - else \ - var = def; \ -} - -#define XML_READ_BOOL(node, name, var, def) { \ - prop = (char *) xmlGetProp(node, (xmlChar*)name); \ - if (prop) \ - var = NLMISC::toBool((const char*)prop); \ - else \ - var = def; \ -} - -#define XML_READ_COLOR(node, name, var, def) { \ - NLMISC::CRGBA tmp; \ - prop = (char *) xmlGetProp(node, (xmlChar*)name); \ - if (prop && fromString((const char*)prop, tmp)) \ - var = tmp; \ - else \ - var = def; \ -} - -#define XML_READ_STRING(node, name, var, def) { \ - prop = (char *) xmlGetProp(node, (xmlChar*)name); \ - if (prop) \ - var = (const char*)prop; \ - else \ - var = def; \ -} - -#endif // XML_MACROS_H - diff --git a/nel/include/nel/3d/async_file_manager_3d.h b/nel/include/nel/3d/async_file_manager_3d.h index 4e86f10b1..fee82d74b 100644 --- a/nel/include/nel/3d/async_file_manager_3d.h +++ b/nel/include/nel/3d/async_file_manager_3d.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -40,7 +43,7 @@ class CTextureFile; class CAsyncFileManager3D { - NLMISC_SAFE_SINGLETON_DECL(CAsyncFileManager3D); + NLMISC_SAFE_RELEASABLE_SINGLETON_DECL(CAsyncFileManager3D); CAsyncFileManager3D(); public: diff --git a/nel/include/nel/3d/computed_string.h b/nel/include/nel/3d/computed_string.h index 3f27a2879..fb1a5873c 100644 --- a/nel/include/nel/3d/computed_string.h +++ b/nel/include/nel/3d/computed_string.h @@ -1,8 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -181,7 +181,8 @@ public: CVertexBuffer Vertices; CMaterial *Material; CRGBA Color; - ucstring Text; + std::string Text; + size_t Length; uint32 CacheVersion; diff --git a/nel/include/nel/3d/driver.h b/nel/include/nel/3d/driver.h index 75472df37..1892aace0 100644 --- a/nel/include/nel/3d/driver.h +++ b/nel/include/nel/3d/driver.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -262,10 +262,10 @@ public: virtual NLMISC::IEventEmitter *getEventEmitter() = 0; /// Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text) = 0; + virtual bool copyTextToClipboard(const std::string &text) = 0; /// Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text) = 0;/// Return the depth of the driver after init(). + virtual bool pasteTextFromClipboard(std::string &text) = 0;/// Return the depth of the driver after init(). virtual uint8 getBitPerPixel() = 0; diff --git a/nel/include/nel/3d/driver_user.h b/nel/include/nel/3d/driver_user.h index c3564975f..a59d167a4 100644 --- a/nel/include/nel/3d/driver_user.h +++ b/nel/include/nel/3d/driver_user.h @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -558,10 +558,10 @@ public: // @} // Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); // Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool pasteTextFromClipboard(std::string &text); virtual uint64 getSwapBufferCounter(); diff --git a/nel/include/nel/3d/font_generator.h b/nel/include/nel/3d/font_generator.h index b69249d58..c756ed2b4 100644 --- a/nel/include/nel/3d/font_generator.h +++ b/nel/include/nel/3d/font_generator.h @@ -1,5 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -33,7 +36,7 @@ typedef struct FT_FaceRec_* FT_Face; #include "nel/misc/types_nl.h" #include - +#include namespace NL3D { @@ -64,17 +67,17 @@ public: * \param height height of the generated bitmap, this value is set by this function * \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function */ - uint8 *getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex); + uint8 *getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex); /** returns the width and height of a character using a specific size and * * \warning this function is not very fast (but faster than getBitmap()) because it has to load the char before. */ - void getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height); + void getSizes (u32char c, uint32 size, uint32 &width, uint32 &height); - void getKerning (ucchar left, ucchar right, sint32 &kernx); + void getKerning (u32char left, u32char right, sint32 &kernx); - uint32 getCharIndex (ucchar c); + uint32 getCharIndex (u32char c); uint32 getUID() { return _UID; } @@ -85,6 +88,7 @@ private: static uint32 _FontGeneratorCounterUID; uint32 _UID; std::string _FontFileName; + std::vector _FontFileNames; #ifndef NL_DONT_USE_EXTERNAL_CODE const char *getFT2Error(FT_Error fte); @@ -92,7 +96,7 @@ private: static FT_Library _Library; static uint _LibraryInit; - FT_Face _Face; + std::vector _Faces; #else // NL_DONT_USE_EXTERNAL_CODE #endif // NL_DONT_USE_EXTERNAL_CODE diff --git a/nel/include/nel/3d/font_manager.h b/nel/include/nel/3d/font_manager.h index 663e9d23a..fc6708256 100644 --- a/nel/include/nel/3d/font_manager.h +++ b/nel/include/nel/3d/font_manager.h @@ -1,5 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -19,6 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/smart_ptr.h" +#include "nel/misc/utf_string_view.h" #include "nel/3d/texture.h" #include "nel/3d/material.h" #include "nel/3d/texture_font.h" @@ -111,6 +115,7 @@ public: * \param output computed string * \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size... */ + /* void computeString (const std::string& s, CFontGenerator *fontGen, const NLMISC::CRGBA &color, @@ -120,11 +125,12 @@ public: IDriver *driver, CComputedString& output, bool keep800x600Ratio= true); + */ /** * Same as computeString but works with a unicode string (ucstring) */ - void computeString (const ucstring &s, + void computeString (NLMISC::CUtfStringView sv, CFontGenerator *fontGen, const NLMISC::CRGBA &color, uint32 fontSize, @@ -137,7 +143,21 @@ public: /** * Same as computeString but do not make vertex buffers and primitives */ - void computeStringInfo (const ucstring &s, + void computeStringInfo (NLMISC::CUtfStringView sv, + size_t len, + CFontGenerator *fontGen, + const NLMISC::CRGBA &color, + uint32 fontSize, + bool embolden, + bool oblique, + IDriver *driver, + CComputedString &output, + bool keep800x600Ratio= true); + + /** + * Same as computeString but do not make vertex buffers and primitives + */ + void computeStringInfo (NLMISC::CUtfStringView sv, CFontGenerator *fontGen, const NLMISC::CRGBA &color, uint32 fontSize, diff --git a/nel/include/nel/3d/landscape.h b/nel/include/nel/3d/landscape.h index f6e1a5861..cf05f6c9a 100644 --- a/nel/include/nel/3d/landscape.h +++ b/nel/include/nel/3d/landscape.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/include/nel/3d/mesh.h b/nel/include/nel/3d/mesh.h index 25872a063..0d47037aa 100644 --- a/nel/include/nel/3d/mesh.h +++ b/nel/include/nel/3d/mesh.h @@ -837,7 +837,7 @@ private: void restoreOriginalSkinVertices(); // apply Skin to all vertices from _OriginalSkin* to _VBuffer. - void applySkin(CSkeletonModel *skeleton); + void applySkin(void *dstVb, CSkeletonModel *skeleton); void flagSkinVerticesForMatrixBlock(uint8 *skinFlags, CMatrixBlock &mb); diff --git a/nel/include/nel/3d/text_context.h b/nel/include/nel/3d/text_context.h index 1eb256855..8ce97216d 100644 --- a/nel/include/nel/3d/text_context.h +++ b/nel/include/nel/3d/text_context.h @@ -1,8 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -134,7 +134,7 @@ public: uint32 textPush (const char *format, ...); /// computes an ucstring and adds the result to the cache (return the index) - uint32 textPush (const ucstring &str); + uint32 textPush (NLMISC::CUtfStringView sv); /// remove a string from the cache void erase (uint32 index); @@ -262,12 +262,12 @@ public: } /// Directly print a string - void printAt (float x, float z, const ucstring &ucstr) + void printAt (float x, float z, NLMISC::CUtfStringView sv) { nlassert(_FontGen); // compute the string just one time - _FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio); + _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio); // draw shaded if (_Shaded) @@ -372,14 +372,19 @@ public: * \param an ucstring * \param the computed string */ - void computeString (const ucstring& s, CComputedString& output) + void computeString (NLMISC::CUtfStringView sv, CComputedString& output) { - _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); + _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); + } + + void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output) + { + _FontManager->computeStringInfo (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); } - void computeStringInfo (const ucstring& s, CComputedString& output) + void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output, size_t len) { - _FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); + _FontManager->computeStringInfo (sv, len, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); } /// Debug : write to the disk the texture cache diff --git a/nel/include/nel/3d/text_context_user.h b/nel/include/nel/3d/text_context_user.h index 2a167b2e9..6be074090 100644 --- a/nel/include/nel/3d/text_context_user.h +++ b/nel/include/nel/3d/text_context_user.h @@ -1,8 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -97,13 +97,14 @@ public: */ // @{ uint32 textPush(const char *format, ...) ; - uint32 textPush(const ucstring &str) ; + uint32 textPush(NLMISC::CUtfStringView sv) ; void setStringColor(uint32 i, CRGBA newCol); void setStringSelection(uint32 i, uint32 selectStart, uint32 selectSize); void resetStringSelection(uint32 i); void erase(uint32 i) ; virtual CStringInfo getStringInfo (uint32 i); - virtual CStringInfo getStringInfo (const ucstring &ucstr); + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv); + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len); void clear() ; void printAt(float x, float y, uint32 i) ; @@ -111,10 +112,10 @@ public: void printClipAtUnProjected(URenderStringBuffer &renderBuffer, class NL3D::CFrustum &frustum, const NLMISC::CMatrix &scaleMatrix, float x, float y, float depth, uint32 i, float xmin, float ymin, float xmax, float ymax); void printClipAtOld (float x, float y, uint32 i, float xmin, float ymin, float xmax, float ymax); - void printAt(float x, float y, const ucstring &ucstr) ; + void printAt(float x, float y, NLMISC::CUtfStringView sv) ; void printfAt(float x, float y, const char * format, ...) ; - void render3D(const CMatrix &mat, const ucstring &ucstr) ; + void render3D(const CMatrix &mat, NLMISC::CUtfStringView sv) ; void render3D(const CMatrix &mat, const char *format, ...) ; float getLastXBound() const ; diff --git a/nel/include/nel/3d/texture.h b/nel/include/nel/3d/texture.h index f74af29d9..6016917d2 100644 --- a/nel/include/nel/3d/texture.h +++ b/nel/include/nel/3d/texture.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/include/nel/3d/texture_font.h b/nel/include/nel/3d/texture_font.h index 865615b63..cacb8a6ac 100644 --- a/nel/include/nel/3d/texture_font.h +++ b/nel/include/nel/3d/texture_font.h @@ -1,5 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -35,12 +38,43 @@ class CTextureFont : public ITexture public: + struct SLetterKey + { + u32char Char; + sint Size; + bool Embolden; + bool Oblique; + CFontGenerator *FontGenerator; + + SLetterKey() : Char(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL) + { + } + + // Does not use FontGenerator in return value + inline uint64 getVal() const + { + return Char // 32 bits + | (uint64(Size & 0xFFFF) << 32) // 16 bits + | (uint64(Embolden) << (32+16)) // 1 bit + | (uint64(Oblique) << (32+16+1)); // 1 bit + } + + bool operator<(const SLetterKey &rhs) const + { + uint64 a = getVal(); + uint64 b = rhs.getVal(); + return (a < b) || ((a == b) && (FontGenerator < rhs.FontGenerator)); + } + }; + // Holds info for glyphs rendered on atlas - struct SGlyphInfo + struct SGlyphInfo : SLetterKey { // font atlas info uint32 CacheVersion; + uint32 GlyphIndex; + // atlas region with padding uint32 X, Y, W, H; @@ -51,30 +85,17 @@ public: // UV coords for rendered glyph without padding float U0, V0, U1, V1; - uint32 GlyphIndex; - sint Size; - bool Embolden; - bool Oblique; - CFontGenerator *FontGenerator; - SGlyphInfo() - : CacheVersion(0), + : CacheVersion(0), GlyphIndex(0), U0(0.f), V0(0.f), U1(0.f), V1(0.f), - X(0), Y(0), W(0), H(0), CharWidth(0), CharHeight(0), - GlyphIndex(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL) + X(0), Y(0), W(0), H(0), CharWidth(0), CharHeight(0) { } }; // Holds info for glyphs displayed on screen - struct SLetterInfo + struct SLetterInfo : SLetterKey { - ucchar Char; - sint Size; - bool Embolden; - bool Oblique; - CFontGenerator *FontGenerator; - uint32 GlyphIndex; uint32 CharWidth; // Displayed glyph height uint32 CharHeight; // Displayed glyph height @@ -85,29 +106,12 @@ public: SGlyphInfo* glyph; SLetterInfo() - : Char(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL), - GlyphIndex(0), CharWidth(0), CharHeight(0), Top(0), Left(0), AdvX(0), + : GlyphIndex(0), CharWidth(0), CharHeight(0), Top(0), Left(0), AdvX(0), glyph(NULL) { } }; - struct SLetterKey - { - ucchar Char; - sint Size; - bool Embolden; - bool Oblique; - CFontGenerator *FontGenerator; - - // Does not use FontGenerator in return value - uint32 getVal(); - - SLetterKey():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false) - { - } - }; - public: /** @@ -148,7 +152,7 @@ private: // Keep track of available space in main texture std::vector _AtlasNodes; - std::vector _Letters; + std::map _Letters; // lookup letter from letter cache or create new SLetterInfo* findLetter(SLetterKey& k, bool insert); @@ -162,7 +166,7 @@ private: uint _GlyphSizeStep; // rendered glyph cache - std::list _GlyphCache; + std::map _GlyphCache; SGlyphInfo* findLetterGlyph(SLetterInfo *letter, bool insert); // render letter glyph into glyph cache diff --git a/nel/include/nel/3d/u_driver.h b/nel/include/nel/3d/u_driver.h index f4f78e2cb..24e3d6482 100644 --- a/nel/include/nel/3d/u_driver.h +++ b/nel/include/nel/3d/u_driver.h @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -835,10 +835,10 @@ public: /// \name Clipboard management // @{ // Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text) =0; + virtual bool copyTextToClipboard(const std::string &text) =0; // Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text) =0; + virtual bool pasteTextFromClipboard(std::string &text) =0; // @} public: diff --git a/nel/include/nel/3d/u_text_context.h b/nel/include/nel/3d/u_text_context.h index cdde02f82..b068a4b36 100644 --- a/nel/include/nel/3d/u_text_context.h +++ b/nel/include/nel/3d/u_text_context.h @@ -1,8 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -24,7 +24,7 @@ #include "nel/misc/rgba.h" #include "nel/misc/ucstring.h" #include "nel/misc/matrix.h" - +#include "nel/misc/utf_string_view.h" namespace NL3D { @@ -104,8 +104,11 @@ public: */ float StringLine; - CStringInfo() {StringWidth= StringHeight= StringLine= 0;} - CStringInfo(float w, float h, float l) {StringWidth= w; StringHeight= h; StringLine = l;} + /// The length in characters + size_t StringLength; + + CStringInfo() { StringWidth = StringHeight = StringLine = 0; StringLength = 0; } + CStringInfo(float w, float h, float l, size_t len) { StringWidth = w; StringHeight = h; StringLine = l; StringLength = len; } /** * Get the string's origin @@ -248,7 +251,7 @@ public: * \param an ucstring * \return the index where computed string has been inserted */ - virtual uint32 textPush (const ucstring &str) = 0; + virtual uint32 textPush (NLMISC::CUtfStringView sv) = 0; /** * set the color of a string. */ @@ -274,7 +277,12 @@ public: * Get a string information from the ucstring * The returned string info is in pixel size per default. */ - virtual CStringInfo getStringInfo (const ucstring &ucstr) = 0; + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv) = 0; + /** + * Get a string information from the ucstring + * The returned string info is in pixel size per default. + */ + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len) = 0; /** * empty the map */ @@ -299,7 +307,7 @@ public: /** * compute and print a ucstring at the location (2D method) x/y E [0,1] */ - virtual void printAt (float x, float y, const ucstring &ucstr) = 0; + virtual void printAt (float x, float y, NLMISC::CUtfStringView sv) = 0; /** * compute and print a string at the location (2D method) x/y E [0,1] */ @@ -309,7 +317,7 @@ public: * compute and render a ucstring at the location (3D method) * render3D() use UDriver Matrix context for Frustum/ViewMatrix, but use its own modelmatrix (mat). */ - virtual void render3D (const NLMISC::CMatrix &mat, const ucstring &ucstr) = 0; + virtual void render3D (const NLMISC::CMatrix &mat, NLMISC::CUtfStringView sv) = 0; /** * compute and render a string at the location (3D method) * render3D() use UDriver Matrix context for Frustum/ViewMatrix, but use its own modelmatrix (mat). diff --git a/nel/include/nel/georges/form.h b/nel/include/nel/georges/form.h index 9b21c4c49..5a387bb6d 100644 --- a/nel/include/nel/georges/form.h +++ b/nel/include/nel/georges/form.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -22,6 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/georges/u_form.h" +#include "form_dfn.h" #include "form_elm.h" #include "header.h" @@ -124,6 +125,10 @@ private: // The form filename std::string _Filename; + + // The dfn + NLMISC::CSmartPtr _Dfn; + }; } // NLGEORGES diff --git a/nel/include/nel/georges/form_elm.h b/nel/include/nel/georges/form_elm.h index bf9b3ef62..9ad0df30f 100644 --- a/nel/include/nel/georges/form_elm.h +++ b/nel/include/nel/georges/form_elm.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -282,6 +282,10 @@ public: { Element = NULL; } + ~CFormElmStructElm() + { + nlassert(!Element); + } std::string Name; CFormElm* Element; @@ -400,6 +404,10 @@ public: { Element = NULL; } + ~CElement () + { + nlassert(!Element); + } std::string Name; CFormElm* Element; @@ -631,7 +639,7 @@ inline bool CFormElm::convertValue (bool &result, const std::string &value) cons } else { - std::string temp = NLMISC::toLower(value); + std::string temp = NLMISC::toLowerAscii(value); if (strcmp (temp.c_str (), "true") == 0) { result = true; diff --git a/nel/include/nel/gui/action_handler.h b/nel/include/nel/gui/action_handler.h index 7288c9529..5edcd3035 100644 --- a/nel/include/nel/gui/action_handler.h +++ b/nel/include/nel/gui/action_handler.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -69,7 +70,7 @@ namespace NLGUI static CAHManager* getInstance() { - if (_GlobalInstance == NULL) + if (_GlobalInstance == NULL && !s_Deleted) _GlobalInstance = new CAHManager; return _GlobalInstance; } @@ -134,6 +135,19 @@ namespace NLGUI static CAHManager *_GlobalInstance; static bool editorMode; + class CDeleter + { + public: + ~CDeleter() + { + delete _GlobalInstance; + _GlobalInstance = NULL; + s_Deleted = true; + } + }; + static CDeleter s_Deleter; + static bool s_Deleted; + }; /// Ah name must all be lower case diff --git a/nel/include/nel/gui/css_background.h b/nel/include/nel/gui/css_background.h new file mode 100644 index 000000000..87ce87d0e --- /dev/null +++ b/nel/include/nel/gui/css_background.h @@ -0,0 +1,83 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010-2019 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_CSS_BACKGROUND_H +#define CL_CSS_BACKGROUND_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/gui/css_types.h" +#include "nel/gui/css_length.h" + +namespace NLGUI +{ + /** + * \brief CSS background info + * \date 2021-07-02 11:36 GMT + * \author Meelis Mägi (Nimetu) + */ + class CSSBackground + { + public: + CSSBackground() + :color(NLMISC::CRGBA::Transparent), + repeatX(CSS_VALUE_REPEAT), repeatY(CSS_VALUE_REPEAT), attachment(CSS_VALUE_SCROLL), + xAnchor(CSS_VALUE_LEFT), yAnchor(CSS_VALUE_TOP), + clip(CSS_VALUE_BORDER_BOX), origin(CSS_VALUE_PADDING_BOX), size(CSS_VALUE_AUTO) + {} + + void setImage(const std::string &value); + void setPosition(const std::string &value); + void setSize(const std::string &value); + void setRepeat(const std::string &value); + void setOrigin(const std::string &value); + void setClip(const std::string &value); + void setAttachment(const std::string &value); + void setColor(const std::string &value); + + public: + // TODO: only final layer has color + NLMISC::CRGBA color; + std::string image; + + CSSValueType repeatX; + CSSValueType repeatY; + CSSValueType attachment; + + CSSValueType xAnchor; + CSSValueType yAnchor; + CSSLength xPosition; + CSSLength yPosition; + + CSSValueType clip; + CSSValueType origin; + + CSSValueType size; + CSSLength width; + CSSLength height; + + private: + void positionFromOne(const std::vector &parts); + void positionFromTwo(const std::vector &parts); + void positionFromThree(const std::vector &parts); + void positionFromFour(const std::vector &parts); + }; + +}//namespace + +#endif // CL_CSS_BACKGROUND_H + + diff --git a/nel/include/nel/gui/css_background_renderer.h b/nel/include/nel/gui/css_background_renderer.h new file mode 100644 index 000000000..86b31cb3d --- /dev/null +++ b/nel/include/nel/gui/css_background_renderer.h @@ -0,0 +1,193 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010-2019 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_CSS_BACKGROUND_RENDERER_H +#define NL_CSS_BACKGROUND_RENDERER_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/misc/geom_ext.h" +#include "nel/gui/css_types.h" +#include "nel/gui/css_background.h" + +namespace NLGUI +{ +class CInterfaceElement; + +/** + * \brief Border renderer for GUI classes + * \date 2021-06-29 15:17 GMT + * \author Meelis Mägi (Nimetu) + */ +class CSSBackgroundRenderer +{ +public: + // alpha value from parent + uint8 CurrentAlpha; + + // TODO: should be moved to CSSBackground + sint32 TextureId; + +public: + CSSBackgroundRenderer(); + ~CSSBackgroundRenderer(); + + // return true if no background is set + bool isEmpty() const + { + return m_Background.image.empty() && m_Background.color.A == 0; + } + + void setModulateGlobalColor(bool m) { m_ModulateGlobalColor = m; } + + void updateCoords(); + void invalidateCoords() { m_Dirty = true; } + void invalidateContent() { m_Dirty = true; }; + + void clear(); + void setBackground(const CSSBackground &bg); + + // helper function to change background image + void setImage(const std::string &bgtex); + void setImageRepeat(bool b); + void setImageCover(bool b); + + // helper function to change background color + void setColor(const NLMISC::CRGBA &color) + { + m_Dirty = true; + m_Background.color = color; + } + + NLMISC::CRGBA getColor() const + { + return m_Background.color; + } + + // override painting area to be at least the size of viewport (ie, background) + void setFillViewport(bool b) { + m_Dirty = true; + m_FillViewport = b; + } + + void setViewport(CInterfaceElement *root) + { + m_Dirty = true; + m_Viewport = root; + } + + void setBorderArea(sint32 x, sint32 y, sint32 w, sint32 h) + { + m_Dirty = true; + m_BorderX = x; + m_BorderY = y; + m_BorderW = w; + m_BorderH = h; + } + + void setPaddingArea(sint32 x, sint32 y, sint32 w, sint32 h) + { + m_Dirty = true; + m_PaddingX = x; + m_PaddingY = y; + m_PaddingW = w; + m_PaddingH = h; + } + + void setContentArea(sint32 x, sint32 y, sint32 w, sint32 h) + { + m_Dirty = true; + m_ContentX = x; + m_ContentY = y; + m_ContentW = w; + m_ContentH = h; + } + + // sizes for em, rem units + void setFontSize(float rootFontSize, float fontSize) + { + m_Dirty = true; + m_RootFontSize = rootFontSize; + m_FontSize = fontSize; + } + + void draw(); + +private: + sint32 m_BorderX, m_BorderY, m_BorderW, m_BorderH; + sint32 m_PaddingX, m_PaddingY, m_PaddingW, m_PaddingH; + sint32 m_ContentX, m_ContentY, m_ContentW, m_ContentH; + + // font size for 'rem' + float m_RootFontSize; + + // font size for 'em' + float m_FontSize; + + // viewport element for vw,wh,vmin,vmax + CInterfaceElement* m_Viewport; + + struct SDrawQueue + { + sint32 TextureId; + NLMISC::CQuadUV Quad; + NLMISC::CRGBA Color; + }; + std::vector m_DrawQueue; + + const sint8 m_RenderLayer; + bool m_ModulateGlobalColor; + // if true, painting area returns area at least the size of viewport (ie, background) + bool m_FillViewport; + + // if true, then updateCoords() is called from draw() + bool m_Dirty; + + CSSBackground m_Background; + + // get clip area based on background-clip + void getPaintingArea(const CSSBackground &bg, sint32 &areaX, sint32 &areaY, sint32 &areaW, sint32 &areaH) const; + + // get positioning area based on background-origin + void getPositioningArea(const CSSBackground &bg, sint32 &areaX, sint32 &areaY, sint32 &areaW, sint32 &areaH) const; + + // calculate image size based on background-size + void calculateSize(const CSSBackground &bg, sint32 &texW, sint32 &texH) const; + + // calculate image position based on background-position + void calculatePosition(const CSSBackground &bg, sint32 &texX, sint32 &texY, sint32 &texW, sint32 &texH) const; + + // calculate image tile position, size, count, and spacing based on background-repeat + void calculateTiles(const CSSBackground &bg, sint32 &texX, sint32 &texY, sint32 &texW, sint32 &texH, sint32 &tilesX, sint32 &tilesY, sint32 &spacingX, sint32 &spacingY) const; + + // position, size, and count for first tile to cover an area + void getImageTile(sint32 &tilePos, sint32 &tileSize, sint32 &spacing, sint32 &tiles, sint32 areaPos, sint32 areaSize, CSSValueType repeat) const; + + // push background color to draw queue + void buildColorQuads(const CSSBackground &bg); + + // push background image to draw quque + void buildImageQuads(const CSSBackground &bg, sint32 textureId); + +}; // CSSBackgroundRenderer + +}//namespace + +#endif // NL_CSS_BACKGROUND_RENDERER_H + + diff --git a/nel/include/nel/gui/css_border.h b/nel/include/nel/gui/css_border.h new file mode 100644 index 000000000..787b71710 --- /dev/null +++ b/nel/include/nel/gui/css_border.h @@ -0,0 +1,72 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010-2019 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_CSS_BORDER_H +#define CL_CSS_BORDER_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/gui/css_types.h" +#include "nel/gui/css_length.h" + +namespace NLGUI +{ + /** + * \brief CSS border info + * \date 2021-07-23 09:51 GMT + * \author Meelis Mägi (Nimetu) + */ + class CSSBorder + { + public: + CSSBorder() + { + reset(); + } + + CSSBorder(uint width, CSSLineStyle style, NLMISC::CRGBA color) + { + set(width, style, color); + } + + void reset() + { + set(CSS_LINE_WIDTH_MEDIUM, CSS_LINE_STYLE_NONE, NLMISC::CRGBA::Transparent); + } + + void set(uint width, CSSLineStyle style, NLMISC::CRGBA color) + { + Width.setFloatValue(width, "px"); + Style = style; + Color = color; + } + + bool empty() const + { + return Style == CSS_LINE_STYLE_NONE || Style == CSS_LINE_STYLE_HIDDEN + || Width.getFloat() == 0; + } + + CSSLength Width; + CSSLineStyle Style; + NLMISC::CRGBA Color; + }; + +}//namespace + +#endif // CL_CSS_BORDER_H + + diff --git a/nel/include/nel/gui/css_border_renderer.h b/nel/include/nel/gui/css_border_renderer.h index 41ea3b7e6..54505a686 100644 --- a/nel/include/nel/gui/css_border_renderer.h +++ b/nel/include/nel/gui/css_border_renderer.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -23,9 +23,12 @@ #include "nel/misc/rgba.h" #include "nel/misc/geom_ext.h" #include "nel/gui/css_types.h" +#include "nel/gui/css_border.h" namespace NLGUI { + class CInterfaceElement; + /** * \brief Border renderer for GUI classes * \date 2019-09-03 10:50 GMT @@ -34,29 +37,76 @@ namespace NLGUI class CSSBorderRenderer { private: + enum EBorderSide + { + BORDER_TOP_LEFT = 0, + BORDER_TOP_RIGHT, + BORDER_BOTTOM_LEFT, + BORDER_BOTTOM_RIGHT, + BORDER_LEFT_TOP, + BORDER_RIGHT_TOP, + BORDER_LEFT_BOTTOM, + BORDER_RIGHT_BOTTOM, + BORDER_TOP, + BORDER_RIGHT, + BORDER_BOTTOM, + BORDER_LEFT, + BORDER_INVALID + }; // parent element screen coordinates - sint32 _XReal, _YReal; - sint32 _WReal, _HReal; + sint32 m_XReal, m_YReal; + sint32 m_WReal, m_HReal; - NLMISC::CQuadUV _QuadT; - NLMISC::CQuadUV _QuadR; - NLMISC::CQuadUV _QuadB; - NLMISC::CQuadUV _QuadL; + struct SDrawBorder + { + NLMISC::CQuadUV Quad; + NLMISC::CRGBA Color; + }; + std::vector m_DrawBorders; - uint8 _RenderLayer; - bool _ModulateGlobalColor; + sint8 m_RenderLayer; + bool m_ModulateGlobalColor; // if true, then updateCoords() is called from draw() - bool _Dirty; - // if true, then at least one border is set - bool _Border; - bool _BorderTop, _BorderRight, _BorderBottom, _BorderLeft; + bool m_Dirty; + // UI scale, used to calculate number of segments to draw for circle + float m_Scale; - public: - uint32 TopWidth, RightWidth, BottomWidth, LeftWidth; - NLMISC::CRGBA TopColor, RightColor, BottomColor, LeftColor; - CSSLineStyle TopStyle, RightStyle, BottomStyle, LeftStyle; + CSSRect m_Border; + CSSRect m_Computed; + + // font size for 'rem' + float m_RootFontSize; + + // font size for 'em' + float m_FontSize; + + // if true, then CSSLength values are recomputed + bool m_MustComputeValues; + + // viewport element for vw,wh,vmin,vmax + CInterfaceElement* m_Viewport; + // update CSSLength values + void computeValues(); + + void getAdjacentBorders(EBorderSide side, EBorderSide &adjBorderL, EBorderSide &adjBorderR) const; + void getAdjacentBorderWidth(EBorderSide side, sint32 &adjWidthL, sint32 &adjWidthR) const; + // dot + void buildDotCornerStart(EBorderSide side, SDrawBorder shape, float x1, float y1, float radius); + void buildDotCornerEnd(EBorderSide side, SDrawBorder shape, float x1, float y1, float radius); + void buildDotCorner(SDrawBorder shape, float x, float y, float r, const NLMISC::CLine &line); + // draw circle, angle is CCW between 0..1 (3'o'clock being 0deg). + void buildDotSegments(SDrawBorder shape, float x, float y, float radius, float fromAngle=0.f, float toAngle=1.f); + // dash + void makeBorderQuad(EBorderSide side, SDrawBorder &shape, float x, float y, float width, float thickness) const; + void makeCornerQuad(EBorderSide side, SDrawBorder &shape) const; + void buildDashedBorder(EBorderSide side); + void buildSolidBorder(EBorderSide side); + + bool hasInnerShape(CSSLineStyle style) const; + + public: // alpha value from parent uint8 CurrentAlpha; @@ -68,21 +118,67 @@ namespace NLGUI void setRect(sint32 x, sint32 y, sint32 w, sint32 h); - void setWidth(uint32 top, uint32 right, uint32 bottom, uint32 left); - void setStyle(CSSLineStyle top, CSSLineStyle right, CSSLineStyle bottom, CSSLineStyle left); - void setColor(const NLMISC::CRGBA &top, const NLMISC::CRGBA &right, const NLMISC::CRGBA &bottom, const NLMISC::CRGBA &left); + void setBorder(const CSSRect &b) { m_Dirty = true; m_Border = b; } void updateCoords(); - void invalidateCoords() { _Dirty = _Border = true; } - void invalidateContent() { _Dirty = _Border = true; }; - - uint32 getTopWidth() const; - uint32 getRightWidth() const; - uint32 getBottomWidth() const; - uint32 getLeftWidth() const; - - uint32 getLeftRightWidth() const; - uint32 getTopBottomWidth() const; + void invalidateCoords() { m_Dirty = true; } + void invalidateContent() { m_Dirty = true; } + + bool isEmpty() const { + return (m_Border.Top.Width.getFloat() + + m_Border.Right.Width.getFloat() + + m_Border.Bottom.Width.getFloat() + + m_Border.Left.Width.getFloat()) == 0; + } + + uint32 getTopWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Top; } + uint32 getRightWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Right; } + uint32 getBottomWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Bottom; } + uint32 getLeftWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Left; } + + uint32 getLeftRightWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Left + m_Computed.Right; } + uint32 getTopBottomWidth() { if (m_MustComputeValues) computeValues(); return m_Computed.Top + m_Computed.Bottom; } + + NLMISC::CRGBA getTopColor() const { return m_Border.Top.Color; } + NLMISC::CRGBA getRightColor() const { return m_Border.Right.Color; } + NLMISC::CRGBA getBottomColor() const { return m_Border.Bottom.Color; } + NLMISC::CRGBA getLeftColor() const { return m_Border.Left.Color; } + + + void setWidth(uint width) + { + m_Dirty = true; + m_MustComputeValues = true; + m_Border.Top.Width.setFloatValue(width, "px"); + m_Border.Right.Width.setFloatValue(width, "px"); + m_Border.Bottom.Width.setFloatValue(width, "px"); + m_Border.Left.Width.setFloatValue(width, "px"); + } + + void setColor(const NLMISC::CRGBA &color) + { + m_Dirty = true; + m_Border.Top.Color = color; + m_Border.Right.Color = color; + m_Border.Bottom.Color = color; + m_Border.Left.Color = color; + } + + // sizes for em, rem units + void setFontSize(float rootFontSize, float fontSize) + { + m_Dirty = true; + m_MustComputeValues = true; + m_RootFontSize = rootFontSize; + m_FontSize = fontSize; + } + + void setViewport(CInterfaceElement *root) + { + m_Dirty = true; + m_MustComputeValues = true; + m_Viewport = root; + } void draw(); }; // CSSBorderRenderer diff --git a/nel/include/nel/gui/css_length.h b/nel/include/nel/gui/css_length.h new file mode 100644 index 000000000..d7b8c657b --- /dev/null +++ b/nel/include/nel/gui/css_length.h @@ -0,0 +1,76 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010-2021 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_CSS_LENGTH_H +#define CL_CSS_LENGTH_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/css_types.h" + +namespace NLGUI +{ + /** + * \brief CSS types used in GUI classes + * \date 2021-07-02 11:36 GMT + * \author Meelis Mägi (Nimetu) + */ + + class CSSLength + { + public: + enum Kind { + Auto, Relative, Fixed + }; + + CSSLength(float value = 0, CSSUnitType unit = CSS_UNIT_NONE, Kind kind = Auto) + : m_Value(value), m_Unit(unit), m_Kind(Auto) + {} + + void setAuto() { m_Kind = Auto; } + bool parseValue(const std::string &value, bool allowPercent = true, bool allowNegative = false); + void setFloatValue(float f, const std::string &unit); + + float getValue() const; + float getFloat() const { return m_Value; } + + bool isPercent() const { return m_Unit == CSS_UNIT_PERCENT; } + + bool isAuto() const { return m_Kind == Auto; } + bool isRelative() const { return m_Kind == Relative; } + + // % uses relValue + // em uses emSize + // rem uses remSize + // vw,vh,vi,vb,vmin,vmax uses vwSize/vhSize + float calculate(uint32 relValue, uint32 emSize, uint32 remSize, uint32 vwSize, uint32 whSize) const; + + CSSUnitType getUnit() const { return m_Unit; } + + std::string toString() const; + + private: + void setUnit(const std::string &unit); + + float m_Value; + CSSUnitType m_Unit; + Kind m_Kind; + }; + +}//namespace + +#endif // CL_CSS_LENGTH_H + + diff --git a/nel/include/nel/gui/css_parser.h b/nel/include/nel/gui/css_parser.h index a6dc92022..8b320bc4e 100644 --- a/nel/include/nel/gui/css_parser.h +++ b/nel/include/nel/gui/css_parser.h @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -38,7 +41,7 @@ namespace NLGUI private: // stylesheet currently parsed - ucstring _Style; + std::string _Style; // keep track of current position in _Style size_t _Position; @@ -70,49 +73,49 @@ namespace NLGUI void preprocess(); // parse selectors + combinators - std::vector parse_selector(const ucstring &sel, std::string &pseudoElement) const; + std::vector parse_selector(const std::string &sel, std::string &pseudoElement, std::string::size_type &pos) const; // parse selector and style - void parseRule(const ucstring &selectorString, const ucstring &styleString); + void parseRule(const std::string &selectorString, const std::string &styleString); inline bool is_eof() const { return _Position >= _Style.size(); } - inline bool is_whitespace(ucchar ch) const + inline bool is_whitespace(char ch) const { - return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n'); + return (ch == ' ' || ch == '\t' || ch == '\n'); } - inline bool is_hex(ucchar ch) const + inline bool is_hex(char ch) const { - return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') || - (ch >= (ucchar)'a' && ch <= (ucchar)'f') || - (ch >= (ucchar)'A' && ch <= (ucchar)'F')); + return ((ch >= '0' && ch <= '9') || + (ch >= 'a' && ch <= 'f') || + (ch >= 'A' && ch <= 'F')); } inline bool maybe_escape() const { // escaping newline (\n) only allowed inside strings - return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n'; + return (_Style.size() - _Position) >= 1 && _Style[_Position] == '\\' && _Style[_Position+1] != '\n'; } - inline bool is_quote(ucchar ch) const + inline bool is_quote(char ch) const { - return ch== (ucchar)'"' || ch == (ucchar)'\''; + return ch== '"' || ch == '\''; } - inline bool is_block_open(ucchar ch) const + inline bool is_block_open(char ch) const { - return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'('; + return ch == (char)'{' || ch == (char)'[' || ch == (char)'('; } - inline bool is_block_close(ucchar ch, ucchar open) const + inline bool is_block_close(char ch, char open) const { - return ((open == '{' && ch == (ucchar)'}') || - (open == '[' && ch == (ucchar)']') || - (open == '(' && ch == (ucchar)')')); + return ((open == '{' && ch == (char)'}') || + (open == '[' && ch == (char)']') || + (open == '(' && ch == (char)')')); } inline bool is_comment_open() const @@ -120,25 +123,25 @@ namespace NLGUI if (_Position+1 > _Style.size()) return false; - return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*'; + return _Style[_Position] == (char)'/' && _Style[_Position+1] == (char)'*'; } - inline bool is_nonascii(ucchar ch) const + inline bool is_nonascii(char ch) const { return ch >= 0x80 /*&& ch <= 255*/; } - inline bool is_alpha(ucchar ch) const + inline bool is_alpha(char ch) const { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); } - inline bool is_digit(ucchar ch) const + inline bool is_digit(char ch) const { return ch >= '0' && ch <= '9'; } - inline bool is_nmchar(ucchar ch) const + inline bool is_nmchar(char ch) const { // checking escape here does not check if next char is '\n' or not return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/; diff --git a/nel/include/nel/gui/css_selector.h b/nel/include/nel/gui/css_selector.h index ed04ba86d..c68369e8a 100644 --- a/nel/include/nel/gui/css_selector.h +++ b/nel/include/nel/gui/css_selector.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -96,6 +96,8 @@ namespace NLGUI // match An+B rule to child index (1 based) bool matchNth(sint childNr, sint a, sint b) const; + // match :lang(xx) + bool matchLang(const CHtmlElement &elm, const std::string &pseudo) const; // parse nth-child string to 'a' and 'b' components // :nth-child(odd) diff --git a/nel/include/nel/gui/css_style.h b/nel/include/nel/gui/css_style.h index 5521818a4..674f0268e 100644 --- a/nel/include/nel/gui/css_style.h +++ b/nel/include/nel/gui/css_style.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -21,6 +21,9 @@ #include "nel/misc/rgba.h" #include "nel/gui/css_selector.h" #include "nel/gui/css_types.h" +#include "nel/gui/css_length.h" +#include "nel/gui/css_background.h" +#include "nel/gui/css_border.h" namespace NLGUI { @@ -60,18 +63,15 @@ namespace NLGUI Underlined=false; StrikeThrough=false; GlobalColor=false; + GlobalColorText=false; DisplayBlock=false; Width=-1; Height=-1; MaxWidth=-1; MaxHeight=-1; - // border style - BorderTopWidth = BorderRightWidth = BorderBottomWidth = BorderLeftWidth = CSS_LINE_WIDTH_MEDIUM; - BorderTopStyle = BorderRightStyle = BorderBottomStyle = BorderLeftStyle = CSS_LINE_STYLE_NONE; - BorderTopColor = BorderRightColor = BorderBottomColor = BorderLeftColor = NLMISC::CRGBA::Transparent; // background - BackgroundColor=NLMISC::CRGBA::Black; BackgroundColorOver=NLMISC::CRGBA::Black; + MarginTop = MarginRight = MarginBottom = MarginLeft = 0; PaddingTop = PaddingRight = PaddingBottom = PaddingLeft = 0; } @@ -94,6 +94,7 @@ namespace NLGUI NLMISC::CRGBA TextColor; STextShadow TextShadow; bool GlobalColor; + bool GlobalColorText; bool Underlined; bool StrikeThrough; bool DisplayBlock; @@ -101,11 +102,10 @@ namespace NLGUI sint32 Height; sint32 MaxWidth; sint32 MaxHeight; - uint32 BorderTopWidth, BorderRightWidth, BorderBottomWidth, BorderLeftWidth; - CSSLineStyle BorderTopStyle, BorderRightStyle, BorderBottomStyle, BorderLeftStyle; - NLMISC::CRGBA BorderTopColor, BorderRightColor, BorderBottomColor, BorderLeftColor; - NLMISC::CRGBA BackgroundColor; + CSSRect Border; + CSSBackground Background; NLMISC::CRGBA BackgroundColorOver; + uint32 MarginTop, MarginRight, MarginBottom, MarginLeft; uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft; std::string WhiteSpace; @@ -177,16 +177,24 @@ namespace NLGUI // parse 'padding' into 'padding-top', 'padding-left', etc void expandPaddingShorthand(const std::string &value, TStyle &style) const; + void expandMarginShorthand(const std::string &value, TStyle &style) const; // expand shorthand rule, ie "border", into longhand names, ie "border-top-width" // if shorthand is present in style, then its removed void expandShorthand(const std::string &prop, const std::string &value, TStyle &style) const; // parse string value into corresponding value - void applyBorderWidth(const std::string &value, uint32 *dest, const uint32 currentWidth, const uint32 fontSize) const; + void applyBorderWidth(const std::string &value, CSSLength *dest, const CSSLength ¤tWidth) const; void applyBorderColor(const std::string &value, NLMISC::CRGBA *dest, const NLMISC::CRGBA ¤tColor, const NLMISC::CRGBA &textColor) const; void applyLineStyle(const std::string &value, CSSLineStyle *dest, const CSSLineStyle ¤tStyle) const; void applyPaddingWidth(const std::string &value, uint32 *dest, const uint32 currentPadding, uint32 fontSize) const; + void applyMarginWidth(const std::string &value, uint32 *dest, const uint32 current, uint32 fontSize) const; + + // parse and replace var(--name, fallback) function + // return false if property should be ignored + bool cssFuncVar(std::string &func, const TStyle &styleRules, const std::set &seenProperties) const; + // return false if property was not defined + bool lookupPropertyValue(const std::string &name, std::string &value, const TStyle &styleRules) const; public: void reset(); @@ -209,15 +217,22 @@ namespace NLGUI _StyleStack.push_back(Current); Current.GlobalColor = false; + // inherit GlobalColorText Current.DisplayBlock = false; Current.Width=-1; Current.Height=-1; Current.MaxWidth=-1; Current.MaxHeight=-1; - Current.BorderTopWidth = Current.BorderRightWidth = Current.BorderBottomWidth = Current.BorderLeftWidth = CSS_LINE_WIDTH_MEDIUM; - Current.BorderTopStyle = Current.BorderRightStyle = Current.BorderBottomStyle = Current.BorderLeftStyle = CSS_LINE_STYLE_NONE; - Current.BorderTopColor = Current.BorderRightColor = Current.BorderBottomColor = Current.BorderLeftColor = Current.TextColor; + Current.Border.Top.reset(); + Current.Border.Right.reset(); + Current.Border.Bottom.reset(); + Current.Border.Left.reset(); + + Current.Background = CSSBackground(); + Current.BackgroundColorOver = NLMISC::CRGBA::Transparent; + + Current.MarginTop = Current.MarginRight = Current.MarginBottom = Current.MarginLeft = 0; Current.PaddingTop = Current.PaddingRight = Current.PaddingBottom = Current.PaddingLeft = 0; Current.StyleRules.clear(); diff --git a/nel/include/nel/gui/css_types.h b/nel/include/nel/gui/css_types.h index 9dd41de36..172c21d18 100644 --- a/nel/include/nel/gui/css_types.h +++ b/nel/include/nel/gui/css_types.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -30,7 +30,12 @@ namespace NLGUI enum CSSLineStyle { CSS_LINE_STYLE_NONE = 0, CSS_LINE_STYLE_HIDDEN, + CSS_LINE_STYLE_DOTTED, + CSS_LINE_STYLE_DASHED, CSS_LINE_STYLE_SOLID, + CSS_LINE_STYLE_DOUBLE, + CSS_LINE_STYLE_GROOVE, + CSS_LINE_STYLE_RIDGE, CSS_LINE_STYLE_INSET, CSS_LINE_STYLE_OUTSET }; @@ -42,6 +47,53 @@ namespace NLGUI CSS_LINE_WIDTH_THICK = 5 }; + enum CSSUnitType { + CSS_UNIT_NONE = 0, + CSS_UNIT_EM, + CSS_UNIT_REM, + CSS_UNIT_PERCENT, + CSS_UNIT_PX, + CSS_UNIT_PT, + CSS_UNIT_VW, + CSS_UNIT_VH, + CSS_UNIT_VI, + CSS_UNIT_VB, + CSS_UNIT_VMIN, + CSS_UNIT_VMAX + }; + + enum CSSValueType { + CSS_VALUE_NONE = 0, + CSS_VALUE_REPEAT, + CSS_VALUE_SPACE, + CSS_VALUE_ROUND, + CSS_VALUE_NOREPEAT, + CSS_VALUE_FIXED, + CSS_VALUE_LOCAL, + CSS_VALUE_SCROLL, + CSS_VALUE_LEFT, + CSS_VALUE_CENTER, + CSS_VALUE_RIGHT, + CSS_VALUE_TOP, + CSS_VALUE_BOTTOM, + CSS_VALUE_BORDER_BOX, + CSS_VALUE_PADDING_BOX, + CSS_VALUE_CONTENT_BOX, + CSS_VALUE_LENGTH, + CSS_VALUE_AUTO, + CSS_VALUE_COVER, + CSS_VALUE_CONTAIN + }; + + template + struct CSSRect + { + T Top; + T Right; + T Bottom; + T Left; + }; + }//namespace #endif // CL_CSS_TYPES_H diff --git a/nel/include/nel/gui/ctrl_base.h b/nel/include/nel/gui/ctrl_base.h index a8bdef85f..e0a90736b 100644 --- a/nel/include/nel/gui/ctrl_base.h +++ b/nel/include/nel/gui/ctrl_base.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -85,9 +86,12 @@ namespace NLGUI /// Get the ContextHelp for this control. Default is to return _ContextHelp - virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;} + virtual void getContextHelp(std::string &help) const {help= _ContextHelp;} +#ifdef RYZOM_LUA_UCSTRING + virtual void getContextHelpAsUtf16(ucstring &help) const {help.fromUtf8(_ContextHelp);} // Compatibility +#endif /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. - virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); } + virtual void getContextHelpToolTip(std::string &help) const { getContextHelp(help); } // Get the name of the context help window. Default to "context_help" virtual std::string getContextHelpWindowName() const; /// Get the ContextHelp ActionHandler. If "", noop @@ -123,8 +127,12 @@ namespace NLGUI void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;} /// replace the default contextHelp - ucstring getDefaultContextHelp() const {return _ContextHelp;} - void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;} + std::string getDefaultContextHelp() const {return _ContextHelp;} + void setDefaultContextHelp(const std::string &help) {_ContextHelp= help;} +#ifdef RYZOM_LUA_UCSTRING + ucstring getDefaultContextHelpAsUtf16() const {return ucstring::makeFromUtf8(_ContextHelp);} // Compatibility + void setDefaultContextHelpAsUtf16(const ucstring &help) {_ContextHelp= help.toUtf8();} // Compatibility +#endif void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} @@ -154,12 +162,18 @@ namespace NLGUI // called when keyboard capture has been lost virtual void onKeyboardCaptureLost() {} +#ifdef RYZOM_LUA_UCSTRING // 'tooltip' property expects string to be ucstring or latin1 which is not possible from html page - int luaSetTooltipUtf8(CLuaState &ls); + int luaSetTooltipUtf8(CLuaState &ls); // Compatibility +#endif REFLECT_EXPORT_START(CCtrlBase, CViewBase) - REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); - REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("tooltip", getDefaultContextHelpAsUtf16, setDefaultContextHelpAsUtf16); // Compatibility + REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); // Compatibility +#else + REFLECT_STRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); +#endif REFLECT_EXPORT_END // special for mouse over : return true and fill the name of the cursor to display @@ -171,7 +185,7 @@ namespace NLGUI protected: // This is the ContextHelp filled by default in parse() - ucstring _ContextHelp; + std::string _ContextHelp; CStringShared _OnContextHelp; CStringShared _OnContextHelpParams; CStringShared _ToolTipSpecialParent; diff --git a/nel/include/nel/gui/ctrl_scroll.h b/nel/include/nel/gui/ctrl_scroll.h index 4052e6cea..02f814acf 100644 --- a/nel/include/nel/gui/ctrl_scroll.h +++ b/nel/include/nel/gui/ctrl_scroll.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/gui/ctrl_text_button.h b/nel/include/nel/gui/ctrl_text_button.h index 9bae24ad5..53fe7d5cc 100644 --- a/nel/include/nel/gui/ctrl_text_button.h +++ b/nel/include/nel/gui/ctrl_text_button.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -96,8 +97,14 @@ namespace NLGUI bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} // Set text (noop if text id) - void setText (const ucstring &text); - ucstring getText () const; + void setText (const std::string &text); + std::string getText () const; +#ifdef RYZOM_LUA_UCSTRING + void setTextAsUtf16 (const ucstring &text); // Compatibility + ucstring getTextAsUtf16 () const; // Compatibility +#endif + void setLocalize (bool localize); + bool isLocalized () const; void setHardText (const std::string &text); std::string getHardText () const; @@ -140,8 +147,12 @@ namespace NLGUI int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) - REFLECT_UCSTRING("uc_hardtext", getText, setText); +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16); // Compatibility +#endif + REFLECT_BOOL("localize", isLocalized, setLocalize); REFLECT_STRING("hardtext", getHardText, setHardText); + REFLECT_STRING("text", getText, setText); REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("wmargin", getWMargin, setWMargin) REFLECT_SINT32("wmin", getWMin, setWMin) diff --git a/nel/include/nel/gui/dbgroup_combo_box.h b/nel/include/nel/gui/dbgroup_combo_box.h index 6f42572bb..93d6f4d4d 100644 --- a/nel/include/nel/gui/dbgroup_combo_box.h +++ b/nel/include/nel/gui/dbgroup_combo_box.h @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -60,13 +60,19 @@ namespace NLGUI // Combo Texts void resetTexts(); - void addText(const ucstring &text); - void setText(uint i, const ucstring &text); - void insertText(uint i, const ucstring &text); - const ucstring &getText(uint i) const; + void addText(const std::string &text); + void setText(uint i, const std::string &text); + void insertText(uint i, const std::string &text); + const std::string &getText(uint i) const; +#ifdef RYZOM_LUA_UCSTRING + ucstring getTextAsUtf16(uint i) const; // Compatibility +#endif uint getTextId(uint i) const; uint getTextPos(uint nId) const; - const ucstring &getTexture(uint i) const; + const std::string &getTexture(uint i) const; +#ifdef RYZOM_LUA_UCSTRING + ucstring getTextureAsUtf16(uint i) const; // Compatibility +#endif void setGrayed(uint i, bool g); bool getGrayed(uint i) const; void removeText(uint nPos); @@ -87,11 +93,15 @@ namespace NLGUI std::string getSelectionText() const; // view text - void setViewText(const ucstring & text); - ucstring getViewText() const; + void setViewText(const std::string & text); + std::string getViewText() const; +#ifdef RYZOM_LUA_UCSTRING + void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); } // Compatibility + ucstring getViewTextAsUtf16() const; // Compatibility +#endif CViewText *getViewText(); - void setTexture(uint i, const ucstring &texture); + void setTexture(uint i, const std::string &texture); sint32 evalContentWidth() const; @@ -122,7 +132,11 @@ namespace NLGUI REFLECT_LUA_METHOD("resetTexts", luaResetTexts) REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) - REFLECT_UCSTRING ("view_text", getViewText, setViewText) +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // Compatibility +#else + REFLECT_STRING ("view_text", getViewText, setViewText) +#endif REFLECT_EXPORT_END @@ -137,8 +151,8 @@ namespace NLGUI // sint32 CInterfaceProperty _Selection; sint32 _NotLinkedToDBSelection; - std::vector > _Texts; - std::vector _Textures; + std::vector > _Texts; + std::vector _Textures; std::vector _Grayed; // Action Handler called on combo click @@ -155,7 +169,7 @@ namespace NLGUI CCtrlBaseButton *_SelectButton; bool _IsExternViewText; - ucstring _ExternViewText; + std::string _ExternViewText; private: diff --git a/nel/include/nel/gui/dbview_quantity.h b/nel/include/nel/gui/dbview_quantity.h index 16a11f5a0..e172624d7 100644 --- a/nel/include/nel/gui/dbview_quantity.h +++ b/nel/include/nel/gui/dbview_quantity.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -57,7 +58,7 @@ namespace NLGUI CInterfaceProperty _NumberMax; sint32 _Cache; sint32 _CacheMax; - ucstring _EmptyText; + std::string _EmptyText; void buildTextFromCache(); }; diff --git a/nel/include/nel/gui/event_descriptor.h b/nel/include/nel/gui/event_descriptor.h index 95bdad212..41c99e101 100644 --- a/nel/include/nel/gui/event_descriptor.h +++ b/nel/include/nel/gui/event_descriptor.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -60,7 +61,7 @@ public: keydown = 0, // a key has been press down. The key value is stored as a TKey keyup, // a key has been released. The key value is stored as a TKey keychar, // a key has been stroke. The key is a ucchar - keystring, // a string has been sent. The string is a ucstring + keystring, // a string has been sent. The string is a utf-8 string unknown, // uninitialized event }; CEventDescriptorKey() : _KeyEvent(unknown), _CtrlState(false), _ShiftState(false), _AltState(false), _Char(0) @@ -82,13 +83,13 @@ public: return _Key; } // return the char that has been pressed. The key event type MUST be 'keychar', else => assert - ucchar getChar() const + u32char getChar() const { nlassert(_KeyEvent == keychar); return _Char; } // return the string that has been sent. The key event type MUST be 'keystring', else => assert - ucstring getString() const + std::string getString() const { nlassert(_KeyEvent == keystring); return _String; @@ -141,9 +142,9 @@ private: union { NLMISC::TKey _Key; - ucchar _Char; + u32char _Char; }; - ucstring _String; + std::string _String; }; // ---------------------------------------------------------------------------- diff --git a/nel/include/nel/gui/group_container.h b/nel/include/nel/gui/group_container.h index 742dfcfb2..5157c22b1 100644 --- a/nel/include/nel/gui/group_container.h +++ b/nel/include/nel/gui/group_container.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -248,12 +249,14 @@ namespace NLGUI // Get the header color draw. NB: depends if grayed, and if active. NLMISC::CRGBA getDrawnHeaderColor () const; - ucstring getUCTitleOpened () const; - void setUCTitleOpened (const ucstring &title); - ucstring getUCTitleClosed () const; - void setUCTitleClosed (const ucstring &title); - ucstring getUCTitle () const; - void setUCTitle (const ucstring &title); +#ifdef RYZOM_LUA_UCSTRING + ucstring getUCTitleOpened () const; // Compatibility + void setUCTitleOpened (const ucstring &title); // Compatibility + ucstring getUCTitleClosed () const; // Compatibility + void setUCTitleClosed (const ucstring &title); // Compatibility + ucstring getUCTitle () const; // Compatibility + void setUCTitle (const ucstring &title); // Compatibility +#endif void setPopable(bool popable) { _Popable = popable; } bool isPopable() const { return _Popable; } @@ -287,9 +290,13 @@ namespace NLGUI REFLECT_STRING("title", getTitle, setTitle); REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); - REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); - REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); - REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); + +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // Compatibility + REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // Compatibility + REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // Compatibility +#endif + REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); @@ -302,6 +309,8 @@ namespace NLGUI REFLECT_BOOL("lockable", isLockable, setLockable); REFLECT_BOOL("locked", isLocked, setLocked); + REFLECT_BOOL("localize", isLocalize, setLocalize); + REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); REFLECT_EXPORT_END @@ -364,7 +373,7 @@ namespace NLGUI bool isActiveSavable() const { return _ActiveSavable; } bool isLocalize() const { return _Localize; } - void setLocalize(bool localize) { _Localize = localize; } + void setLocalize(bool localize); void setPopupX(sint32 x) { _PopupX = x; } void setPopupY(sint32 y) { _PopupY = y; } @@ -477,8 +486,8 @@ namespace NLGUI float _CurrentRolloverAlphaContainer; float _CurrentRolloverAlphaContent; sint32 _LayerSetup; - ucstring _TitleTextOpened; - ucstring _TitleTextClosed; + std::string _TitleTextOpened; + std::string _TitleTextClosed; CViewText *_TitleOpened; CViewText *_TitleClosed; sint32 _TitleDeltaMaxW; @@ -636,6 +645,9 @@ namespace NLGUI TTileClass convertTitleClass(const char *ptr); + void setTitledOpenedViewText(); + void setTitledClosedViewText(); + static COptionsContainerMove *getMoveOptions(); COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used diff --git a/nel/include/nel/gui/group_container_base.h b/nel/include/nel/gui/group_container_base.h index ab65b005b..7f99cac3c 100644 --- a/nel/include/nel/gui/group_container_base.h +++ b/nel/include/nel/gui/group_container_base.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2014 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h index 096f3daa0..1f4f316fc 100644 --- a/nel/include/nel/gui/group_editbox.h +++ b/nel/include/nel/gui/group_editbox.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -63,26 +64,29 @@ namespace NLGUI virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); /// Accessors - ucstring getInputString() const { return _InputString; } - const ucstring &getInputStringRef() const { return _InputString; } - const ucstring &getPrompt() const { return _Prompt; } + std::string getInputString() const; + std::string getPrompt() const; + const ::u32string &getInputStringRef() const { return _InputString; } + const ::u32string &getPromptRef() const { return _Prompt; } /** Set the prompt * NB : line returns are encoded as '\n', not '\r\n' */ - void setPrompt(const ucstring &s) { _Prompt = s; } - void setInputString(const ucstring &str); - void setInputStringRef(const ucstring &str) {_InputString = str; }; + void setPrompt(const std::string &s); + void setInputString(const std::string &str); + void setInputStringRef(const ::u32string &str); void setInputStringAsInt(sint32 val); sint32 getInputStringAsInt() const; void setInputStringAsInt64(sint64 val); sint64 getInputStringAsInt64() const; void setInputStringAsFloat(float val); float getInputStringAsFloat() const; - void setInputStringAsStdString(const std::string &str); - std::string getInputStringAsStdString() const; - void setInputStringAsUtf8(const std::string &str); - std::string getInputStringAsUtf8() const; +#ifdef RYZOM_LUA_UCSTRING + void setInputStringAsUtf16(const ucstring &str); // Compatibility + ucstring getInputStringAsUtf16() const; // Compatibility + void setInputStringAsUtf32(const ::u32string &str) { setInputStringRef(str); } // Compatibility + ::u32string getInputStringAsUtf32() const { return _InputString; } // Compatibility +#endif void setColor(NLMISC::CRGBA col); @@ -97,7 +101,7 @@ namespace NLGUI static CGroupEditBox *getMenuFather() { return _MenuFather; } - void setCommand(const ucstring &command, bool execute); + void setCommand(const std::string &command, bool execute); // Stop parent from blinking void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } @@ -121,7 +125,7 @@ namespace NLGUI sint32 getMaxHistoric() const {return _MaxHistoric;} sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} - const ucstring &getHistoric(uint32 index) const {return _Historic[index];} + const ::u32string &getHistoric(uint32 index) const {return _Historic[index];} uint32 getNumHistoric() const {return (uint32)_Historic.size ();} // Get on change action handler @@ -139,7 +143,7 @@ namespace NLGUI // Paste the selection into buffer void paste(); // Write the string into buffer - void writeString(const ucstring &str, bool replace = true, bool atEnd = true); + void writeString(const std::string &str, bool replace = true, bool atEnd = true); // Expand the expression (true if there was a '/' at the start of the line) bool expand(); @@ -170,7 +174,7 @@ namespace NLGUI virtual void onKeyboardCaptureLost(); // set the input string as "default". will be reseted at first click (used for user information) - void setDefaultInputString(const ucstring &str); + void setDefaultInputString(const std::string &str); // For Interger and PositiveInteger, can specify min and max values void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} @@ -189,8 +193,10 @@ namespace NLGUI REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); - REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); - REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); + REFLECT_STRING("input_string", getInputString, setInputString); +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16); // Compatibility +#endif REFLECT_EXPORT_END /** Restore the original value of the edit box. @@ -215,6 +221,7 @@ namespace NLGUI float _BlinkTime; sint32 _CursorPos; uint32 _MaxNumChar; + uint32 _MaxNumBytes; uint32 _MaxNumReturn; uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only sint32 _MaxCharsSize; @@ -228,17 +235,17 @@ namespace NLGUI NLMISC::CRGBA _BackSelectColor; // Text info - ucstring _Prompt; - ucstring _InputString; + ::u32string _Prompt; + ::u32string _InputString; CViewText *_ViewText; // undo / redo - ucstring _StartInputString; // value of the input string when focus was acuired first - ucstring _ModifiedInputString; + ::u32string _StartInputString; // value of the input string when focus was acuired first + ::u32string _ModifiedInputString; // Historic info - typedef std::deque THistoric; + typedef std::deque<::u32string> THistoric; THistoric _Historic; uint32 _MaxHistoric; sint32 _CurrentHistoricIndex; @@ -275,7 +282,7 @@ namespace NLGUI bool _CanRedo : 1; bool _CanUndo : 1; - std::vector _NegativeFilter; + std::vector _NegativeFilter; sint _CursorTexID; sint32 _CursorWidth; @@ -298,13 +305,13 @@ namespace NLGUI void handleEventString(const NLGUI::CEventDescriptorKey &event); void setup(); void triggerOnChangeAH(); - void appendStringFromClipboard(const ucstring &str); + void appendStringFromClipboard(const std::string &str); - ucstring getSelection(); + std::string getSelection(); static CGroupEditBox *_MenuFather; - static bool isValidAlphaNumSpace(ucchar c) + static bool isValidAlphaNumSpace(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -314,7 +321,7 @@ namespace NLGUI ac==' '; } - static bool isValidAlphaNum(ucchar c) + static bool isValidAlphaNum(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -323,7 +330,7 @@ namespace NLGUI (ac >= 'A' && ac <= 'Z'); } - static bool isValidAlpha(ucchar c) + static bool isValidAlpha(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -331,13 +338,13 @@ namespace NLGUI (ac >= 'A' && ac <= 'Z'); } - static bool isValidPlayerNameChar(ucchar c) + static bool isValidPlayerNameChar(u32char c) { // valid player name (with possible shard prefix / suffix format return isValidAlpha(c) || c=='.' || c=='(' || c==')'; } - static bool isValidFilenameChar(ucchar c) + static bool isValidFilenameChar(u32char c) { if (c == '\\' || c == '/' || @@ -351,12 +358,12 @@ namespace NLGUI return true; } // - bool isFiltered(ucchar c) + bool isFiltered(u32char c) { - uint length = (uint)_NegativeFilter.size(); - for (uint k = 0; k < length; ++k) + ptrdiff_t length = _NegativeFilter.size(); + for (ptrdiff_t k = 0; k < length; ++k) { - if ((ucchar) _NegativeFilter[k] == c) return true; + if (_NegativeFilter[k] == c) return true; } return false; } diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index d04593870..8b6ad19b6 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -29,12 +30,14 @@ #include "nel/gui/html_element.h" #include "nel/gui/html_parser.h" #include "nel/gui/css_style.h" +#include "nel/gui/css_background_renderer.h" // forward declaration typedef void CURLM; namespace NLGUI { + class CViewLink; class CCtrlButton; class CCtrlTextButton; class CCtrlScroll; @@ -45,6 +48,20 @@ namespace NLGUI extern std::string CurrentCookie; + class ICurlDownloadCB + { + public: + ICurlDownloadCB(const std::string &url) + : url(url) + {} + + virtual ~ICurlDownloadCB() {}; + + virtual void finish() = 0; + + std::string url; + }; + // HTML group /** * Widget to have a resizable scrolltext and its scrollbar @@ -131,9 +148,9 @@ namespace NLGUI void endParagraph(); // add image download (used by view_bitmap.cpp to load web images) - void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage, const std::string &placeholder = "web_del.tga"); - // remove image from download list if present - void removeImageDownload(CViewBase *img); + ICurlDownloadCB *addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage, const std::string &placeholder = "web_del.tga"); + ICurlDownloadCB *addTextureDownload(const std::string &url, sint32 &texId, CViewBase *view); + void removeImageDownload(ICurlDownloadCB *handle, CViewBase *img); std::string localImageName(const std::string &url); // Timeout @@ -141,37 +158,15 @@ namespace NLGUI float getTimeout() const {return (float)_TimeoutValue;} // Some constants - NLMISC::CRGBA BgColor; NLMISC::CRGBA ErrorColor; NLMISC::CRGBA LinkColor; - NLMISC::CRGBA TextColor; - NLMISC::CRGBA H1Color; - NLMISC::CRGBA H2Color; - NLMISC::CRGBA H3Color; - NLMISC::CRGBA H4Color; - NLMISC::CRGBA H5Color; - NLMISC::CRGBA H6Color; bool ErrorColorGlobalColor; bool LinkColorGlobalColor; bool TextColorGlobalColor; - bool H1ColorGlobalColor; - bool H2ColorGlobalColor; - bool H3ColorGlobalColor; - bool H4ColorGlobalColor; - bool H5ColorGlobalColor; - bool H6ColorGlobalColor; - uint TextFontSize; - uint H1FontSize; - uint H2FontSize; - uint H3FontSize; - uint H4FontSize; - uint H5FontSize; - uint H6FontSize; uint TDBeginSpace; uint PBeginSpace; uint LIBeginSpace; uint ULBeginSpace; - uint LIIndent; uint ULIndent; float LineSpaceFontFactor; std::string DefaultButtonGroup; @@ -185,8 +180,8 @@ namespace NLGUI std::string DefaultRadioButtonBitmapNormal; std::string DefaultRadioButtonBitmapPushed; std::string DefaultRadioButtonBitmapOver; + // TODO: remove from interface xml and code std::string DefaultBackgroundBitmapView; - std::string CurrentLinkTitle; struct TFormField { public: @@ -324,16 +319,22 @@ namespace NLGUI void clearContext(); // Translate a char - bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const; + bool translateChar(u32char &output, u32char input, u32char lastChar) const; + + // return true if text has same style + bool isSameStyle(CViewLink *text, const CStyleParams &style) const; + // add text link using template + void newTextButton(const std::string &text, const std::string &tpl); + void newTextLink(const std::string &text); // Add a string in the current paragraph - void addString(const ucstring &str); + void addString(const std::string &str); // Add an image in the current paragraph void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams()); // Add a text area in the current paragraph - CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength); + CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const std::string &content, uint maxlength); // Add a combo box in the current paragraph CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); @@ -344,6 +345,9 @@ namespace NLGUI const std::string &overBitmap, const char *actionHandler, const char *actionHandlerParams, const std::string &tooltip, const CStyleParams &style = CStyleParams()); + // Set the background color + void setupBackground(CSSBackgroundRenderer *bg); + // Set the background color void setBackgroundColor (const NLMISC::CRGBA &bgcolor); @@ -354,9 +358,9 @@ namespace NLGUI void flushString(); // Set the title - void setTitle (const ucstring &title); void setTitle (const std::string &title); std::string getTitle() const; + void setContainerTitle (const std::string &title); // Lookup a url in local file system bool lookupLocalFile (std::string &result, const char *url, bool isUrl); @@ -383,6 +387,13 @@ namespace NLGUI // +
+ + link + link + + + diff --git a/nel/tools/htmlcss_test/tests/css-tricks/01-var-toggle.html b/nel/tools/htmlcss_test/tests/css-tricks/01-var-toggle.html new file mode 100644 index 000000000..72e49b854 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/css-tricks/01-var-toggle.html @@ -0,0 +1,24 @@ + + + + +

+

+

+

+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e01.basic.html b/nel/tools/htmlcss_test/tests/custom-properties/e01.basic.html new file mode 100644 index 000000000..c5085b8ef --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e01.basic.html @@ -0,0 +1,18 @@ + + + + +
+

Header

+
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e02.case-sensitive-name.html b/nel/tools/htmlcss_test/tests/custom-properties/e02.case-sensitive-name.html new file mode 100644 index 000000000..1d9dc7b88 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e02.case-sensitive-name.html @@ -0,0 +1,23 @@ + + + + +
+

Header1

+

Header2

+
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e03.value-syntax.html b/nel/tools/htmlcss_test/tests/custom-properties/e03.value-syntax.html new file mode 100644 index 000000000..28f0a9c69 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e03.value-syntax.html @@ -0,0 +1,17 @@ + + + + +
+

Header

+
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e05.inherited.html b/nel/tools/htmlcss_test/tests/custom-properties/e05.inherited.html new file mode 100644 index 000000000..bafbbf37f --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e05.inherited.html @@ -0,0 +1,17 @@ + + + + +

I inherited blue from the root element!

+
I got green set directly on me!
+
+ While I got red set directly on me! +

I’m red too, because of inheritance!

+
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e06.i18n.html b/nel/tools/htmlcss_test/tests/custom-properties/e06.i18n.html new file mode 100644 index 000000000..861e60412 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e06.i18n.html @@ -0,0 +1,15 @@ + + + + + + link + + link + + + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e07-safe-use-not-cyclic.html b/nel/tools/htmlcss_test/tests/custom-properties/e07-safe-use-not-cyclic.html new file mode 100644 index 000000000..39ed3a299 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e07-safe-use-not-cyclic.html @@ -0,0 +1,15 @@ + + + + +
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e08-cyclic.html b/nel/tools/htmlcss_test/tests/custom-properties/e08-cyclic.html new file mode 100644 index 000000000..4d1f5fdd8 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e08-cyclic.html @@ -0,0 +1,14 @@ + + + + +
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e09-not-cyclic.html b/nel/tools/htmlcss_test/tests/custom-properties/e09-not-cyclic.html new file mode 100644 index 000000000..f3e1788ee --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e09-not-cyclic.html @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e10.fallback.html b/nel/tools/htmlcss_test/tests/custom-properties/e10.fallback.html new file mode 100644 index 000000000..5d785bffa --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e10.fallback.html @@ -0,0 +1,24 @@ + + + + +
+

header

+

text

+
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e11.1.invalid-property-name.html b/nel/tools/htmlcss_test/tests/custom-properties/e11.1.invalid-property-name.html new file mode 100644 index 000000000..488e733a9 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e11.1.invalid-property-name.html @@ -0,0 +1,12 @@ + + + + +
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e11.2.whitespace-after-var.html b/nel/tools/htmlcss_test/tests/custom-properties/e11.2.whitespace-after-var.html new file mode 100644 index 000000000..a67b4ba1d --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e11.2.whitespace-after-var.html @@ -0,0 +1,13 @@ + + + + + +
+ + diff --git a/nel/tools/htmlcss_test/tests/custom-properties/e13.invalid-variables.html b/nel/tools/htmlcss_test/tests/custom-properties/e13.invalid-variables.html new file mode 100644 index 000000000..f60877d82 --- /dev/null +++ b/nel/tools/htmlcss_test/tests/custom-properties/e13.invalid-variables.html @@ -0,0 +1,13 @@ + + + + + + +
+ + diff --git a/nel/tools/ligo/CMakeLists.txt b/nel/tools/ligo/CMakeLists.txt index 9a7f24ebe..230e4c74a 100644 --- a/nel/tools/ligo/CMakeLists.txt +++ b/nel/tools/ligo/CMakeLists.txt @@ -2,5 +2,8 @@ IF(WITH_LIGO) IF(WITH_3D) ADD_SUBDIRECTORY(unbuild_land) + IF(WITH_GEORGES) + ADD_SUBDIRECTORY(unbuild_flora) + ENDIF() ENDIF() ENDIF() diff --git a/nel/tools/ligo/unbuild_flora/CMakeLists.txt b/nel/tools/ligo/unbuild_flora/CMakeLists.txt new file mode 100644 index 000000000..6c9dc99c4 --- /dev/null +++ b/nel/tools/ligo/unbuild_flora/CMakeLists.txt @@ -0,0 +1,11 @@ +FILE(GLOB SRC *.cpp *.h *.rc) + +SOURCE_GROUP("" FILES ${SRC}) + +ADD_EXECUTABLE(nl_unbuild_flora ${SRC}) + +TARGET_LINK_LIBRARIES(nl_unbuild_flora nel3d nelmisc nelligo nelgeorges) +NL_DEFAULT_PROPS(nl_unbuild_flora "NeL, Tools, Ligo: Unbuild Flora") +NL_ADD_RUNTIME_FLAGS(nl_unbuild_flora) + +INSTALL(TARGETS nl_unbuild_flora RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsligo) diff --git a/nel/tools/ligo/unbuild_flora/gold_pill.ico b/nel/tools/ligo/unbuild_flora/gold_pill.ico new file mode 100644 index 000000000..618b67a5d Binary files /dev/null and b/nel/tools/ligo/unbuild_flora/gold_pill.ico differ diff --git a/nel/tools/ligo/unbuild_flora/main.rc b/nel/tools/ligo/unbuild_flora/main.rc new file mode 100644 index 000000000..b01178a11 --- /dev/null +++ b/nel/tools/ligo/unbuild_flora/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "gold_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "NeL Unbuild Flora" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "nl_unbuild_flora" NL_FILEEXT ".exe" + VALUE "ProductName", "NeL Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp b/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp new file mode 100644 index 000000000..83e25eb69 --- /dev/null +++ b/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp @@ -0,0 +1,442 @@ +// NeL - MMORPG Framework +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// This utility is intended to rescue a lost flora .primitive file. +// It only recovers the generated flora positions, it cannot recover +// the flora zones. +// +// Author: Jan BOON (Kaetemi) + +// #include "../../3d/zone_lib/zone_utility.h" + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +using namespace std; +using namespace NLMISC; +using namespace NL3D; +using namespace NLGEORGES; +//using namespace NLLIGO; + +namespace /* anonymous */ +{ + +/* + +Process: +- Load all .plant sheets, map from .shape to .plant and bounding radius (Reference: prim_export, main.cpp) +- Load all source igs (Reference: ig_info, ig_info.cpp) +- Load all reference igs, remove matching entries from source igs +- Generate primitives + +*/ + +std::string s_DfnDir; /* R:\leveldesign\DFN */ +std::string s_LeveldesignDir; /* R:\leveldesign\game_elem\plant\ecosystem */ +std::string s_SourceDir; /* R:\reference\2008_july\data\r2_desert2 */ +std::string s_ReferenceDir; /* R:\pipeline\export\continents\r2_desert\zone_lighted_ig_land */ +std::string s_PrimitiveFile; /* R:\graphics\primitive\r2_desert\r2_desert.primitive */ + +/* + +Debug arguments: + +"R:\leveldesign\DFN" "R:\leveldesign\game_elem\plant\ecosystem" "R:\reference\2008_july\data\r2_desert2" "R:\pipeline\export\continents\r2_desert\zone_lighted_ig_land" "R:\graphics\primitive\r2_desert\r2_desert.primitive" +"R:\leveldesign\DFN" "R:\leveldesign\game_elem\plant\ecosystem" "R:\reference\2008_july\data\r2_forest2" "R:\pipeline\export\continents\r2_forest\zone_lighted_ig_land" "R:\graphics\primitive\r2_forest\r2_forest.primitive" +"R:\leveldesign\DFN" "R:\leveldesign\game_elem\plant\ecosystem" "R:\reference\2008_july\data\r2_jungle2" "R:\pipeline\export\continents\r2_jungle\zone_lighted_ig_land" "R:\graphics\primitive\r2_jungle\r2_jungle.primitive" +"R:\leveldesign\DFN" "R:\leveldesign\game_elem\plant\ecosystem" "R:\reference\2008_july\data\r2_lakes2" "R:\pipeline\export\continents\r2_lakes\zone_lighted_ig_land" "R:\graphics\primitive\r2_lakes\r2_lakes.primitive" +"R:\leveldesign\DFN" "R:\leveldesign\game_elem\plant\ecosystem" "R:\reference\2008_july\data\r2_roots2" "R:\pipeline\export\continents\r2_roots\zone_lighted_ig_land" "R:\graphics\primitive\r2_roots\r2_roots.primitive" + +*/ + +struct CPoint +{ + std::string ZoneLwr; + + CVector Pos; /* Position, height not necessarily specified (X="26218.738281" Y="-1092.078979" Z="0.000000") */ + float Angle; /* (2.827213) */ + float Scale; /* Scale (0.643217) */ + std::string Shape; + + bool Plant; + std::string Form; /* (FY_S2_savantree_B) */ + std::string Name; /* Generated unique name (ilot_008_savantree 13) */ + float Radius; /* Bounding radius (calculated from plant sheet and scale) (0.450252) */ + +}; + +/* + + + + + class + prim + + + form + FY_S2_savantree_B + + + layer + 0 + + + name + ilot_008_savantree 15 + + + radius + 0.784730 + + + scale + 1.121043 + + +*/ + +/* +* + + + + + + class + flora + + + name + R2 flora 1 + + + + + ... + + + +*/ + +/* +instance fy_s2_savantree_c.shape : x = 23031.2, y = -1269.2, z = 75.8, sx = 0.5, sy = 0.5, sz = 0.5 +instance fy_s2_savantree_c.shape : x = 22906.6, y = -1148.1, z = 79.6, sx = 0.6, sy = 0.6, sz = 0.6 +*/ + +struct CPlant +{ + std::string Form; + std::string Shape; + float Radius; +}; + +std::map s_ShapeToForm; +std::list s_Instances; + +bool loadLeveldesign() +{ + UFormLoader *formLoader = UFormLoader::createLoader(); + struct CRel0 { CRel0(UFormLoader *v) : m(v) {} ~CRel0() { UFormLoader::releaseLoader(m); } UFormLoader *m; } rel0(formLoader); + + std::vector plants; + CPath::getFileList("plant", plants); + + for (std::vector::iterator it(plants.begin()), end(plants.end()); it != end; ++it) + { + printf("%s\n", nlUtf8ToMbcs(*it)); + CSmartPtr form = formLoader->loadForm(*it); + if (!form) + continue; + CPlant plant; + plant.Form = toLowerAscii(*it); + if (!form->getRootNode().getValueByName(plant.Shape, "3D.Shape")) + continue; + if (plant.Shape.empty()) + { + if (!form->getRootNode().getValueByName(plant.Shape, "3D.SpringFX.FXName")) + continue; + } + if (plant.Shape.empty()) + continue; + (void)plant.Shape.c_str(); + toLowerAscii(&plant.Shape[0]); + if (!form->getRootNode().getValueByName(plant.Radius, "3D.Bounding Radius")) + continue; + printf(" = '%s', %f\n", nlUtf8ToMbcs(plant.Shape), plant.Radius); + s_ShapeToForm[plant.Shape] = plant; + } + + return true; +} + +bool loadInstances() +{ + std::vector igs; + CPath::getPathContent(s_SourceDir, true, false, true, igs); + + for (std::vector::iterator it(igs.begin()), end(igs.end()); it != end; ++it) + { + if (CFile::getExtension(*it) != nlstr("ig")) + continue; + printf("%s\n", nlUtf8ToMbcs(*it)); + CInstanceGroup ig; + CIFile inputStream; + if (!inputStream.open(*it)) + { + nlwarning("Unable to open %s\n", (*it).c_str()); + return false; + } + ig.serial(inputStream); + CVector gpos = ig.getGlobalPos(); + if (gpos.x != 0.0f || gpos.y != 0.0f || gpos.z != 0.0f) + { + nlwarning("Invalid global pos: %f, %f, %f", gpos.x, gpos.y, gpos.z); + return false; + } + string zoneLwr = toLowerAscii(CFile::getFilenameWithoutExtension(*it)); + for (ptrdiff_t i = 0; i < (ptrdiff_t)ig._InstancesInfos.size(); ++i) + { + CInstanceGroup::CInstance &info = ig._InstancesInfos[i]; + CPoint instance; + instance.Pos = info.Pos; + instance.Angle = info.Rot.getAngle(); + instance.Scale = info.Scale.z; + instance.Shape = toLowerAscii(info.Name); + printf("%s\n", nlUtf8ToMbcs(instance.Shape)); + std::map::iterator formIt = s_ShapeToForm.find(instance.Shape); + if (formIt != s_ShapeToForm.end()) + { + instance.Form = formIt->second.Form; + instance.Name = CFile::getFilenameWithoutExtension(instance.Form) + nlstr("_") + zoneLwr + nlstr("_") + toString(i); + instance.Radius = instance.Scale * formIt->second.Radius; + printf(" = %f, %f, %f, %f, %f, '%s', '%s', %f\n", instance.Pos.x, instance.Pos.y, instance.Pos.z, instance.Angle, instance.Scale, nlUtf8ToMbcs(instance.Form), nlUtf8ToMbcs(instance.Name), instance.Radius); + instance.Plant = true; + } + else + { + instance.Plant = false; + } + s_Instances.push_back(instance); + } + } + + return true; +} + +bool eraseReference() +{ + std::vector igs; + CPath::getPathContent(s_ReferenceDir, true, false, true, igs); + + for (std::vector::iterator it(igs.begin()), end(igs.end()); it != end; ++it) + { + if (CFile::getExtension(*it) != nlstr("ig")) + continue; + printf("%s\n", nlUtf8ToMbcs(*it)); + CInstanceGroup ig; + CIFile inputStream; + if (!inputStream.open(*it)) + { + nlwarning("Unable to open %s\n", (*it).c_str()); + return false; + } + ig.serial(inputStream); + CVector gpos = ig.getGlobalPos(); + if (gpos.x != 0.0f || gpos.y != 0.0f || gpos.z != 0.0f) + { + nlwarning("Invalid global pos: %f, %f, %f", gpos.x, gpos.y, gpos.z); + return false; + } + string zoneLwr = toLowerAscii(CFile::getFilenameWithoutExtension(*it)); + for (ptrdiff_t i = 0; i < (ptrdiff_t)ig._InstancesInfos.size(); ++i) + { + CInstanceGroup::CInstance &info = ig._InstancesInfos[i]; + string shape = toLowerAscii(info.Name); + printf("%s\n", nlUtf8ToMbcs(shape)); + bool erased = false; + for (std::list::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end; ++it) + { + const CPoint &instance = *it; + if (instance.Pos.x == info.Pos.x + && instance.Pos.y == info.Pos.y + && instance.Shape == shape) + { + printf(" = Found and erased\n"); + s_Instances.erase(it); + erased = true; + break; + } + } + if (!erased) + printf(" = NOT FOUND!\n"); + } + } + + return true; +} + +bool eraseNonPlants() +{ + for (std::list::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end;) + { + const CPoint &instance = *it; + if (!instance.Plant) + { + printf("Erase '%s' because it's not a plant!\n", nlUtf8ToMbcs(instance.Shape)); + std::list::iterator nextIt = it; + ++nextIt; + s_Instances.erase(it); + it = nextIt; + } + else + { + ++it; + } + } + + return true; +} + +bool writeFlora() +{ + ofstream fo; +#ifdef NL_OS_WINDOWS + fo.open(utf8ToWide(s_PrimitiveFile)); +#else + fo.open(s_PrimitiveFile); +#endif + fo << "\n"; + fo << "\n"; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " class\n"; + fo << " flora\n"; + fo << " \n"; + fo << " \n"; + fo << " name\n"; + fo << " " << CFile::getFilenameWithoutExtension(s_PrimitiveFile) << "_flora\n"; + fo << " \n"; + for (std::list::iterator it(s_Instances.begin()), end(s_Instances.end()); it != end; ++it) + { + const CPoint &instance = *it; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " \n"; + fo << " class\n"; + fo << " prim\n"; + fo << " \n"; + fo << " \n"; + fo << " form\n"; + fo << " " << CFile::getFilenameWithoutExtension(instance.Form) << "\n"; + fo << " \n"; + fo << " \n"; + fo << " layer\n"; + fo << " 0\n"; + fo << " \n"; + fo << " \n"; + fo << " name\n"; + fo << " " << instance.Name << "\n"; + fo << " \n"; + fo << " \n"; + fo << " radius\n"; + fo << " " << instance.Radius << "\n"; + fo << " \n"; + fo << " \n"; + fo << " scale\n"; + fo << " " << instance.Scale << "\n"; + fo << " \n"; + fo << " \n"; + } + fo << " \n"; + fo << " \n"; + fo << "\n"; + printf("Generated:\n%s\n", nlUtf8ToMbcs(s_PrimitiveFile)); + return true; +} + +bool unbuildFlora() +{ + CPath::addSearchPath(s_DfnDir, true, false); + CPath::addSearchPath(s_LeveldesignDir, true, false); + + return loadLeveldesign() + && loadInstances() + && eraseReference() + && eraseNonPlants() + && writeFlora(); +} + +bool unbuildFlora(NLMISC::CCmdArgs &args) +{ + s_DfnDir = args.getAdditionalArg("dfn")[0]; + s_LeveldesignDir = args.getAdditionalArg("leveldesign")[0]; + s_SourceDir = args.getAdditionalArg("source")[0]; + s_ReferenceDir = args.getAdditionalArg("reference")[0]; + s_PrimitiveFile = args.getAdditionalArg("primitive")[0]; + + return unbuildFlora(); +} + +} /* anonymous namespace */ + +int main(int argc, char **argv) +{ + NLMISC::CApplicationContext myApplicationContext; + + NLMISC::CCmdArgs args; + + args.addAdditionalArg("dfn", "Input folder with DFN"); + args.addAdditionalArg("leveldesign", "Input folder with plant sheets"); + args.addAdditionalArg("source", "Input folder with IGs containing flora"); + args.addAdditionalArg("reference", "Input folder with IGs missing flora"); + args.addAdditionalArg("primitive", "Output flora primitive file"); + + if (!args.parse(argc, argv)) + { + return EXIT_FAILURE; + } + + if (!unbuildFlora(args)) + { + args.displayHelp(); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +/* end of file */ diff --git a/nel/tools/ligo/unbuild_land/unbuild_land.cpp b/nel/tools/ligo/unbuild_land/unbuild_land.cpp index 37b3b4e79..534f01a12 100644 --- a/nel/tools/ligo/unbuild_land/unbuild_land.cpp +++ b/nel/tools/ligo/unbuild_land/unbuild_land.cpp @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -104,7 +104,7 @@ bool getXYFromZoneName(sint32 &x, sint32 &y, const string &zoneName) } if (xStr.size() != 2) goto Fail; - xStr = NLMISC::toUpper(xStr); + xStr = NLMISC::toUpperAscii(xStr); x = ((xStr[0] - 'A') * 26 + (xStr[1] - 'A')); return true; Fail: diff --git a/nel/tools/misc/CMakeLists.txt b/nel/tools/misc/CMakeLists.txt index f9112a823..dbe814d3f 100644 --- a/nel/tools/misc/CMakeLists.txt +++ b/nel/tools/misc/CMakeLists.txt @@ -12,6 +12,7 @@ IF(WITH_NEL_TOOLS) lock make_sheet_id xml_packer + utf_generator ) IF(WITH_QT OR WITH_QT5) diff --git a/nel/tools/misc/bnp_make/main.cpp b/nel/tools/misc/bnp_make/main.cpp index d6842b8fe..823962f59 100644 --- a/nel/tools/misc/bnp_make/main.cpp +++ b/nel/tools/misc/bnp_make/main.cpp @@ -1,5 +1,8 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -56,7 +59,7 @@ bool keepFile (const std::string &fileName) uint i; bool ifPresent = false; bool ifTrue = false; - string file = toLower(CFile::getFilename (fileName)); + string file = toLowerAscii(CFile::getFilename (fileName)); for (i=0; i + if (args.haveLongArg("extract") && !args.getLongArg("extract").empty()) + { + std::string bnpName = args.getAdditionalArg("input").front(); + CBigFile::getInstance().add(bnpName, BF_ALWAYS_OPENED); + + // Output directory or filename + if (!args.haveArg("o") || args.getArg("o").empty()) + { + nlerror("Output file or directory not set"); + } + + std::string srcName = args.getLongArg("extract").front(); + std::string dstName = args.getArg("o").front(); + if (CFile::fileExists(dstName) && CFile::isDirectory(dstName)) + { + dstName += "/" + srcName; + } + + CIFile inFile; + // bnpName without path + if (!inFile.open(CFile::getFilename(bnpName) + "@" + srcName)) + { + nlerror("Unable to open '%s' for reading", inFile.getStreamName().c_str()); + } + + COFile outFile; + if (!outFile.open(dstName)) + { + nlerror("Unable to open '%s' for writing", outFile.getStreamName().c_str()); + } + + std::string buf; + inFile.readAll(buf); + outFile.serialBuffer((uint8 *)&buf[0], buf.size()); + + return 0; + } + args.displayHelp(); return -1; } diff --git a/nel/tools/misc/data_mirror/data_mirror.cpp b/nel/tools/misc/data_mirror/data_mirror.cpp index 03830cff8..6ae79994e 100644 --- a/nel/tools/misc/data_mirror/data_mirror.cpp +++ b/nel/tools/misc/data_mirror/data_mirror.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -108,21 +108,21 @@ BOOL CData_mirrorApp::InitInstance() cf.load (path); MainDirectory = cf.getVar ("MainDirectory").asString (); - MainDirectory = toLower (CPath::standardizePath (MainDirectory)); + MainDirectory = toLowerAscii (CPath::standardizePath (MainDirectory)); MirrorDirectory = cf.getVar ("MirrorDirectory").asString (); - MirrorDirectory = toLower (CPath::standardizePath (MirrorDirectory)); + MirrorDirectory = toLowerAscii (CPath::standardizePath (MirrorDirectory)); LogDirectory = cf.getVar ("LogDirectory").asString (); - LogDirectory = toLower (CPath::standardizePath (LogDirectory)); + LogDirectory = toLowerAscii (CPath::standardizePath (LogDirectory)); IgnoreDirectory = cf.getVar ("IgnoreDirectory").asString (); - IgnoreDirectory = toLower (CPath::standardizePath (IgnoreDirectory)); + IgnoreDirectory = toLowerAscii (CPath::standardizePath (IgnoreDirectory)); if (IgnoreDirectory.empty()) IgnoreDirectory = MainDirectory; string sBinaryCompare = cf.getVar ("BinaryCompare").asString (); - sBinaryCompare = toLower (sBinaryCompare); + sBinaryCompare = toLowerAscii (sBinaryCompare); BinaryCompare = false; if ((sBinaryCompare == "true") || (sBinaryCompare=="1")) BinaryCompare = true; @@ -145,12 +145,12 @@ BOOL CData_mirrorApp::InitInstance() if (NLMISC::CFile::isDirectory (CurrentDir)) { directory = true; - CurrentDir = toLower(CPath::standardizePath (CurrentDir)); + CurrentDir = toLowerAscii(CPath::standardizePath (CurrentDir)); } else if (NLMISC::CFile::fileExists (CurrentDir)) { directory = false; - CurrentDir = toLower(CPath::standardizePath (NLMISC::CFile::getPath (CurrentDir))); + CurrentDir = toLowerAscii(CPath::standardizePath (NLMISC::CFile::getPath (CurrentDir))); } else { diff --git a/nel/tools/misc/data_mirror/data_mirrorDlg.cpp b/nel/tools/misc/data_mirror/data_mirrorDlg.cpp index a7f65aa3a..0f5e33041 100644 --- a/nel/tools/misc/data_mirror/data_mirrorDlg.cpp +++ b/nel/tools/misc/data_mirror/data_mirrorDlg.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -628,7 +628,7 @@ void CData_mirrorDlg::buildSourceFiles () { // Get the filename string &str = fileSource[i]; - str = toLower(str.substr (MainDirectory.size (), str.size ())); + str = toLowerAscii(str.substr (MainDirectory.size (), str.size ())); // In the ignore list ? if (IgnoreFiles.find (str) == IgnoreFiles.end () && (str != "ignore_list.txt")) @@ -716,7 +716,7 @@ void CData_mirrorDlg::buildSourceFiles () { // Get the filename string &str = fileSource[i]; - str = toLower(str.substr (MirrorDirectory.size (), str.size ())); + str = toLowerAscii(str.substr (MirrorDirectory.size (), str.size ())); // In the ignore list ? if (IgnoreFiles.find (str) == IgnoreFiles.end () && (str != "ignore_list.txt")) diff --git a/nel/tools/misc/extract_filename/extract_filename.cpp b/nel/tools/misc/extract_filename/extract_filename.cpp index 7708f9031..3dbf05b8d 100644 --- a/nel/tools/misc/extract_filename/extract_filename.cpp +++ b/nel/tools/misc/extract_filename/extract_filename.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -214,7 +217,7 @@ void extractStringsFromBinary (const vector &fileArray, set &filen if (str != "") { // Lower case - str = toLower (str); + str = toLowerAscii (str); // Filter extensions if (filterExtension (str.c_str(), extensions)) @@ -280,7 +283,7 @@ void extractStringsFromASCII (const vector &fileArray, set &filena temp[c] = begin[c]; // Lower case - temp = toLower (temp); + temp = toLowerAscii (temp); // Filter extensions if (filterExtension (temp.c_str(), extensions)) @@ -325,7 +328,7 @@ bool loadConfigFiles (const char *ext, const char *input_files, const char *avai while (fgets (name, 512, file)) { // To string and lower - temp = toLower (string(name)); + temp = toLowerAscii (string(name)); // Remove return removeChar (temp, '\n'); @@ -374,8 +377,8 @@ bool loadConfigFiles (const char *ext, const char *input_files, const char *avai while (fgets (name, 512, file)) { // To lower - temp = toLower (string(name)); - temp2 = toLower (string(name)); + temp = toLowerAscii (string(name)); + temp2 = toLowerAscii (string(name)); // Remove space removeBeginEndSpaces (temp); @@ -597,7 +600,7 @@ int main(int argc, char* argv[]) // It is used ? if (usedFiles.find (available->first) == usedFiles.end()) { - string temp = toLower (available->second); + string temp = toLowerAscii (available->second); fprintf (stderr, "UNUSED: %s\n", temp.c_str()); } diff --git a/nel/tools/misc/make_sheet_id/make_sheet_id.cpp b/nel/tools/misc/make_sheet_id/make_sheet_id.cpp index be8f9cb53..3bf7db43c 100644 --- a/nel/tools/misc/make_sheet_id/make_sheet_id.cpp +++ b/nel/tools/misc/make_sheet_id/make_sheet_id.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012-2019 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -320,10 +320,10 @@ void addId( string fileName ) if( itFI == FormToId.end() ) { // double check : if file not found we check with lower case version of filename - map::iterator itFILwr = FormToId.find( toLower(fileName) ); + map::iterator itFILwr = FormToId.find( toLowerAscii(fileName) ); if( itFILwr != FormToId.end() ) { - nlwarning("Trying to add %s but the file %s is already known ! becareful with lower case and upper case.", fileName.c_str(), toLower(fileName).c_str()); + nlwarning("Trying to add %s but the file %s is already known ! becareful with lower case and upper case.", fileName.c_str(), toLowerAscii(fileName).c_str()); NbFilesDiscarded++; return; } diff --git a/nel/tools/misc/snp_make/main.cpp b/nel/tools/misc/snp_make/main.cpp index 8b94b7afc..3cadfec6e 100644 --- a/nel/tools/misc/snp_make/main.cpp +++ b/nel/tools/misc/snp_make/main.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -64,7 +64,7 @@ bool keepFile (const char *fileName) uint i; bool ifPresent = false; bool ifTrue = false; - string file = toLower(CFile::getFilename (fileName)); + string file = toLowerAscii(CFile::getFilename (fileName)); for (i=0; i +// Copyright (C) 2020 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "nel/misc/types_nl.h" + +#include "nel/misc/debug.h" +#include "nel/misc/common.h" +#include "nel/misc/string_common.h" +#include "nel/misc/string_view.h" +#include "nel/misc/utf_string_view.h" + +#include +#include +#include +#include +#include + +void printStringMap(const std::string &name, std::map &m, bool trim) +{ + std::cout << "static const char " << name << "[" << std::dec << (trim ? "64" : "256") << " * 4] = {\n"; + bool zero = false; + for (int i = 0; i < (trim ? 64 : 256); ++i) + { + int x = trim ? i + 0x80 : i; + if (m.find(x) == m.end()) + { + if (x % 8 == 7) + { + zero = false; + std::cout << "0, 0, 0, 0,\n"; + } + else + { + zero = true; + std::cout << "0, 0, 0, 0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::stringstream ss; + ss << "'\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 0 ? (unsigned char)m[x][0] : 0) + << "', '\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 1 ? (unsigned char)m[x][1] : 0) + << "', '\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 2 ? (unsigned char)m[x][2] : 0) + << "', 0,\n"; + std::cout << ss.str(); + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << "};\n\n"; +} + +void printMapMap(const std::string &name, const std::string &strName, std::map> &m, int base, int size) +{ + std::cout << "static const char *" << name << "[" << size << "] = {\n"; + bool zero = false; + for (int i = base; i < (base + size); ++i) + { + int x = i; + if (m.find(x) == m.end()) + { + if (x % 32 == 1315) + { + zero = false; + std::cout << "0, \n"; + } + else + { + zero = true; + std::cout << "0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::stringstream n; + n << strName; + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x; + std::cout << n.str() << ",\n"; + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << std::dec << "};\n\n"; +} + +void printMapMapMap(const std::string &name, const std::string &mapName, std::map>> &m, int base, int size) +{ + std::cout << "static const char **" << name << "[" << size << "] = {\n"; + bool zero = false; + for (int i = base; i < (base + size); ++i) + { + int x = i; + if (m.find(x) == m.end()) + { + if (x % 32 == 1315) + { + zero = false; + std::cout << "0, \n"; + } + else + { + zero = true; + std::cout << "0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::stringstream n; + n << mapName; + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x; + std::cout << n.str() << ",\n"; + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << "};\n\n"; +} + +void printMapMapMapMap(const std::string &name, const std::string &mapName, std::map>>> &m, int base, int size) +{ + std::cout << "static const char ***" << name << "[" << size << "] = {\n"; + bool zero = false; + for (int i = base; i < (base + size); ++i) + { + int x = i; + if (m.find(x) == m.end()) + { + if (x % 32 == 1315) + { + zero = false; + std::cout << "0, \n"; + } + else + { + zero = true; + std::cout << "0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::stringstream n; + n << mapName; + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x; + std::cout << n.str() << ",\n"; + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << "};\n\n"; +} + +void generateMap(const std::string &file, const std::string &name, const std::vector &map) +{ + std::map m1; + std::map> m2; + std::map>> m3; + std::map>>> m4; + for (u32char i = 0; i < 0x110000; ++i) + { + if (map[i] != i) + { + std::string from; + NLMISC::CUtfStringView::append(from, i); + std::string to; + NLMISC::CUtfStringView::append(to, map[i]); + // assert(from.size() == to.size()); + if (from.length() == 1) + { + m1[from[0]] = to; + } + else if (from.length() == 2) + { + if (m2.find(from[0]) == m2.end()) + m2[from[0]] = std::map(); + m2[from[0]][from[1]] = to; + } + else if (from.length() == 3) + { + if (m3.find(from[0]) == m3.end()) + m3[from[0]] = std::map>(); + if (m3[from[0]].find(from[1]) == m3[from[0]].end()) + m3[from[0]][from[1]] = std::map(); + m3[from[0]][from[1]][from[2]] = to; + } + else if (from.length() == 4) + { + if (m4.find(from[0]) == m4.end()) + m4[from[0]] = std::map>>(); + if (m4[from[0]].find(from[1]) == m4[from[0]].end()) + m4[from[0]][from[1]] = std::map>(); + if (m4[from[0]][from[1]].find(from[2]) == m4[from[0]][from[1]].end()) + m4[from[0]][from[1]][from[2]] = std::map(); + m4[from[0]][from[1]][from[2]][from[3]] = to; + } + } + } + printStringMap("s_" + name, m1, false); + for (int i = 0; i < 256; ++i) + { + std::stringstream n; + n << "s_" << name; + if (m2.find(i) != m2.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + printStringMap(n.str(), m2[i], true); + } + else if (m3.find(i) != m3.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + for (int j = 0; j < 256; ++j) + { + if (m3[i].find(j) != m3[i].end()) + { + std::stringstream nn; + nn << n.str(); + nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j; + printStringMap(nn.str(), m3[i][j], true); + } + } + } + else if (m4.find(i) != m4.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + for (int j = 0; j < 256; ++j) + { + if (m4[i].find(j) != m4[i].end()) + { + std::stringstream nn; + nn << n.str(); + nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j; + for (int k = 0; k < 256; ++k) + { + if (m4[i][j].find(k) != m4[i][j].end()) + { + std::stringstream nnn; + nnn << nn.str(); + nnn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)k; + printStringMap(nnn.str(), m4[i][j][k], true); + } + } + } + } + } + } + printMapMap("s_" + name + "Map", "s_" + name, m2, 0xC0, 32); + + for (int i = 0; i < 256; ++i) + { + std::stringstream n; + n << "s_" << name << "Map"; + std::stringstream nn; + nn << "s_" << name; + if (m3.find(i) != m3.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + printMapMap(n.str(), nn.str(), m3[i], 0x80, 64); + } + } + printMapMapMap("s_" + name + "MapMap", "s_" + name + "Map", m3, 0xE0, 16); + + for (int i = 0; i < 256; ++i) + { + std::stringstream n; + n << "s_" << name << "Map"; + std::stringstream nn; + nn << "s_" << name; + std::stringstream nnn; + nnn << "s_" << name << "MapMap"; + if (m4.find(i) != m4.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + nnn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + for (int j = 0; j < 256; ++j) + { + if (m4[i].find(j) != m4[i].end()) + { + std::stringstream n2, nn2; + n2 << n.str() << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j; + nn2 << nn.str() << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j; + printMapMap(n2.str(), nn2.str(), m4[i][j], 0x80, 64); + } + } + printMapMapMap(nnn.str(), n.str(), m4[i], 0x80, 64); + } + } + printMapMapMapMap("s_" + name + "MapMapMap", "s_" + name + "MapMap", m4, 0xF0, 8); +} + +int main (int argc, char **argv) +{ + std::ifstream fi("UnicodeData.txt"); + + std::vector upper; + std::vector lower; + std::vector title; + std::vector ci; + + upper.resize(0x110000); + lower.resize(0x110000); + title.resize(0x110000); + ci.resize(0x110000); + + for (u32char i = 0; i < 0x110000; ++i) + { + upper[i] = i; + lower[i] = i; + title[i] = i; + ci[i] = i; + } + + std::string line; + while (std::getline(fi, line)) + { + std::vector cols; + NLMISC::explode(line, nlstr(";"), cols, false); + nlassert(cols.size() == 15); + + u32char c = NLMISC::atoiInt64(cols[0].c_str(), 16); + u32char up = NLMISC::atoiInt64(cols[12].c_str(), 16); + u32char low = NLMISC::atoiInt64(cols[13].c_str(), 16); + u32char tit = NLMISC::atoiInt64(cols[14].c_str(), 16); + + if (up) upper[c] = up; + if (low) lower[c] = low; + if (tit) title[c] = tit; + } + + std::vector ref; + int rounds = 0; + for (;;) + { + ref = ci; + + for (u32char i = 0; i < 0x110000; ++i) + { + ci[i] = title[ci[i]]; + } + + for (u32char i = 0; i < 0x110000; ++i) + { + ci[i] = upper[ci[i]]; + } + + for (u32char i = 0; i < 0x110000; ++i) + { + ci[i] = lower[ci[i]]; + } + + bool equal = true; + for (u32char i = 0; i < 0x110000; ++i) + { + if (ci[i] != ref[i]) + equal = false; + } + ++rounds; + std::cout << rounds << std::endl; + if (equal) + break; + } + + for (u32char i = 0; i < 0x110000; ++i) + { + if (ci[i] != lower[i]) + std::cout << i << std::endl; + } + + generateMap("string_to_upper", "StringToUpper", upper); + //generateMap("string_to_lower", "StringToLower", lower); + //generateMap("string_to_title", "StringToTitle", title); + //generateMap("string_to_ci", "StringToCaseInsensitive", ci); + + std::string test = nlstr("Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,"); + std::string testUpper = NLMISC::toUpper(test); + std::string testLower = NLMISC::toLower(test); + std::string testUpper2 = NLMISC::toUpper(testLower); + std::string testLower2 = NLMISC::toLower(testUpper); + std::cout << test << std::endl; + std::cout << testUpper << std::endl; + std::cout << testLower << std::endl; + std::cout << testUpper2 << std::endl; + std::cout << testLower2 << std::endl; + + int cci1 = NLMISC::compareCaseInsensitive("bAAAAfdsklj", "Cldsfjslkf"); + int cci2 = NLMISC::compareCaseInsensitive("Cldsfjslkf", "bAAAAfdsklj"); + int strc1 = strcmp(NLMISC::toLower("bAAAAfdsklj").c_str(), NLMISC::toLower("Cldsfjslkf").c_str()); + int strc2 = strcmp(NLMISC::toLower("Cldsfjslkf").c_str(), NLMISC::toLower("bAAAAfdsklj").c_str()); + + int bcci1 = NLMISC::compareCaseInsensitive("bAAAAfdsklj", "AnlsqFDS"); + int bcci2 = NLMISC::compareCaseInsensitive("AnlsqFDS", "bAAAAfdsklj"); + int bstrc1 = strcmp(NLMISC::toLower("bAAAAfdsklj").c_str(), NLMISC::toLower("AnlsqFDS").c_str()); + int bstrc2 = strcmp(NLMISC::toLower("AnlsqFDS").c_str(), NLMISC::toLower("bAAAAfdsklj").c_str()); + + std::vector arr; + arr.push_back("AnlsqFDS"); + arr.push_back("yozeRNZE"); + arr.push_back("yOzeihfn"); + arr.push_back("bAAAAfdsklj"); + arr.push_back("Cldsfjslkf"); + std::sort(arr.begin(), arr.end(), NLMISC::ltCaseInsensitive); + for (int i = 0; i < arr.size(); ++i) + std::cout << arr[i] << std::endl; + + return EXIT_SUCCESS; +} + +/* end of file */ diff --git a/nel/tools/misc/utf_generator/main.rc b/nel/tools/misc/utf_generator/main.rc new file mode 100644 index 000000000..ea4618245 --- /dev/null +++ b/nel/tools/misc/utf_generator/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "gold_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "NeL UTF Generator" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "nl_utf_generator" NL_FILEEXT ".exe" + VALUE "ProductName", "NeL Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/nel/tools/nel_unit_test/ut_misc.h b/nel/tools/nel_unit_test/ut_misc.h index aef1e4c90..97bc0d410 100644 --- a/nel/tools/nel_unit_test/ut_misc.h +++ b/nel/tools/nel_unit_test/ut_misc.h @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/tools/nel_unit_test/ut_misc_base64.h b/nel/tools/nel_unit_test/ut_misc_base64.h index 84ddfcefc..ff5d24c4c 100644 --- a/nel/tools/nel_unit_test/ut_misc_base64.h +++ b/nel/tools/nel_unit_test/ut_misc_base64.h @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/tools/nel_unit_test/ut_misc_common.h b/nel/tools/nel_unit_test/ut_misc_common.h index 8a7aab150..b21fa22f3 100644 --- a/nel/tools/nel_unit_test/ut_misc_common.h +++ b/nel/tools/nel_unit_test/ut_misc_common.h @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/tools/pacs/build_rbank/prim_checker.cpp b/nel/tools/pacs/build_rbank/prim_checker.cpp index 3b8c11bf9..f8e14b88a 100644 --- a/nel/tools/pacs/build_rbank/prim_checker.cpp +++ b/nel/tools/pacs/build_rbank/prim_checker.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2021 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -336,13 +336,19 @@ void CPrimChecker::render(CPrimZone *zone, uint8 bits) */ void CPrimChecker::render(const CPolygon &poly, uint16 value) { + static const sint centerOffset = 20480; // zones are max 40960 + CPolygon polyOffset = poly; + for (ptrdiff_t i = 0; i < (ptrdiff_t)polyOffset.Vertices.size(); ++i) + // center to computeBorders range (-32k to 32k) + polyOffset.Vertices[i] += CVector(-centerOffset, centerOffset, 0); + list convex; // divide poly in convex polys - if (!poly.toConvexPolygons(convex, CMatrix::Identity)) + if (!polyOffset.toConvexPolygons(convex, CMatrix::Identity)) { convex.clear(); - CPolygon reverse = poly; + CPolygon reverse = polyOffset; std::reverse(reverse.Vertices.begin(), reverse.Vertices.end()); if (!reverse.toConvexPolygons(convex, CMatrix::Identity)) return; @@ -357,6 +363,7 @@ void CPrimChecker::render(const CPolygon &poly, uint16 value) sint ymin; convex2d.computeBorders(rasterized, ymin); + ymin -= centerOffset; // uncenter sint dy; for (dy=0; dy<(sint)rasterized.size(); ++dy) @@ -365,19 +372,19 @@ void CPrimChecker::render(const CPolygon &poly, uint16 value) for (x=rasterized[dy].first; x<=rasterized[dy].second; ++x) { - uint8 prevBits = _Grid.get((uint)x, (uint)(ymin+dy)); + uint8 prevBits = _Grid.get((uint)x + centerOffset, (uint)(ymin + dy)); // only set if there was not a water shape there or if previous was lower if ((prevBits & Water) != 0) { - uint16 prevWS = _Grid.index((uint)x, (uint)(ymin+dy)); + uint16 prevWS = _Grid.index((uint)x + centerOffset, (uint)(ymin + dy)); if (_WaterHeight[value] < _WaterHeight[prevWS]) continue; } - _Grid.index((uint)x, (uint)(ymin+dy), value); - _Grid.set((uint)x, (uint)(ymin+dy), Water); + _Grid.index((uint)x + centerOffset, (uint)(ymin + dy), value); + _Grid.set((uint)x + centerOffset, (uint)(ymin + dy), Water); } } } @@ -389,13 +396,19 @@ void CPrimChecker::render(const CPolygon &poly, uint16 value) */ void CPrimChecker::renderBits(const CPolygon &poly, uint8 bits) { + static const sint centerOffset = 20480; // zones are max 40960 + CPolygon polyOffset = poly; + for (ptrdiff_t i = 0; i < (ptrdiff_t)polyOffset.Vertices.size(); ++i) + // center to computeBorders range (-32k to 32k) + polyOffset.Vertices[i] += CVector(-centerOffset, centerOffset, 0); + list convex; // divide poly in convex polys - if (!poly.toConvexPolygons(convex, CMatrix::Identity)) + if (!polyOffset.toConvexPolygons(convex, CMatrix::Identity)) { convex.clear(); - CPolygon reverse = poly; + CPolygon reverse = polyOffset; std::reverse(reverse.Vertices.begin(), reverse.Vertices.end()); if (!reverse.toConvexPolygons(convex, CMatrix::Identity)) return; @@ -410,6 +423,7 @@ void CPrimChecker::renderBits(const CPolygon &poly, uint8 bits) sint ymin; convex2d.computeBorders(rasterized, ymin); + ymin -= centerOffset; // uncenter sint dy; for (dy=0; dy<(sint)rasterized.size(); ++dy) @@ -418,7 +432,7 @@ void CPrimChecker::renderBits(const CPolygon &poly, uint8 bits) for (x=rasterized[dy].first; x<=rasterized[dy].second; ++x) { - _Grid.set((uint)x, (uint)(ymin+dy), bits); + _Grid.set((uint)x + centerOffset, (uint)(ymin + dy), bits); } } } diff --git a/ryzom/client/src/CMakeLists.txt b/ryzom/client/src/CMakeLists.txt index 7e1f89348..1b224ee8d 100644 --- a/ryzom/client/src/CMakeLists.txt +++ b/ryzom/client/src/CMakeLists.txt @@ -21,7 +21,7 @@ IF(WITH_RYZOM_CLIENT) ENDIF() FILE(GLOB CFG ../*.cfg) - FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc) + FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc *.manifest) FILE(GLOB SRC_INTERFACE interface_v3/*.h interface_v3/*.cpp) FILE(GLOB SRC_MODE motion/modes/*.cpp motion/modes/*.h) FILE(GLOB SRC_R2 r2/*.h r2/*.cpp r2/dmc/*.h r2/dmc/*.cpp) diff --git a/ryzom/client/src/actions.cpp b/ryzom/client/src/actions.cpp index c9b43795e..06b0e1d21 100644 --- a/ryzom/client/src/actions.cpp +++ b/ryzom/client/src/actions.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -41,7 +42,7 @@ extern CEventsListener EventsListener; // Hierarchical timer H_AUTO_DECL ( RZ_Client_Actions_Context_Mngr_Update ) -static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, ucstring ¶mValue, const std::string &argu, uint paramId); +static bool getParam (CBaseAction::CParameter::TType type, string ¶mName, string ¶mValue, const std::string &argu, uint paramId); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// @@ -267,8 +268,8 @@ bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const const CBaseAction::CParameter ¶meter = baseAction->Parameters[i]; if (parameter.Type == CBaseAction::CParameter::Constant) { - ucstring paramName; - ucstring paramValue = parameter.DefaultValue; + string paramName; + string paramValue = parameter.DefaultValue; // Get the param from the argu getParam (parameter.Type, paramName, paramValue, name.Argu, i); @@ -276,7 +277,7 @@ bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const bool found = true; for (uint k = 0; k < parameter.Values.size(); ++k) { - if (parameter.Values[k].Value == paramValue.toUtf8()) + if (parameter.Values[k].Value == paramValue) { if (!ActionsContext.matchContext(parameter.Values[k].Contexts)) return false; found = true; @@ -524,9 +525,9 @@ void CCombo::init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons) } // *************************************************************************** -ucstring CCombo::toUCString() const +string CCombo::toString() const { - ucstring ret; + string ret; if ((KeyButtons & shiftKeyButton) && (Key != 0x10)) ret += CI18N::get("uiKeySHIFT") + "+"; if ((KeyButtons & ctrlKeyButton) && (Key != 0x11)) @@ -655,7 +656,7 @@ CBaseAction::CParameter::CParameter () // *************************************************************************** -static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, ucstring ¶mValue, const std::string &argu, uint paramId) +static bool getParam (CBaseAction::CParameter::TType type, string ¶mName, string ¶mValue, const std::string &argu, uint paramId) { const string separator = "|"; const string equal_separator = "="; @@ -696,10 +697,7 @@ static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, } // Value ? - if(type==CBaseAction::CParameter::User || type==CBaseAction::CParameter::UserName) - paramValue.fromUtf8(argu.substr(pos, end-pos)); - else - paramValue = argu.substr(pos, end-pos); + paramValue = argu.substr(pos, end-pos); // Ok return true; @@ -707,10 +705,10 @@ static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, return false; } -ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const +string CBaseAction::getActionLocalizedText(const CAction::CName &name) const { // Action base name - ucstring temp = CI18N::get(LocalizedName); + string temp = CI18N::get(LocalizedName); // Get the parameter uint i; @@ -718,8 +716,8 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const { bool parameterOk = false; const CParameter ¶meter = Parameters[i]; - ucstring paramName; - ucstring paramValue; + string paramName; + string paramValue; // Get the param from the argu if (getParam (parameter.Type, paramName, paramValue, name.Argu, i)) @@ -727,7 +725,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const switch (parameter.Type) { case CParameter::Hidden: - if ((ucstring (parameter.DefaultValue) == paramValue) && (ucstring (parameter.Name) == paramName)) + if ((parameter.DefaultValue == paramValue) && (parameter.Name == paramName)) parameterOk = true; break; case CParameter::Constant: @@ -737,7 +735,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const { // This value ? const CParameter::CValue &value = parameter.Values[j]; - if (ucstring(value.Value) == paramValue) + if (value.Value == paramValue) { temp += " "; @@ -770,7 +768,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const if (i==Parameters.size ()) return temp; - return ucstring(""); + return string(); } // *************************************************************************** @@ -815,8 +813,8 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons { bool parameterOk = false; const CBaseAction::CParameter ¶meter = baseAction.Parameters[i]; - ucstring paramName; - ucstring paramValue; + string paramName; + string paramValue; // Get the param from the argu if (getParam (parameter.Type, paramName, paramValue, name.Argu, i)) @@ -824,7 +822,7 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons switch (parameter.Type) { case CBaseAction::CParameter::Hidden: - if ((ucstring (parameter.DefaultValue) == paramValue) && (ucstring (parameter.Name) == paramName)) + if ((parameter.DefaultValue == paramValue) && (parameter.Name == paramName)) parameterOk = true; break; case CBaseAction::CParameter::Constant: @@ -834,7 +832,7 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons for (j=0; jgetActionLocalizedText(name); } diff --git a/ryzom/client/src/actions.h b/ryzom/client/src/actions.h index a36fd082b..7e03452b9 100644 --- a/ryzom/client/src/actions.h +++ b/ryzom/client/src/actions.h @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -66,7 +66,7 @@ public: void init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons); /// Get the combo in human readable form - ucstring toUCString() const; + std::string toString() const; // For maps bool operator<(const CCombo &other) const @@ -248,7 +248,7 @@ public: std::string Contexts; /// Get an action localized text - ucstring getActionLocalizedText (const CAction::CName &name) const; + std::string getActionLocalizedText (const CAction::CName &name) const; // see if there's at least one set of parameters for which this action is usable in current context bool isUsableInCurrentContext() const; @@ -417,7 +417,7 @@ public: const TActionsForceDisplaySet &getActionsForceDisplaySet() const {return _ActionForceDisplay;} /// Get an action localized text - ucstring getActionLocalizedText (const CAction::CName &name) const; + std::string getActionLocalizedText (const CAction::CName &name) const; //@} diff --git a/ryzom/client/src/animation_fx.cpp b/ryzom/client/src/animation_fx.cpp index 8f716d64e..0ab586a92 100644 --- a/ryzom/client/src/animation_fx.cpp +++ b/ryzom/client/src/animation_fx.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -65,7 +68,7 @@ void CAnimationFX::buildTrack(NL3D::UAnimationSet *as) nlassert(Sheet != NULL); if (!as) return; if (Sheet->TrajectoryAnim.empty()) return; - std::string animName = NLMISC::toLower(Sheet->TrajectoryAnim); + std::string animName = NLMISC::toLowerAscii(Sheet->TrajectoryAnim); uint id = as->getAnimationIdByName(animName); NL3D::UAnimation *anim = NULL; if (id != NL3D::UAnimationSet::NotFound) diff --git a/ryzom/client/src/auto_anim.cpp b/ryzom/client/src/auto_anim.cpp index 9676742bb..97efb324e 100644 --- a/ryzom/client/src/auto_anim.cpp +++ b/ryzom/client/src/auto_anim.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -84,7 +87,7 @@ void initAutoAnimation() file.getline(line, 512); // Read the animation file - string animName = toLower(CFile::getFilenameWithoutExtension(line)); + string animName = toLowerAscii(CFile::getFilenameWithoutExtension(line)); uint id = AutoAnimSet->addAnimation (line, animName.c_str ()); if (id == UAnimationSet::NotFound) { diff --git a/ryzom/client/src/bg_downloader_access.cpp b/ryzom/client/src/bg_downloader_access.cpp index 61364ea5f..338b86f9a 100644 --- a/ryzom/client/src/bg_downloader_access.cpp +++ b/ryzom/client/src/bg_downloader_access.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -19,6 +19,9 @@ #include "stdpch.h" #include "bg_downloader_access.h" + +#ifdef RYZOM_BG_DOWNLOADER + #include "global.h" #include "login_patch.h" // @@ -84,7 +87,7 @@ CBGDownloaderAccess::CBGDownloaderAccess() //===================================================== void CBGDownloaderAccess::clearCurrentMessage() { - _CurrentMessage = ucstring(); + _CurrentMessage = ucstring(); // OLD _CurrentFilesToGet = 0; _TotalFilesToGet = 0; _PatchingSize = 0; @@ -194,7 +197,7 @@ void CBGDownloaderAccess::startTask(const BGDownloader::CTaskDesc &taskDesc, con } //===================================================== -bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const +bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const // OLD { if (_State == State_Finished) { @@ -230,7 +233,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() // that the downloader is still running and in slave mode if (!isDownloaderProcessRunning() && getDownloaderMode() != DownloaderMode_Slave) { - throw EDownloadException(CI18N::get("uiBGD_DownloaderStopped").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_DownloaderStopped")); } } else @@ -354,7 +357,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() { shutdownDownloader(); Parent->_TaskResult = TaskResult_Error; - Parent->_ErrorMsg = ucstring(e.what()); + Parent->_ErrorMsg = ucstring(e.what()); // OLD Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError; } catch(const NLMISC::EStream &e) @@ -362,7 +365,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() shutdownDownloader(); Parent->_TaskResult = TaskResult_Error; nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Stream error"); - Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); + Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); // OLD Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError; } catch (const EWaitMessageTimeoutException &e) @@ -370,7 +373,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() shutdownDownloader(); Parent->_TaskResult = TaskResult_Error; nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Message timeout"); - Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); + Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); // OLD Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError; } Parent->_State = State_Finished; @@ -429,7 +432,7 @@ void CBGDownloaderAccess::CDownloadCoTask::createDownloaderProcess() BOOL ok = NLMISC::launchProgram(BGDownloaderName, Parent->_CommandLine); if (!ok) { - throw EDownloadException(CI18N::get("uiBGD_LaunchError").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_LaunchError")); } } else @@ -458,7 +461,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() { nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with NULL pid"); // some problem here ... - throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance")); } } bool ok = NLMISC::CWinProcess::terminateProcess(*(DWORD *) ryzomInstPIDPtr); @@ -467,7 +470,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() { nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with good pid, but couldn't stop the process"); // couldn't stop the other client ... - throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance")); } } // write our pid into shared mem @@ -475,7 +478,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() if (!Parent->_RyzomInstPIDPtr) { // really, really bad luck ... - throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance")); } *(uint32 *) Parent->_RyzomInstPIDPtr = (uint32) GetCurrentProcessId(); @@ -514,7 +517,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() const uint32 totalTries = 7; while (waitTime <= 32000) { - Parent->_CurrentMessage.fromUtf8(toString(CI18N::get("uiBGD_HandShaking").toUtf8().c_str(), tryIndex, totalTries)); + Parent->_CurrentMessage.fromUtf8(toString(CI18N::get("uiBGD_HandShaking").c_str(), tryIndex, totalTries)); sendSimpleMsg(CL_Probe); NLMISC::CMemStream dummyMsg; @@ -614,7 +617,7 @@ TDownloaderMode CBGDownloaderAccess::CDownloadCoTask::getDownloaderMode() void CBGDownloaderAccess::CDownloadCoTask::getTaskResult(TTaskResult &result, uint32 &availablePatchs, bool &mustLaunchBatFile, - ucstring &errorMsg + ucstring &errorMsg // OLD ) { sendSimpleMsg(CL_GetTaskResult); @@ -623,7 +626,7 @@ void CBGDownloaderAccess::CDownloadCoTask::getTaskResult(TTaskResult &result, inMsg.serialEnum(result); inMsg.serial(availablePatchs); inMsg.serial(mustLaunchBatFile); - inMsg.serial(errorMsg); + inMsg.serial(errorMsg); // OLD } //===================================================== @@ -687,7 +690,7 @@ void CBGDownloaderAccess::CDownloadCoTask::shutdownDownloader() } } CWinProcess::terminateProcessFromModuleName(BGDownloaderName); // for safety - Parent->_CurrentMessage = ucstring(); + Parent->_CurrentMessage = ucstring(); // OLD } //===================================================== @@ -758,7 +761,7 @@ void CBGDownloaderAccess::CDownloadCoTask::waitMsg(BGDownloader::TMsgType wanted if (msgType != wantedMsgType) { nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Bad message type received. Expected type is '%d', received type is '%d'", (int) wantedMsgType, (int) msgType); - throw EDownloadException(CI18N::get("uiBGD_ProtocolError").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_ProtocolError")); } } @@ -795,7 +798,7 @@ bool CBGDownloaderAccess::CDownloadCoTask::defaultMessageHandling(BGDownloader:: case BGD_Error: { Parent->_TaskResult = TaskResult_Error; - ucstring errorMsg; + ucstring errorMsg; // OLD msg.serial(errorMsg); throw EDownloadException(errorMsg.toUtf8()); } @@ -816,7 +819,7 @@ void CBGDownloaderAccess::CDownloadCoTask::checkDownloaderAlive() { if (!Parent->_DownloaderMsgQueue.connected() || !isDownloaderProcessRunning()) { - throw EDownloadException(CI18N::get("uiBGD_DownloaderDisconnected").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_DownloaderDisconnected")); } } @@ -885,7 +888,7 @@ void CBGDownloaderAccess::startTask(const BGDownloader::CTaskDesc &taskDesc, con } //===================================================== -bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const +bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const // OLD { // TODO for Linux return false; @@ -956,3 +959,5 @@ void unpauseBGDownloader() DownloaderPaused = false; } } + +#endif diff --git a/ryzom/client/src/bg_downloader_access.h b/ryzom/client/src/bg_downloader_access.h index e27cadb3e..00bc4cd05 100644 --- a/ryzom/client/src/bg_downloader_access.h +++ b/ryzom/client/src/bg_downloader_access.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -14,11 +17,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifdef RYZOM_BG_DOWNLOADER #ifndef CL_BG_DOWNLOADER_ACCESS #define CL_BG_DOWNLOADER_ACCESS #include "nel/misc/singleton.h" -#include "nel/misc/ucstring.h" +#include "nel/misc/ucstring.h" // OLD #include "nel/misc/inter_window_msg_queue.h" #include "nel/misc/co_task.h" // @@ -36,7 +40,7 @@ public: void release(); // jobs void startTask(const BGDownloader::CTaskDesc &taskDesc, const std::string &commandLine, bool showDownloader); - bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const; + bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const; // OLD // The following flag will be true after a 'patch' task has been completed successfully bool getPatchCompletionFlag(bool clearFlag); // @@ -50,7 +54,7 @@ public: // void update(); // call this at each frame to update the download process // Get last displayed message by the background downloader - const ucstring &getCurrentMessage() const { return _CurrentMessage; } + const ucstring &getCurrentMessage() const { return _CurrentMessage; } // OLD uint32 getCurrentFilesToGet() const { return _CurrentFilesToGet; } uint32 getTotalFilesToGet() const { return _TotalFilesToGet; } // @@ -66,17 +70,17 @@ public: bool isDownloaderUIFrozen() const { return _FrozenUI; } void requestDownloadThreadPriority(BGDownloader::TThreadPriority newPriority, bool freezeUI); - const ucstring &getLastErrorMessage() const { return _ErrorMsg; } + const ucstring &getLastErrorMessage() const { return _ErrorMsg; } // OLD private: enum TState { State_Idle, State_Patching, State_Finished }; TState _State; - ucstring _CurrentMessage; + ucstring _CurrentMessage; // OLD #ifdef NL_OS_WINDOWS NLMISC::CInterWindowMsgQueue _DownloaderMsgQueue; #endif - ucstring _ErrorMsg; + ucstring _ErrorMsg; // OLD std::string _CommandLine; BGDownloader::TTaskResult _TaskResult; uint32 _AvailablePatchs; @@ -122,7 +126,7 @@ private: void getTaskResult(BGDownloader::TTaskResult &result, uint32 &availablePatchs, bool &mustLaunchBatFile, - ucstring &errorMsg + ucstring &errorMsg // OLD ); void getDescFile(); BGDownloader::TDownloaderMode getDownloaderMode(); @@ -146,3 +150,4 @@ void unpauseBGDownloader(); #endif +#endif diff --git a/ryzom/client/src/candidate.h b/ryzom/client/src/candidate.h index aa190111a..7b33cdabe 100644 --- a/ryzom/client/src/candidate.h +++ b/ryzom/client/src/candidate.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -14,8 +17,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// FIXME: Lost code - +#if 0 #ifndef CL_CANDIDATE_H #define CL_CANDIDATE_H @@ -33,9 +37,10 @@ struct Candidate NLMISC::CEntityId id; std::string name; std::string surname; - std::list program; + std::list program; uint32 nbVotes; }; #endif // CL_CANDIDATE_H +#endif \ No newline at end of file diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index b371e4765..68f8acfcb 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -1,10 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2018 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -617,7 +617,7 @@ uint32 CCharacterCL::buildEquipment(const CCharacterSheet::CEquipment &slot, SLO { // IS the item a valid one ? CSheetId itemId; - if(itemId.buildSheetId(NLMISC::toLower(slot.getItem()))) + if(itemId.buildSheetId(NLMISC::toLowerAscii(slot.getItem()))) { // Is it stored in the database ? CEntitySheet *entitySheet = SheetMngr.get(itemId); @@ -809,8 +809,8 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual if (Type == Fauna) { // Get the fauna name in the sheet - const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); - if (creatureName.find(ucstring("Id); + if (!FINAL_VERSION || !NLMISC::startsWith(creatureName, "getAnimSetBaseName(), _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet, _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet, !modeWithHiddenItems())) { - //nlwarning("CH:computeAnimSet:%d: pb when trying to compute the animset. Sheet Id '%u(%s)'.", _Slot, _SheetId.asInt(), _SheetId.toString().c_str()); + nlwarning("CH:computeAnimSet:%d: pb when trying to compute the animset. Sheet Id '%u(%s)'.", _Slot, _SheetId.asInt(), _SheetId.toString().c_str()); } }// computeAnimSet // @@ -3360,7 +3360,7 @@ void CCharacterCL::showOrHideBodyParts( bool objectsVisible ) lHandInstIdx = SLOTTYPE::LEFT_HAND_SLOT; // hide gloves(armor) if player has magician amplifier - if( _Items[rHandInstIdx].Sheet && (_Items[rHandInstIdx].Sheet->ItemType == ITEM_TYPE::MAGICIAN_STAFF) ) + if( _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet && (_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->ItemType == ITEM_TYPE::MAGICIAN_STAFF) ) { if( !_Instances[SLOTTYPE::HANDS_SLOT].Current.empty() ) _Instances[SLOTTYPE::HANDS_SLOT].Current.hide(); @@ -3378,8 +3378,9 @@ void CCharacterCL::showOrHideBodyParts( bool objectsVisible ) if( !objectsVisible ) { // Right Hand + nlassert(SLOTTYPE::RIGHT_HAND_SLOT < _Items.size() && SLOTTYPE::LEFT_HAND_SLOT < _Items.size()); if(rHandInstIdx<_Instances.size()) - if( !(_Items[rHandInstIdx].Sheet && _Items[rHandInstIdx].Sheet->NeverHideWhenEquipped ) ) + if( !(_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet && _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->NeverHideWhenEquipped ) ) if(!_Instances[rHandInstIdx].Current.empty()) { _Instances[rHandInstIdx].Current.hide(); @@ -3387,7 +3388,7 @@ void CCharacterCL::showOrHideBodyParts( bool objectsVisible ) } // Left Hand if(lHandInstIdx <_Instances.size()) - if( !(_Items[lHandInstIdx].Sheet && _Items[lHandInstIdx].Sheet->NeverHideWhenEquipped ) ) + if( !(_Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet && _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet->NeverHideWhenEquipped ) ) if(!_Instances[lHandInstIdx].Current.empty()) { _Instances[lHandInstIdx].Current.hide(); @@ -7588,7 +7589,7 @@ void CCharacterCL::displayName() //--------------------------------------------------- void CCharacterCL::drawName(const NLMISC::CMatrix &mat) // virtual { - const ucstring &ucname = getEntityName(); + const string &ucname = getEntityName(); if(!getEntityName().empty()) { // If there is no extended name, just display the name @@ -7615,8 +7616,8 @@ void CCharacterCL::drawName(const NLMISC::CMatrix &mat) // virtual { if(_Sheet != 0) { - const ucstring name(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); - if (name.find(ucstring("Id); + if (!FINAL_VERSION || !NLMISC::startsWith(name, "render3D(mat, name); } } @@ -7673,9 +7674,9 @@ void CCharacterCL::displayModifiers() // virtual } else if (TimeInSec >= mod.Time) { - ucstring hpModifier; + string hpModifier; if (mod.Text.empty()) - hpModifier = ucstring(toString("%d", mod.Value)); + hpModifier = toString("%d", mod.Value); else hpModifier = mod.Text; double t = TimeInSec-mod.Time; @@ -9293,14 +9294,14 @@ const char *CCharacterCL::getBoneNameFromBodyPart(BODY::TBodyPart part, BODY::TS const CItemSheet *CCharacterCL::getRightHandItemSheet() const { if (_RHandInstIdx == CEntityCL::BadIndex) return NULL; - return _Items[_RHandInstIdx].Sheet; + return _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet; } // ********************************************************************************************* const CItemSheet *CCharacterCL::getLeftHandItemSheet() const { if (_LHandInstIdx == CEntityCL::BadIndex) return NULL; - return _Items[_LHandInstIdx].Sheet; + return _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet; } // *************************************************************************** @@ -10249,11 +10250,11 @@ NLMISC_COMMAND(setNamePosZ, "", " ") CRaceStatsSheet *sheet = const_cast(playerTarget->playerSheet()); if (sheet) { - if (toLower(args[0]) == "low") + if (toLowerAscii(args[0]) == "low") namePosZ = &sheet->GenderInfos[playerTarget->getGender()].NamePosZLow; - else if (toLower(args[0]) == "normal") + else if (toLowerAscii(args[0]) == "normal") namePosZ = &sheet->GenderInfos[playerTarget->getGender()].NamePosZNormal; - else if (toLower(args[0]) == "high") + else if (toLowerAscii(args[0]) == "high") namePosZ = &sheet->GenderInfos[playerTarget->getGender()].NamePosZHigh; sheetName = sheet->Id.toString(); @@ -10269,11 +10270,11 @@ NLMISC_COMMAND(setNamePosZ, "", " ") CCharacterSheet *sheet = const_cast(creatureTarget->getSheet()); if (sheet) { - if (toLower(args[0]) == "low") + if (toLowerAscii(args[0]) == "low") namePosZ = &sheet->NamePosZLow; - else if (toLower(args[0]) == "normal") + else if (toLowerAscii(args[0]) == "normal") namePosZ = &sheet->NamePosZNormal; - else if (toLower(args[0]) == "high") + else if (toLowerAscii(args[0]) == "high") namePosZ = &sheet->NamePosZHigh; sheetName = sheet->Id.toString(); @@ -10300,11 +10301,11 @@ NLMISC_COMMAND(setMyNamePosZ, "", " ") CRaceStatsSheet *sheet = const_cast(UserEntity->playerSheet()); if (sheet) { - if (toLower(args[0]) == "low") + if (toLowerAscii(args[0]) == "low") namePosZ = &sheet->GenderInfos[UserEntity->getGender()].NamePosZLow; - else if (toLower(args[0]) == "normal") + else if (toLowerAscii(args[0]) == "normal") namePosZ = &sheet->GenderInfos[UserEntity->getGender()].NamePosZNormal; - else if (toLower(args[0]) == "high") + else if (toLowerAscii(args[0]) == "high") namePosZ = &sheet->GenderInfos[UserEntity->getGender()].NamePosZHigh; sheetName = sheet->Id.toString(); @@ -10366,7 +10367,7 @@ NLMISC_COMMAND(pvpMode, "modify pvp mode", "[ ]") str+="in_safe_zone "; if( pvpMode&PVP_MODE::PvpSafe) str+="safe "; - IM->displaySystemInfo(ucstring(str)); + IM->displaySystemInfo(str); nlinfo(" %s",str.c_str()); } else diff --git a/ryzom/client/src/client.cpp b/ryzom/client/src/client.cpp index 4e933b6da..49c4616e3 100644 --- a/ryzom/client/src/client.cpp +++ b/ryzom/client/src/client.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2015-2019 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -303,7 +303,7 @@ int main(int argc, char **argv) uint i; for (i=0; i -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2010-2019 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2011-2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // @@ -1374,6 +1374,9 @@ void CClientConfig::setValues() // Data Path no recurse. READ_STRINGVECTOR_FV(DataPathNoRecurse); + // Pre-load path + READ_STRING_DEV(PreLoadPath); + // Streamed package path READ_STRING_FV(StreamedPackagePath); @@ -1496,7 +1499,7 @@ void CClientConfig::setValues() else if (stricmp(mode, "centeraround") == 0) p.Mode = SSysInfoParam::CenterAround; else if (stricmp(mode, "around") == 0) p.Mode = SSysInfoParam::Around; - ClientCfg.SystemInfoParams[toLower(sic->asString(2 * k))] = p; + ClientCfg.SystemInfoParams[toLowerAscii(sic->asString(2 * k))] = p; } } } @@ -1911,7 +1914,7 @@ void CClientConfig::setValues() ClientCfg.HardwareCursors.clear (); int iSz = pcvHardwareCursors->size(); for (int i = 0; i < iSz; i++) - ClientCfg.HardwareCursors.insert(toLower(pcvHardwareCursors->asString(i))); + ClientCfg.HardwareCursors.insert(toLowerAscii(pcvHardwareCursors->asString(i))); } else { @@ -2078,7 +2081,7 @@ void CClientConfig::init(const string &configFileName) } // read the exising config file (don't parse it yet!) - ucstring content; + ucstring content; // UTF-16 and UTF-8 textfile support NLMISC::CI18N::readTextFile(configFileName, content); std::string contentUtf8 = content.toUtf8(); @@ -2321,14 +2324,13 @@ string CClientConfig::getHtmlLanguageCode() const } // *************************************************************************** -ucstring CClientConfig::buildLoadingString( const ucstring& ucstr ) const +string CClientConfig::buildLoadingString( const string& ucstr ) const { if( LoadingStringCount > 0 ) { uint index = rand()%LoadingStringCount; - string tipId = "uiLoadingString"+toString(index); - ucstring randomUCStr = CI18N::get(tipId); - return randomUCStr; + string tipId = "uiLoadingString" + toString(index); + return CI18N::get(tipId); } else return ucstr; diff --git a/ryzom/client/src/client_cfg.h b/ryzom/client/src/client_cfg.h index 16a1e9e0c..60be270fa 100644 --- a/ryzom/client/src/client_cfg.h +++ b/ryzom/client/src/client_cfg.h @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2010-2014 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2011-2012 Matt RAYKOWSKI (sfb) // // This program is free software: you can redistribute it and/or modify @@ -391,6 +391,8 @@ struct CClientConfig std::vector DataPath; /// Data Path no recurse. std::vector DataPathNoRecurse; + /// Pre-load path + std::string PreLoadPath; /// Streamed package path std::string StreamedPackagePath; /// Streamed package hosts @@ -891,10 +893,10 @@ public: float getActualLandscapeThreshold() const; // Return LanguageCode but if "wk", then return "en" - string getHtmlLanguageCode() const; + std::string getHtmlLanguageCode() const; // return a random loading tip or, if there are not, return the string in argument - ucstring buildLoadingString( const ucstring& ucstr ) const; + std::string buildLoadingString(const std::string &ucstr) const; /// get the path to client_default.cfg including the filename itself. bool getDefaultConfigLocation(std::string& fileLocation) const; diff --git a/ryzom/client/src/client_chat_manager.cpp b/ryzom/client/src/client_chat_manager.cpp index 9d222a1b7..1414c175d 100644 --- a/ryzom/client/src/client_chat_manager.cpp +++ b/ryzom/client/src/client_chat_manager.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -64,7 +65,7 @@ extern CEntityManager EntitiesMngr; //#ifdef OLD_STRING_SYSTEM // -//bool CNetworkString::getString (ucstring &result, CClientChatManager *mng) +//bool CNetworkString::getString (ucstring &result, CClientChatManager *mng) // OLD //{ // result = StaticString + " / "; // for (uint i = 0; i < Args.size(); i++) @@ -85,7 +86,7 @@ extern CEntityManager EntitiesMngr; // return mng->getString (result, Args, StaticString); //} // -//void CNetworkString::setString (const ucstring &staticStringId, CClientChatManager *mng) +//void CNetworkString::setString (const ucstring &staticStringId, CClientChatManager *mng) // OLD //{ // CBitMemStream bms; // mng->getStaticDB().getInfos(staticStringId, StaticString, bms); @@ -95,11 +96,11 @@ extern CEntityManager EntitiesMngr; //// add //// ////----------------------------------------------- -//uint32 CChatDynamicDatabase::add( uint32 index, ucstring& ucstr, vector& code ) +//uint32 CChatDynamicDatabase::add( uint32 index, ucstring& ucstr, vector& code ) // OLD //{ // nlinfo ("receive dynamic string association '%d' '%s'", index, ucstr.toString().c_str()); // -// map::iterator itIdx = _StringToIndex.find( ucstr ); +// map::iterator itIdx = _StringToIndex.find( ucstr ); // OLD // if( itIdx == _StringToIndex.end() ) // { // map::iterator itStr = _Data.find( index ); @@ -161,7 +162,7 @@ extern CEntityManager EntitiesMngr; //// decodeString //// ////----------------------------------------------- -//void CChatDynamicDatabase::decodeString( ucstring& str, CBitMemStream& bms ) +//void CChatDynamicDatabase::decodeString( ucstring& str, CBitMemStream& bms ) // OLD //{ // _Huffman.getId( str, bms ); // @@ -240,7 +241,7 @@ CClientChatManager::CClientChatManager() } //------------------------------------------------------- -const ucstring *CClientChatManager::cycleLastTell() +const string *CClientChatManager::cycleLastTell() { if (_TellPeople.empty()) return NULL; _TellPeople.push_front(_TellPeople.back()); @@ -281,14 +282,14 @@ void CClientChatManager::init( const string& /* staticDBFileName */ ) // chat // //----------------------------------------------- -void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) +void CClientChatManager::chat( const string& strIn, bool isChatTeam ) { // Truncate to 255 chars max (because of server restriction) - ucstring str= strIn.substr(0,255); + ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial) // send str to IOS CBitMemStream bms; - string msgType; + const char *msgType; if (isChatTeam) { @@ -302,13 +303,13 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { - bms.serial( str ); + bms.serial( str ); // FIXME: UTF-8 (serial) NetMngr.push( bms ); //nlinfo("impulseCallBack : %s %s sent", msgType.c_str(), str.toString().c_str()); } else { - nlwarning(" unknown message name : %s", msgType.c_str()); + nlwarning(" unknown message name : %s", msgType); } if (UserEntity != NULL) UserEntity->setAFK(false); @@ -320,19 +321,19 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) // tell // //----------------------------------------------- -void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn ) +void CClientChatManager::tell( const string& receiverIn, const string& strIn ) { // Truncate to 255 chars max (because of server restriction) - string receiver= receiverIn.substr(0,255); - ucstring str= strIn.substr(0,255); + string receiver= receiverIn.substr(0,255); // FIXME: UTF-8 (serial) + ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial) // *** send str CBitMemStream bms; - string msgType = "STRING:TELL"; + const char *msgType = "STRING:TELL"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( receiver ); - bms.serial( str ); + bms.serial( str ); // FIXME: UTF-8 NetMngr.push( bms ); //nlinfo("impulseCallBack : %s %s %s sent", msgType.c_str(), receiver.c_str(), str.toString().c_str()); } @@ -344,10 +345,10 @@ void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn ) // *** manage list of last telled people // remove the telled people from list (if present) - std::list::iterator it = _TellPeople.begin(); + std::list::iterator it = _TellPeople.begin(); while(it != _TellPeople.end()) { - if (*it == ucstring(receiver)) + if (*it == receiver) { it = _TellPeople.erase(it); nlassert(_NumTellPeople != 0); @@ -384,7 +385,7 @@ void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn ) void CClientChatManager::filter( uint8 filter ) { CBitMemStream bms; - string msgType = "STRING:FILTER"; + const char *msgType = "STRING:FILTER"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( filter ); @@ -416,7 +417,7 @@ void CClientChatManager::setChatMode(CChatGroup::TGroupType group, TChanID dynam if (group != CChatGroup::team) { CBitMemStream bms; - string msgType = "STRING:CHAT_MODE"; + const char *msgType = "STRING:CHAT_MODE"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( mode ); @@ -453,14 +454,14 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp // Serial. For tell message, there is no chat mode, coz we know we are in tell mode ! bms.serial (chatMsg.CompressedIndex); bms.serial (chatMsg.SenderNameId); - bms.serial (chatMsg.Content); + bms.serial (chatMsg.Content); // FIXME: UTF-8 (serial) if (PermanentlyBanned) return; chatMsg.ChatMode = (uint8) CChatGroup::tell; // If !complete, wait - ucstring senderStr; + string senderStr; bool complete = true; complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr); if (!complete) @@ -471,8 +472,8 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp } // display - ucstring ucstr; - buildTellSentence(senderStr, chatMsg.Content, ucstr); + string ucstr; + buildTellSentence(senderStr, chatMsg.Content.toUtf8(), ucstr); chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr); } @@ -487,9 +488,9 @@ void CClientChatManager::processFarTellString(NLMISC::CBitMemStream& bms, IChatD if (PermanentlyBanned) return; // display - ucstring ucstr; - buildTellSentence(farTellMsg.SenderName, farTellMsg.Text, ucstr); - chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, farTellMsg.SenderName); + string ucstr; + buildTellSentence(farTellMsg.SenderName.toUtf8(), farTellMsg.Text.toUtf8(), ucstr); + chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, farTellMsg.SenderName.toUtf8()); } @@ -504,7 +505,7 @@ void CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDis CChatMsg chatMsg; bms.serial( chatMsg ); CChatGroup::TGroupType type = static_cast(chatMsg.ChatMode); - ucstring senderStr; + string senderStr; bool complete = true; complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr); @@ -527,9 +528,9 @@ void CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDis } // display - ucstring ucstr; - buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content, type, ucstr); - chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content, type, chatMsg.DynChatChanID, senderStr); + string ucstr; + buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content.toUtf8(), type, ucstr); + chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content.toUtf8(), type, chatMsg.DynChatChanID, senderStr); } @@ -544,8 +545,8 @@ void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDis bms.serial(chatMsg.PhraseId); // if !complete, wait - ucstring senderStr; - ucstring rawMessage; + string senderStr; + string rawMessage; bool complete = true; complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr); complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, rawMessage); @@ -557,7 +558,7 @@ void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDis } // display - ucstring ucstr; + string ucstr; buildTellSentence(senderStr, rawMessage, ucstr); chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr); } @@ -570,8 +571,8 @@ void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDis bms.serial( chatMsg ); if (PermanentlyBanned) return; CChatGroup::TGroupType type = static_cast(chatMsg.ChatMode); - ucstring senderStr; - ucstring rawMessage; + string senderStr; + string rawMessage; // here, the type cannot be dyn_chat (no DynChatId in the message) => discard if(type==CChatGroup::dyn_chat) @@ -591,11 +592,11 @@ void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDis return; } - rawMessage += ucstring(" "); - rawMessage += chatMsg.CustomTxt; + rawMessage += " "; + rawMessage += chatMsg.CustomTxt.toUtf8(); // display - ucstring ucstr; + string ucstr; buildChatSentence(chatMsg.CompressedIndex, senderStr, rawMessage, type, ucstr); chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, rawMessage, type, CEntityId::Unknown, senderStr); } @@ -614,7 +615,7 @@ void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& b chatMsg.SenderNameId = 0; chatMsg.ChatMode = type; chatMsg.PhraseId = phraseID; - ucstring ucstr; + string ucstr; // if !complete, wait bool complete = STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, ucstr); @@ -626,7 +627,7 @@ void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& b } // diplay - ucstring senderName(""); + string senderName; chatDisplayer.displayChat(INVALID_DATASET_INDEX, ucstr, ucstr, type, CEntityId::Unknown, senderName); } @@ -642,7 +643,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) for( itMsg = _ChatBuffer.begin(); itMsg != _ChatBuffer.end(); ) { CChatGroup::TGroupType type = static_cast(itMsg->ChatMode); - ucstring sender, content; + string sender, content; // all strings received? bool complete = true; @@ -651,7 +652,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) if(itMsg->UsePhraseId) complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(itMsg->PhraseId, content); else - content= itMsg->Content; + content= itMsg->Content.toUtf8(); if (type == CChatGroup::dyn_chat) { @@ -665,7 +666,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) // if complete, process if (complete) { - ucstring ucstr; + string ucstr; if (itMsg->SenderNameId == 0) { ucstr = content; @@ -702,7 +703,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) // getString // //----------------------------------------------- -ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) +string CClientChatManager::getString( CBitMemStream& bms, string& ucstr ) { // deal with parameters @@ -713,11 +714,11 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { // search if a parameter exists in the string sprintf(chTmp,"$%d",dynParamIdx); - ucstring ucstrTmp( chTmp ); - ucstring::size_type idx = ucstr.find(ucstrTmp); + string ucstrTmp( chTmp ); + string::size_type idx = ucstr.find(ucstrTmp); // if there's a parameter in the string - if( idx != ucstring::npos ) + if( idx != string::npos ) { char c = (char)ucstr[idx+ucstrTmp.size()]; switch( c ) @@ -727,7 +728,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { bool huff; bms.serialBit(huff); - const ucstring dynStr("???"); + const string dynStr("???"); if( huff ) { nldebug(" receiving huffman dynamic parameter in static string"); @@ -755,8 +756,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { string dynStr; bms.serial( dynStr ); - ucstring ucDynStr(dynStr); - ucstr.replace( idx, ucstrTmp.size()+1, ucDynStr ); + ucstr.replace( idx, ucstrTmp.size()+1, dynStr ); } break; @@ -765,7 +765,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { uint32 nb; bms.serial( nb ); - ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) ); + ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) ); } break; /* @@ -793,7 +793,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { sint32 nb; bms.serial( nb ); - ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) ); + ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) ); } break; /* @@ -822,7 +822,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { float nb; bms.serial( nb ); - ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) ); + ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) ); } break; @@ -848,7 +848,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) // getString // //----------------------------------------------- -bool CClientChatManager::getString( ucstring &result, std::vector& args, const ucstring &ucstrbase ) +bool CClientChatManager::getString( string &result, std::vector& args, const string &ucstrbase ) { result = ucstrbase; @@ -862,17 +862,17 @@ bool CClientChatManager::getString( ucstring &result, std::vector& args, { // search if a parameter exists in the string sprintf(chTmp,"$%d",dynParamIdx); - ucstring ucstrTmp( chTmp ); - ucstring::size_type idx = result.find(ucstrTmp); + string ucstrTmp( chTmp ); + string::size_type idx = result.find(ucstrTmp); // if there's a parameter in the string - if( idx != ucstring::npos ) + if( idx != string::npos ) { - ucstring rep; + string rep; rep = "???"; if (dynParamIdx >= args.size()) { - nlwarning ("Missing args for string '%s', only %d args, need arg %d", ucstrbase.toString().c_str(), args.size(), dynParamIdx); + nlwarning ("Missing args for string '%s', only %d args, need arg %d", ucstrbase.c_str(), args.size(), dynParamIdx); } else { @@ -947,15 +947,15 @@ bool CClientChatManager::getString( ucstring &result, std::vector& args, } // getString // // *************************************************************************** -void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstring &msg, ucstring &result) +void CClientChatManager::buildTellSentence(const string &sender, const string &msg, string &result) { // If no sender name was provided, show only the msg if ( sender.empty() ) result = msg; else { - ucstring name = CEntityCL::removeTitleAndShardFromName(sender); - ucstring csr; + string name = CEntityCL::removeTitleAndShardFromName(sender); + string csr; // special case where there is only a title, very rare case for some NPC if (name.empty()) @@ -967,8 +967,8 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); { // Sometimes translation contains another title - ucstring::size_type pos = name.find('$'); - if (pos != ucstring::npos) + string::size_type pos = name.find('$'); + if (pos != string::npos) { name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman); } @@ -977,16 +977,16 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin else { // Does the char have a CSR title? - csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? "(CSR) " : ""; } - result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; + result = csr + name + " " + CI18N::get("tellsYou") + ": " + msg; } } // *************************************************************************** -void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const ucstring &sender, const ucstring &msg, CChatGroup::TGroupType type, ucstring &result) +void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const string &sender, const string &msg, CChatGroup::TGroupType type, string &result) { // if its a tell, then use buildTellSentence if(type==CChatGroup::tell) @@ -1004,24 +1004,24 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde // get the category if any. Note, in some case (chat from other player), there is not categories // and we do not want getStringCategory to return 'SYS' category. - ucstring finalMsg; + string finalMsg; string catStr = getStringCategory(msg, finalMsg, false); - ucstring cat; + string cat; if (!catStr.empty()) - cat = string("&")+catStr+"&"; + cat = "&" + catStr + "&"; - if ( ! cat.empty()) + if (!cat.empty()) { result = msg; return; } // Format the sentence with the provided sender name - ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender); + string senderName = CEntityCL::removeTitleAndShardFromName(sender); - ucstring csr; + string csr; // Does the char have a CSR title? - csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? "(CSR) " : ""; if (UserEntity && senderName == UserEntity->getDisplayName()) { @@ -1029,10 +1029,10 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde switch(type) { case CChatGroup::shout: - result = cat + csr + CI18N::get("youShout") + ucstring(": ") + finalMsg; + result = cat + csr + CI18N::get("youShout") + ": " + finalMsg; break; default: - result = cat + csr + CI18N::get("youSay") + ucstring(": ") + finalMsg; + result = cat + csr + CI18N::get("youSay") + ": " + finalMsg; break; } } @@ -1048,8 +1048,8 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); { // Sometimes translation contains another title - ucstring::size_type pos = senderName.find('$'); - if (pos != ucstring::npos) + string::size_type pos = senderName.find('$'); + if (pos != string::npos) { senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman); } @@ -1060,10 +1060,10 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde switch(type) { case CChatGroup::shout: - result = cat + csr + senderName + ucstring(" ") + CI18N::get("heShout") + ucstring(": ") + finalMsg; + result = cat + csr + senderName + " " + CI18N::get("heShout") + ": " + finalMsg; break; default: - result = cat + csr + senderName + ucstring(" ") + CI18N::get("heSays") + ucstring(": ") + finalMsg; + result = cat + csr + senderName + " " + CI18N::get("heSays") + ": " + finalMsg; break; } } @@ -1173,12 +1173,12 @@ void CClientChatManager::updateDynamicChatChannels(IChatDisplayer &chatDisplayer class CHandlerTell : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { string receiver = getParam (sParams, "player"); - ucstring message; - message.fromUtf8(getParam (sParams, "text")); -// message = getParam (sParams, "text"); + string message; + message = getParam (sParams, "text"); + if (receiver.empty() || message.empty()) return; @@ -1194,10 +1194,10 @@ class CHandlerTell : public IActionHandler // display in the good window CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); - ucstring finalMsg; + string finalMsg; CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false); - ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); + string csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); finalMsg += csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true); @@ -1206,7 +1206,7 @@ class CHandlerTell : public IActionHandler // TDataSetIndex dsi; // not used .... PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA()); - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", receiver); strFindReplace(finalMsg, CI18N::get("youTell"), s); CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell)); @@ -1218,7 +1218,7 @@ REGISTER_ACTION_HANDLER( CHandlerTell, "tell"); class CHandlerEnterTell : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { CInterfaceManager *im = CInterfaceManager::getInstance(); string receiver = getParam (sParams, "player"); @@ -1230,11 +1230,13 @@ class CHandlerEnterTell : public IActionHandler { CGroupContainer *pGC = pCGW->createFreeTeller(receiver); if (pGC != NULL) - pGC->setActive(true); - CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb")); - if (eb) { - CWidgetManager::getInstance()->setCaptureKeyboard(eb); + pGC->setActive(true); + CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb")); + if (eb) + { + CWidgetManager::getInstance()->setCaptureKeyboard(eb); + } } } } @@ -1292,7 +1294,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne case CChatGroup::guild: if (guildActive) pUserBut->setHardText("uiFilterGuild"); break; case CChatGroup::dyn_chat: uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChannelDbIndex); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); if (title.empty()) { @@ -1302,7 +1304,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne } else { - pUserBut->setHardText(title.toUtf8()); + pUserBut->setHardText(title); } break; } @@ -1334,14 +1336,12 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne class CHandlerTalk : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { // Param uint mode; fromString(getParam (sParams, "mode"), mode); - ucstring text; - text.fromUtf8 (getParam (sParams, "text")); -// text = getParam (sParams, "text"); + string text = getParam (sParams, "text"); // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) @@ -1354,7 +1354,7 @@ class CHandlerTalk : public IActionHandler { if(text[0] == '/') { - string str = text.toUtf8(); + string str = text; string cmdWithArgs = str.substr(1); // Get the command name from the string, can contain spaces @@ -1375,7 +1375,7 @@ class CHandlerTalk : public IActionHandler else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (cmd + ": " + CI18N::get ("uiCommandNotExists")); } } else @@ -1408,7 +1408,7 @@ REGISTER_ACTION_HANDLER( CHandlerTalk, "talk"); class CHandlerEnterTalk : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { // Param uint mode; @@ -1435,10 +1435,10 @@ REGISTER_ACTION_HANDLER( CHandlerEnterTalk, "enter_talk"); class CHandlerTalkMessage : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { // Param - ucstring text = CI18N::get ("uiTalkMemMsg"+sParams); + string text = CI18N::get ("uiTalkMemMsg"+sParams); // Find the base group if (!text.empty()) @@ -1454,7 +1454,7 @@ REGISTER_ACTION_HANDLER( CHandlerTalkMessage, "talk_message"); class CHandlerSwapChatMode : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); bool updateCapture= getParam(sParams, "update_capture")=="1"; diff --git a/ryzom/client/src/client_chat_manager.h b/ryzom/client/src/client_chat_manager.h index 2f7decac9..2cdc44c24 100644 --- a/ryzom/client/src/client_chat_manager.h +++ b/ryzom/client/src/client_chat_manager.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -54,7 +55,7 @@ class CCDBNodeLeaf; struct CDynamicStringInfos { /// string - ucstring Str; + ucstring Str; // OLD /// index in the infos buffer, same as the index in the client dynamic string known buffer uint32 Index; @@ -89,12 +90,12 @@ public : /// \param str the string /// \param huffCode the Huffman code(may be empty) /// \return the index of the string - uint32 add( uint32 index, ucstring& str, std::vector& huffCode ); + uint32 add( uint32 index, ucstring& str, std::vector& huffCode ); // OLD /// Get the string from its Huffman code /// \param str will be filled with the string /// \param bms contains the Huffman code - void decodeString( ucstring& str, NLMISC::CBitMemStream& bms ); + void decodeString( ucstring& str, NLMISC::CBitMemStream& bms ); // OLD /// Get infos on the dynamic string CDynamicStringInfos * getDynamicStringInfos( uint32 index ); @@ -111,7 +112,7 @@ private : std::map< uint32, CDynamicStringInfos *> _Data; /// Map to find index from the string (only for uncoded strings) - std::map< ucstring, uint32> _StringToIndex; + std::map< ucstring, uint32> _StringToIndex; // OLD }; #endif @@ -137,11 +138,11 @@ public: * \param mode in which channel should this message goes * \param dynChatId is valid only if mode==dyn_chat. This the Id of channel (not the index in DB!) */ - virtual void displayChat(TDataSetIndex compressedSenderIndex, const ucstring &ucstr, const ucstring &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, ucstring &senderName, uint bubbleTimer=0) =0; + virtual void displayChat(TDataSetIndex compressedSenderIndex, const std::string &ucstr, const std::string &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, std::string &senderName, uint bubbleTimer=0) =0; /** * display a player tell message */ - virtual void displayTell(/*TDataSetIndex senderIndex, */const ucstring &ucstr, const ucstring &senderName) =0; + virtual void displayTell(/*TDataSetIndex senderIndex, */const std::string &ucstr, const std::string &senderName) =0; /** * Clear a channel. * \param dynChatDbIndex is valid only if mode==dyn_chat. Contrary to displayChat, this is the Db Index (0..MaxDynChanPerPlayer) @@ -177,18 +178,18 @@ public : * \param str is the chat content (truncated to 255 char max) * \param isChatTeam special case for Chat TEAM */ - void chat( const ucstring& str, bool isChatTeam = false ); + void chat( const std::string& str, bool isChatTeam = false ); /** * Transmit a chat message to the receiver * \param receiver is the name of the listening char (truncated to 255 char max) * \param str is the chat content (truncated to 255 char max) */ - void tell( const std::string& receiver, const ucstring& str ); + void tell( const std::string& receiver, const std::string& str ); /** Get the last name of the people with which a 'tell' has been done, then move that name at the start of the list */ - const ucstring *cycleLastTell(); + const std::string *cycleLastTell(); /** Set the max number of name in the tell list */ @@ -263,12 +264,12 @@ public : * \param result decoded string * \return true if the string is finalize, false if some param are missing from network */ - bool getString( ucstring &result, std::vector& args, const ucstring& strbase ); + bool getString( std::string &result, std::vector& args, const std::string& strbase ); // build a sentence to be displayed in the chat (e.g add "you say", "you shout", "[user name] says" or "[user name] shout") - static void buildChatSentence(TDataSetIndex compressedSenderIndex, const ucstring &sender, const ucstring &msg, CChatGroup::TGroupType type, ucstring &result); + static void buildChatSentence(TDataSetIndex compressedSenderIndex, const std::string &sender, const std::string &msg, CChatGroup::TGroupType type, std::string &result); // build a sentence to be displayed in the tell - static void buildTellSentence(const ucstring &sender, const ucstring &msg, ucstring &result); + static void buildTellSentence(const std::string &sender, const std::string &msg, std::string &result); /// \name Dynamic Chat channel mgt @@ -304,7 +305,7 @@ private : uint8 ChatMode; NLMISC::CEntityId DynChatChanID; // For Chat and Tell messages - ucstring Content; + ucstring Content; // FIXME: UTF-8 (serial) // For Chat2 and Tell2 messages uint32 PhraseId; // Use PhraseId or Content? @@ -338,7 +339,7 @@ private : std::list _ChatBuffer; // peoples - std::list _TellPeople; // the last people on which tells ha been done + std::list _TellPeople; // the last people on which tells ha been done uint _NumTellPeople; uint _MaxNumTellPeople; @@ -361,7 +362,7 @@ private : * \param str string with parameter values at end (str will change after) * \return decoded string (str) */ - ucstring getString( NLMISC::CBitMemStream& bms, ucstring& str ); + std::string getString( NLMISC::CBitMemStream& bms, std::string& str ); }; @@ -372,13 +373,13 @@ private : #ifdef OLD_STRING_SYSTEM class CNetworkString { - ucstring StaticString; + ucstring StaticString; // OLD public: std::vector Args; - bool getString (ucstring &result, CClientChatManager *mng); + bool getString (ucstring &result, CClientChatManager *mng); // OLD - void setString (const ucstring &staticStringId, CClientChatManager *mng); + void setString (const ucstring &staticStringId, CClientChatManager *mng); // OLD }; #endif diff --git a/ryzom/client/src/client_sheets/automaton_list_sheet.cpp b/ryzom/client/src/client_sheets/automaton_list_sheet.cpp index 013847fa2..c7a3bd6bd 100644 --- a/ryzom/client/src/client_sheets/automaton_list_sheet.cpp +++ b/ryzom/client/src/client_sheets/automaton_list_sheet.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -204,7 +207,7 @@ void CAutomatonStateSheet::build(const NLGEORGES::UFormElm &item, const string & for(uint mode = 0; mode // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -126,7 +129,7 @@ void CCharacterSheet::readEquipment(const NLGEORGES::UFormElm &form, const strin string itemName; if(!form.getValueByName(itemName, string(key + ".Item").c_str() )) debug(NLMISC::toString("Key '%s.Item' not found.", key.c_str())); - slot.IdItem = ClientSheetsStrings.add(NLMISC::toLower(itemName)); + slot.IdItem = ClientSheetsStrings.add(NLMISC::toLowerAscii(itemName)); // Get the texture. if(!form.getValueByName(slot.Texture, string(key + ".Texture").c_str() )) @@ -213,6 +216,21 @@ void CCharacterSheet::build(const NLGEORGES::UFormElm &item) // IN LEFT HAND readEquipment(item, "Basics.Equipment.HandL", ObjectInLeftHand); + if (!ObjectInRightHand.IdItem) + { + std::string right; + item.getValueByName(right, "item_right"); + if (!right.empty()) + ObjectInRightHand.IdItem = ClientSheetsStrings.add(NLMISC::toLowerAscii(right)); + } + + if (!ObjectInLeftHand.IdItem) + { + std::string left; + item.getValueByName(left, "item_left"); + if (!left.empty()) + ObjectInLeftHand.IdItem = ClientSheetsStrings.add(NLMISC::toLowerAscii(left)); + } // Get the animation set Base Name. string AnimSetBaseName; @@ -221,7 +239,7 @@ void CCharacterSheet::build(const NLGEORGES::UFormElm &item) if(AnimSetBaseName.empty()) debug("AnimSetBaseName is Empty."); else - AnimSetBaseName = NLMISC::toLower(AnimSetBaseName); // Force the CASE in UPPER to not be CASE SENSITIVE. + AnimSetBaseName = NLMISC::toLowerAscii(AnimSetBaseName); // Force the CASE in UPPER to not be CASE SENSITIVE. } else debug("Key '3d data.AnimSetBaseName' not found."); @@ -235,7 +253,7 @@ void CCharacterSheet::build(const NLGEORGES::UFormElm &item) debug("Automaton is Empty."); // Lower Case else - Automaton = NLMISC::toLower(Automaton); + Automaton = NLMISC::toLowerAscii(Automaton); } // Key not Found else diff --git a/ryzom/client/src/client_sheets/item_sheet.cpp b/ryzom/client/src/client_sheets/item_sheet.cpp index b89b5fcd4..d5831167c 100644 --- a/ryzom/client/src/client_sheets/item_sheet.cpp +++ b/ryzom/client/src/client_sheets/item_sheet.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -237,28 +240,28 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) string IconMain; if(!item.getValueByName (IconMain, "3d.icon")) debug("key '3d.icon' not found."); - IconMain = toLower(IconMain); + IconMain = toLowerAscii(IconMain); IdIconMain = ClientSheetsStrings.add(IconMain); // Get the icon associated. string IconBack; if(!item.getValueByName (IconBack, "3d.icon background")) debug("key '3d.icon background' not found."); - IconBack = toLower(IconBack); + IconBack = toLowerAscii(IconBack); IdIconBack = ClientSheetsStrings.add(IconBack); // Get the icon associated. string IconOver; if(!item.getValueByName (IconOver, "3d.icon overlay")) debug("key '3d.icon overlay' not found."); - IconOver = toLower(IconOver); + IconOver = toLowerAscii(IconOver); IdIconOver = ClientSheetsStrings.add(IconOver); // Get the icon associated. string IconOver2; if(!item.getValueByName (IconOver2, "3d.icon overlay2")) debug("key '3d.icon overlay2' not found."); - IconOver2 = toLower(IconOver2); + IconOver2 = toLowerAscii(IconOver2); IdIconOver2 = ClientSheetsStrings.add(IconOver2); // Get Special modulate colors @@ -298,7 +301,7 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) debug(toString("The slot name %d is Empty.", i)); // Push the possible slots for the item in the list. - SlotBF|= SINT64_CONSTANT(1)<< (SLOTTYPE::stringToSlotType(NLMISC::toUpper(slotName))); + SlotBF|= SINT64_CONSTANT(1)<< (SLOTTYPE::stringToSlotType(NLMISC::toUpperAscii(slotName))); } } } @@ -317,7 +320,7 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) } else { - Family = (ITEMFAMILY::EItemFamily) ITEMFAMILY::stringToItemFamily(NLMISC::toUpper( family) ); + Family = (ITEMFAMILY::EItemFamily) ITEMFAMILY::stringToItemFamily(NLMISC::toUpperAscii( family) ); if(Family == ITEMFAMILY::UNDEFINED) debug("Item Family Undefined."); } @@ -331,7 +334,7 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) } else { - ItemType = (ITEM_TYPE::TItemType) ITEM_TYPE::stringToItemType(NLMISC::toUpper(itemtype) ); + ItemType = (ITEM_TYPE::TItemType) ITEM_TYPE::stringToItemType(NLMISC::toUpperAscii(itemtype) ); if (ItemType == ITEM_TYPE::UNDEFINED) debug("Item Type Undefined."); } @@ -362,7 +365,7 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) debug("key '3d.anim_set' not found."); // Force the CASE in UPPER to not be CASE SENSITIVE. else - AnimSet = NLMISC::toLower(AnimSet); + AnimSet = NLMISC::toLowerAscii(AnimSet); IdAnimSet = ClientSheetsStrings.add(AnimSet); // Get the Trail Shape @@ -377,28 +380,28 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) string Effect1; if(!item.getValueByName(Effect1, "Effects.Effect1")) debug("key 'Effects.Effect1' not found."); - Effect1 = toLower(Effect1); + Effect1 = toLowerAscii(Effect1); IdEffect1 = ClientSheetsStrings.add(Effect1); // Get special Effect2 string Effect2; if(!item.getValueByName(Effect2, "Effects.Effect2")) debug("key 'Effects.Effect2' not found."); - Effect2 = toLower(Effect2); + Effect2 = toLowerAscii(Effect2); IdEffect2 = ClientSheetsStrings.add(Effect2); // Get special Effect3 string Effect3; if(!item.getValueByName(Effect3, "Effects.Effect3")) debug("key 'Effects.Effect3' not found."); - Effect3 = toLower(Effect3); + Effect3 = toLowerAscii(Effect3); IdEffect3 = ClientSheetsStrings.add(Effect3); // Get special Effect4 string Effect4; if(!item.getValueByName(Effect4, "Effects.Effect4")) debug("key 'Effects.Effect4' not found."); - Effect4 = toLower(Effect4); + Effect4 = toLowerAscii(Effect4); IdEffect4 = ClientSheetsStrings.add(Effect4); // Get its bulk @@ -982,7 +985,7 @@ bool CItemSheet::canExchangeOrGive(bool botChatGift) const } // *************************************************************************** -void CItemSheet::getItemPartListAsText(ucstring &ipList) const +void CItemSheet::getItemPartListAsText(std::string &ipList) const { bool all= true; for(uint i=0;i // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -466,7 +469,7 @@ public: bool canExchangeOrGive(bool botChatGift) const; // MP only. return translated text of all item part this MP can build. empty, if can't build anything - void getItemPartListAsText(ucstring &ipList) const; + void getItemPartListAsText(std::string &ipList) const; // get craft plan const NLMISC::CSheetId &getCraftPlan() const { return CraftPlan; } diff --git a/ryzom/client/src/client_sheets/outpost_building_sheet.cpp b/ryzom/client/src/client_sheets/outpost_building_sheet.cpp index db7e9e55a..8c54bc9fd 100644 --- a/ryzom/client/src/client_sheets/outpost_building_sheet.cpp +++ b/ryzom/client/src/client_sheets/outpost_building_sheet.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -110,21 +113,21 @@ void COutpostBuildingSheet::build(const NLGEORGES::UFormElm &root) string IconMain; if(!root.getValueByName (IconMain, "icon")) debug("key 'icon' not found."); - IconMain = toLower(IconMain); + IconMain = toLowerAscii(IconMain); IdIconMain = ClientSheetsStrings.add(IconMain); // Get the icon associated. string IconBack; if(!root.getValueByName (IconBack, "icon background")) debug("key 'icon background' not found."); - IconBack = toLower(IconBack); + IconBack = toLowerAscii(IconBack); IdIconBack = ClientSheetsStrings.add(IconBack); // Get the icon associated. string IconOver; if(!root.getValueByName (IconOver, "icon overlay")) debug("key 'icon overlay' not found."); - IconOver = toLower(IconOver); + IconOver = toLowerAscii(IconOver); IdIconOver = ClientSheetsStrings.add(IconOver); // Get the icon text associated. diff --git a/ryzom/client/src/client_sheets/player_sheet.cpp b/ryzom/client/src/client_sheets/player_sheet.cpp index d339f99cb..999b683c6 100644 --- a/ryzom/client/src/client_sheets/player_sheet.cpp +++ b/ryzom/client/src/client_sheets/player_sheet.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -74,7 +77,7 @@ void CPlayerSheet::build(const NLGEORGES::UFormElm &item) debug("Key 'AnimSetBaseName' not found."); // Force the CASE in UPPER to not be CASE SENSITIVE. else - AnimSetBaseName = NLMISC::toLower(AnimSetBaseName); + AnimSetBaseName = NLMISC::toLowerAscii(AnimSetBaseName); // Load Lod character name if(!item.getValueByName(LodCharacterName, "LodCharacterName")) @@ -240,7 +243,7 @@ void CPlayerSheet::CEquipment::build(const std::string &key,const NLGEORGES::UFo if(!item.getValueByName(itemName, string(key + ".Item").c_str() )) debug(NLMISC::toString("Key '%s.Item' not found.", key.c_str())); else - Item = NLMISC::toLower(itemName); + Item = NLMISC::toLowerAscii(itemName); // Get the color. if(!item.getValueByName(Color, string(key + ".Color").c_str() )) diff --git a/ryzom/client/src/client_sheets/sbrick_sheet.cpp b/ryzom/client/src/client_sheets/sbrick_sheet.cpp index 81bd338fa..5f3f0c149 100644 --- a/ryzom/client/src/client_sheets/sbrick_sheet.cpp +++ b/ryzom/client/src/client_sheets/sbrick_sheet.cpp @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -103,7 +106,7 @@ void CSBrickSheet::build (const NLGEORGES::UFormElm &root) { string sheetName= Id.toString(); std::string::size_type end= sheetName.find(".sbrick")-2; - BrickFamily = BRICK_FAMILIES::toSBrickFamily ( NLMISC::toUpper(sheetName.substr(0,end)) ); + BrickFamily = BRICK_FAMILIES::toSBrickFamily ( NLMISC::toUpperAscii(sheetName.substr(0,end)) ); if(BrickFamily==BRICK_FAMILIES::Unknown) nlwarning("Unknown Family for SBrick: %s", sheetName.c_str()); } @@ -113,22 +116,22 @@ void CSBrickSheet::build (const NLGEORGES::UFormElm &root) // read icons string Icon; root.getValueByName (Icon, "Client.Icon" ); - Icon = toLower(Icon); + Icon = toLowerAscii(Icon); IdIcon = ClientSheetsStrings.add(Icon); string IconBack; root.getValueByName (IconBack, "Client.IconBack" ); - IconBack = toLower(IconBack); + IconBack = toLowerAscii(IconBack); IdIconBack = ClientSheetsStrings.add(IconBack); string IconOver; root.getValueByName (IconOver, "Client.IconOver" ); - IconOver = toLower(IconOver); + IconOver = toLowerAscii(IconOver); IdIconOver = ClientSheetsStrings.add(IconOver); string IconOver2; root.getValueByName (IconOver2, "Client.IconOver2" ); - IconOver2 = toLower(IconOver2); + IconOver2 = toLowerAscii(IconOver2); IdIconOver2 = ClientSheetsStrings.add(IconOver2); root.getValueByName (IconColor, "Client.IconColor" ); @@ -312,7 +315,7 @@ void CSBrickSheet::build (const NLGEORGES::UFormElm &root) BrickRequiredFlags= 0; for(i=0;i -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/color_slot_manager.cpp b/ryzom/client/src/color_slot_manager.cpp index cccd680c2..254cfb43e 100644 --- a/ryzom/client/src/color_slot_manager.cpp +++ b/ryzom/client/src/color_slot_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -134,7 +137,7 @@ uint CColorSlotManager::addSlot(const TStringVect &slotDescs) _Slots.push_back(slotDescs); for(uint k = 0; k < slotDescs.size(); ++k) { - _Slots.back()[k] = NLMISC::toUpper(_Slots.back()[k]); + _Slots.back()[k] = NLMISC::toUpperAscii(_Slots.back()[k]); } return (uint)_Slots.size() - 1; } @@ -266,7 +269,7 @@ bool CColorSlotManager::parseTexName(const char *texName, std::string *texNameWi static std::string nameToParse; static std::string currentExt; static TIntCoupleVect slotsId; - nameToParse = NLMISC::toUpper(NLMISC::CFile::getFilenameWithoutExtension(texName)); + nameToParse = NLMISC::toUpperAscii(NLMISC::CFile::getFilenameWithoutExtension(texName)); TStrPos currPos = nameToParse.length(); @@ -376,7 +379,7 @@ bool CColorSlotManager::changeTexName(std::string &texName, TIntCouple *slotIDs, static TIntCoupleVect srcSlotIDs; everythingOk = true; - texNameNoExt = NLMISC::toUpper(NLMISC::CFile::getFilenameWithoutExtension(texName)); + texNameNoExt = NLMISC::toUpperAscii(NLMISC::CFile::getFilenameWithoutExtension(texName)); texExt = NLMISC::CFile::getExtension(texName); TTex2Slots::const_iterator texIt = _TexMap.find(texNameNoExt); if (texIt != _TexMap.end()) diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index fad157147..00d2b9e4f 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -181,14 +181,14 @@ NLMISC_COMMAND(where, "Ask information on the position", "") // Check parameters. if(args.empty()) { // Create the message and send. - const string msgName = "COMMAND:WHERE"; + const char *msgName = "COMMAND:WHERE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("command 'where': unknown message named '%s'", msgName.c_str()); + nlwarning("command 'where': unknown message named '%s'", msgName); return true; } return false; @@ -240,20 +240,18 @@ NLMISC_COMMAND(equipGroup, "equip group ", "name") } if(CItemGroupManager::getInstance()->equipGroup(args[0])) { - ucstring msg = CI18N::get("cmdEquipGroupSuccess"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdEquipGroupSuccess"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { - ucstring msg = CI18N::get("cmdEquipGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdEquipGroupError"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; @@ -274,10 +272,9 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1]))) { - ucstring msg = CI18N::get("cmdMoveGroupSuccess"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdMoveGroupSuccess"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); pIM->displaySystemInfo(msg); @@ -285,10 +282,9 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") } else { - ucstring msg = CI18N::get("cmdMoveGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdMoveGroupError"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); pIM->displaySystemInfo(msg); @@ -312,24 +308,22 @@ NLMISC_COMMAND(createGroup, "create group [true](create a for ev removeUnequiped = !args[1].empty(); if(CItemGroupManager::getInstance()->createGroup(args[0], removeUnequiped)) { - ucstring msg; + string msg; if(removeUnequiped) msg = CI18N::get("cmdCreateGroupSuccess2"); else msg = CI18N::get("cmdCreateGroupSuccess1"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { - ucstring msg = CI18N::get("cmdCreateGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdCreateGroupError"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; @@ -350,20 +344,18 @@ NLMISC_COMMAND(deleteGroup, "delete group ", "name") } if(CItemGroupManager::getInstance()->deleteGroup(args[0])) { - ucstring msg = CI18N::get("cmdDeleteGroupSuccess"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdDeleteGroupSuccess"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { - ucstring msg = CI18N::get("cmdDeleteGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string msg = CI18N::get("cmdDeleteGroupError"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; @@ -494,7 +486,7 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[] [h if (!randomFromString(args[0], max)) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("uiRandomBadParameter"); + string msg = CI18N::get("uiRandomBadParameter"); strFindReplace(msg, "%s", args[0] ); pIM->displaySystemInfo(msg); return false; @@ -504,7 +496,7 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[] [h if (!randomFromString(args[1], min)) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("uiRandomBadParameter"); + string msg = CI18N::get("uiRandomBadParameter"); strFindReplace(msg, "%s", args[1] ); pIM->displaySystemInfo(msg); return false; @@ -544,7 +536,7 @@ NLMISC_COMMAND(dumpShapePos, "Dump Last Added Shape Pos.", "") CInterfaceManager *IM = CInterfaceManager::getInstance(); CVector pos = ShapeAddedByCommand.back().getPos(); - IM->displaySystemInfo(ucstring(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z))); + IM->displaySystemInfo(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z)); return true; } //----------------------------------------------- @@ -853,7 +845,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", " string sys; - sys = "Language "+CI18N::getCurrentLanguageName().toString() +" "; + sys = "Language "+CI18N::getCurrentLanguageName() +" "; if (!args.empty()) { @@ -932,9 +924,7 @@ NLMISC_COMMAND(a, "Execute an admin command on you"," ") cmd = args[0]; for (uint i = 1; i < args.size(); i++) { - // temporary fix for utf-8 - // servers commands are not decoded so convert them to ansi - std::string tmp = ucstring::makeFromUtf8(args[i]).toString(); + std::string tmp = args[i]; if (!arg.empty()) arg += ' '; @@ -976,9 +966,7 @@ NLMISC_COMMAND(b, "Execute an admin command on your target"," ") cmd = args[0]; for (uint i = 1; i < args.size(); i++) { - // temporary fix for utf-8 - // servers commands are not decoded so convert them to ansi - std::string tmp = ucstring::makeFromUtf8(args[i]).toString(); + std::string tmp = args[i]; if (!arg.empty()) arg += ' '; @@ -1023,9 +1011,7 @@ NLMISC_COMMAND(c, "Execute an admin command on character name"," cmd = args[1]; for (uint i = 2; i < args.size(); i++) { - // temporary fix for utf-8 - // servers commands are not decoded so convert them to ansi - std::string tmp = ucstring::makeFromUtf8(args[i]).toString(); + std::string tmp = args[i]; if (!arg.empty()) arg += ' '; @@ -1096,15 +1082,15 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic" { // Help CInterfaceManager *IM = CInterfaceManager::getInstance(); - IM->displaySystemInfo(ucstring("This command need 1 parameter :")); - IM->displaySystemInfo(ucstring(" :")); - IM->displaySystemInfo(ucstring("- none(to remove all verboses)")); - IM->displaySystemInfo(ucstring("- magic(to add debug infos about magic)")); - IM->displaySystemInfo(ucstring("- anim (to add debug infos about animation)")); + IM->displaySystemInfo("This command need 1 parameter :"); + IM->displaySystemInfo(" :"); + IM->displaySystemInfo("- none(to remove all verboses)"); + IM->displaySystemInfo("- magic(to add debug infos about magic)"); + IM->displaySystemInfo("- anim (to add debug infos about animation)"); } else { - std::string type = NLMISC::toLower(args[0]); + std::string type = NLMISC::toLowerAscii(args[0]); if (type == "none") Verbose = VerboseNone; else if(type == "magic") @@ -1114,11 +1100,11 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic" else { CInterfaceManager *IM = CInterfaceManager::getInstance(); - IM->displaySystemInfo(ucstring("This command need 1 parameter :")); - IM->displaySystemInfo(ucstring(" :")); - IM->displaySystemInfo(ucstring("- none(to remove all verboses)")); - IM->displaySystemInfo(ucstring("- magic(to add debug infos about magic)")); - IM->displaySystemInfo(ucstring("- anim (to add debug infos about animation)")); + IM->displaySystemInfo("This command need 1 parameter :"); + IM->displaySystemInfo(" :"); + IM->displaySystemInfo("- none(to remove all verboses)"); + IM->displaySystemInfo("- magic(to add debug infos about magic)"); + IM->displaySystemInfo("- anim (to add debug infos about animation)"); } } return true; @@ -1306,9 +1292,9 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","") inComment++; if(inComment<=0) { - ucstring ucline(line); + string ucline(line); CInterfaceManager::parseTokens(ucline); - ICommand::execute(ucline.toUtf8(), g_log); + ICommand::execute(ucline, g_log); } if(strncmp(line, "*/", 2)==0) inComment--; @@ -1323,7 +1309,7 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","") } else { - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Cannot open file")); + CInterfaceManager::getInstance()->displaySystemInfo("Cannot open file"); } return true; @@ -1358,7 +1344,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") else pIM->displaySystemInfo(toString("DB '%s' does not exist.", args[0].c_str())); #else - pIM->displaySystemInfo(ucstring("Can't write to DB when in Final Version.")); + pIM->displaySystemInfo("Can't write to DB when in Final Version."); #endif } else if (size == 1) @@ -1368,7 +1354,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") { sint64 prop = node->getValue64(); string str = toString(prop); - pIM->displaySystemInfo(ucstring(str)); + pIM->displaySystemInfo(str); nlinfo("%s", str.c_str()); } else @@ -1385,14 +1371,14 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc.."," 2) - desc.fromUtf8(args[2]); + desc = args[2]; if (args.size() > 3) - desc2.fromUtf8(args[3]); + desc2 = args[3]; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC) @@ -1406,10 +1392,10 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc.."," ") { if (args.size() < 2) return false; - ucstring name; - name.fromUtf8(args[0]); - ucstring text; - text.fromUtf8(args[1]); + string name; + name = args[0]; + string text; + text = args[1]; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC) @@ -1438,7 +1424,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", " ") if (args.empty()) return false; - if (!ClientCfg.AllowDebugLua && toLower(args[0]) == "lua") + if (!ClientCfg.AllowDebugLua && toLowerAscii(args[0]) == "lua") { return false; // not allowed!! } @@ -1459,7 +1445,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", " ") static void setDynString(uint32 strID, const std::string &value) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - pSMC->receiveString(strID, ucstring(value)); + pSMC->receiveString(strID, value); CBitMemStream bm; if (bm.isReading()) bm.invert(); bm.serial(strID); @@ -1686,10 +1672,10 @@ NLMISC_COMMAND(missionProgress, "debug"," ") NLMISC_COMMAND( displayDBModifs, "display server database modification in the chat window"," ") { if ( VerboseDatabase ) - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already in verbose mode"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("the database is already in verbose mode",CRGBA(255,255,255,255)); else { - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is now in verbose mode"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("database is now in verbose mode",CRGBA(255,255,255,255)); VerboseDatabase = true; } return true; @@ -1698,10 +1684,10 @@ NLMISC_COMMAND( displayDBModifs, "display server database modification in the ch NLMISC_COMMAND( hideDBModifs, "stop displaying server database modification in the chat window"," ") { if ( !VerboseDatabase ) - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already not in verbose mode"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("the database is already not in verbose mode",CRGBA(255,255,255,255)); else { - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is not in verbose mode anymore"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("database is not in verbose mode anymore",CRGBA(255,255,255,255)); VerboseDatabase = false; } return true; @@ -1722,7 +1708,7 @@ NLMISC_COMMAND(getSheetId, "get_sheet_id","") return false; CSheetId id(args[0]); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(toString(id.asInt()))); + CInterfaceManager::getInstance()->displaySystemInfo(toString(id.asInt())); return true; } @@ -1737,7 +1723,7 @@ NLMISC_COMMAND(getSheetName, "get_sheet_name","") string name = id.toString(); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name)); + CInterfaceManager::getInstance()->displaySystemInfo(name); return true; } @@ -1817,14 +1803,14 @@ NLMISC_COMMAND(usePreprogCombat, "use the specified combat preprog sentence", "< NLMISC_COMMAND(engage, "engage target in combat", "") { // Create the message for the server to execute a phrase. - const string msgName = "COMBAT:ENGAGE"; + const char *msgName = "COMBAT:ENGAGE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); + nlwarning("mainLoop : unknown message name : '%s'", msgName); return true; } @@ -1850,14 +1836,14 @@ NLMISC_COMMAND(disengage, "disengage from combat", "") NLMISC_COMMAND(leaveTeam, "leave team", "") { // Create the message for the server to execute a phrase. - const string msgName = "TEAM:LEAVE"; + const char *msgName = "TEAM:LEAVE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); + nlwarning("mainLoop : unknown message name : '%s'", msgName); return true; } @@ -1865,14 +1851,14 @@ NLMISC_COMMAND(leaveTeam, "leave team", "") NLMISC_COMMAND(joinTeam, "join the specified team", "") { // Create the message for the server to execute a phrase. - const string msgName = "TEAM:JOIN"; + const char *msgName = "TEAM:JOIN"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); + nlwarning("mainLoop : unknown message name : '%s'", msgName); return true; } @@ -1880,14 +1866,14 @@ NLMISC_COMMAND(joinTeam, "join the specified team", "") NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", "") { // Create the message for the server to execute a phrase. - const string msgName = "TEAM:JOIN_PROPOSAL"; + const char *msgName = "TEAM:JOIN_PROPOSAL"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); + nlwarning("mainLoop : unknown message name : '%s'", msgName); return true; } @@ -1895,14 +1881,14 @@ NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", " NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "") { // Create the message for the server to execute a phrase. - const string msgName = "TEAM:JOIN_PROPOSAL_DECLINE"; + const char *msgName = "TEAM:JOIN_PROPOSAL_DECLINE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); + nlwarning("mainLoop : unknown message name : '%s'", msgName); return true; } @@ -1910,14 +1896,14 @@ NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "") NLMISC_COMMAND(kickTeammate, "kick someone from your team", "") { // Create the message for the server to execute a phrase. - const string msgName = "TEAM:KICK"; + const char *msgName = "TEAM:KICK"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); + nlwarning("mainLoop : unknown message name : '%s'", msgName); return true; } @@ -1927,14 +1913,14 @@ NLMISC_COMMAND(cancelCurrentSentence, "cancel the sentence being executed", "") // no parameter needed // Create the message for the server to cancel the phrase being executed - const string msgName = "SENTENCE:CANCEL_CURRENT"; + const char *msgName = "SENTENCE:CANCEL_CURRENT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else - nlwarning("command : unknown message name : '%s'", msgName.c_str()); + nlwarning("command : unknown message name : '%s'", msgName); return true; } @@ -1966,7 +1952,7 @@ NLMISC_COMMAND(drop,"drop an item to the ground","") sint32 z = (sint32)UserEntity->pos().z * 1000; CBitMemStream bms; - string msgType = "ITEM:DROP"; + const char *msgType = "ITEM:DROP"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( itemId ); @@ -1995,7 +1981,7 @@ NLMISC_COMMAND(pos, "Change the position of the user (in local only)", "") // Warning when already recording. if(NetMngr.isRecording()) { - IM->displaySystemInfo(ucstring("Already Recording. Stop the current Record first")); + IM->displaySystemInfo("Already Recording. Stop the current Record first"); return true; } @@ -2388,7 +2374,7 @@ NLMISC_COMMAND(sheet2idx, "Return the index of a sheet", " displaySystemInfo(ucstring(result)); + IM->displaySystemInfo(result); nlinfo("'sheet2idx': %s", result.c_str()); return true; } @@ -2411,7 +2397,7 @@ NLMISC_COMMAND(dynstr, "display a dyn string value", "") uint dynId; fromString(args[0], dynId); - ucstring result; + string result; STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynId, result); CInterfaceManager::getInstance()->displaySystemInfo(result); @@ -2426,7 +2412,7 @@ NLMISC_COMMAND(serverstr, "display a server string value", "getString(dynId, result); CInterfaceManager::getInstance()->displaySystemInfo(result); @@ -2510,11 +2496,11 @@ NLMISC_COMMAND(mode, "Change the mode for an entity in a slot", " [ if(args.size() < 2) { // Help - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 paramters :")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the mode wanted for the entity, one of the following number :")); + CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 paramters :"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the mode wanted for the entity, one of the following number :"); for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i).c_str()))); + CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i).c_str())); } // Right parameters number else @@ -2544,7 +2530,7 @@ NLMISC_COMMAND(mode, "Change the mode for an entity in a slot", " [ } // Invalid slot. else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -2557,12 +2543,12 @@ NLMISC_COMMAND(behaviour, "Change the behaviour for an entity in a slot", " 6) { // Help - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 to 6 paramters :")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); + CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 to 6 paramters :"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the behaviour to play for the entity, one of the following number :"); for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i).c_str()))); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); + CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i).c_str())); + CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END)); } else { @@ -2633,7 +2619,7 @@ NLMISC_COMMAND(behaviour, "Change the behaviour for an entity in a slot", "updateVisualProperty(NetMngr.getCurrentServerTick()+dt, CLFECOMMON::PROPERTY_BEHAVIOUR); } else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -2655,12 +2641,12 @@ NLMISC_COMMAND(magic, "Cast a spell", "\n" if(args.size() != 6) { // Help -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); +// CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 or 3 paramters :"); +// CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); +// CInterfaceManager::getInstance()->displaySystemInfo(" : the behaviour to play for the entity, one of the following number :"); // for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); +// CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i))); +// CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END)); } else { @@ -2709,7 +2695,7 @@ NLMISC_COMMAND(magic, "Cast a spell", "\n" entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); } else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -2728,12 +2714,12 @@ NLMISC_COMMAND(spell, "Cast a spell", "\n" if(args.size() != 6) { // Help - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); + // CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 or 3 paramters :"); + // CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); + // CInterfaceManager::getInstance()->displaySystemInfo(" : the behaviour to play for the entity, one of the following number :"); // for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); + // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i))); + // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END)); } else { @@ -2782,7 +2768,7 @@ NLMISC_COMMAND(spell, "Cast a spell", "\n" entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); } else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -3783,7 +3769,7 @@ NLMISC_COMMAND( createPerso, "create a new character", "Parameters:\n-Character fromString(args[4], level); CBitMemStream bms; - string msgType = "CHEAT:CREATE_CHARACTER"; + const char *msgType = "CHEAT:CREATE_CHARACTER"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( characterName ); @@ -3814,7 +3800,7 @@ NLMISC_COMMAND( add_role, "add role to character", " fromString(args[0], entityId); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"); + string text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"); uint duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); CEntityCL *entity = EntitiesMngr.entity(entityId); @@ -4005,7 +3991,7 @@ NLMISC_COMMAND(displayInventoryCounter, "display the Inventory counter to compar srvVal&= pIM->getLocalSyncActionCounterMask(); locVal&= pIM->getLocalSyncActionCounterMask(); - pIM->displaySystemInfo(ucstring( "ServerCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); + pIM->displaySystemInfo("ServerCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)); // Well done. return true; @@ -4023,7 +4009,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "") srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; - pIM->displaySystemInfo(ucstring( "NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); + pIM->displaySystemInfo("NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)); // cycle srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); @@ -4031,7 +4017,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "") srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; - pIM->displaySystemInfo(ucstring( "CycleCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); + pIM->displaySystemInfo("CycleCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)); return true; } @@ -4114,7 +4100,7 @@ NLMISC_COMMAND(skillToInt, "Convert a skill to an int", "") { if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo(ucstring(toString((uint) SKILLS::toSkill(args[0])))); + im->displaySystemInfo(toString((uint) SKILLS::toSkill(args[0]))); return true; } @@ -4144,11 +4130,11 @@ NLMISC_COMMAND(browseRingAdmin, "Browse a HTML document with the ring web browse NLMISC_COMMAND(GUCreate, "create a guild", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:CREATE"; + const char *msgName = "GUILD:CREATE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { - string buf = args[0]; + ucstring buf = ucstring::makeFromUtf8(args[0]); // FIXME: UTF-8 (serial) out.serial( buf ); NetMngr.push(out); } @@ -4158,7 +4144,7 @@ NLMISC_COMMAND(GUCreate, "create a guild", "") NLMISC_COMMAND(GUQuit, "quit a guild", "") { if (args.size() != 0) return false; - const string msgName = "GUILD:QUIT"; + const char *msgName = "GUILD:QUIT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4170,7 +4156,7 @@ NLMISC_COMMAND(GUQuit, "quit a guild", "") NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "") { if (args.size() != 0) return false; - const string msgName = "GUILD:ABANDON_LEADERSHIP"; + const char *msgName = "GUILD:ABANDON_LEADERSHIP"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4181,7 +4167,7 @@ NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "") NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "") { if (args.size() != 0) return false; - const string msgName = "GUILD:ABANDON_OFFICER_TITLE"; + const char *msgName = "GUILD:ABANDON_OFFICER_TITLE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4193,7 +4179,7 @@ NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "") NLMISC_COMMAND(GUNameOfficer, "name an officer", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:NAME_OFFICER"; + const char *msgName = "GUILD:NAME_OFFICER"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4207,7 +4193,7 @@ NLMISC_COMMAND(GUNameOfficer, "name an officer", "") NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:DISMISS_OFFICER"; + const char *msgName = "GUILD:DISMISS_OFFICER"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4221,7 +4207,7 @@ NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "") NLMISC_COMMAND(GUKick, "kick a member", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:KICK_MEMBER"; + const char *msgName = "GUILD:KICK_MEMBER"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4248,7 +4234,7 @@ NLMISC_COMMAND(GURefuse, "refuse an invitation", "") NLMISC_COMMAND(GUFriend, "invite a player to become a friend of the guild", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:FRIEND_INVITATION"; + const char *msgName = "GUILD:FRIEND_INVITATION"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4262,7 +4248,7 @@ NLMISC_COMMAND(GUFriend, "invite a player to become a friend of the guild", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:SET_SUCCESSOR"; + const char *msgName = "GUILD:SET_SUCCESSOR"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4300,7 +4286,7 @@ NLMISC_COMMAND(GUSetSuccessor, "set the successor of the guild leader", "") { if (args.size() != 1) return false; - const string msgName = "GUILD:GET_INFOS"; + const char *msgName = "GUILD:GET_INFOS"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4314,7 +4300,7 @@ NLMISC_COMMAND(GUInfos, "get information on a guild", "") NLMISC_COMMAND(GUJournal, "get the guild journal", "") { if (args.size() != 0) return false; - const string msgName = "GUILD:GET_LOG"; + const char *msgName = "GUILD:GET_LOG"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4328,7 +4314,7 @@ NLMISC_COMMAND(buildingTeleport, "teleport to a building", "building index") if (args.size() != 1) return false; uint16 index; fromString(args[0], index); - const string msgName = "GUILD:TELEPORT"; + const char *msgName = "GUILD:TELEPORT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4520,7 +4506,7 @@ NLMISC_COMMAND(getSkillValue, "get a skill value by its name", "skill_name") CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); if(node) { - pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); + pIM->displaySystemInfo(toString(node->getValue32())); } return true; @@ -4550,7 +4536,7 @@ NLMISC_COMMAND(getBaseSkillValue, "get a baseskill value by its name", "skill_na CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); if(node) { - pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); + pIM->displaySystemInfo(toString(node->getValue32())); } return true; @@ -4812,7 +4798,7 @@ NLMISC_COMMAND(stick_log, "", "") skel->getStickedObjects(sticks); nlinfo("StickedModels: %d", sticks.size()); - pIM->displaySystemInfo(ucstring(toString("StickedModels: %d", sticks.size()))); + pIM->displaySystemInfo(toString("StickedModels: %d", sticks.size())); for(uint i=0;i= args.size()) { // Not enough arguments - pIM->displaySystemInfo (ucstring(CommandName+" : ")+CI18N::get ("uiCommandWrongArgumentCount")); + pIM->displaySystemInfo (CommandName+" : "+CI18N::get ("uiCommandWrongArgumentCount")); return false; } else { if (keywords[i] == "$") - finalArgs += /*ucstring(*/args[index++]/*).toUtf8()*/; + finalArgs += args[index++]; else { while (indexdisplaySystemInfo (ucstring(CommandName+" : ")+CI18N::get ("uiCommandWrongArgumentCount")); + pIM->displaySystemInfo (CommandName+" : "+CI18N::get ("uiCommandWrongArgumentCount")); return false; } return true; @@ -5461,13 +5447,13 @@ void CUserCommand::createCommand (const char *name, const char *action, const ch } // Find action name - ucstring help; + string help; const CBaseAction *ab = Actions.getBaseAction (::CAction::CName (action, ptrParams)); if (ab) help = CI18N::get(ab->LocalizedName); // Build a argument help - ucstring argsHelp; + string argsHelp; if (ab) { @@ -5491,7 +5477,7 @@ void CUserCommand::createCommand (const char *name, const char *action, const ch // Add the string if (!argsHelp.empty()) argsHelp += " "; - argsHelp += ucstring("<") + CI18N::get(ab->Parameters[j].LocalizedName) + ucstring(">"); + argsHelp += "<" + CI18N::get(ab->Parameters[j].LocalizedName) + ">"; bFound = true; } } @@ -5658,7 +5644,7 @@ NLMISC_COMMAND(tickToDate, "convert a tick value into a readable ryzom time", "" CInterfaceManager *im = CInterfaceManager::getInstance(); float ryTime = rt.getRyzomTime(); std::string readableDate = toString("Day = %d, hour = %d:%d", rt.getRyzomDay(), (int) floorf(ryTime), (int) floorf(60.f * fmodf(ryTime, 1.f))); - im->displaySystemInfo(ucstring(readableDate)); + im->displaySystemInfo(readableDate); return true; } @@ -5680,7 +5666,7 @@ NLMISC_COMMAND(dumpShapeMaxDist, "dump max dist for shapes", "") cs->getWholeEquipmentList(equipList); for (uint k = 0; k < equipList.size(); ++k) { - std::string item = toLower(equipList[k]->getItem()); + std::string item = toLowerAscii(equipList[k]->getItem()); if (!item.empty()) { @@ -5930,7 +5916,7 @@ NLMISC_COMMAND(time, "Shows information about the current time", "") tm = gmtime(&date); strftime(cs_utc, size, "%X", tm); - ucstring msg = CI18N::get("uiCurrentLocalAndUtcTime"); + string msg = CI18N::get("uiCurrentLocalAndUtcTime"); strFindReplace(msg, "%local", cs_local); strFindReplace(msg, "%utc", cs_utc); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); @@ -5939,7 +5925,7 @@ NLMISC_COMMAND(time, "Shows information about the current time", "") NLMISC_COMMAND(playedTime, "Display character played time", "") { - ucstring msg = CI18N::get("uiPlayedTime"); + string msg = CI18N::get("uiPlayedTime"); strFindReplace(msg, "%time", NLMISC::secondsToHumanReadable(CharPlayedTime)); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); return true; @@ -5947,7 +5933,7 @@ NLMISC_COMMAND(playedTime, "Display character played time", "") NLMISC_COMMAND(version, "Display client version", "") { - ucstring msg = getDebugVersion(); + string msg = getDebugVersion(); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); return true; } diff --git a/ryzom/client/src/commands.h b/ryzom/client/src/commands.h index 8a0b8764a..0d77b38cc 100644 --- a/ryzom/client/src/commands.h +++ b/ryzom/client/src/commands.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -43,7 +44,7 @@ public: std::vector Keywords; }; - CUserCommand (const std::string &commandName, const ucstring &help, const ucstring &argsHelp); + CUserCommand (const std::string &commandName, const std::string &help, const std::string &argsHelp); void addMode (const std::string &action, uint numArg, bool infiniteAgr, const std::vector &keywords); diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 4352f456f..fe5ec64f3 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -1,10 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -146,13 +146,12 @@ string CharNameValidDBLink; uint8 PlayerSelectedSlot = 0; string PlayerSelectedFileName; TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!! -ucstring PlayerSelectedHomeShardName; -ucstring PlayerSelectedHomeShardNameWithParenthesis; +std::string PlayerSelectedHomeShardName; +std::string PlayerSelectedHomeShardNameWithParenthesis; extern std::string CurrentCookie; - -ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created -ucstring NewKeysCharNameValidated; +std::string NewKeysCharNameWanted; // name of the character for which a new keyset must be created +std::string NewKeysCharNameValidated; std::string GameKeySet = "keys.xml"; std::string RingEditorKeySet = "keys_r2ed.xml"; @@ -310,9 +309,9 @@ void CSoundGlobalMenu::updateSound() // **** update the music played // The first music played is the music played at loading, before select char if (_MusicPlayed.empty()) - _MusicPlayed = toLower(LoadingMusic.empty() ? ClientCfg.StartMusic : LoadingMusic); + _MusicPlayed = toLowerAscii(LoadingMusic.empty() ? ClientCfg.StartMusic : LoadingMusic); if (_MusicWanted.empty()) - _MusicWanted = toLower(LoadingMusic.empty() ? ClientCfg.StartMusic : LoadingMusic); + _MusicWanted = toLowerAscii(LoadingMusic.empty() ? ClientCfg.StartMusic : LoadingMusic); // because music is changed when the player select other race for instance, // wait the 3D to load (stall some secs) @@ -339,7 +338,7 @@ void CSoundGlobalMenu::updateSound() void CSoundGlobalMenu::setMusic(const string &music, bool async) { - _MusicWanted= toLower(music); + _MusicWanted= toLowerAscii(music); _MusicWantedAsync= async; // reset the counter _NbFrameBeforeChange= NbFrameBeforeChangeMax; @@ -366,7 +365,7 @@ bool connection (const string &cookie, const string &fsaddr) // Preload continents { - const ucstring nmsg("Loading continents..."); + const string nmsg("Loading continents..."); ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) ); ContinentMngr.preloadSheets(); @@ -404,7 +403,7 @@ bool connection (const string &cookie, const string &fsaddr) // Init out game setOutGameFullScreen(); - ucstring nmsg("Initializing outgame..."); + string nmsg("Initializing outgame..."); ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) ); pIM->initOutGame(); @@ -524,7 +523,9 @@ bool connection (const string &cookie, const string &fsaddr) if (InterfaceState == GOGOGO_IN_THE_GAME) { // set background downloader to 'paused' to ease loading of client +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif return true; } @@ -548,7 +549,7 @@ bool reconnection() // Preload continents { - const ucstring nmsg ("Loading continents..."); + const string nmsg ("Loading continents..."); ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) ); ContinentMngr.preloadSheets(); } @@ -663,7 +664,9 @@ bool reconnection() if (InterfaceState == GOGOGO_IN_THE_GAME) { +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif return true; } if (InterfaceState == QUIT_THE_GAME) @@ -783,12 +786,12 @@ void globalMenuMovieShooter() // ------------------------------------------------------------------------------------------------ // Build a valid PlayerName for file Save selection. -std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn) +std::string buildPlayerNameForSaveFile(const std::string &playerNameIn) { // remove any shard name appended - ucstring playerName = playerNameIn; - ucstring::size_type pos = playerNameIn.find('('); - if(pos!=ucstring::npos && pos>0) + string playerName = playerNameIn; + string::size_type pos = playerNameIn.find('('); + if(pos!=string::npos && pos>0) { playerName.resize(pos); } @@ -804,7 +807,7 @@ std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn) (c>='0' && c<='9') || (c=='_') ) { - ret[i]= tolower(c); + ret[i]= tolower(c); // TODO: toLowerAscii } else ret[i]= '_'; @@ -813,9 +816,9 @@ std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn) } +#ifdef RYZOM_BG_DOWNLOADER static bool LuaBGDSuccessFlag = true; // tmp, for debug - void updateBGDownloaderUI() { CInterfaceManager *im = CInterfaceManager::getInstance(); @@ -913,11 +916,12 @@ void updateBGDownloaderUI() nlwarning("Some scipt error occurred"); } } - +#endif // compute patcher priority, depending on the presence of one or more mainland characters : in this case, give the patch a boost void updatePatcherPriorityBasedOnCharacters() { +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { if (CBGDownloaderAccess::getInstance().getDownloadThreadPriority() != BGDownloader::ThreadPriority_Paused) @@ -936,6 +940,7 @@ void updatePatcherPriorityBasedOnCharacters() CBGDownloaderAccess::getInstance().requestDownloadThreadPriority(hasMainlandChar ? BGDownloader::ThreadPriority_Normal : BGDownloader::ThreadPriority_Low, false); } } +#endif } // Launch the interface to choose a character @@ -944,6 +949,7 @@ TInterfaceState globalMenu() { CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_CharacterSelection, "login_step_character_selection")); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); if (isBGDownloadEnabled()) @@ -954,14 +960,14 @@ TInterfaceState globalMenu() // if a task is already started, then this was a situation where player went back from game to the character selection, // so just unpause BGDownloader::TTaskResult dummyResult; - ucstring dummyMessage; + ucstring dummyMessage; // OLD if (!bgDownloader.isTaskEnded(dummyResult, dummyMessage)) { unpauseBGDownloader(); } } } - +#endif CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -987,7 +993,7 @@ TInterfaceState globalMenu() while (PlayerWantToGoInGame == false) { - #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) + #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) && 0 // tmp for debug if (::GetAsyncKeyState(VK_SPACE)) { @@ -1007,8 +1013,9 @@ TInterfaceState globalMenu() } #endif +#ifdef RYZOM_BG_DOWNLOADER updateBGDownloaderUI(); - +#endif // Update network. try @@ -1027,7 +1034,7 @@ TInterfaceState globalMenu() // Display the firewall alert string CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title")); if (pVT != NULL) - pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); + pVT->setTextLocalized("uiFirewallAlert", true); // The mouse and fullscreen mode should be unlocked for the user to set the firewall permission nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts @@ -1073,7 +1080,7 @@ TInterfaceState globalMenu() nlSleep(ClientCfg.Sleep); } - #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) + #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) && 0 if (::GetAsyncKeyState(VK_CONTROL)) { pIM->displayUIViewBBoxs(""); @@ -1091,7 +1098,7 @@ TInterfaceState globalMenu() { if (noUserChar || userChar) { - +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { // If there's a need for mainland download, then proceed @@ -1100,7 +1107,7 @@ TInterfaceState globalMenu() // if a task is already started, then this was a situation where player went back from game to the character selection, // so just unpause BGDownloader::TTaskResult dummyResult; - ucstring dummyMessage; + ucstring dummyMessage; // OLD if (bgDownloader.isTaskEnded(dummyResult, dummyMessage)) { // launch mainland patch as a background task @@ -1115,6 +1122,7 @@ TInterfaceState globalMenu() } } } +#endif //nlinfo("impulseCallBack : received userChars list"); noUserChar = userChar = false; @@ -1243,8 +1251,8 @@ TInterfaceState globalMenu() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ - CI18N::get("uiFirewallAlert")+ucstring(".")); + pVT->setTextLocalized(CI18N::get("uiFirewallFail")+".\n"+ + CI18N::get("uiFirewallAlert")+".", false); } } } @@ -1264,8 +1272,8 @@ TInterfaceState globalMenu() LoginSM.pushEvent(CLoginStateMachine::ev_global_menu_exited); // Init the current Player Name (for interface.cfg and sentence.name save). Make a good File Name. - ucstring &playerName= CharacterSummaries[PlayerSelectedSlot].Name; - PlayerSelectedFileName= buildPlayerNameForSaveFile(playerName); + string playerName = CharacterSummaries[PlayerSelectedSlot].Name.toUtf8(); + PlayerSelectedFileName = buildPlayerNameForSaveFile(playerName); // Init the current Player Home shard Id and name CharacterHomeSessionId = CharacterSummaries[PlayerSelectedSlot].Mainland; @@ -1325,23 +1333,23 @@ public: if (pVT == NULL) return; if (rCS.Name.empty()) - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setTextLocalized("uiEmptySlot", true); else - pVT->setText(rCS.Name); + pVT->setTextLocalized(rCS.Name.toUtf8(), false); } // 5 slots for (; i < 5; ++i) { CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i))); if (pVT == NULL) return; - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setTextLocalized("uiEmptySlot", true); } } }; REGISTER_ACTION_HANDLER (CAHNetInitCharSel, "net_init_char_sel"); // ------------------------------------------------------------------------------------------------ -void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) +void setTarget(CCtrlBase *ctrl, const string &targetName, std::string &value) { std::vector targets; // find first enclosing group @@ -1356,7 +1364,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) if (ig) { CInterfaceExprValue exprValue; - exprValue.setUCString(value); + exprValue.setString(value); CInterfaceLink::splitLinkTargets(targetName, ig, targets); for(uint k = 0; k < targets.size(); ++k) @@ -1414,12 +1422,12 @@ public: if (CharacterSummaries[PlayerSelectedSlot].Name.empty()) return; - ucstring sValue(""); + string sValue; uint32 nValue = 0; if (sProp == "name") { - sValue = CharacterSummaries[PlayerSelectedSlot].Name; + sValue = CharacterSummaries[PlayerSelectedSlot].Name.toUtf8(); setTarget (pCaller, sTarget, sValue); } /* else if (sProp == "surname") @@ -1444,8 +1452,8 @@ Deprecated { sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(titleStr, womanTitle); { // Sometimes translation contains another title - ucstring::size_type pos = sValue.find('$'); - if (pos != ucstring::npos) + string::size_type pos = sValue.find('$'); + if (pos != string::npos) { sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle); } @@ -1688,8 +1696,8 @@ public: // Setup the name string sEditBoxPath = getParam (Params, "name"); - ucstring sFirstName = ucstring("NotSet"); - ucstring sSurName = ucstring("NotSet"); + string sFirstName = "NotSet"; + string sSurName = "NotSet"; CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath)); if (pGEB != NULL) sFirstName = pGEB->getInputString(); @@ -1701,7 +1709,7 @@ public: string sCharSumPath = getParam(Params, "charsum"); SCharacter3DSetup::setupCharacterSummaryFromDB(CS, sCharSumPath); CS.Mainland = MainlandSelected; - CS.Name = sFirstName; + CS.Name = ucstring::makeFromUtf8(sFirstName); // FIXME: UTF-8 (serial) //CS.Surname = sSurName; // Create the message to send to the server from the character summary @@ -1807,8 +1815,8 @@ public: out.serial (nSelectedSlot); // Yoyo: delete the Local files. To avoid problem if recreate a character with same name. - ucstring &playerName= CharacterSummaries[nSelectedSlot].Name; - string playerDeletedFileName= buildPlayerNameForSaveFile(playerName); + string playerName = CharacterSummaries[nSelectedSlot].Name.toUtf8(); + string playerDeletedFileName = buildPlayerNameForSaveFile(playerName); // Delete the 2 Local files pIM->deletePlayerConfig(playerDeletedFileName); pIM->deletePlayerKeys(playerDeletedFileName); @@ -1858,6 +1866,7 @@ string getTarget(CCtrlBase * /* ctrl */, const string &targetName) return ""; } +#ifdef RYZOM_LUA_UCSTRING // ------------------------------------------------------------------------------------------------ ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName) { @@ -1871,14 +1880,15 @@ ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName) if (!elem) { nlwarning(" : Element is NULL"); - return ucstring(""); + return ucstring(""); // TODO: UTF-8 Lua } const CReflectedProperty *pRP = elem->getReflectedProperty(rTI.PropertyName); if (pRP->Type == CReflectedProperty::UCString) return ((elem->*(pRP->GetMethod.GetUCString))()); - return ucstring(""); + return ucstring(""); // TODO: UTF-8 Lua } +#endif /*// Ask the server to rename a character // ------------------------------------------------------------------------------------------------ @@ -1950,7 +1960,11 @@ public: string sDBLink = getParam(Params, "dblink"); CharNameValidDBLink = sDBLink; - ucstring sName = getUCTarget(NULL,sTarget); +#ifdef RYZOM_LUA_UCSTRING + string sName = getUCTarget(NULL,sTarget).toUtf8(); // TODO: UTF-8 Lua +#else + string sName = getTarget(NULL, sTarget); +#endif CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (sName.empty()) @@ -1992,13 +2006,13 @@ public: if (Mainlands[k].Id == MainlandSelected) { // extract name from mainland - /*ucstring::size_type first = Mainlands[k].Name.find('('); - ucstring::size_type last = Mainlands[k].Name.find(')'); - if (first != ucstring::npos && last != ucstring::npos && first < last) + /*ucstring::size_type first = Mainlands[k].Name.find('('); // OLD + ucstring::size_type last = Mainlands[k].Name.find(')');// OLD + if (first != ucstring::npos && last != ucstring::npos && first < last)// OLD { NewKeysCharNameWanted += Mainlands[k].Name.substr(first, last - first + 1); }*/ - NewKeysCharNameWanted += ('(' + Mainlands[k].Name + ')'); + NewKeysCharNameWanted += ('(' + Mainlands[k].Name.toUtf8() + ')'); break; } } @@ -2021,7 +2035,7 @@ public: for (uint i = 0; i < CharacterSummaries.size(); ++i) { - ucstring ls = CharacterSummaries[i].Name.toString(); + string ls = CharacterSummaries[i].Name.toString(); if (ls == sName) CharNameValid = false; } @@ -2176,8 +2190,8 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - ucstring ucstr = Mainlands[i].Name + ucstring(" ") + Mainlands[i].Description; - pVT->setText(ucstr); + std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8(); + pVT->setTextLocalized(str, false); } // Add to the list @@ -2332,7 +2346,7 @@ public: } // add a new keyset in the list - void addKeySet(const std::string &filename, const ucstring &name, const ucstring tooltip) + void addKeySet(const std::string &filename, const std::string &name, const std::string tooltip) { nlassert(List); CInterfaceGroup *pNewLine = buildTemplate("t_keyset", toString(filename)); @@ -2341,7 +2355,7 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - pVT->setText(name); + pVT->setTextLocalized(name, false); } CCtrlBase *pBut = pNewLine->getCtrl("but"); @@ -2383,12 +2397,12 @@ public: std::string strId = "uiCP_KeysetName_" + keySetVar->asString(k); strFindReplace(strId, ".", "_"); - ucstring keySetName = CI18N::get(strId); + const string &keySetName = CI18N::get(strId); strId = "uiCP_KeysetTooltip_" + keySetVar->asString(k); strFindReplace(strId, ".", "_"); if (CI18N::hasTranslation(strId)) { - ucstring keySetTooltip = CI18N::get(strId); + const string &keySetTooltip = CI18N::get(strId); addKeySet(keySetVar->asString(k), keySetName, keySetTooltip); } } @@ -2397,8 +2411,8 @@ public: { nlwarning("'%s' var not found in config file, or list is empty, proposing default keyset only", KeySetVarName); std::string defaultKeySet = "keys"; - ucstring keySetName = CI18N::get("uiCP_KeysetName_" + defaultKeySet); - ucstring keySetTooltip = CI18N::get("uiCP_KeysetTooltip_" + defaultKeySet); + const string &keySetName = CI18N::get("uiCP_KeysetName_" + defaultKeySet); + const string &keySetTooltip = CI18N::get("uiCP_KeysetTooltip_" + defaultKeySet); addKeySet(defaultKeySet, keySetName, keySetTooltip); } @@ -2424,19 +2438,19 @@ public: { for(TKeySetFileMap::iterator it = keySetFiles.begin(); it != keySetFiles.end(); ++it) { - ucstring name; + string name; if (ClientCfg.Local) { - name = ucstring(it->first); + name = it->first; } else { - // search matching ucstring name from character summaries + // search matching utf-8 string name from character summaries for (uint k = 0; k < CharacterSummaries.size(); ++k) { - if (it->first == buildPlayerNameForSaveFile(CharacterSummaries[k].Name)) + if (it->first == buildPlayerNameForSaveFile(CharacterSummaries[k].Name.toUtf8())) { - name = CharacterSummaries[k].Name; + name = CharacterSummaries[k].Name.toUtf8(); } } } @@ -2447,7 +2461,7 @@ public: addSeparator(); separatorAdded = true; } - addKeySet(it->first, ucstring(it->first), CI18N::get(std::string("uiCP_KeysetImport") + (it->second & GameKeys ? "_Game" : "") + addKeySet(it->first, it->first, CI18N::get(std::string("uiCP_KeysetImport") + (it->second & GameKeys ? "_Game" : "") + (it->second & EditorKeys ? "_Editor" : ""))); } } @@ -2587,14 +2601,14 @@ REGISTER_ACTION_HANDLER (CAHResetKeysetSelect, "keyset_select"); // *************************** SCENARIO CONTROL WINDOW *********************** // *************************************************************************** // helper function for "setScenarioInformation" -static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const ucstring &text) +static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const std::string &text) { CInterfaceElement *result = scenarioWnd->findFromShortId(uiName); if(result) { CViewText* viewText = dynamic_cast(result); if(viewText) - viewText->setText(text); + viewText->setTextLocalized(text, false); CGroupEditBox* editBox = dynamic_cast(result); if(editBox) editBox->setInputString(text); @@ -2602,11 +2616,9 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName } } // helper function for "setScenarioInformation" -static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const std::string &utf8Text) +static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const ucstring &text) // TODO: UTF-8 Lua { - ucstring ucText; - ucText.fromUtf8(utf8Text); - setTextField(scenarioWnd, uiName, ucText); + setTextField(scenarioWnd, uiName, text.toUtf8()); } // helper function for "setScenarioInformation" static std::string fieldLookup(const vector< pair< string, string > > &values, const std::string &id) @@ -2717,7 +2729,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText = dynamic_cast(result); if(viewText) { - viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName")); + viewText->setTextLocalized(R2::getEditor().isInitialized() ? "uiR2EDScenarioName" : "uiR2EDScenarioFileName", true); } } @@ -2729,9 +2741,9 @@ class CAHScenarioControl : public IActionHandler if(okButton) { if(R2::getEditor().getAccessMode()!=R2::CEditor::AccessDM) - okButton->setHardText(CI18N::get("uiR2EDLaunchScenario").toString()); + okButton->setHardText(CI18N::get("uiR2EDLaunchScenario")); else - okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters").toString()); + okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters")); } } @@ -2747,7 +2759,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText= dynamic_cast(result); if(viewText) - viewText->setText(ucstring("")); + viewText->setText(std::string()); } } setScenarioInformation(scenarioWnd, ""); @@ -2783,7 +2795,7 @@ class CAHScenarioControl : public IActionHandler CViewText *shardName = dynamic_cast(toggleGr->getView("button_text")); if (shardName) { - shardName->setText(Mainlands[i].Name); + shardName->setTextLocalized(Mainlands[i].Name.toUtf8(), false); } } } @@ -2923,7 +2935,7 @@ class CAHScenarioInformation : public IActionHandler scenarioName = scenarioName.substr(posScenarioName==0?posScenarioName:posScenarioName+1); posScenarioName = scenarioName.find('/'); } - viewText->setText(scenarioName); + viewText->setTextLocalized(scenarioName, false); } } @@ -3012,7 +3024,7 @@ class CAHLoadScenario : public IActionHandler { CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - description = editBox->getInputString().toString(); + description = editBox->getInputString(); } // races @@ -3219,9 +3231,9 @@ class CAHLoadScenario : public IActionHandler // -------------------------- TRuleType ruleType(TRuleType::rt_strict); - if(rules==CI18N::get("uiR2EDliberal").toString()) + if(rules==CI18N::get("uiR2EDliberal")) ruleType = TRuleType(TRuleType::rt_liberal); - else if(rules == CI18N::get("uiR2EDstrict").toString()) + else if(rules == CI18N::get("uiR2EDstrict")) ruleType = TRuleType(TRuleType::rt_strict); volatile static bool override = false; if (override) @@ -3285,7 +3297,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setTextLocalized("uiRingWarningFreeTrial", true); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); return; @@ -3366,7 +3378,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setTextLocalized("uiRingWarningFreeTrial", true); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } @@ -3380,10 +3392,10 @@ class CAHLoadScenario : public IActionHandler if(val!=0) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring res; + string res; if (pSMC->getString(val,res)) { - string charName = CEntityCL::removeTitleAndShardFromName(res).toString(); + string charName = CEntityCL::removeTitleAndShardFromName(res); sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName); if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult"))) @@ -3395,7 +3407,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); + pVT->setTextLocalized("uiRingWarningInviteFreeTrial", true); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } } @@ -3488,7 +3500,7 @@ class CAHInitImportCharacter : public IActionHandler CPath::getPathContent("save/", false, false, true, savedCharacters); CInterfaceGroup *newLine; - CInterfaceGroup *prevLine; + CInterfaceGroup *prevLine = NULL; for (uint i = 0; i < savedCharacters.size(); ++i) { @@ -3511,7 +3523,7 @@ class CAHInitImportCharacter : public IActionHandler { CViewText *text = dynamic_cast(newLine->getView("name")); if (text) - text->setText(ucstring(savedCharacters[i])); + text->setText(string(savedCharacters[i])); // first button is pushed CCtrlButton *button = dynamic_cast(newLine->getCtrl("but")); @@ -3677,7 +3689,7 @@ class CAHExportCharacter : public IActionHandler return; // extract name - const std::string name = buildPlayerNameForSaveFile(CS.Name.toString()); + const std::string name = buildPlayerNameForSaveFile(CS.Name.toUtf8()); COFile fd; bool success = false; diff --git a/ryzom/client/src/connection.h b/ryzom/client/src/connection.h index 72a44d31c..08e95d99f 100644 --- a/ryzom/client/src/connection.h +++ b/ryzom/client/src/connection.h @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -30,14 +33,14 @@ extern std::vector Mainlands; extern uint8 PlayerSelectedSlot; extern std::string PlayerSelectedFileName; extern TSessionId PlayerSelectedMainland; // This is the mainland selected at the SELECT perso!! -extern ucstring PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) -extern ucstring PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis +extern std::string PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) +extern std::string PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis extern std::vector CharacterSummaries; extern std::string UserPrivileges; extern sint LoginCharsel; -extern ucstring NewKeysCharNameWanted; -extern ucstring NewKeysCharNameValidated; +extern std::string NewKeysCharNameWanted; +extern std::string NewKeysCharNameValidated; extern std::string GameKeySet; extern std::string RingEditorKeySet; @@ -73,12 +76,14 @@ enum TInterfaceState TInterfaceState autoLogin (const std::string &cookie, const std::string &fsaddr, bool firstConnection); -std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn); +std::string buildPlayerNameForSaveFile(const std::string &playerNameIn); void globalMenuMovieShooter(); +#ifdef RYZOM_BG_DOWNLOADER void updateBGDownloaderUI(); +#endif // compute patcher priority, depending on the presence of one or more mainland characters : in this case, give the patch a boost void updatePatcherPriorityBasedOnCharacters(); diff --git a/ryzom/client/src/contextual_cursor.cpp b/ryzom/client/src/contextual_cursor.cpp index 15dd6a17a..2a4d053d1 100644 --- a/ryzom/client/src/contextual_cursor.cpp +++ b/ryzom/client/src/contextual_cursor.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -129,7 +130,7 @@ void CContextualCursor::del(const std::string &contextName) // context : // Select a nex context. //----------------------------------------------- -bool CContextualCursor::context(const std::string &contextName, float dist, const ucstring &cursName) +bool CContextualCursor::context(const std::string &contextName, float dist, const std::string &cursName) { // Delete the context. TContext::iterator it = _Contexts.find(contextName); diff --git a/ryzom/client/src/contextual_cursor.h b/ryzom/client/src/contextual_cursor.h index 6dfd20749..93eb1509f 100644 --- a/ryzom/client/src/contextual_cursor.h +++ b/ryzom/client/src/contextual_cursor.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -68,7 +71,7 @@ public: void del(const std::string &contextName); // Select a nex context. - bool context(const std::string &contextName, float dist = 0, const ucstring &cursName = ucstring("")); + bool context(const std::string &contextName, float dist = 0, const std::string &cursName = std::string()); inline const std::string &context() const {return _Context;} // Check if there is an entity under the cursor. diff --git a/ryzom/client/src/continent.cpp b/ryzom/client/src/continent.cpp index d0fb15a95..ac5760708 100644 --- a/ryzom/client/src/continent.cpp +++ b/ryzom/client/src/continent.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -410,7 +413,9 @@ static uint16 getZoneIdFromName(const string &zoneName) //----------------------------------------------- void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress, bool complete, bool unhibernate, EGSPD::CSeason::TSeason season) { +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif CNiceInputAuto niceInputs; // Season has changed ? Season = season; @@ -542,7 +547,7 @@ void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress // Associate IGs with the ZC number or -1 if there is no ZC. for(uint i = 0; i this zone should be a ZC. - string outpostZone = toLower(CFile::getFilenameWithoutExtension(ZCList[j].Name)); + string outpostZone = toLowerAscii(CFile::getFilenameWithoutExtension(ZCList[j].Name)); if(igZone == outpostZone) { nlctassert(RZ_MAX_BUILDING_PER_OUTPOST==4); @@ -836,7 +841,7 @@ void CContinent::reloadFogMap() const R2::CScenarioEntryPoints::CCompleteIsland *completeIsland = R2::CScenarioEntryPoints::getInstance().getCompleteIslandFromCoords(CVector2f((float) UserEntity->pos().x, (float) UserEntity->pos().y)); if (completeIsland) { - std::string islandName = toLower(completeIsland->Island); + std::string islandName = toLowerAscii(completeIsland->Island); std::string::size_type lastPos = islandName.find_last_of("_"); if (lastPos != std::string::npos) { @@ -964,6 +969,7 @@ void CContinent::unselect() // Setup the Root scene. if (BackgroundIG) { + nlassert(SceneRoot); BackgroundIG->removeFromScene (*SceneRoot); SceneRoot->deleteInstanceGroup (BackgroundIG); BackgroundIG = NULL; diff --git a/ryzom/client/src/continent.h b/ryzom/client/src/continent.h index 7e0d599b4..96417160a 100644 --- a/ryzom/client/src/continent.h +++ b/ryzom/client/src/continent.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -109,7 +112,7 @@ public: }; NLMISC::CVector2f Pos; // Pos in local map - ucstring Title; + ucstring Title; // FIXME: UTF-8 (serial) uint8 Type; //User LandMarks Colors diff --git a/ryzom/client/src/continent_manager.cpp b/ryzom/client/src/continent_manager.cpp index 4bdb470f3..3001eac34 100644 --- a/ryzom/client/src/continent_manager.cpp +++ b/ryzom/client/src/continent_manager.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -187,7 +187,7 @@ void CContinentManager::preloadSheets() for (i = 0; i < ws->ContLocs.size(); ++i) { const SContLoc &clTmp = ws->ContLocs[i]; - std::string continentSheetName = NLMISC::toLower(clTmp.ContinentName); + std::string continentSheetName = NLMISC::toLowerAscii(clTmp.ContinentName); if (continentSheetName.find(".continent") == std::string::npos) { continentSheetName += ".continent"; @@ -564,7 +564,7 @@ void CContinentManager::readFrom(xmlNodePtr node) nlwarning("Ignore landmarks group without 'type' attribute."); return; } - lmtype = toLower((const char*)prop); + lmtype = toLowerAscii((const char*)prop); if (lmtype != "user") { nlwarning("Ignore landmarks group with type '%s', expected 'user'.", lmtype.c_str()); diff --git a/ryzom/client/src/continent_manager.h b/ryzom/client/src/continent_manager.h index 1a0641627..4e6d0774c 100644 --- a/ryzom/client/src/continent_manager.h +++ b/ryzom/client/src/continent_manager.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/continent_manager_build.h b/ryzom/client/src/continent_manager_build.h index 52719f9ad..9a86ea00f 100644 --- a/ryzom/client/src/continent_manager_build.h +++ b/ryzom/client/src/continent_manager_build.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,7 +46,7 @@ public: TContLMType Type; NLMISC::CVector2f Pos; // Center of the zone NLLIGO::CPrimZone Zone; // Region & Place - std::string TitleTextID; // should be converted with CStringManagerClient::getPlaceLocalizedName() to get the actual title in ucstring + std::string TitleTextID; // should be converted with CStringManagerClient::getPlaceLocalizedName() to get the actual title in utf-8 string CContLandMark() { diff --git a/ryzom/client/src/cursor_functions.cpp b/ryzom/client/src/cursor_functions.cpp index 44e2dde7e..17bef41f5 100644 --- a/ryzom/client/src/cursor_functions.cpp +++ b/ryzom/client/src/cursor_functions.cpp @@ -3,8 +3,8 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -197,7 +197,7 @@ static bool testMissionOption(sint32 priorityWanted) // Get the Text for the cursor if(textID) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, result); if (!res) result = NLMISC::CI18N::get("uiMissionOptionNotReceived"); @@ -224,7 +224,7 @@ static bool testMissionRing() uint32 textID = pNL->getValue32(); // if the string is not received display a temp string - ucstring missionRingText; + string missionRingText; if(!STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, missionRingText)) missionRingText = NLMISC::CI18N::get("uiMissionRingNameNotReceived"); @@ -445,7 +445,7 @@ void checkUnderCursor() uint32 textID = pNL->getValue32(); // if the string is not received display a temp string - ucstring webPageText; + string webPageText; if(!STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, webPageText)) webPageText = NLMISC::CI18N::get("uiWebPageNameNotReceived"); @@ -463,8 +463,8 @@ void checkUnderCursor() { // get the outpost name CSheetId outpostSheet(pNL->getValue32()); - ucstring outpostName; - outpostName= ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)); + string outpostName; + outpostName= STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet); // display the cursor if(ContextCur.context("OUTPOST", 0.f, outpostName)) @@ -564,14 +564,13 @@ void checkUnderCursor() cursor->setCursor("r2ed_tool_select_move_over.tga"); InstanceId = instance_idx; - if (ContextCur.context("ARKITECT", 0.f, ucstring("Edit"))) + if (ContextCur.context("ARKITECT", 0.f, "Edit")) return; } else { cursor->setCursor("curs_pick.tga"); - ucstring contextText; - contextText.fromUtf8(instref.ContextText); + string contextText = instref.ContextText; if (ContextCur.context("WEBIG", 0.f, contextText)) return; } diff --git a/ryzom/client/src/debug_client.cpp b/ryzom/client/src/debug_client.cpp index dd182f3c9..cbceca4ef 100644 --- a/ryzom/client/src/debug_client.cpp +++ b/ryzom/client/src/debug_client.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -514,7 +514,7 @@ string getDebugInformation() if(UserEntity) { - str += toString("Player Name: '%s'\n", UserEntity->getEntityName().toString().c_str()); + str += toString("Player Name: '%s'\n", UserEntity->getEntityName().c_str()); str += toString("UserPosition: %.2f %.2f %.2f\n", UserEntity->pos().x, UserEntity->pos().y, UserEntity->pos().z); } else @@ -529,7 +529,7 @@ string getDebugInformation() str += toString("ServerTick: %u\n", NetMngr.getCurrentServerTick()); str += toString("ConnectState: %s\n", NetMngr.getConnectionStateCStr()); str += toString("LocalAddress: %s\n", NetMngr.getAddress().asString().c_str()); - str += toString("Language: %s\n", CI18N::getCurrentLanguageName().toString().c_str()); + str += toString("Language: %s\n", CI18N::getCurrentLanguageName().c_str()); str += toString("ClientVersion: %s\n", getDebugVersion().c_str()); if (ClientCfg.R2Mode) { diff --git a/ryzom/client/src/decal.cpp b/ryzom/client/src/decal.cpp index e270a7c29..24e3e756b 100644 --- a/ryzom/client/src/decal.cpp +++ b/ryzom/client/src/decal.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Jan BOON (Kaetemi) @@ -162,7 +162,9 @@ CDecal::CDecal() { DecalAttenuationVertexProgram = new CVertexProgramDecalAttenuation(); } - _ShadowMap = new CShadowMap(&(((CSceneUser *) Scene)->getScene().getRenderTrav().getShadowMapManager())); + + // initialized in render() as depends on scene + _ShadowMap = NULL; _Material.initUnlit(); _Diffuse = CRGBA::White; _Emissive = CRGBA::Black; @@ -251,7 +253,11 @@ CRGBA CDecal::getDiffuse() const // **************************************************************************** CDecal::~CDecal() { - delete _ShadowMap; + if (_ShadowMap) + { + delete _ShadowMap; + _ShadowMap = NULL; + } } // **************************************************************************** @@ -527,7 +533,12 @@ void CDecal::render(NL3D::UDriver &/* drv */, // float tileNear = Landscape->getTileNear(); // - nlassert(_ShadowMap); + if (!_ShadowMap) + { + _ShadowMap = new CShadowMap(&(((CSceneUser *) Scene)->getScene().getRenderTrav().getShadowMapManager())); + nlassert(_ShadowMap); + } + _ShadowMap->LocalClipPlanes.resize(4); CVector corners[4] = { diff --git a/ryzom/client/src/door_manager.cpp b/ryzom/client/src/door_manager.cpp index 64b1d65a5..1b094ad7b 100644 --- a/ryzom/client/src/door_manager.cpp +++ b/ryzom/client/src/door_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -248,7 +251,7 @@ void CDoorManager::SDoor::checkToClose() std::string CDoorManager::transformName (uint /* index */, const std::string &/* instanceName */, const std::string &shapeName) { if (shapeName.rfind('.') == string::npos) return shapeName; - string sExt = toLower(shapeName.substr(shapeName.rfind('.')+1,shapeName.size())); + string sExt = toLowerAscii(shapeName.substr(shapeName.rfind('.')+1,shapeName.size())); if (sExt != "pacs_prim") return shapeName; return ""; // Do not load a pacs prim as a mesh... } @@ -265,7 +268,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) string sShapeName = ig->getShapeName(k); if (sShapeName.rfind('.') == string::npos) continue; - string sExt = toLower(sShapeName.substr(sShapeName.rfind('.')+1,sShapeName.size())); + string sExt = toLowerAscii(sShapeName.substr(sShapeName.rfind('.')+1,sShapeName.size())); if (sExt != "pacs_prim") continue; // Check if the pacs_prim is a door detection @@ -347,7 +350,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) case SDoor::Matis3PartBourgeon: { string sDebug = ig->getShapeName(i); - sDebug = toLower(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); + sDebug = toLowerAscii(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); if (sDebug == "gauche") pDoor->Instances[0] = i; else if (sDebug == "droite") @@ -360,7 +363,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) case SDoor::Zorai2Part: { string sDebug = ig->getShapeName(i); - sDebug = toLower(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); + sDebug = toLowerAscii(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); if (sDebug == "gauche") pDoor->Instances[0] = i; else if (sDebug == "droite") diff --git a/ryzom/client/src/entities.cpp b/ryzom/client/src/entities.cpp index 9ecadba93..6a64ea449 100644 --- a/ryzom/client/src/entities.cpp +++ b/ryzom/client/src/entities.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -178,7 +178,7 @@ public : CCompassTarget ct = pGC->getTarget(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring oldName; + string oldName; if (!pSMC->getDynString(leaf->getOldValue32(), oldName)) { nlwarning("Can't get compass target name"); @@ -201,7 +201,7 @@ public : { // TODO : maybe the following code could be include in CGroupMap::checkCoords, but it is not called when the map is not visible... STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring name; + string name; if (pSMC->getDynString((*tmpIt)->getValue32(), name)) { // if (_AlreadyReceived.count(name) == 0) @@ -246,7 +246,7 @@ public : } private: std::list _PendingMissionTitle; -// std::set _AlreadyReceived; +// std::set _AlreadyReceived; }; //----------------------------------------------- @@ -2268,7 +2268,7 @@ void CEntityManager::dumpXML(class NLMISC::IStream &f) f.xmlPushBegin("Name"); // Set a property name f.xmlSetAttrib ("string"); - ucstring n = _Entities[i]->getEntityName(); + string n = _Entities[i]->getEntityName(); f.serial(n); // Close the new node header f.xmlPushEnd(); @@ -2361,11 +2361,11 @@ CEntityCL *CEntityManager::getEntityByName (uint32 stringId) const } //----------------------------------------------- -CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const +CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const { if (keywords.empty()) return NULL; - std::vector lcKeywords; + std::vector lcKeywords; lcKeywords.resize(keywords.size()); for(uint k = 0; k < keywords.size(); k++) { @@ -2382,14 +2382,13 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &key if (onlySelectable && !_Entities[i]->properties().selectable()) continue; - ucstring lcName; - lcName = toLower(_Entities[i]->getDisplayName()); + string lcName = toLower(_Entities[i]->getDisplayName()); if (lcName.empty()) continue; bool match = true; for (uint k = 0; k < lcKeywords.size(); ++k) { - if (lcName.find(lcKeywords[k]) == ucstring::npos) + if (lcName.find(lcKeywords[k]) == string::npos) { match = false; break; @@ -2418,16 +2417,10 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &key } //----------------------------------------------- -CEntityCL *CEntityManager::getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const +CEntityCL *CEntityManager::getEntityByName (const string &name, bool caseSensitive, bool complete) const { - ucstring source = name; - const uint size = (uint)source.size(); - if (!caseSensitive) - { - uint j; - for (j=0; jgetDisplayName(); + string value = caseSensitive ? _Entities[i]->getDisplayName() : toLower(_Entities[i]->getDisplayName()); // TODO: toLowerInsensitive bool foundEntity = false; - uint j; - if (!caseSensitive) - { - for (j=0; j= size) - { - if (std::operator==(source, value.substr (0, size))) - foundEntity = true; - } + if (NLMISC::startsWith(value, source)) + foundEntity = true; } if (foundEntity) diff --git a/ryzom/client/src/entities.h b/ryzom/client/src/entities.h index 48707d5cf..d7a0c34c5 100644 --- a/ryzom/client/src/entities.h +++ b/ryzom/client/src/entities.h @@ -2,7 +2,7 @@ // Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -308,13 +308,13 @@ public: * \param caseSensitive type of test to perform * \param complete : if true, the name must match the full name of the entity. */ - CEntityCL *getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const; + CEntityCL *getEntityByName (const std::string &name, bool caseSensitive, bool complete) const; /** * Case insensitive match against entity name. All listed keywords must match. * \param keywords to match * \param onlySelectable : if true, match only entity that can be selected */ - CEntityCL *getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const; + CEntityCL *getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const; CEntityCL *getEntityBySheetName (const std::string &sheet) const; /// Get an entity by dataset index. Returns NULL if the entity is not found. CEntityCL *getEntityByCompressedIndex(TDataSetIndex compressedIndex) const; diff --git a/ryzom/client/src/entity_animation_manager.cpp b/ryzom/client/src/entity_animation_manager.cpp index 02ed9969b..c2bcb28d8 100644 --- a/ryzom/client/src/entity_animation_manager.cpp +++ b/ryzom/client/src/entity_animation_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -205,7 +208,7 @@ void CEntityAnimationManager::load(NLMISC::IProgressCallback &/* progress */, bo for (uint32 i = 0; i < pASLS->AnimSetList.size(); ++i) { CAnimationSet as; - string sTmp = toLower(pASLS->AnimSetList[i].Name); + string sTmp = toLowerAscii(pASLS->AnimSetList[i].Name); sTmp = sTmp.substr(0,sTmp.rfind('.')); pair::iterator, bool> it; it = _AnimSet.insert(pair(sTmp,as)); diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 14f3a1769..9b7ca340e 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -1,10 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2017 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -378,6 +378,8 @@ void CEntityCL::SInstanceCL::updateCurrentFromLoading(NL3D::USkeleton Skeleton) sint stickID = Skeleton.getBoneIdByName(StickPoint); if(stickID != -1) Skeleton.stickObject(Current, stickID); + else + nlwarning("Skeleton '%s' is missing bone '%s' for object attachment.", Skeleton.getShapeName().c_str(), StickPoint.c_str()); } } @@ -2095,7 +2097,7 @@ bool CEntityCL::clipped (const std::vector &clippingPlanes, cons // Set the name of the entity. Handle replacement tag if any // to insert NPC task translated. //--------------------------------------------------- -void CEntityCL::setEntityName(const ucstring &name) +void CEntityCL::setEntityName(const std::string &name) { _EntityName = name; } @@ -2260,7 +2262,7 @@ void CEntityCL::load() // virtual // onStringAvailable : // Callback when the name is arrived. //----------------------------------------------- -void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) +void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value) { _EntityName = value; @@ -2268,24 +2270,24 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) _EntityName= removeShardFromName(_EntityName); // New title - ucstring newtitle; + string newtitle; _HasReservedTitle = false; // check if there is any replacement tag in the string - ucstring::size_type p1 = _EntityName.find('$'); - if (p1 != ucstring::npos) + string::size_type p1 = _EntityName.find('$'); + if (p1 != string::npos) { // we found a replacement point begin tag - ucstring::size_type p2 = _EntityName.find('$', p1+1); - if (p2 != ucstring::npos) + string::size_type p2 = _EntityName.find('$', p1+1); + if (p2 != string::npos) { // ok, we have the second replacement point! // extract the replacement id - ucstring id = _EntityName.substr(p1+1, p2-p1-1); + string id = _EntityName.substr(p1+1, p2-p1-1); // retrieve the translated string - _TitleRaw = id.toString(); -// ucstring replacement = CI18N::get(strNewTitle); + _TitleRaw = id; +// string replacement = CI18N::get(strNewTitle); bool womanTitle = false; CCharacterCL * c = dynamic_cast(this); if(c) @@ -2293,17 +2295,16 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) womanTitle = ( c->getGender() == GSGENDER::female ); } - ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle)); + string replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); // Sometimes translation contains another title { - ucstring::size_type pos = replacement.find('$'); - if (pos != ucstring::npos) + string::size_type pos = replacement.find('$'); + if (pos != string::npos) { - ucstring sn = replacement; - _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos)); - ucstring::size_type pos2 = sn.find('$', pos + 1); - _TitleRaw = sn.substr(pos+1, pos2 - pos - 1); + _EntityName = _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(replacement.substr(0, pos)); + string::size_type pos2 = replacement.find('$', pos + 1); + _TitleRaw = replacement.substr(pos+1, pos2 - pos - 1); replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); } } @@ -2319,7 +2320,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) _NameEx = replacement; newtitle = _NameEx; } - CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw.toString() ); + CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw ); if ( titleEnum >= CHARACTER_TITLE::BeginGmTitle && titleEnum <= CHARACTER_TITLE::EndGmTitle ) { _GMTitle = titleEnum - CHARACTER_TITLE::BeginGmTitle; @@ -2354,10 +2355,10 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) if (pVT != NULL) pVT->setText(_Title); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player")); - if (pGC != NULL) pGC->setUCTitle(_EntityName); + if (pGC != NULL) pGC->setTitle(_EntityName); CSkillManager *pSM = CSkillManager::getInstance(); - pSM->setPlayerTitle(_TitleRaw.toString()); + pSM->setPlayerTitle(_TitleRaw); } // Must rebuild the in scene interface 'cause name has changed @@ -2368,33 +2369,33 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) //----------------------------------------------- // getTitleFromName //----------------------------------------------- -ucstring CEntityCL::getTitleFromName(const ucstring &name) +std::string CEntityCL::getTitleFromName(const std::string &name) { - ucstring::size_type p1 = name.find('$'); - if (p1 != ucstring::npos) + std::string::size_type p1 = name.find('$'); + if (p1 != string::npos) { - ucstring::size_type p2 = name.find('$', p1 + 1); - if (p2 != ucstring::npos) + std::string::size_type p2 = name.find('$', p1 + 1); + if (p2 != std::string::npos) return name.substr(p1+1, p2-p1-1); } - return ucstring(""); + return std::string(); }// getTitleFromName // //----------------------------------------------- // removeTitleFromName //----------------------------------------------- -ucstring CEntityCL::removeTitleFromName(const ucstring &name) +std::string CEntityCL::removeTitleFromName(const std::string &name) { - ucstring::size_type p1 = name.find('$'); - if (p1 == ucstring::npos) + std::string::size_type p1 = name.find('$'); + if (p1 == string::npos) { return name; } else { - ucstring::size_type p2 = name.find('$', p1 + 1); - if (p2 != ucstring::npos) + std::string::size_type p2 = name.find('$', p1 + 1); + if (p2 != string::npos) { return name.substr(0, p1) + name.substr(p2 + 1); } @@ -2408,16 +2409,16 @@ ucstring CEntityCL::removeTitleFromName(const ucstring &name) //----------------------------------------------- // removeShardFromName //----------------------------------------------- -ucstring CEntityCL::removeShardFromName(const ucstring &name) +std::string CEntityCL::removeShardFromName(const std::string &name) { // The string must contains a '(' and a ')' - ucstring::size_type p0= name.find('('); - ucstring::size_type p1= name.find(')'); - if(p0==ucstring::npos || p1==ucstring::npos || p1<=p0) + std::string::size_type p0= name.find('('); + std::string::size_type p1= name.find(')'); + if(p0==std::string::npos || p1==std::string::npos || p1<=p0) return name; // if it is the same as the shard name of the user, remove it - if(ucstrnicmp(name, (uint)p0+1, (uint)(p1-p0-1), PlayerSelectedHomeShardName)==0) + if (!NLMISC::compareCaseInsensitive(name.c_str() + p0 + 1, p1-p0-1, PlayerSelectedHomeShardName.c_str(), PlayerSelectedHomeShardName.size())) return name.substr(0,p0) + name.substr(p1+1); // else don't modify else @@ -2427,7 +2428,7 @@ ucstring CEntityCL::removeShardFromName(const ucstring &name) //----------------------------------------------- // removeTitleAndShardFromName //----------------------------------------------- -ucstring CEntityCL::removeTitleAndShardFromName(const ucstring &name) +std::string CEntityCL::removeTitleAndShardFromName(const std::string &name) { return removeTitleFromName(removeShardFromName(name)); } diff --git a/ryzom/client/src/entity_cl.h b/ryzom/client/src/entity_cl.h index e2985493a..f2f99b347 100644 --- a/ryzom/client/src/entity_cl.h +++ b/ryzom/client/src/entity_cl.h @@ -3,8 +3,8 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -334,19 +334,19 @@ public: */ //@{ /// Return the Name of the entity. There may be a specification in it (guard, trader, etc ...). It is then surrounded by '$' - const ucstring &getEntityName() const {return _EntityName;} + const std::string &getEntityName() const {return _EntityName;} /// Return the title from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..) - static ucstring getTitleFromName(const ucstring &name); + static std::string getTitleFromName(const std::string &name); /// Remove the specification from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..) - static ucstring removeTitleFromName(const ucstring &name); + static std::string removeTitleFromName(const std::string &name); /// Remove the shard from a name (if player from the same shard). The shard is surrounded by (), and tells the incoming shard of the entity (aniro, leanon etc...) - static ucstring removeShardFromName(const ucstring &name); + static std::string removeShardFromName(const std::string &name); /// Remove both title and shard from name - static ucstring removeTitleAndShardFromName(const ucstring &name); + static std::string removeTitleAndShardFromName(const std::string &name); /// Change the entity name. - void setEntityName(const ucstring &name); + void setEntityName(const std::string &name); /// Return a displayable name - ucstring getDisplayName() const + std::string getDisplayName() const { return removeTitleAndShardFromName(_EntityName); } @@ -638,7 +638,7 @@ public: // Add hit points gain/lost by this entity. void addHPOutput(sint16 hp, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20) _HPModifiers.push_back(CHPModifier(hp,color,dt));} - void addHPOutput(const ucstring &text, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20 && !text.empty()) _HPModifiers.push_back(CHPModifier(text,color,dt));} + void addHPOutput(const std::string &text, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20 && !text.empty()) _HPModifiers.push_back(CHPModifier(text,color,dt));} /// Return the entity sheet scale. (return 1.0 if there is any problem). virtual float getSheetScale() const {return 1.0f;} @@ -769,25 +769,25 @@ public: bool isAnOutpostAlly() const; /// Return the entity title - const ucstring &getTitle() const + const std::string &getTitle() const { return _Title; } /// Return the entity tags - const ucstring &getTag(uint8 id) const + const std::string &getTag(uint8 id) const { if (_Tags.size() > id) { return _Tags[id]; } - static ucstring empty; + static const std::string empty; return empty; } /// Return the raw unparsed entity title - const ucstring getTitleRaw() const + const std::string &getTitleRaw() const { - return ucstring(_TitleRaw); + return _TitleRaw; } /// Return true if this entity has a reserved title @@ -931,20 +931,20 @@ protected: // Flags to know what is possible to do with the entity (selectable, liftable, etc.). CProperties _Properties; // Current Name for the entity - ucstring _EntityName; + std::string _EntityName; // Current entity title - ucstring _Title; + std::string _Title; // Current entity tags - std::vector _Tags; + std::vector _Tags; // Current entity title string id - ucstring _TitleRaw; + std::string _TitleRaw; // Current permanent content symbol for the entity std::string _PermanentStatutIcon; // Has reserved title? bool _HasReservedTitle; // Extended Name - ucstring _NameEx; + std::string _NameEx; // String ID uint32 _NameId; // Primitive used for the collision in PACS @@ -995,10 +995,10 @@ protected: CHPModifier() {} virtual ~CHPModifier() {} CHPModifier (sint16 value, NLMISC::CRGBA color, float dt) : Value(value), Color(color), DeltaT(dt) {} - CHPModifier (const ucstring &text, NLMISC::CRGBA color, float dt) : Text(text), Color(color), DeltaT(dt) {} + CHPModifier (const std::string &text, NLMISC::CRGBA color, float dt) : Text(text), Color(color), DeltaT(dt) {} sint16 Value; // If Text.empty(), take the Value - ucstring Text; + std::string Text; NLMISC::CRGBA Color; float DeltaT; }; @@ -1222,7 +1222,7 @@ public: private: // Override for string reception callback - virtual void onStringAvailable(uint stringId, const ucstring &value); + virtual void onStringAvailable(uint stringId, const std::string &value); }; diff --git a/ryzom/client/src/events_listener.cpp b/ryzom/client/src/events_listener.cpp index cfa9d2b3c..83385a0e7 100644 --- a/ryzom/client/src/events_listener.cpp +++ b/ryzom/client/src/events_listener.cpp @@ -1,8 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2016 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/far_tp.cpp b/ryzom/client/src/far_tp.cpp index 6509b4d2a..6bd05172a 100644 --- a/ryzom/client/src/far_tp.cpp +++ b/ryzom/client/src/far_tp.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2011 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -423,11 +423,13 @@ void CLoginStateMachine::run() bool mustReboot = false; +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { mustReboot = CBGDownloaderAccess::getInstance().mustLaunchBatFile(); } else +#endif { mustReboot = CPatchManager::getInstance()->mustLaunchBatFile(); } @@ -473,11 +475,13 @@ void CLoginStateMachine::run() initPatchCheck(); SM_BEGIN_EVENT_TABLE +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { SM_EVENT(ev_patch_needed, st_patch); // no choice for patch content when background downloader is used } else +#endif { SM_EVENT(ev_patch_needed, st_display_cat); } @@ -603,7 +607,9 @@ void CLoginStateMachine::run() break; case st_enter_far_tp_main_loop: // if bgdownloader is used, then pause it +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif // Far TP part 1.2: let the main loop finish the current frame. @@ -930,7 +936,7 @@ retryJoinEdit: } } pIM->messageBoxWithHelp( - CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + ucstring(errorMsg), + CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + errorMsg, letReturnToCharSelect ? "ui:outgame:charsel" : "ui:interface"); // Info in the log @@ -1007,13 +1013,13 @@ void CFarTP::hookNextFarTPForEditor() */ void CFarTP::requestReturnToPreviousSession(TSessionId rejectedSessionId) { - const string msgName = "CONNECTION:RET_MAINLAND"; + const char *msgName = "CONNECTION:RET_MAINLAND"; CBitMemStream out; nlverify(GenericMsgHeaderMngr.pushNameToStream(msgName, out)); out.serial(PlayerSelectedSlot); out.serial(rejectedSessionId); NetMngr.push(out); - nlinfo("%s sent", msgName.c_str()); + nlinfo("%s sent", msgName); } /* @@ -1120,7 +1126,7 @@ void CFarTP::disconnectFromPreviousShard() // Start progress bar and display background ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.progress(0); diff --git a/ryzom/client/src/forage_source_cl.cpp b/ryzom/client/src/forage_source_cl.cpp index 4e673caaf..7141ad62f 100644 --- a/ryzom/client/src/forage_source_cl.cpp +++ b/ryzom/client/src/forage_source_cl.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -101,7 +102,7 @@ bool CForageSourceCL::build( const CEntitySheet *sheet ) const CForageSourceSheet *forageSourceSheet = dynamic_cast(sheet); if ( ! forageSourceSheet ) { - nlwarning( "Bad sheet %s for forage source", sheet->Id.toString().c_str() ); + nlwarning( "Bad sheet %s for forage source", sheet ? sheet->Id.toString().c_str() : "NULL" ); return false; } if ( ! setFx( forageSourceSheet->FxFilename ) ) @@ -507,9 +508,9 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/* CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName += ucstring(" [") + prospectorName + ucstring("]"); + _EntityName += " [" + prospectorName + "]"; } } @@ -535,7 +536,7 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/* void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop) { CSheetId rmSheetId( (const uint32&)prop ); - const ucchar *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); + const char *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); if ( name ) { _EntityName = name; @@ -544,9 +545,9 @@ void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* game CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + std::string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName += ucstring(" [") + prospectorName + ucstring("]"); + _EntityName += " [" + prospectorName + "]"; } } // Rebuild inscene interface @@ -567,9 +568,9 @@ void CForageSourceCL::updateVisualPropertyTarget(const NLMISC::TGameCycle &/* ga CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; // NULL if entity not received if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + std::string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName = _EntityName + ucstring(" [") + prospectorName + ucstring("]"); + _EntityName = _EntityName + " [" + prospectorName + "]"; } // Rebuild inscene interface @@ -622,7 +623,7 @@ void CForageSourceCL::displayModifiers() { uint16 qttyDelta = ((uint16)mod.Value) & 0xFF; uint16 qlty = ((uint16)mod.Value) >> 8; - ucstring hpModifier = ucstring(toString("%u ", qttyDelta) + CI18N::get("uittQualityAbbrev") + toString(" %u", qlty)); + string hpModifier = toString("%u ", qttyDelta) + CI18N::get("uittQualityAbbrev") + toString(" %u", qlty); double t = TimeInSec-mod.Time; // Compute the position for the Modifier. CVector pos= namePos + CVector(0.0f, 0.0f, 0.3f+(float)t*1.0f/totalDuration); diff --git a/ryzom/client/src/fx_cl.cpp b/ryzom/client/src/fx_cl.cpp index e1f29fd77..32a764e99 100644 --- a/ryzom/client/src/fx_cl.cpp +++ b/ryzom/client/src/fx_cl.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -75,7 +78,7 @@ bool CFxCL::build( const CEntitySheet *sheet ) if ( (! _FXSheet) || (_FXSheet->PSList.empty()) ) { _BadBuild = true; - nlwarning( "Bad sheet %s for fx", sheet->Id.toString().c_str() ); + nlwarning( "Bad sheet %s for fx", sheet ? sheet->Id.toString().c_str() : "NULL" ); return false; } diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp index 1306c0704..c3163225d 100644 --- a/ryzom/client/src/game_context_menu.cpp +++ b/ryzom/client/src/game_context_menu.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -761,17 +762,17 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide ) uint32 textID = (uint32) _MissionOption[k]->getValue32(); if (textID) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, result); if (!res) { result = NLMISC::CI18N::get("uiMissionOptionNotReceived"); } - if (result == ucstring("Qui etes-vous ?") - || result == ucstring("Wer bist Du?") - || result == ucstring("Who are you?") - || result == ucstring("Quién eres tú?") - || result == ucstring("Кто ты?")) + if (result == string("Qui etes-vous ?") + || result == string("Wer bist Du?") + || result == string("Who are you?") + || result == string("Quién eres tú?") + || result == string("Кто ты?")) { pVTM->setActive(false); } @@ -783,13 +784,13 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide ) } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } @@ -813,7 +814,7 @@ void CGameContextMenu::updateContextMenuWebPage(uint options) uint32 textID = (uint32) _WebPageTitle->getValue32(); if (textID) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, result); if (!res) { @@ -823,12 +824,12 @@ void CGameContextMenu::updateContextMenuWebPage(uint options) } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); } } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); } } @@ -857,7 +858,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options) { CViewTextMenu *pVTM = _TextOutpostState; if (pVTM) - pVTM->setText(ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet))); + pVTM->setText(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)); } // apply the active @@ -893,7 +894,7 @@ void CGameContextMenu::updateContextMenuMissionRing() // if the textId is ok and Flag is set. if ( textId ) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, result); if (!res) { @@ -904,7 +905,7 @@ void CGameContextMenu::updateContextMenuMissionRing() } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } diff --git a/ryzom/client/src/game_context_menu.h b/ryzom/client/src/game_context_menu.h index 5104aad60..499bd5197 100644 --- a/ryzom/client/src/game_context_menu.h +++ b/ryzom/client/src/game_context_menu.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/global.cpp b/ryzom/client/src/global.cpp index 4738835e7..623686f98 100644 --- a/ryzom/client/src/global.cpp +++ b/ryzom/client/src/global.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2017 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -91,7 +91,7 @@ void resetTextContext (const char *font, bool resetInterfaceManager) { if (TextContext != NULL) Driver->deleteTextContext(TextContext); - TextContext = Driver->createTextContext(CPath::lookup(font)); + TextContext = Driver->createTextContext(NLMISC::startsWith(font, "ui") ? font : CPath::lookup(font)); if (TextContext != NULL) TextContext->setKeep800x600Ratio(false); else diff --git a/ryzom/client/src/global.h b/ryzom/client/src/global.h index 8897b3755..ecfa323e0 100644 --- a/ryzom/client/src/global.h +++ b/ryzom/client/src/global.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2017 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013-2019 Jan BOON (Kaetemi) diff --git a/ryzom/client/src/ground_fx_manager.cpp b/ryzom/client/src/ground_fx_manager.cpp index ac5e540e3..41e6895a5 100644 --- a/ryzom/client/src/ground_fx_manager.cpp +++ b/ryzom/client/src/ground_fx_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -524,7 +524,7 @@ void CGroundFXManager::update(const NLMISC::CVectorD &camPos) } if (!fxName.empty()) { - stdFXName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fxName)); + stdFXName = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(fxName)); } // is an fx already attached to the entity ? if (_SortedInstances[k]->HasFX) diff --git a/ryzom/client/src/hair_set.cpp b/ryzom/client/src/hair_set.cpp index 5d44e2857..e196ad836 100644 --- a/ryzom/client/src/hair_set.cpp +++ b/ryzom/client/src/hair_set.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -50,7 +53,7 @@ void CHairSet::init (NLMISC::IProgressCallback &progress) if (item->getShape().find("cheveux", 0) != std::string::npos) { // get race - std::string itemName = NLMISC::toLower(item->getShape()); + std::string itemName = NLMISC::toLowerAscii(item->getShape()); // fortunately, first character of each race is distinct switch(itemName[0]) diff --git a/ryzom/client/src/ig_callback.cpp b/ryzom/client/src/ig_callback.cpp index bf7b41625..e59c844aa 100644 --- a/ryzom/client/src/ig_callback.cpp +++ b/ryzom/client/src/ig_callback.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -200,7 +203,7 @@ void CIGCallback::CIGInstance::instanceGroupAdded() uint numInstances = _IG->getNumInstance(); for(uint k = 0; k < numInstances; ++k) { - TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(_IG->getShapeName(k)))); + TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(_IG->getShapeName(k)))); if (pbIt != PacsPrims.end()) { // compute orientation and position diff --git a/ryzom/client/src/init.cpp b/ryzom/client/src/init.cpp index 5e7b03549..7e4e09521 100644 --- a/ryzom/client/src/init.cpp +++ b/ryzom/client/src/init.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2011 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2010-2019 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify @@ -168,7 +168,7 @@ extern NLMISC::CCmdArgs Args; // Tips of the day count #define RZ_NUM_TIPS 17 -ucstring TipsOfTheDay; +std::string TipsOfTheDay; uint TipsOfTheDayIndex; // includes for following register classes @@ -262,7 +262,7 @@ char *XmlStrdup4NeL (const char *str) #ifdef NL_OS_WINDOWS -static ucstring CurrentErrorMessage; +static std::wstring CurrentErrorMessage; static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM /* lParam */) { @@ -272,19 +272,19 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA { if (CI18N::hasTranslation("TheSagaOfRyzom")) { - if (!SetWindowTextW(hwndDlg, (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str ())) + if (!SetWindowTextW(hwndDlg, nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()))) { nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); } } - SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*) CurrentErrorMessage.c_str ()); + SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*)CurrentErrorMessage.c_str()); if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit")) { - SetDlgItemTextW(hwndDlg, IDOK, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxExit").c_str ()); + SetDlgItemTextW(hwndDlg, IDOK, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxExit").c_str())); } if (CI18N::hasTranslation("uiRyzomErrorMsgBoxHelp")) { - SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxHelp").c_str ()); + SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxHelp").c_str())); } RECT rect; RECT rectDesktop; @@ -338,12 +338,10 @@ void ExitClientError (const char *format, ...) } #ifdef NL_OS_WINDOWS - CurrentErrorMessage.fromUtf8(str); + CurrentErrorMessage = NLMISC::utf8ToWide(str); DialogBox(HInstance, MAKEINTRESOURCE(IDD_ERROR_HELP_MESSAGE_BOX), NULL, ExitClientErrorDialogProc); /* - ucstring ucstr; - ucstr.fromUtf8 (str); - MessageBoxW (NULL, (WCHAR*)ucstr.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONERROR); + MessageBoxW (NULL, nlUtf8ToWide(str.c_str()), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR); */ #else fprintf (stderr, "%s\n", str); @@ -357,18 +355,18 @@ void ExitClientError (const char *format, ...) } // Use this function to return an information to the final user -void ClientInfo (const ucstring &message) +void ClientInfo (const std::string &message) { #ifdef NL_OS_WINDOWS - MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONINFORMATION); + MessageBoxW(NULL, nlUtf8ToWide(message.c_str()), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION); #endif } // Use this function to ask a question to the final user -bool ClientQuestion (const ucstring &message) +bool ClientQuestion (const std::string &message) { #ifdef NL_OS_WINDOWS - return MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_YESNO|MB_ICONQUESTION) != IDNO; + return MessageBoxW(NULL, nlUtf8ToWide(message.c_str()), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO; #else return false; #endif @@ -379,7 +377,7 @@ void selectTipsOfTheDay (uint /* tips */) /* todo tips of the day uncomment tips %= RZ_NUM_TIPS; TipsOfTheDayIndex = tips; - ucstring title = CI18N::get ("uiTipsTitle"); + string title = CI18N::get ("uiTipsTitle"); title += toString (tips+1); title += " : "; TipsOfTheDay = title+CI18N::get ("uiTips"+toString (tips));*/ @@ -536,12 +534,12 @@ void checkDriverVersion() uint i; for (i=0; i< sizeofarray(driversVersion); i++) { - string lwr = toLower(deviceName); + string lwr = toLowerAscii(deviceName); if ((lwr.find (driversTest[i])!=string::npos) && (driversNTest[i]==NULL || lwr.find (driversNTest[i])==string::npos)) { if (driverVersion < driversVersion[i]) { - ucstring message = CI18N::get ("uiUpdateDisplayDriversNotUpToDate") + "\n\n"; + string message = CI18N::get ("uiUpdateDisplayDriversNotUpToDate") + "\n\n"; // message += CI18N::get ("uiUpdateDisplayDriversVendor") + driversVendor[i] + "\n"; message += CI18N::get ("uiUpdateDisplayDriversCard") + deviceName + "\n"; message += CI18N::get ("uiUpdateDisplayDriversCurrent") + getVersionString (driverVersion) + "\n"; @@ -578,7 +576,7 @@ void checkDriverDepth () #else if (mode.Depth != 16 && mode.Depth != 24 && mode.Depth != 32) #endif - ExitClientError (CI18N::get ("uiDesktopNotIn32").toUtf8().c_str ()); + ExitClientError (CI18N::get ("uiDesktopNotIn32").c_str ()); } } @@ -937,7 +935,7 @@ void prelogInit() initDebugMemory(); // Load the application configuration. - ucstring nmsg("Loading config file..."); + string nmsg("Loading config file..."); ProgressBar.newMessage (nmsg); ClientCfg.init(ConfigFileName); @@ -999,7 +997,7 @@ void prelogInit() FPU_CHECKER_ONCE // Set the data path for the localisation. - const ucstring nmsg("Loading I18N..."); + const string nmsg("Loading I18N..."); ProgressBar.newMessage ( nmsg ); FPU_CHECKER_ONCE @@ -1058,7 +1056,7 @@ void prelogInit() if(Driver == NULL) { - ExitClientError (CI18N::get ("Can_t_load_the_display_driver").toUtf8().c_str ()); + ExitClientError (CI18N::get ("Can_t_load_the_display_driver").c_str ()); // ExitClientError() call exit() so the code after is never called return; } @@ -1149,14 +1147,14 @@ void prelogInit() string msg; if (mode.Windowed) { - msg = CI18N::get ("can_t_create_a_window_display").toUtf8(); + msg = CI18N::get ("can_t_create_a_window_display"); } else { - msg = CI18N::get ("can_t_create_a_fullscreen_display").toUtf8(); + msg = CI18N::get ("can_t_create_a_fullscreen_display"); } msg += " (%dx%d %d "; - msg += CI18N::get ("bits").toUtf8 (); + msg += CI18N::get ("bits"); msg += ")"; ExitClientError (msg.c_str (), mode.Width, mode.Height, mode.Depth); // ExitClientError() call exit() so the code after is never called @@ -1177,7 +1175,9 @@ void prelogInit() #ifdef NL_OS_WINDOWS +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().init(); +#endif if (SlashScreen) DestroyWindow (SlashScreen); @@ -1283,7 +1283,7 @@ void prelogInit() std::string deviceName; uint64 driverVersion; CSystemInfo::getVideoInfo(deviceName, driverVersion); - deviceName = NLMISC::toLower(deviceName); + deviceName = NLMISC::toLowerAscii(deviceName); // for radeon 7200, patch because agp crash with agp with OpenGL -> don't display the message if (!(Driver->getNbTextureStages() <= 3 && strstr(deviceName.c_str(), "radeon"))) {*/ @@ -1495,7 +1495,7 @@ void initBotObjectSelection() { // IS the item a valid one ? CSheetId itemId; - if(itemId.buildSheetId(NLMISC::toLower(strShape))) + if(itemId.buildSheetId(NLMISC::toLowerAscii(strShape))) { // Get this item sheet ? CItemSheet *itemSheet= dynamic_cast(SheetMngr.get(itemId)); @@ -1532,7 +1532,7 @@ void postlogInit() Driver->clearBuffers(CRGBA::Black); Driver->swapBuffers(); CNiceInputAuto niceInputs; - ucstring nmsg; + string nmsg; try { diff --git a/ryzom/client/src/init_main_loop.cpp b/ryzom/client/src/init_main_loop.cpp index deeda2149..9d1ebf784 100644 --- a/ryzom/client/src/init_main_loop.cpp +++ b/ryzom/client/src/init_main_loop.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2017 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -225,18 +225,18 @@ struct CStatThread : public NLMISC::IRunnable string cookie() { string name; - if(UserEntity && !UserEntity->getEntityName().toString().empty()) - name = UserEntity->getEntityName().toString(); + if(UserEntity && !UserEntity->getEntityName().empty()) + name = UserEntity->getEntityName(); std::string userid = toString("u%d", NetMngr.getUserId())+name; - return toUpper(getMD5((const uint8 *)userid.c_str(), (uint32)userid.size()).toString()); + return toUpperAscii(getMD5((const uint8 *)userid.c_str(), (uint32)userid.size()).toString()); } // return true if we sent the connect because we have all information bool connect() { //nlinfo("connect"); - if(!UserEntity || UserEntity->getEntityName().toString().empty()) + if(!UserEntity || UserEntity->getEntityName().empty()) return false; referer = ContinentMngr.getCurrentContinentSelectName(); @@ -244,7 +244,7 @@ struct CStatThread : public NLMISC::IRunnable std::string params; addParam(params, "ra", randomString()); std::string session = toString("%d%d", NetMngr.getUserId(), CTime::getSecondsSince1970()); - addParam(params, "sessioncookie", toUpper(getMD5((const uint8 *)session.c_str(), (uint32)session.size()).toString())); + addParam(params, "sessioncookie", toUpperAscii(getMD5((const uint8 *)session.c_str(), (uint32)session.size()).toString())); addParam(params, "cookie", cookie()); addParam(params, "browsertoken", "X"); addParam(params, "platformtoken", "Win32"); @@ -260,7 +260,7 @@ struct CStatThread : public NLMISC::IRunnable timeinfo = localtime ( &rawtime ); strftime (buffer,80,"%H%%3A%M", timeinfo); addParam(params, "localtime", buffer); - addParam(params, "cv_name", UserEntity->getEntityName().toUtf8()); + addParam(params, "cv_name", UserEntity->getEntityName()); //addParam(params, "cv_email", ""); //addParam(params, "cv_avatar", ""); addParam(params, "cv_Userid", toString(NetMngr.getUserId())); @@ -469,7 +469,7 @@ void initMainLoop() // Progress bar for init_main_loop() ProgressBar.reset (BAR_STEP_INIT_MAIN_LOOP); - ucstring nmsg; + string nmsg; FPU_CHECKER_ONCE @@ -1017,7 +1017,7 @@ void initMainLoop() // PreLoad Fauna and Characters if (!ClientCfg.Light && ClientCfg.PreCacheShapes) { - ucstring nmsg("Loading character shapes ..."); + string nmsg("Loading character shapes ..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); @@ -1071,14 +1071,18 @@ void initMainLoop() ProgressBar.pushCropedValues (0, 0.25f); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, "data/3d/common/characters/shapes", "*.shape", false, &ProgressBar); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/characters/shapes" : ClientCfg.PreLoadPath + "/characters_shapes", + "*.shape", false, &ProgressBar); } ProgressBar.popCropedValues (); ProgressBar.progress (0.25f); ProgressBar.pushCropedValues (0.25f,0.5f); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, "data/3d/common/characters/skeletons", "*.skel", false, &ProgressBar); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/characters/skeletons" : ClientCfg.PreLoadPath + "/characters_skeletons", + "*.skel", false, &ProgressBar); } ProgressBar.popCropedValues (); } @@ -1126,14 +1130,18 @@ void initMainLoop() ProgressBar.pushCropedValues (0.5f, 0.75f); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, "data/3d/common/fauna/shapes", "*.shape", false, &ProgressBar); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/fauna/shapes" : ClientCfg.PreLoadPath + "/fauna_shapes", + "*.shape", false, &ProgressBar); } ProgressBar.popCropedValues (); ProgressBar.progress (0.75f); ProgressBar.pushCropedValues (0.75f,1); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, "data/3d/common/fauna/skeletons", "*.skel", false, &ProgressBar); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheName, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/fauna/skeletons" : ClientCfg.PreLoadPath + "/fauna_skeletons", + "*.skel", false, &ProgressBar); } ProgressBar.popCropedValues (); } @@ -1174,14 +1182,18 @@ void initMainLoop() ProgressBar.pushCropedValues (0.0f, 0.5f); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheNameFX, "data/3d/common/sfx", "*.ps", true, &ProgressBar, preloadFXTextures); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheNameFX, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/sfx" : ClientCfg.PreLoadPath + "/sfx", + "*.ps", true, &ProgressBar, preloadFXTextures); } ProgressBar.popCropedValues (); ProgressBar.progress (0.5f); ProgressBar.pushCropedValues (0.5f,1); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheNameFX, "data/3d/common/sfx", "*.shape", true, &ProgressBar, preloadFXTextures); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheNameFX, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/sfx" : ClientCfg.PreLoadPath + "/sfx", + "*.shape", true, &ProgressBar, preloadFXTextures); } ProgressBar.popCropedValues (); } @@ -1214,7 +1226,9 @@ void initMainLoop() ProgressBar.pushCropedValues (0.0f, 1.f); if(!DBG_DisablePreloadShape) { - Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheNameObjects, "data/3d/common/objects", "*.shape", true, &ProgressBar, preloadObjectTextures); + Driver->getShapeBank()->preLoadShapesFromDirectory(PreLoadCacheNameObjects, + ClientCfg.PreLoadPath.empty() ? "data/3d/common/objects" : ClientCfg.PreLoadPath + "/objects", + "*.shape", true, &ProgressBar, preloadObjectTextures); } ProgressBar.popCropedValues (); } @@ -1702,6 +1716,6 @@ void initBloomConfigUI() else { if(group) - group->setDefaultContextHelp(ucstring("")); + group->setDefaultContextHelp(std::string()); } } diff --git a/ryzom/client/src/input.cpp b/ryzom/client/src/input.cpp index 2b0b83c96..cdd813a4a 100644 --- a/ryzom/client/src/input.cpp +++ b/ryzom/client/src/input.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) diff --git a/ryzom/client/src/interface_v3/action_handler_base.cpp b/ryzom/client/src/interface_v3/action_handler_base.cpp index 6bb27d772..925fc7827 100644 --- a/ryzom/client/src/interface_v3/action_handler_base.cpp +++ b/ryzom/client/src/interface_v3/action_handler_base.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/action_handler_debug.cpp b/ryzom/client/src/interface_v3/action_handler_debug.cpp index 8c8c37a39..2b123bce9 100644 --- a/ryzom/client/src/interface_v3/action_handler_debug.cpp +++ b/ryzom/client/src/interface_v3/action_handler_debug.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp index 00a07dd39..d3fd022ad 100644 --- a/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -27,6 +28,7 @@ using namespace NLMISC; #include "nel/gui/action_handler.h" #include "nel/gui/group_editbox.h" +#include "nel/misc/utf_string_view.h" #include "interface_manager.h" #include "../client_chat_manager.h" #include "people_interraction.h" @@ -56,7 +58,7 @@ extern CClientChatManager ChatMngr; // *************************************************************************** // used for character classifiction (when the user press Ctrl-arrow) -static inline uint getCharacterCategory(ucchar c) +static inline uint getCharacterCategory(u32char c) { if (c == ' ') return 0; if (c > 127 || isalpha((char) c)) return 1; // alpha & other characters @@ -69,7 +71,7 @@ static inline uint getCharacterCategory(ucchar c) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) * It returns the new index */ -static uint skipUCCharsRight(uint startPos, const ucstring &str) +static uint skipUCCharsRight(uint startPos, const ::u32string &str) { uint pos = startPos; uint endIndex = (uint)str.length(); @@ -86,7 +88,7 @@ static uint skipUCCharsRight(uint startPos, const ucstring &str) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) * It returns the new index */ -static uint skipUCCharsLeft(uint startPos, const ucstring &str) +static uint skipUCCharsLeft(uint startPos, const ::u32string &str) { uint pos = startPos; -- pos; @@ -287,11 +289,11 @@ class CAHEditGotoLineBegin : public CAHEdit // go to the start of line if (_GroupEdit->getViewText()) { - sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length()); + sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length()); if (line == -1) return; - sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPrompt().length()); + sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPromptRef().length()); if (newPos == -1) return; - _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(false); } } @@ -309,20 +311,20 @@ class CAHEditGotoLineEnd : public CAHEdit { if (_GroupEdit->getViewText()->getMultiLine()) { - sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd()); + sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd()); if (line == -1) return; sint newPos; bool endOfPreviousLine; _GroupEdit->getViewText()->getLineEndIndex(line, newPos, endOfPreviousLine); if (newPos != -1) { - _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(endOfPreviousLine); } } else { - _GroupEdit->setCursorPos((sint32)_GroupEdit->getPrompt().length() + (sint32)_GroupEdit->getInputString().length()); + _GroupEdit->setCursorPos((sint32)_GroupEdit->getPromptRef().length() + (sint32)_GroupEdit->getInputString().length()); } } } @@ -362,7 +364,7 @@ class CAHEditPreviousLine : public CAHEdit if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine())) { // Get the start of the string. - ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); + ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); // Search all historic string that match startStr. for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++) @@ -377,7 +379,7 @@ class CAHEditPreviousLine : public CAHEdit } else if (_GroupEdit->getViewText()->getMultiLine()) { - uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(); + uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(); if ( (_GroupEdit->getCursorPos() == (sint32) _GroupEdit->getInputStringRef().length() && _GroupEdit->getViewText()->getNumLine() == 1) || _GroupEdit->getViewText()->getLineFromIndex(cursorPosInText, _GroupEdit->isCursorAtPreviousLineEnd()) == 0 @@ -395,7 +397,7 @@ class CAHEditPreviousLine : public CAHEdit _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); if (newLineEnd) { - _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(true); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); @@ -416,7 +418,7 @@ class CAHEditPreviousLine : public CAHEdit { _GroupEdit->setCursorPos(newCharIndex + 1); } - _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length()); sint32 newpos = _GroupEdit->getCursorPos(); clamp(newpos, (sint32) 0, (sint32)_GroupEdit->getInputStringRef().size()); _GroupEdit->setCursorPos(newpos); @@ -434,7 +436,7 @@ class CAHEditNextLine : public CAHEdit if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0) { // Get the start of the string. - ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); + ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); // Search all historic string that match startStr. for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--) @@ -451,7 +453,7 @@ class CAHEditNextLine : public CAHEdit { float cx, cy; float height; - _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height); + _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height); if (cy != 0) { cy -= height; @@ -460,7 +462,7 @@ class CAHEditNextLine : public CAHEdit _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); if (newLineEnd) { - _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(true); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); @@ -479,9 +481,9 @@ class CAHEditNextLine : public CAHEdit } else { - _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPrompt().length()))); + _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPromptRef().length()))); } - _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length()); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); _GroupEdit->setCursorPos(newPos); @@ -520,8 +522,8 @@ protected: // else cut forwards else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length()) { - ucstring inputString = _GroupEdit->getInputStringRef(); - ucstring::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); + ::u32string inputString = _GroupEdit->getInputStringRef(); + ::u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); inputString.erase(it); _GroupEdit->setInputStringRef (inputString); if (!_GroupEdit->getAHOnChange().empty()) @@ -638,15 +640,14 @@ class CAHEditExpandOrCycleTell : public CAHEdit void actionPart () { // If the line starts with '/tell ', do not try to expand - static const ucstring TELL_STR("/tell "); - if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR) + if (!NLMISC::startsWith(_GroupEdit->getInputString(), "/tell ")) { if (_GroupEdit->expand()) return; } CInterfaceManager *im = CInterfaceManager::getInstance(); if (!im->isInGame()) return; // there was no / at the start of the line so try to cycle through the last people on which a tell was done - const ucstring *lastTellPeople = ChatMngr.cycleLastTell(); + const string *lastTellPeople = ChatMngr.cycleLastTell(); if (!lastTellPeople) return; // Get chat box from ist edit box // If it isn't a user chat or the main chat, just display 'tell' with the name. Otherwise, change the target of the window @@ -660,7 +661,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit else { // it is not a filtered chat, display 'tell' (must be ingame) - _GroupEdit->setCommand(ucstring("tell ") + *lastTellPeople + (ucchar) ' ', false); + _GroupEdit->setCommand("tell " + (*lastTellPeople) + ' ', false); } } }; diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index b200205be..60690428f 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -192,9 +192,9 @@ public: CEntityCL *selection = EntitiesMngr.entity(UserEntity->selection()); if (selection && selection->Type == CEntityCL::Player) { - ucstring name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName()); + string name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName()); if (name.empty()) return; - CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name.toString()); + CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name); } } protected: @@ -732,7 +732,7 @@ public: CEntityCL *entity = EntitiesMngr.entity(trader); if (entity) { - ucstring playerName = entity->getEntityName(); + string playerName = entity->getEntityName(); if (!playerName.empty()) { PeopleInterraction.askAddContact(playerName, &PeopleInterraction.FriendList); @@ -1166,7 +1166,7 @@ public: game_exit_request = true; ryzom_exit_request = true; - const string msgName = "CONNECTION:CLIENT_QUIT_REQUEST"; + const char *msgName = "CONNECTION:CLIENT_QUIT_REQUEST"; CBitMemStream out; nlverify(GenericMsgHeaderMngr.pushNameToStream(msgName, out)); bool bypassDisconnectionTimer = FarTP.isFastDisconnectGranted() && (!IsInRingSession); // no need on a ring shard, as it's very short @@ -1334,7 +1334,7 @@ class CSelectItemSheet : public IActionHandler // check if user has the level to use the item (applies to item & plans) if (ctrlSheet->getSheetCategory() == CDBCtrlSheet::Item) { - if (csg->getName() == "buy_selection") + if (csg && csg->getName() == "buy_selection") { const CItemSheet *is = ctrlSheet->asItemSheet(); if (is) @@ -1358,19 +1358,19 @@ class CSelectItemSheet : public IActionHandler // display msg in the system infos if (!canUse) { - ucstring msg = CI18N::get("msgCantUseItem"); + string msg = CI18N::get("msgCantUseItem"); string cat = getStringCategory(msg, msg); im->displaySystemInfo(msg, cat); } if (!canBuild) { - ucstring msg = CI18N::get("msgCantBuild"); + string msg = CI18N::get("msgCantBuild"); string cat = getStringCategory(msg, msg); im->displaySystemInfo(msg, cat); } if (!canUseBuiltItem) { - ucstring msg = CI18N::get("msgCantUseBuiltItem"); + string msg = CI18N::get("msgCantUseBuiltItem"); string cat = getStringCategory(msg, msg); im->displaySystemInfo(msg, cat); } @@ -1489,7 +1489,7 @@ void beastOrder (const std::string &orderStr, const std::string &beastIndexStr, else { // execute the order. - const string msgName = "ANIMALS:BEAST"; + const char *msgName = "ANIMALS:BEAST"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -1500,7 +1500,7 @@ void beastOrder (const std::string &orderStr, const std::string &beastIndexStr, NetMngr.push(out); } else - nlwarning(" : unknown message name : '%s'.", msgName.c_str()); + nlwarning(" : unknown message name : '%s'.", msgName); } } @@ -1943,13 +1943,13 @@ public: sint32 Slot; - bool cbIDStringReceived(ucstring &inout) + bool cbIDStringReceived(string &inout) { if (UserEntity != NULL) { if (UserEntity->selection() == Slot) { - ucstring copyInout = inout; + string copyInout = inout; CStringPostProcessRemoveTitle::cbIDStringReceived(inout); if (inout.empty()) { @@ -1959,11 +1959,11 @@ public: if (pChar != NULL) womanTitle = pChar->getGender() == GSGENDER::female; - STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); + copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); // Sometimes translation contains another title - ucstring::size_type pos = copyInout.find('$'); - if (pos != ucstring::npos) + string::size_type pos = copyInout.find('$'); + if (pos != string::npos) { copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); } @@ -1987,7 +1987,7 @@ public: sint32 Slot; - bool cbIDStringReceived(ucstring &inout) + bool cbIDStringReceived(string &inout) { if (UserEntity != NULL) { @@ -2038,8 +2038,8 @@ class CActionHandlerSetTargetName : public IActionHandler { sint32 nSlot = (sint32)evValue.getInteger(); - ucstring TargetName; - ucstring TargetTitle; + string TargetName; + string TargetTitle; // Get from nSlot if (nSlot > -1) @@ -2074,9 +2074,9 @@ class CActionHandlerSetTargetName : public IActionHandler // Set to target CInterfaceExprValue evUCStr; TargetName = STRING_MANAGER::CStringManagerClient::getLocalizedName(TargetName); - evUCStr.setUCString(TargetName); + evUCStr.setString(TargetName); CInterfaceLink::setTargetProperty(sNameTarget, evUCStr); - evUCStr.setUCString(TargetTitle); + evUCStr.setString(TargetTitle); CInterfaceLink::setTargetProperty(sTitleTarget, evUCStr); } } @@ -2116,7 +2116,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler pVBR->setColor(CRGBA(0,0,0,0)); if (pTooltip) - pTooltip->setDefaultContextHelp(ucstring("")); + pTooltip->setDefaultContextHelp(std::string()); return; } @@ -2169,7 +2169,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler pVBR->setColor(CRGBA(0,0,0,0)); if (pTooltip) - pTooltip->setDefaultContextHelp(ucstring("")); + pTooltip->setDefaultContextHelp(std::string()); return; } @@ -2194,7 +2194,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler CCtrlBase *tooltip = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:header_opened:force")); if (tooltip) { - ucstring str; + string str; if (nForceRegion == 1) nForceRegion = 2; @@ -2424,28 +2424,27 @@ class CAHTarget : public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { - ucstring entityName; - entityName.fromUtf8(getParam(Params, "entity")); + string entityName = getParam(Params, "entity"); if (entityName.empty()) return; string completeMatch = getParam(Params, "prefer_complete_match"); bool quiet = (getParam (Params, "quiet") == "true"); - vector keywords; - NLMISC::splitUCString(entityName, ucstring(" "), keywords); - if (!keywords.empty() && keywords[0].size() > 0 && keywords[0][0] == (ucchar)'"') + vector keywords; + NLMISC::splitString(entityName, " ", keywords); + if (!keywords.empty() && keywords[0].size() > 0 && keywords[0][0] == '"') { // entity name is in quotes, do old style match with 'starts with' filter // search for optional second parameter from old command for prefer_complete_match param keywords.clear(); - ucstring::size_type lastOf = entityName.rfind(ucstring("\"")); + string::size_type lastOf = entityName.rfind("\""); if (lastOf == 0) - lastOf = ucstring::npos; + lastOf = string::npos; // override the value only when there is no 'prefer_complete_match' parameter set if (completeMatch.empty() && lastOf < entityName.size()) - completeMatch = trim(entityName.substr(lastOf+1).toUtf8()); + completeMatch = trim(entityName.substr(lastOf+1)); entityName = entityName.substr(1, lastOf-1); } @@ -2474,7 +2473,7 @@ class CAHTarget : public IActionHandler if (entity == NULL) { //Get the entity with a sheetName - entity = EntitiesMngr.getEntityBySheetName(entityName.toUtf8()); + entity = EntitiesMngr.getEntityBySheetName(entityName); } if (entity && entity->properties().selectable() && !entity->getDisplayName().empty()) @@ -2758,8 +2757,7 @@ class CAHAssist : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { // Get the entity name to target - ucstring entityName; - entityName.fromUtf8 (getParam (Params, "entity")); + string entityName = getParam (Params, "entity"); if (!entityName.empty()) { // Get the entity @@ -2822,24 +2820,6 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { - /* // Previous version (multiple pressed on a desktop change a central window - uint desktop; - fromString(Params, desktop); - if (desktop getDbProp(dbNames[desktop], false); - if (pNL != NULL) - sValue = NLMISC::toString((sint32)pNL->getValue64()); - vector vecStr; - vecStr.push_back(procNames[desktop]); - vecStr.push_back(sValue); - CWidgetManager::getInstance()->runProcedure(procNames[desktop], NULL, vecStr); - }*/ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows")); if (pGC == NULL) @@ -2850,11 +2830,14 @@ public: CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows:close"); if (pIE != NULL) pIE->setActive(false); + bool switchDesktop = false; + CActionsManager *pAM = &Actions; if (!pAM->valide(CAction::CName("set_desktop",Params.c_str()))) { pGC->setActive(false); _FirstTime = true; + switchDesktop = true; } else // Key is down { @@ -2862,11 +2845,7 @@ public: if (_FirstTime) { _FirstTime = false; - - vector vecStr; - vecStr.push_back("tb_setdesktop"); - vecStr.push_back(Params); - CWidgetManager::getInstance()->runProcedure("tb_setdesktop", NULL, vecStr); + switchDesktop = true; } else // Not the first time { @@ -2876,6 +2855,13 @@ public: CWidgetManager::getInstance()->setTopWindow(pGC); } } + if (switchDesktop) + { + vector vecStr; + vecStr.push_back("tb_setdesktop"); + vecStr.push_back(Params); + CWidgetManager::getInstance()->runProcedure("tb_setdesktop", NULL, vecStr); + } } private: bool _FirstTime; @@ -3025,7 +3011,7 @@ void updateVRDevicesComboUI(bool enable) { std::stringstream displayname; displayname << std::string("[") << VRDeviceCache[i].first << "] [" << VRDeviceCache[i].second << "]"; - pCB->addText(ucstring(displayname.str())); + pCB->addText(displayname.str()); if (ClientCfg.VRDisplayDevice == VRDeviceCache[i].first) { if (selectedDevice == -1 || ClientCfg.VRDisplayDeviceId == VRDeviceCache[i].second) @@ -3039,7 +3025,7 @@ void updateVRDevicesComboUI(bool enable) // configured device not found, add a dummy std::stringstream displayname; displayname << std::string("[") << ClientCfg.VRDisplayDevice << "] [" << ClientCfg.VRDisplayDeviceId<< "] [DEVICE NOT FOUND]"; - pCB->addText(ucstring(displayname.str())); + pCB->addText(displayname.str()); selectedDevice = VRDeviceCache.size(); } NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_VR_DEVICE_DB)->setValue32(-1); @@ -3074,7 +3060,7 @@ public: { pCB->resetTexts(); for (sint j = 0; j < (sint)stringModeList.size(); j++) - pCB->addText(ucstring(stringModeList[j])); + pCB->addText(stringModeList[j]); } // frequencies @@ -3083,7 +3069,7 @@ public: { pCB->resetTexts(); for (sint j = 0; j < (sint)stringFreqList.size(); j++) - pCB->addText(ucstring(stringFreqList[j])); + pCB->addText(stringFreqList[j]); } // -1 is important to indicate we set this value in edit mode @@ -3129,7 +3115,7 @@ public: while (anisotropic <= maxAnisotropic) { - pCB->addText(ucstring(NLMISC::toString("%dx", anisotropic))); + pCB->addText(NLMISC::toString("%dx", anisotropic)); if (ClientCfg.AnisotropicFilter == anisotropic) nAnisotropic = i; @@ -3234,7 +3220,7 @@ class CHandlerGameConfigMode : public IActionHandler // Get W, H sint w,h; { - string vidModeStr = pCB->getText(nVideModeNb).toString(); + string vidModeStr = pCB->getText(nVideModeNb); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); fromString(tmp, w); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); @@ -3274,7 +3260,7 @@ class CHandlerGameConfigMode : public IActionHandler { pCB->resetTexts(); for (j = 0; j < (sint)stringFreqList.size(); j++) - pCB->addText(ucstring(stringFreqList[j]) + " Hz"); + pCB->addText(stringFreqList[j] + " Hz"); } NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq); @@ -3476,7 +3462,7 @@ class CHandlerGameConfigApply : public IActionHandler CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB != NULL ) { - string vidModeStr = pCB->getText(nVideModeNb).toString(); + string vidModeStr = pCB->getText(nVideModeNb); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); fromString(tmp, w); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); @@ -3490,7 +3476,7 @@ class CHandlerGameConfigApply : public IActionHandler CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if( pCB != NULL ) { - string vidFreqStr = pCB->getText(nVideoFreqNb).toString(); + string vidFreqStr = pCB->getText(nVideoFreqNb); fromString(vidFreqStr, freq); } } @@ -3809,7 +3795,7 @@ class CHandlerSetInterfaceScale : public IActionHandler } } - ucstring help("/setuiscale "+toString("%.1f .. %.1f", ClientCfg.InterfaceScale_min, ClientCfg.InterfaceScale_max)); + string help = "/setuiscale "+toString("%.1f .. %.1f", ClientCfg.InterfaceScale_min, ClientCfg.InterfaceScale_max); CInterfaceManager::getInstance()->displaySystemInfo(help); } }; @@ -3993,7 +3979,7 @@ public: // display parry mode msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserModeParry"); + string msg = CI18N::get("msgUserModeParry"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -4010,7 +3996,7 @@ public: // display dodge mode msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserModeDodge"); + string msg = CI18N::get("msgUserModeDodge"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -4037,8 +4023,7 @@ REGISTER_ACTION_HANDLER(CHandlerSelectProtectedSlot, "select_protected_slot"); // *************************************************************************** // Common code -//static void fillPlayerBarText(ucstring &str, const string &dbScore, const string &dbScoreMax, const string &ttFormat) -static void fillPlayerBarText(ucstring &str, const string &dbScore, SCORES::TScores score, const string &ttFormat) +static void fillPlayerBarText(std::string &str, const string &dbScore, SCORES::TScores score, const string &ttFormat) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCDBNodeLeaf *node; @@ -4068,7 +4053,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "HP", SCORES::hit_points, "uittPlayerLifeFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4085,7 +4070,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "STA", SCORES::stamina, "uittPlayerStaminaFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4102,7 +4087,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "SAP", SCORES::sap, "uittPlayerSapFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4119,7 +4104,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "FOCUS", SCORES::focus, "uittPlayerFocusFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4149,7 +4134,7 @@ public: maxVal= node->getValue32(); // Replace in the formated text - ucstring str= CI18N::get("uittBulkFormat"); + string str= CI18N::get("uittBulkFormat"); strFindReplace(str, "%v", toString("%.2f", val) ); strFindReplace(str, "%m", toString(maxVal) ); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4545,7 +4530,7 @@ public: if( sCustomPhrase.empty() ) { // Create the message and send. - const string msgName = "COMMAND:EMOTE"; + static const char *msgName = "COMMAND:EMOTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4555,16 +4540,16 @@ public: //nlinfo("impulseCallBack : %s %d %d sent", msgName.c_str(), (uint32)behavToSend, phraseNbToSend); } else - nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + nlwarning("command 'emote': unknown message named '%s'.", msgName); } else { // Create the message and send. - const string msgName = "COMMAND:CUSTOM_EMOTE"; + static const char *msgName = "COMMAND:CUSTOM_EMOTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { - ucstring ucstr; + ucstring ucstr; // FIXME: UTF-8 (serial) ucstr.fromUtf8(sCustomPhrase); if( sCustomPhrase == "none" ) @@ -4573,7 +4558,7 @@ public: { // display "no animation for emote" CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCustomizedEmoteNoAnim"); + string msg = CI18N::get("msgCustomizedEmoteNoAnim"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; @@ -4581,16 +4566,16 @@ public: } else { - ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; + ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; // FIXME: UTF-8 (serial) } out.serialEnum(behavToSend); - out.serial(ucstr); + out.serial(ucstr); // FIXME: UTF-8 (serial) NetMngr.push(out); //nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str()); } else - nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + nlwarning("command 'emote': unknown message named '%s'.", msgName); } } }; @@ -4618,7 +4603,7 @@ public: CViewText *pVT = dynamic_cast(pIG->getView("t")); if (!pVT) break; - names.push_back(toUpper(pVT->getText().toUtf8())); + names.push_back(toUpper(pVT->getText())); } if (names.size() != nbChilds) @@ -4628,7 +4613,7 @@ public: } std::locale loc(""); - const std::collate& coll = std::use_facet >(loc); + const std::collate& coll = std::use_facet >(loc); // FIXME: Probably does not work for(uint i = 0; i < nbChilds - 1; ++i) { diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index 814ae65b0..632c7d578 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -88,14 +89,14 @@ using namespace STRING_MANAGER; // STATIC FUNCTIONS DECLARATIONS // /////////////////////////////////// static void setupCreatorName(CSheetHelpSetup &setup); -static void setHelpText(CSheetHelpSetup &setup, const ucstring &text); +static void setHelpText(CSheetHelpSetup &setup, const string &text); static void setHelpTextID(CSheetHelpSetup &setup, sint32 id); static void fillSabrinaPhraseListBrick(const CSPhraseCom &phrase, IListSheetBase *listBrick); static void setupListBrickHeader(CSheetHelpSetup &setup); static void hideListBrickHeader(CSheetHelpSetup &setup); static void setupHelpPage(CInterfaceGroup *window, const string &url); -static void setupHelpTitle(CInterfaceGroup *group, const ucstring &title); +static void setupHelpTitle(CInterfaceGroup *group, const string &title); static void setHelpCtrlSheet(CSheetHelpSetup &setup, uint32 sheetId); // Setup help for an item in a window (type is known) @@ -186,7 +187,7 @@ void CInterfaceHelp::initWindows() // add observers for the update of phrase help texts (depends of weight of equipped weapons) for (uint i = 0; i < MAX_HANDINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -209,7 +210,7 @@ void CInterfaceHelp::release() // add observers for the update of phrase help texts (depends of weight of equipped weapons) for (uint i = 0; i < MAX_HANDINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -564,7 +565,7 @@ void CInterfaceHelp::updateWindowSPhraseTexts() */ class CHandlerCloseHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceHelp::closeAll(); } @@ -577,7 +578,7 @@ REGISTER_ACTION_HANDLER( CHandlerCloseHelp, "close_help"); */ class CHandlerOpenItemHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (cs != NULL && cs->getSheetId()!=0 ) @@ -608,7 +609,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenItemHelp, "open_item_help"); */ class CHandlerOpenPactHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (cs != NULL && cs->getSheetId()!=0 ) @@ -632,7 +633,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenPactHelp, "open_pact_help"); */ class CHandlerOpenTitleHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { // display web profile if necessary if (getParam(sParams, "from") == "contact") @@ -655,10 +656,10 @@ class CHandlerOpenTitleHelp : public IActionHandler sint index = peopleList->getIndexFromContainerID(fatherGC->getId()); if (index == -1) return; - ucstring name = peopleList->getName(index); + string name = peopleList->getName(index); if ( ! name.empty()) { - CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)CEntityCL::Player)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name+"|ptype="+toString((int)CEntityCL::Player)); } return; } @@ -669,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler if (selection == NULL) return; //if(selection->isNPC()) { - ucstring name = selection->getEntityName(); + string name = selection->getEntityName(); if(name.empty()) { // try to get the name from the string manager (for npc) @@ -678,7 +679,7 @@ class CHandlerOpenTitleHelp : public IActionHandler { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); pSMC->getString (nDBid, name); - ucstring copyName = name; + string copyName = name; name = CEntityCL::removeTitleAndShardFromName(name); if (name.empty()) { @@ -688,7 +689,7 @@ class CHandlerOpenTitleHelp : public IActionHandler woman = pChar->getGender() == GSGENDER::female; // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(copyName); + string strNewTitle = CEntityCL::getTitleFromName(copyName); // retrieve the translated string if (!strNewTitle.empty()) @@ -699,7 +700,7 @@ class CHandlerOpenTitleHelp : public IActionHandler } } if(!name.empty()) - CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)selection->Type)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name+"|ptype="+toString((int)selection->Type)); return; } } @@ -715,8 +716,8 @@ class CHandlerOpenTitleHelp : public IActionHandler // Get name and title // ------------------ - ucstring name; - ucstring title; + string name; + string title; bool reservedTitle = false; string sFrom = getParam(sParams, "from"); if (sFrom == "target") @@ -763,21 +764,21 @@ class CHandlerOpenTitleHelp : public IActionHandler // Display all infos found // ----------------------- - ucstring titleText = CI18N::get("uihelpTitleFormat"); - strFindReplace(titleText, "%name", name.toString()); + string titleText = CI18N::get("uihelpTitleFormat"); + strFindReplace(titleText, "%name", name); // Display title - ucstring::size_type p1 = title.find('('); - if (p1 != ucstring::npos) + string::size_type p1 = title.find('('); + if (p1 != string::npos) { - ucstring::size_type p2 = title.find(')', p1+1); - if (p2 != ucstring::npos) + string::size_type p2 = title.find(')', p1+1); + if (p2 != string::npos) title = title.substr(p1+1, p2-p1-1); } strFindReplace(titleText, "%title", title); // Display all skills needed to obtain this title - ucstring sSkillsNeeded; + string sSkillsNeeded; if (!title.empty() && pTU == NULL) sSkillsNeeded = CI18N::get("uiTitleCantObtain"); @@ -821,7 +822,7 @@ class CHandlerOpenTitleHelp : public IActionHandler strFindReplace(titleText, "%skills", sSkillsNeeded); // Display all bricks needed to obtain this title - ucstring sBricksNeeded; + string sBricksNeeded; if (pTU != NULL) { sBricksNeeded = CI18N::get("uiTitleBrickHeader"); @@ -860,7 +861,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenTitleHelp, "open_title_help"); */ class CHandlerOpenSkillToTradeHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (cs != NULL) @@ -883,7 +884,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenSkillToTradeHelp, "open_skill_to_trade_help */ class CHandlerOpenHelpAuto : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (!cs) @@ -913,7 +914,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenHelpAuto, "open_help_auto"); */ class CHandlerBrowse : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { string container = getParam (sParams, "name"); CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container); @@ -972,12 +973,12 @@ class CHandlerBrowse : public IActionHandler { if(params[i]=='%' && irunActionHandler(action, elementGroup, params); @@ -1053,7 +1052,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowse, "browse"); class CHandlerBrowseUndo : public IActionHandler { public: - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); @@ -1072,7 +1071,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseUndo, "browse_undo"); class CHandlerBrowseRedo : public IActionHandler { public: - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); @@ -1091,7 +1090,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseRedo, "browse_redo"); class CHandlerBrowseRefresh : public IActionHandler { public: - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); @@ -1109,7 +1108,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseRefresh, "browse_refresh"); // *************************************************************************** class CHandlerHTMLSubmitForm : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { string container = getParam (sParams, "name"); @@ -1154,9 +1153,9 @@ static void setupHelpPage(CInterfaceGroup *window, const string &url) } // *************************************************************************** -void setHelpText(CSheetHelpSetup &setup, const ucstring &text) +void setHelpText(CSheetHelpSetup &setup, const string &text) { - ucstring copyStr= text; + string copyStr= text; // remove trailing \n while(!copyStr.empty() && copyStr[copyStr.size()-1]=='\n') { @@ -1204,12 +1203,12 @@ void setHelpTextID(CSheetHelpSetup &setup, sint32 id) } // *************************************************************************** -static void setupHelpTitle(CInterfaceGroup *group, const ucstring &title) +static void setupHelpTitle(CInterfaceGroup *group, const string &title) { CGroupContainer *pGC= dynamic_cast(group); if(!group) return; - pGC->setUCTitle(title); + pGC->setTitle(title); } // *************************************************************************** @@ -1238,10 +1237,10 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) setup.DestSheet->setActive(true); } - ucstring skillText; + string skillText; // Name in title - const ucstring title(CStringManagerClient::getSkillLocalizedName(skill)); + const char *title = CStringManagerClient::getSkillLocalizedName(skill); setupHelpTitle(setup.HelpWindow, title); // search all job that have minimum required level for that skill @@ -1250,7 +1249,7 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) // { // for (uint job = 0; job < 8; ++job) // { -// std::string dbPath = toString("CHARACTER_INFO:CAREER%d:JOB%d:JOB_CAP", (int) career, (int) job); +// string dbPath = toString("CHARACTER_INFO:CAREER%d:JOB%d:JOB_CAP", (int) career, (int) job); // uint level = (uint) NLGUI::CDBManager::getInstance()->getDbProp(dbPath)->getValue32(); // if (level != 0) // has the player this job ? // { @@ -1266,10 +1265,11 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) // } // setup skill desc if available. - const ucstring desc(CStringManagerClient::getSkillLocalizedDescription(skill)); - if( !desc.empty() ) + const char *desc = CStringManagerClient::getSkillLocalizedDescription(skill); + if (*desc) { - skillText+= "\n" + desc; + skillText += "\n"; + skillText += desc; } setHelpText(setup, skillText); @@ -1306,7 +1306,7 @@ static string toPercentageText(float val) } // *************************************************************************** -void getItemDefenseText(CDBCtrlSheet *item, ucstring &itemText) +void getItemDefenseText(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1323,7 +1323,7 @@ void getItemDefenseText(CDBCtrlSheet *item, ucstring &itemText) } -void getDamageText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText, bool displayAsMod) +void getDamageText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText, bool displayAsMod) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1348,7 +1348,7 @@ void getDamageText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText, } } -void getSpeedText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) +void getSpeedText(CDBCtrlSheet *item, string &itemText, bool displayAsMod) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1359,7 +1359,7 @@ void getSpeedText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) strFindReplace(itemText, "%speed", strMod + toReadableFloat(itemInfo.HitRate)); } -void getRangeText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) +void getRangeText(CDBCtrlSheet *item, string &itemText, bool displayAsMod) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1370,7 +1370,7 @@ void getRangeText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) strFindReplace(itemText, "%range", strMod + toReadableFloat(itemInfo.Range/1000.f)); } -void getHPAndSapLoadText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getHPAndSapLoadText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1387,7 +1387,7 @@ void getHPAndSapLoadText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &ite } -void getBuffText(CDBCtrlSheet *item, ucstring &itemText) +void getBuffText(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1395,7 +1395,7 @@ void getBuffText(CDBCtrlSheet *item, ucstring &itemText) const string valIds[]={"Hp", "Sap", "Sta", "Focus"}; sint32 vals[]= {itemInfo.HpBuff, itemInfo.SapBuff, itemInfo.StaBuff, itemInfo.FocusBuff}; uint numVals= sizeof(vals) / sizeof(vals[0]); - ucstring bufInfo; + string bufInfo; // For each buf, append a line if !=0 for(uint i=0;i0?"Bonus":"Malus") ); + string line= CI18N::get( "uihelpItem" + valIds[i] + (modifier>0?"Bonus":"Malus") ); strFindReplace(line, "%val", toString(modifier) ); bufInfo+= line; } @@ -1417,13 +1417,13 @@ void getBuffText(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%buffs", bufInfo); } -void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) +void getMagicProtection(CDBCtrlSheet *item, string &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); - ucstring mProtInfo; + string mProtInfo; // Header (always here, because at least max absorb) mProtInfo= CI18N::get("uihelpMagicProtectFormatHeader"); @@ -1434,7 +1434,7 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) if(itemInfo.MagicProtection[i] != PROTECTION_TYPE::None) { // Protection info - ucstring str= CI18N::get("uihelpMagicProtectFormat"); + string str= CI18N::get("uihelpMagicProtectFormat"); strFindReplace(str, "%t", CI18N::get("pt"+PROTECTION_TYPE::toString(itemInfo.MagicProtection[i])) ); strFindReplace(str, "%v", toString(itemInfo.MagicProtectionFactor[i]) ); mProtInfo+= str; @@ -1450,7 +1450,7 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) maxAbsorb= maxAbsorb*nodeFactor->getValue32()/100; // Add to text - ucstring str= CI18N::get("uihelpMagicProtectMaxAbsorbFormat"); + string str= CI18N::get("uihelpMagicProtectMaxAbsorbFormat"); strFindReplace(str, "%v", toString(maxAbsorb) ); mProtInfo+= str; } @@ -1459,12 +1459,12 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%magic_protection", mProtInfo); } -void getMagicResistance(CDBCtrlSheet *item, ucstring &itemText) +void getMagicResistance(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); - ucstring mResistInfo; + string mResistInfo; // Header (always here, because at least max absorb) mResistInfo= CI18N::get("uihelpMagicResistFormatHeader"); @@ -1482,7 +1482,7 @@ void getMagicResistance(CDBCtrlSheet *item, ucstring &itemText) if(resist[i] != 0) { // Resist info - ucstring str= CI18N::get("uihelpMagicResistFormat"); + string str= CI18N::get("uihelpMagicResistFormat"); strFindReplace(str, "%t", CI18N::get("rs"+RESISTANCE_TYPE::toString((RESISTANCE_TYPE::TResistanceType)i) )); strFindReplace(str, "%v", toReadableFloat(float(resist[i])/100) ); mResistInfo+= str; @@ -1493,7 +1493,7 @@ void getMagicResistance(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%magic_resistance", mResistInfo); } -void getActionMalus(CDBCtrlSheet *item, ucstring &itemText) +void getActionMalus(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1501,7 +1501,7 @@ void getActionMalus(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%actmalus", toPercentageText(itemInfo.WearEquipmentMalus) ); } -void getBulkText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getBulkText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { // Display direct value: because cannot know where this item will be drop!! (bag, mektoub etc...) float slotBulkTotal= max((sint32)1, item->getQuantity()) * pIS->Bulk; @@ -1514,7 +1514,7 @@ void getBulkText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) strFindReplace(itemText, "%bulk", toString("%.2f", slotBulkTotal) ); } -void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -1551,14 +1551,14 @@ void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) strFindReplace(itemText, "%weight", "???" ); } -void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) +void getMagicBonus(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); nlctassert(CClientItemInfo::NumMagicFactorType==4); const string valIds[CClientItemInfo::NumMagicFactorType]={"OffElemental", "OffAffliction", "DefHeal", "DefAffliction"}; - ucstring mbInfo; + string mbInfo; // For each magic bonus, test first if equal sint32 allCastSpeedFactor= sint(itemInfo.CastingSpeedFactor[0]*100); @@ -1583,7 +1583,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) if(allCastSpeedFactor!=0 || allMagicPowerFactor!=0) { // else display "all" - ucstring line= CI18N::get( "uihelpItemMagicBonusAll"); + string line= CI18N::get( "uihelpItemMagicBonusAll"); strFindReplace(line, "%cs", toString("%+d", allCastSpeedFactor) ); strFindReplace(line, "%mp", toString("%+d", allMagicPowerFactor) ); mbInfo+= line; @@ -1598,7 +1598,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) sint32 mp= sint(itemInfo.MagicPowerFactor[i]*100); if(cs!=0 || mp!=0) { - ucstring line= CI18N::get( string("uihelpItemMagicBonus") + valIds[i] ); + string line= CI18N::get( string("uihelpItemMagicBonus") + valIds[i] ); strFindReplace(line, "%cs", toString("%+d", cs) ); strFindReplace(line, "%mp", toString("%+d", mp) ); mbInfo+= line; @@ -1610,7 +1610,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) if(!mbInfo.empty()) { // add spell level header - ucstring spellRuleFmt= CI18N::get("uihelpItemMagicBonusHeader"); + string spellRuleFmt= CI18N::get("uihelpItemMagicBonusHeader"); strFindReplace(spellRuleFmt, "%mglvl", toString(item->getQuality())); mbInfo= spellRuleFmt + mbInfo; } @@ -1619,11 +1619,11 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%magic_bonus", mbInfo); } -void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); bool requiredNeeded= false; - ucstring fmt, fmtc; + string fmt, fmtc; // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1656,7 +1656,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & fmt = CI18N::get("uihelpItemSkillReqNotMetFmt"); strFindReplace(fmt, "%d", toString((uint)itemInfo.RequiredSkillLevel)); - const ucstring skillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill)); + const char *skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill); strFindReplace(fmt, "%s", skillName); } else @@ -1687,7 +1687,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & fmt = CI18N::get("uihelpItemSkillReqNotMetFmt"); strFindReplace(fmt, "%d", toString((uint)itemInfo.RequiredSkillLevel2)); - const ucstring skillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill2)); + const char *skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill2); strFindReplace(fmt, "%s", skillName); } else @@ -1750,7 +1750,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & if(req) { // Build the req string - ucstring fmt; + string fmt; if(pIM->isItemCaracRequirementMet(caracType, (sint32)caracValue)) fmt= CI18N::get("uihelpItemCaracReqMetFmt"); else @@ -1785,7 +1785,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & if (skillReq) { // Build the req string - ucstring fmt; + string fmt; if (req) fmt = CI18N::get("uihelpItemCaracReqAnd"); @@ -1794,7 +1794,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & else fmt += CI18N::get("uihelpItemSkillReqNotMetFmt"); strFindReplace(fmt, "%d", toString((uint)itemInfo.MinRequiredSkillLevel)); - const ucstring skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill); + const char *skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill); strFindReplace(fmt, "%s", skillName); strFindReplace(itemText, "%skillreq", fmt ); @@ -1806,12 +1806,12 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & #endif } -void getSkillModVsType(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getSkillModVsType(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); - ucstring sMod; + string sMod; // check skill mod if(!itemInfo.TypeSkillMods.empty()) { @@ -1832,9 +1832,9 @@ void getSkillModVsType(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemT strFindReplace(itemText, "%skill_mod_vs_type", sMod); } -void getArmorBonus(CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) +void getArmorBonus(CDBCtrlSheet *item, string &itemText, const CItemSheet*pIS) { - ucstring armor_bonus(""); + string armor_bonus; sint32 level = 0; if (pIS->Armor.ArmorType == ARMORTYPE::HEAVY) @@ -1849,7 +1849,7 @@ void getArmorBonus(CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) } // *************************************************************************** -void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) +void getItemText (CDBCtrlSheet *item, string &itemText, const CItemSheet*pIS) { if ((item == NULL) || (pIS == NULL)) return; @@ -1895,13 +1895,13 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) CItemSpecialEffectHelper::getInstance()->getItemSpecialEffectText(pIS, itemText); // Description - const ucstring desc(CStringManagerClient::getItemLocalizedDescription(pIS->Id)); - if(!desc.empty()) + const char *desc = CStringManagerClient::getItemLocalizedDescription(pIS->Id); + if (*desc) { strFindReplace(itemText, "%desc", "@{FFF9}" + CI18N::get("uiMissionDesc") + "\n@{FFFF}" + desc + "\n" ); } else - strFindReplace(itemText, "%desc", ucstring() ); + strFindReplace(itemText, "%desc", string() ); // Custom text const CClientItemInfo &itemInfo = getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1915,12 +1915,12 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) else { strFindReplace(itemText, "%custom_text", "\n@{FFFF}" + itemInfo.CustomText.toUtf8() + "\n"); - ucstring itemMFC = CI18N::get("uiItemTextMessageFromCrafter"); + string itemMFC = CI18N::get("uiItemTextMessageFromCrafter"); strFindReplace(itemText, "%mfc", itemMFC); } } else - strFindReplace(itemText, "%custom_text", ucstring() ); + strFindReplace(itemText, "%custom_text", string() ); if ( pIS->Family == ITEMFAMILY::COSMETIC ) { @@ -1928,10 +1928,10 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) if ( UserEntity->getGender() != pIS->Cosmetic.Gender || UserEntity->people() != people ) strFindReplace(itemText, "%cansell", CI18N::get("uihelpItemCosmeticDontFit") ); else - strFindReplace(itemText, "%cansell", ucstring() ); + strFindReplace(itemText, "%cansell", string() ); } else if(pIS->DropOrSell ) - strFindReplace(itemText, "%cansell", ucstring() ); + strFindReplace(itemText, "%cansell", string() ); else strFindReplace(itemText, "%cansell", CI18N::get("uihelpItemCantSell") ); @@ -2021,8 +2021,8 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) // Craft some part? if(pIS->canBuildSomeItemPart()) { - ucstring fmt= CI18N::get("uihelpItemMPCraft"); - ucstring ipList; + string fmt= CI18N::get("uihelpItemMPCraft"); + string ipList; pIS->getItemPartListAsText(ipList); strFindReplace(fmt, "%ip", ipList); strFindReplace(itemText, "%craft", fmt); @@ -2112,19 +2112,17 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) INVENTORIES::TInventory inventory = (INVENTORIES::TInventory)item->getInventoryIndex(); sint32 slot = item->getIndexInDB(); string debugText = NLMISC::toString("inventory: %s\nslot: %d\n", INVENTORIES::toString(inventory).c_str(), slot); - ucstring debugText2; - debugText2.fromUtf8(debugText); - itemText = debugText2 + itemText; + itemText = debugText + itemText; #endif } // *************************************************************************** -static void setupEnchantedItem(CSheetHelpSetup &setup, ucstring &itemText) +static void setupEnchantedItem(CSheetHelpSetup &setup, string &itemText) { // if don't find the tag in the text (eg: if not useful), no-op - static const ucstring enchantTag("%enchantment"); - if( itemText.find(enchantTag) == ucstring::npos ) + static const string enchantTag("%enchantment"); + if( itemText.find(enchantTag) == string::npos ) return; // retrieve the current itemInfo @@ -2141,7 +2139,7 @@ static void setupEnchantedItem(CSheetHelpSetup &setup, ucstring &itemText) CSPhraseManager *pPM= CSPhraseManager::getInstance(); // fill the enchantement info - ucstring enchantInfo; + string enchantInfo; const CItemSheet *pIS= ctrl->asItemSheet(); if(pIS && pIS->Family == ITEMFAMILY::CRYSTALLIZED_SPELL) pPM->buildPhraseDesc(enchantInfo, itemInfo.Enchantment, 0, false, "uihelpPhraseCrystalSpellFormat"); @@ -2169,7 +2167,7 @@ static void setupEnchantedItem(CSheetHelpSetup &setup, ucstring &itemText) hideListBrickHeader(setup); // hide the text - strFindReplace(itemText, enchantTag, ucstring()); + strFindReplace(itemText, enchantTag, string()); } } @@ -2510,14 +2508,14 @@ void refreshItemHelp(CSheetHelpSetup &setup) setupCreatorName(setup); // **** setup the item Text info - ucstring itemText; + string itemText; CEntitySheet *pES = SheetMngr.get ( CSheetId(setup.SrcSheet->getSheetId()) ); if ((pES != NULL) && (pES->type() == CEntitySheet::ITEM)) { CItemSheet *pIS = (CItemSheet*)pES; // ---- Common - ucstring title = setup.SrcSheet->getItemActualName(); + string title = setup.SrcSheet->getItemActualName(); setupHelpTitle(setup.HelpWindow, title ); getItemText (setup.SrcSheet, itemText, pIS); @@ -2545,10 +2543,10 @@ void refreshItemHelp(CSheetHelpSetup &setup) // itemText += CI18N::get("uiRingPlotItemDesc"); // itemText += mi->Description.empty() ? CI18N::get("uiRingPlotItemEmpty") // : mi->Description; -// //itemText += ucstring("\n@{6F6F}") + CI18N::get("uiRingPlotItemComment") + ucstring("\n"); +// //itemText += "\n@{6F6F}" + CI18N::get("uiRingPlotItemComment") + "\n"; // /* // itemText += mi->Comment.empty() ? CI18N::get("uiRingPlotItemEmpty") -// : (ucstring("\n") + mi->Comment); +// : ("\n" + mi->Comment); // */ // } // } @@ -2601,7 +2599,7 @@ static void setupPactHelp(CSheetHelpSetup &setup) const CPactSheet::SPact &pactLose = pact->PactLose[pactLevel]; // **** setup the brick Text info - ucstring pactText; + string pactText; // TODO Localisation setupHelpTitle(setup.HelpWindow, pactLose.Name); @@ -2708,7 +2706,7 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) // fill text, choose color according to conditions and block for (uint j = i ; j < orIndexMax ; ++j ) { - const std::string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",j+1); + const string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",j+1); CViewText *viewText = dynamic_cast(setup.HelpWindow->getElement(text)); if (viewText) { @@ -2719,7 +2717,7 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) viewText->setHardText("uiMissionOr"); } - const std::string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",j+1); + const string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",j+1); CViewTextID *viewTextID = dynamic_cast(setup.HelpWindow->getElement(textId)); if(viewTextID) @@ -2747,12 +2745,12 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) // inactivate other lines for (uint i = (uint)infos.Prerequisits.size(); i < 15 ; ++i) { - const std::string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",i+1); + const string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",i+1); CViewText *viewText = dynamic_cast(setup.HelpWindow->getElement(text)); if (viewText) viewText->setActive(false); - const std::string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",i+1); + const string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",i+1); CViewTextID *viewTextID = dynamic_cast(setup.HelpWindow->getElement(textId)); if(viewTextID) viewTextID->setActive(false); @@ -2770,7 +2768,7 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) // *************************************************************************** class CPlayerShardNameRemover : public IOnReceiveTextId { - virtual void onReceiveTextId(ucstring &str) + virtual void onReceiveTextId(std::string &str) { str= CEntityCL::removeShardFromName(str); } @@ -2883,12 +2881,12 @@ void setupOutpostBuildingHelp(CSheetHelpSetup &setup) setupHelpTitle(setup.HelpWindow, CI18N::get("uihelpOutpostBuilding")); - ucstring sOBText; + string sOBText; sOBText = CI18N::get("uihelpOBFormat_"+COutpostBuildingSheet::toString(pOBS->OBType)); { - ucstring timeText; + string timeText; timeText = toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); if ((pOBS->CostTime % 60) != 0) timeText += toString(pOBS->CostTime%60) + CI18N::get("uiBotChatTimeSecond"); @@ -2954,7 +2952,7 @@ static sint getBonusMalusSpecialTT(CDBCtrlSheet *cs) // *************************************************************************** -void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) +void getSabrinaBrickText(CSBrickSheet *pBR, string &brickText) { if(!pBR) return; @@ -2973,15 +2971,15 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) // Level strFindReplace(brickText, "%lvl", toString(pBR->Level)); // Kill the whole text between %ks, if the skill is unknown - const ucstring killSkill("%ks"); + const string killSkill("%ks"); if( pBR->getSkill()==SKILLS::unknown ) { - ucstring::size_type pos0= brickText.find(killSkill); - if(pos0 != ucstring::npos) + string::size_type pos0= brickText.find(killSkill); + if(pos0 != string::npos) { - ucstring::size_type pos1= brickText.find(killSkill, pos0 + killSkill.size() ); - if(pos1 != ucstring::npos) - brickText.replace(pos0, pos1+killSkill.size()-pos0, ucstring() ); + string::size_type pos1= brickText.find(killSkill, pos0 + killSkill.size() ); + if(pos1 != string::npos) + brickText.replace(pos0, pos1+killSkill.size()-pos0, string() ); } } else @@ -2994,7 +2992,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) strFindReplace(brickText, "%skill", CStringManagerClient::getSkillLocalizedName(pBR->getSkill())); else { - ucstring fullSkillText; + string fullSkillText; bool first= true; for(uint i=0;iUsedSkills.size();i++) { @@ -3024,13 +3022,13 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) // Kill the whole text between %krc, if the relative cost is 0 if(pBR->SabrinaRelativeCost==0.f) { - const ucstring killRC("%krc"); - ucstring::size_type pos0= brickText.find(killRC); - if(pos0 != ucstring::npos) + const string killRC("%krc"); + string::size_type pos0= brickText.find(killRC); + if(pos0 != string::npos) { - ucstring::size_type pos1= brickText.find(killRC, pos0 + killRC.size() ); - if(pos1 != ucstring::npos) - brickText.replace(pos0, pos1+killRC.size()-pos0, ucstring() ); + string::size_type pos1= brickText.find(killRC, pos0 + killRC.size() ); + if(pos1 != string::npos) + brickText.replace(pos0, pos1+killRC.size()-pos0, string() ); } } else @@ -3063,7 +3061,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) } else { - ucstring mpInfo; + string mpInfo; for(uint i=0;iFaberPlan.ItemPartMps.size();i++) { CSBrickSheet::CFaberPlan::CItemPartMP &mpSlot= pBR->FaberPlan.ItemPartMps[i]; @@ -3084,7 +3082,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) } else { - ucstring mpInfo; + string mpInfo; for(uint i=0;iFaberPlan.FormulaMps.size();i++) { CSBrickSheet::CFaberPlan::CFormulaMP &mpSlot= pBR->FaberPlan.FormulaMps[i]; @@ -3100,7 +3098,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) } // *** Magic - ucstring magicResistStr; + string magicResistStr; // Has Some Magic Resistance setuped? if( pBR->isMagic() && pBR->MagicResistType!=RESISTANCE_TYPE::None) { @@ -3200,10 +3198,10 @@ void setupSabrinaPhraseHelp(CSheetHelpSetup &setup, const CSPhraseCom &phrase, u } // **** setup the phrase Text info - setupHelpTitle(setup.HelpWindow, phrase.Name); + setupHelpTitle(setup.HelpWindow, phrase.Name.toUtf8()); // get the phraseText - ucstring phraseText; + string phraseText; // if required, add the .sphrase requirements. // NB: don't add if from bot chat validation (useless cause already filtered by server) pPM->buildPhraseDesc(phraseText, phrase, phraseSheetId, !setup.FromBotChat); @@ -3271,12 +3269,12 @@ static void setupSabrinaBrickHelp(CSheetHelpSetup &setup, bool auraDisabled) // **** setup the brick Text info - ucstring brickText; + string brickText; CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickSheet *pBR= pBM->getBrick(CSheetId(setup.SrcSheet->getSheetId())); if(pBR) { - const ucstring title(CStringManagerClient::getSBrickLocalizedName(pBR->Id)); + const char *title = CStringManagerClient::getSBrickLocalizedName(pBR->Id); setupHelpTitle(setup.HelpWindow, title); // add brick info @@ -3482,7 +3480,7 @@ void setConsoModSuccessTooltip( CDBCtrlSheet *cs ) CInterfaceManager * pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf * nodeSM = NULL; - ucstring ustr; + string ustr; if( CSheetId(cs->getSheetId()).toString() == "mod_melee_success.sbrick" ) { ustr = CI18N::get("uittModMeleeSuccess"); @@ -3597,7 +3595,7 @@ public: CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEATH_XP_MALUS", false); if( node ) { - ucstring txt = CI18N::get("uittDeathPenalty"); + string txt = CI18N::get("uittDeathPenalty"); strFindReplace(txt, "%dp", toString((100*node->getValue16())/254)); CWidgetManager::getInstance()->setContextHelpText(txt); } @@ -3606,7 +3604,7 @@ public: else if( getAuraDisabledState(cs) ) { // get the normal string, and append a short info. - ucstring str; + string str; cs->getContextHelp(str); str+= CI18N::get("uittAuraDisabled"); @@ -3635,7 +3633,7 @@ public: return; } - ucstring txt; + string txt; CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) { @@ -3677,7 +3675,7 @@ public: } } - ucstring str; + string str; BOMB_IF( minTimeRemaining < 0, "at least one animal should be dead", return; ); str += CI18N::get("uittAnimalDeadPopupToolTip"); @@ -3717,17 +3715,17 @@ public: sint n = PeopleInterraction.TeamList.getIndexFromName(selection->getEntityName()); if (n >= 0) { - const string msgName = "TEAM:KICK"; + const char *msgName = "TEAM:KICK"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { uint8 teamMember = (uint8)n; out.serialEnum(teamMember); NetMngr.push(out); - //nlinfo("impulseCallBack : %s %d sent", msgName.c_str(), teamMember); + //nlinfo("impulseCallBack : %s %d sent", msgName, teamMember); } else - nlwarning("unknown message named '%s'.", msgName.c_str()); + nlwarning("unknown message named '%s'.", msgName); } } } @@ -3745,7 +3743,7 @@ REGISTER_ACTION_HANDLER( CAHMilkoKick, "milko_kick"); // *************************************************************************** -static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const std::string &statPrefixId) +static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const string &statPrefixId) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -3809,7 +3807,7 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s CViewText *viewText= dynamic_cast(groupMp->getElement(groupMp->getId()+":text" )); if(viewText) { - ucstring mpCraft; + string mpCraft; // add the Origin filter. string originFilterKey= "iompf" + ITEM_ORIGIN::enumToString((ITEM_ORIGIN::EItemOrigin)itemPart.OriginFilter); @@ -3949,7 +3947,7 @@ public: s += getSystemInformation(); string progname; - std::string moduleName; + string moduleName; #ifdef NL_OS_WINDOWS wchar_t name[1024]; GetModuleFileNameW(NULL, name, 1023); diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 3d0981306..9bbf9fbc8 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -129,7 +130,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() { if ( pIS->Family == ITEMFAMILY::SCROLL) { - editBoxLarge->setInputString(itemInfo.CustomText); + editBoxLarge->setInputString(itemInfo.CustomText.toUtf8()); // TODO: UTF-8 (serial) editLarge->setActive(true); editBoxLarge->setActive(true); @@ -140,11 +141,11 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { - ucstring customText; + string customText; if (!itemInfo.CustomText.empty()) { - customText = itemInfo.CustomText; - strFindReplace(customText, "%mfc", ucstring()); + customText = itemInfo.CustomText.toUtf8(); // TODO: UTF-8 (serial) + strFindReplace(customText, "%mfc", string()); } editBoxShort->setInputString(customText); @@ -160,22 +161,22 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); + const char *localDesc = STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id); if (itemInfo.CustomText.empty()) display->setTextFormatTaged(localDesc); else { - ucstring text = itemInfo.CustomText; + string text = itemInfo.CustomText.toUtf8(); if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(text.substr(4, text.size()-4).toString().c_str()); + pGH->browse(text.substr(4, text.size()-4).c_str()); text = localDesc; } else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') { - string code = text.substr(4, text.size()-4).toString(); + string code = text.substr(4, text.size()-4); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); text = localDesc; @@ -239,9 +240,9 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() closeButton->setActive(false); group->setActive(true); - editBoxShort->setInputString(ucstring()); - editBoxLarge->setInputString(ucstring()); - display->setTextFormatTaged(ucstring()); + editBoxShort->setInputString(std::string()); + editBoxLarge->setInputString(std::string()); + display->setTextFormatTaged(std::string()); // Finish the display or add the waiter @@ -250,7 +251,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // If we already have item info if ( pIS->Family == ITEMFAMILY::SCROLL) { - editBoxLarge->setInputString(itemInfo.CustomText); + editBoxLarge->setInputString(itemInfo.CustomText.toUtf8()); // TODO: UTF-8 (serial) editLarge->setActive(true); editBoxLarge->setActive(true); @@ -262,11 +263,11 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() else { - ucstring customText; + string customText; if (!itemInfo.CustomText.empty()) { - customText = itemInfo.CustomText; - strFindReplace(customText, "%mfc", ucstring()); + customText = itemInfo.CustomText.toUtf8(); + strFindReplace(customText, "%mfc", string()); } editBoxShort->setInputString(customText); @@ -297,29 +298,29 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() closeButton->setActive(true); group->setActive(false); - editBoxShort->setInputString(ucstring()); - editBoxLarge->setInputString(ucstring()); - display->setTextFormatTaged(ucstring()); + editBoxShort->setInputString(std::string()); + editBoxLarge->setInputString(std::string()); + display->setTextFormatTaged(std::string()); // Finish the display or add the waiter if (getInventory().isItemInfoUpToDate(ItemSlotId)) { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); + const char *localDesc = STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id); if (itemInfo.CustomText.empty()) display->setTextFormatTaged(localDesc); else { - ucstring text = itemInfo.CustomText; + string text = itemInfo.CustomText.toUtf8(); if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(text.substr(4, text.size()-4).toString().c_str()); + pGH->browse(text.substr(4, text.size()-4).c_str()); text = localDesc; } else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') { - string code = text.substr(4, text.size()-4).toString(); + string code = text.substr(4, text.size()-4); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); text = localDesc; @@ -406,7 +407,7 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) { bool textValid = editShort->getActive(); - ucstring text = editBoxShort->getInputString(); + string text = editBoxShort->getInputString(); if (!textValid) { textValid = editLarge->getActive(); @@ -416,10 +417,10 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() if (textValid) { CBitMemStream out; - const string msgName = "EVENT:SET_ITEM_CUSTOM_TEXT"; + const char *msgName = "EVENT:SET_ITEM_CUSTOM_TEXT"; if (!GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { - nlwarning ("don't know message name %s", msgName.c_str()); + nlwarning ("don't know message name %s", msgName); } else { @@ -427,7 +428,8 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() out.serial(uiInventory); uint32 uiSlot = (uint32)pCSItem->getIndexInDB(); out.serial(uiSlot); - out.serial(text); + ucstring ucText = ucstring::makeFromUtf8(text); // TODO: UTF-8 (serial) + out.serial(ucText); NetMngr.push(out); //nlinfo("impulseCallBack : %s %s %d \"%s\" sent", msgName.c_str(), INVENTORIES::toString((INVENTORIES::TInventory)pCSItem->getInventoryIndex()).c_str(), pCSItem->getIndexInDB(), text.toUtf8().c_str()); } @@ -454,7 +456,7 @@ static void checkItemCommand(const CItemSheet *itemSheet); static void sendSwapItemMsg(const CDBCtrlSheet *pCSSrc, const CDBCtrlSheet *pCSDst, sint32 quantitySrc) { CBitMemStream out; - const string sMsg = "ITEM:SWAP"; + const char *sMsg = "ITEM:SWAP"; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { // Swap all the Src (quantity= quantitySrc) to dest @@ -487,7 +489,7 @@ static void sendSwapItemMsg(const CDBCtrlSheet *pCSSrc, const CDBCtrlSheet *pCSD //nlinfo("impulseCallBack : %s %d %d %d %d %d sent", sMsg.c_str(), srcInvId, srcSlotId, dstInvId, dstSlotId, quantity); } else - nlwarning(" unknown message name '%s'",sMsg.c_str()); + nlwarning(" unknown message name '%s'",sMsg); } /** Display the popup to ask item quantity @@ -565,7 +567,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet CInterfaceManager *pIM= CInterfaceManager::getInstance(); CBitMemStream out; - const string sMsg = "EXCHANGE:ADD"; + const char *sMsg = "EXCHANGE:ADD"; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { // Swap all the Src (quantity= quantitySrc) to dest @@ -578,7 +580,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet //nlinfo("impulseCallBack : %s %d %d %d sent", sMsg.c_str(), srcSlotIndex, destSlotIndex, quantitySrc); } else - nlwarning(" unknown message name '%s'",sMsg.c_str()); + nlwarning(" unknown message name '%s'",sMsg); } //===================================================================================================================== @@ -634,8 +636,8 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet // send msg to server CBitMemStream out; - const string sMsg = "EXCHANGE:REMOVE"; - if(GenericMsgHeaderMngr.pushNameToStream(sMsg.c_str(), out)) + const char *sMsg = "EXCHANGE:REMOVE"; + if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { // Swap all the Src (quantity= quantitySrc) to dest uint16 slotIndex = (uint16) exchangeSlot->getIndexInDB(); @@ -645,7 +647,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet //nlinfo("impulseCallBack : %s %d sent", sMsg.c_str(), slotIndex); } else - nlwarning(" unknown message name '%s'",sMsg.c_str()); + nlwarning(" unknown message name '%s'",sMsg); } @@ -1656,7 +1658,7 @@ REGISTER_ACTION_HANDLER( CHandlerDragNDrop, "drag_n_drop" ); static void sendToServerEnchantMessage(uint8 invent, uint16 slot) { CBitMemStream out; - const string sMsg = "ITEM:ENCHANT"; + const char *sMsg = "ITEM:ENCHANT"; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -1665,7 +1667,7 @@ static void sendToServerEnchantMessage(uint8 invent, uint16 slot) NetMngr.push(out); } else - nlinfo("unknown message %s", sMsg.c_str()); + nlinfo("unknown message %s", sMsg); } // ********************************************************************************************************** @@ -1733,10 +1735,11 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet) // get the CreatorTextID bool isCraftedByUserEntity = false; - ucstring creatorNameString; + string creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( itemInfo.CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + std::string userNameString = UserEntity->getEntityName() + PlayerSelectedHomeShardNameWithParenthesis; + if (NLMISC::compareCaseInsensitive(userNameString, creatorNameString) == 0) isCraftedByUserEntity = true; } @@ -1841,10 +1844,11 @@ class CHandlerItemMenuCheck : public IActionHandler if (getInventory().isItemInfoUpToDate(getInventory().getItemSlotId(pCS))) { // get the CreatorTextID - ucstring creatorNameString; + string creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( getInventory().getItemInfo(getInventory().getItemSlotId(pCS)).CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + string userNameString = UserEntity->getEntityName() + PlayerSelectedHomeShardNameWithParenthesis; + if (NLMISC::compareCaseInsensitive(userNameString, creatorNameString) == 0) isTextEditionActive = true; } } @@ -2120,10 +2124,8 @@ class CHandlerItemMenuCheck : public IActionHandler { std::string name = groupNames[i]; std::string ahParams = "name=" + name; - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(name); - pGroupMenu->addLine(nameUC, "", "", name); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + pGroupMenu->addLine(name, "", "", name); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); if(pNewSubMenu) @@ -2149,7 +2151,7 @@ class CHandlerItemMenuCheck : public IActionHandler { //there is an offset of 1 because TInventory names are pet_animal1/2/3/4 std::string dst = toString("destination=pet_animal%d|", j + 1); - CViewTextMenu* tmp = pNewSubMenu->addLine(ucstring(pMoveToPa[j]->getHardText()),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); + CViewTextMenu* tmp = pNewSubMenu->addLine(pMoveToPa[j]->getHardText(),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); if(tmp) tmp->setGrayed(pMoveToPa[j]->getGrayed()); } } @@ -2228,7 +2230,7 @@ static void sendMsgUseItem(uint16 slot) if(!ClientCfg.Local) { CBitMemStream out; - const string sMsg = "ITEM:USE_ITEM"; + const char *sMsg = "ITEM:USE_ITEM"; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -2236,7 +2238,7 @@ static void sendMsgUseItem(uint16 slot) NetMngr.push(out); } else - nlinfo("unknown message %s", sMsg.c_str()); + nlinfo("unknown message %s", sMsg); } } @@ -2246,7 +2248,7 @@ static void sendMsgStopUseXpCat( bool isRingCatalyser ) if(!ClientCfg.Local) { CBitMemStream out; - const string sMsg = "ITEM:STOP_USE_XP_CAT"; + const char *sMsg = "ITEM:STOP_USE_XP_CAT"; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -2254,7 +2256,7 @@ static void sendMsgStopUseXpCat( bool isRingCatalyser ) NetMngr.push(out); } else - nlinfo("unknown message %s", sMsg.c_str()); + nlinfo("unknown message %s", sMsg); } } diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 8b379f6d1..91e00807d 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -598,7 +598,7 @@ void getBuffer (CBitmap &btm) void displayScreenShotSavedInfo(const string &filename) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg("'" + filename + "' " + CI18N::get("uiScreenshotSaved")); + string msg = "'" + filename + "' " + CI18N::get("uiScreenshotSaved"); pIM->displaySystemInfo(msg); } @@ -863,7 +863,7 @@ class CAHReplyTellerOnce : public IActionHandler { w->setKeyboardFocus(); w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName) + ucstring(" "), false); + w->setCommand("tell " + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName) + " ", false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -885,7 +885,7 @@ class CAHCycleTell : public IActionHandler { CInterfaceManager *im = CInterfaceManager::getInstance(); if (!im->isInGame()) return; - const ucstring *lastTellPeople = ChatMngr.cycleLastTell(); + const string *lastTellPeople = ChatMngr.cycleLastTell(); if (!lastTellPeople) return; // just popup the main chat //CChatWindow *w = PeopleInterraction.MainChat.Window; @@ -908,15 +908,15 @@ REGISTER_ACTION_HANDLER (CAHCycleTell, "cycle_tell") NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "") { if (args.size() != 1) return false; - PeopleInterraction.LastSenderName = ucstring(args[0]); + PeopleInterraction.LastSenderName = args[0]; return true; } // *************************************************************************** -bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) +bool CStringPostProcessRemoveName::cbIDStringReceived(string &inOut) { // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(inOut); + string strNewTitle = CEntityCL::getTitleFromName(inOut); // retrieve the translated string if (!strNewTitle.empty()) @@ -924,8 +924,8 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(strNewTitle, Woman); { // Sometimes translation contains another title - ucstring::size_type pos = inOut.find('$'); - if (pos != ucstring::npos) + string::size_type pos = inOut.find('$'); + if (pos != string::npos) { inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut), Woman); } @@ -938,16 +938,16 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) } // *************************************************************************** -bool CStringPostProcessRemoveTitle::cbIDStringReceived(ucstring &inOut) +bool CStringPostProcessRemoveTitle::cbIDStringReceived(string &inOut) { inOut = CEntityCL::removeTitleAndShardFromName(inOut); return true; } // *************************************************************************** -bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut) +bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(string &inOut) { - ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut); + string sOut = CEntityCL::removeTitleAndShardFromName(inOut); if (sOut.empty()) { CStringPostProcessRemoveName SPPRM; diff --git a/ryzom/client/src/interface_v3/action_handler_misc.h b/ryzom/client/src/interface_v3/action_handler_misc.h index d820963ac..61fbbc552 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.h +++ b/ryzom/client/src/interface_v3/action_handler_misc.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -157,7 +158,7 @@ class CStringPostProcessRemoveName : public CInterfaceManager::IStringProcess public: CStringPostProcessRemoveName():Woman(false) {} bool Woman; - bool cbIDStringReceived(ucstring &inOut); + bool cbIDStringReceived(std::string &inOut); }; // *************************************************************************** @@ -165,7 +166,7 @@ public: class CStringPostProcessRemoveTitle : public CInterfaceManager::IStringProcess { public: - bool cbIDStringReceived(ucstring &inOut); + bool cbIDStringReceived(std::string &inOut); }; // *************************************************************************** @@ -173,7 +174,7 @@ public: class CStringPostProcessNPCRemoveTitle : public CInterfaceManager::IStringProcess { public: - bool cbIDStringReceived(ucstring &inOut); + bool cbIDStringReceived(std::string &inOut); }; diff --git a/ryzom/client/src/interface_v3/action_handler_move.cpp b/ryzom/client/src/interface_v3/action_handler_move.cpp index ad07c7eb5..848ec780b 100644 --- a/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2017 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -466,7 +467,7 @@ class CAHToggleDodgeParry : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg; + string msg; // 0 - dodge mode // 1 - parry mode if (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DEFENSE:DEFENSE_MODE")->getValue32() == 0) diff --git a/ryzom/client/src/interface_v3/action_handler_outpost.cpp b/ryzom/client/src/interface_v3/action_handler_outpost.cpp index 023030ebe..67e90ce02 100644 --- a/ryzom/client/src/interface_v3/action_handler_outpost.cpp +++ b/ryzom/client/src/interface_v3/action_handler_outpost.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -471,7 +472,7 @@ public: startAttackTime= node->getValue32(); // send a DECLARE_WAR_VALIDATE message to server - string sMsg= "OUTPOST:DECLARE_WAR_VALIDATE"; + const char *sMsg= "OUTPOST:DECLARE_WAR_VALIDATE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -483,7 +484,7 @@ public: } else { - nlwarning("command : unknown message name : '%s'.", sMsg.c_str()); + nlwarning("command : unknown message name : '%s'.", sMsg); } } @@ -508,7 +509,7 @@ public: // Send a msg to server if(outpostSheet) { - string sMsg= "OUTPOST:SELECT"; + const char *sMsg= "OUTPOST:SELECT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -518,7 +519,7 @@ public: } else { - nlwarning("command : unknown message name : '%s'.", sMsg.c_str()); + nlwarning("command : unknown message name : '%s'.", sMsg); } } } diff --git a/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/ryzom/client/src/interface_v3/action_handler_phrase.cpp index b18e348e5..5e73b9e5a 100644 --- a/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -278,9 +279,9 @@ void launchPhraseComposition(bool creation) // Set the Text of the Window if(creation) - window->setUCTitle(CI18N::get("uiPhraseCreate")); + window->setTitle(CI18N::get("uiPhraseCreate")); else - window->setUCTitle(CI18N::get("uiPhraseEdit")); + window->setTitle(CI18N::get("uiPhraseEdit")); // clear the sentence for a New Phrase creation. buildSentenceTarget->clearBuildingPhrase(); @@ -1198,7 +1199,7 @@ public: { // display "you can't cast while moving" CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgNoCastWhileMoving"); + string msg = CI18N::get("msgNoCastWhileMoving"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; @@ -1217,57 +1218,60 @@ public: if( pPM->avoidCyclicForPhrase(phraseCom) ) cyclic= false; - // **** Launch the cast - // Cast only if their is a target, or if it is not a combat action - CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot()); - if(target || !rootBrick->isCombat()) + if (UserEntity) { - // combat (may moveTo before) ? - if(rootBrick->isCombat()) + // **** Launch the cast + // Cast only if their is a target, or if it is not a combat action + CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot()); + if (target || !rootBrick->isCombat()) { - if( !UserEntity->canEngageCombat() ) - return; + // combat (may moveTo before) ? + if (rootBrick->isCombat()) + { + if (!UserEntity->canEngageCombat()) + return; - UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic); - } - // else can cast soon! - else if ( rootBrick->isForageExtraction() && (! UserEntity->isRiding()) ) // if mounted, send directly to server (without moving) to receive the error message - { - // Yoyo: TEMP if a target selected, must be a forage source - if(!target || target->isForageSource()) + UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic); + } + // else can cast soon! + else if (rootBrick->isForageExtraction() && (!UserEntity->isRiding())) // if mounted, send directly to server (without moving) to receive the error message + { + // Yoyo: TEMP if a target selected, must be a forage source + if (!target || target->isForageSource()) + { + // Cancel any follow + UserEntity->disableFollow(); + // reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called) + // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) + UserEntity->resetAnyMoveTo(); + + // Move to targetted source + if (target) + UserEntity->moveToExtractionPhrase(target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic); + + // start client execution + pPM->clientExecute(memoryLine, memoryIndex, cyclic); + + if (!target) + { + // inform Server of phrase cast + pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); + } + } + } + else { - // Cancel any follow - UserEntity->disableFollow(); - // reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called) + // Cancel any moveTo(), because don't want to continue reaching the prec entity // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) UserEntity->resetAnyMoveTo(); - // Move to targetted source - if ( target ) - UserEntity->moveToExtractionPhrase( target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic ); - - // start client execution + // start client execution: NB: start client execution even if it pPM->clientExecute(memoryLine, memoryIndex, cyclic); - if ( ! target ) - { - // inform Server of phrase cast - pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); - } + // inform Server of phrase cast + pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); } } - else - { - // Cancel any moveTo(), because don't want to continue reaching the prec entity - // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) - UserEntity->resetAnyMoveTo(); - - // start client execution: NB: start client execution even if it - pPM->clientExecute(memoryLine, memoryIndex, cyclic); - - // inform Server of phrase cast - pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); - } } } } @@ -1439,7 +1443,7 @@ public: else { // debug: - pIM->displaySystemInfo( ucstring("PHRASE:CANCEL_ALL") ); + pIM->displaySystemInfo("PHRASE:CANCEL_ALL"); } } }; @@ -1691,7 +1695,7 @@ static DECLARE_INTERFACE_USER_FCT(getSPhraseName) return false; sint sphraseId= (sint)args[0].getInteger(); CSPhraseManager *pPM= CSPhraseManager::getInstance(); - result.setUCString(pPM->getPhrase(sphraseId).Name); + result.setString(pPM->getPhrase(sphraseId).Name.toUtf8()); return true; } else @@ -1714,7 +1718,7 @@ public: if(!ctrlSheet) return; - ucstring str(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(CSheetId(ctrlSheet->getSheetId()))); + string str(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(CSheetId(ctrlSheet->getSheetId()))); // According to locked state if(ctrlSheet->getGrayed()) diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 1c99983e3..7625be010 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -116,7 +117,7 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn if (!rootBrick->Properties.empty()) { - string prop= NLMISC::toUpper(rootBrick->Properties[0].Text); + string prop= NLMISC::toUpperAscii(rootBrick->Properties[0].Text); vector strList; splitString(prop, " ", strList); // The prop Id should be 'FPLAN:' @@ -187,8 +188,8 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn window->setActive(true); // Setup the Title with a default text - ucstring title= CI18N::get("uiPhraseFaberExecuteNoPlan"); - window->setUCTitle (title); + string title= CI18N::get("uiPhraseFaberExecuteNoPlan"); + window->setTitle (title); } // **** setup DB observer! @@ -523,7 +524,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick CViewText *viewText= dynamic_cast(itemReqLineGroup->getView(FaberPhraseText)); if(viewText) { - ucstring text; + string text; if(mpBuild.RequirementType==CMPBuild::ItemPartReq) { text= CI18N::get("uihelpFaberMpHeader"); @@ -537,7 +538,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick { nlstop; } - viewText->setText( text ); + viewText->setText(text); } // Set as Icon the required MP FaberType / or Sheet Texture (directly...) @@ -583,9 +584,9 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick if(window) { // Setup the Title with the item built - ucstring title= CI18N::get("uiPhraseFaberExecute"); + string title= CI18N::get("uiPhraseFaberExecute"); strFindReplace(title, "%item", STRING_MANAGER::CStringManagerClient::getItemLocalizedName(_ExecuteFromItemPlanBrick->FaberPlan.ItemBuilt) ); - window->setUCTitle (title); + window->setTitle (title); } @@ -1700,7 +1701,7 @@ void CActionPhraseFaber::updateItemResult() CViewText *successView= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseFpSuccessText)); if(successView) { - ucstring text= CI18N::get("uiPhraseFaberSuccessRate"); + string text= CI18N::get("uiPhraseFaberSuccessRate"); // Get the success rate of the related phrase uint phraseSlot= pPM->getMemorizedPhrase(_ExecuteFromMemoryLine, _ExecuteFromMemoryIndex); @@ -1826,7 +1827,7 @@ void CActionPhraseFaber::updateItemResult() RM_FABER_STAT_TYPE::isMagicProtectStat(RM_FABER_STAT_TYPE::TRMStatType(i)) ) statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatActive")); else - statToolTip->setDefaultContextHelp(ucstring()); + statToolTip->setDefaultContextHelp(std::string()); } else statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatGrayed")); diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.h b/ryzom/client/src/interface_v3/action_phrase_faber.h index f406d0ee2..5f10c0c51 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.h +++ b/ryzom/client/src/interface_v3/action_phrase_faber.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) diff --git a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index b7ec631b9..6bfbea0b3 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -70,15 +71,15 @@ class CHandlerGuildCreate : public IActionHandler CGroupEditBox *pDesc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildDescWin)); - ucstring guildName = pGEB->getInputString(); + ucstring guildName = ucstring::makeFromUtf8(pGEB->getInputString()); // FIXME: UTF-8 (serial) - ucstring guildDesc; - if (pDesc != NULL) guildDesc = pDesc->getInputString(); + ucstring guildDesc; // FIXME: UTF-8 (serial) + if (pDesc != NULL) guildDesc.fromUtf8(pDesc->getInputString()); // FIXME: UTF-8 (serial) uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(), pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2()); - const string msgName = "GUILD:CREATE"; + const char *msgName = "GUILD:CREATE"; NLMISC::CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { diff --git a/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index 1e9d56dc3..c8190e8e7 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -156,14 +157,14 @@ void CBotChatPageDynamicMission::update() { if (ClientCfg.Local) { - _ChoiceCB[k]->setText(l, ucstring(toString("Dynamic mission %d:%d", (int) k, (int) l))); + _ChoiceCB[k]->setText(l, toString("Dynamic mission %d:%d", (int) k, (int) l)); _TextReceived[k][l] = true; } else { uint32 textID = (uint32) NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); // see if text has been receive - ucstring result; + string result; bool received = CStringManagerClient::instance()->getDynString(textID, result); if (received) { @@ -179,7 +180,7 @@ void CBotChatPageDynamicMission::update() uint32 textID = (uint32) NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); if (textID == 0 && !ClientCfg.Local) break; // see if text has been received - ucstring result; + string result; bool received = CStringManagerClient::instance()->getDynString(textID, result); if (received) { @@ -206,7 +207,7 @@ void CBotChatPageDynamicMission::update() uint32 textID = NLGUI::CDBManager::getInstance()->getDbProp(DM_TITLE_DB_PATH)->getValue32(); if (textID != 0) { - ucstring result; + string result; if (CStringManagerClient::instance()->getDynString(textID, result)) { textID = NLGUI::CDBManager::getInstance()->getDbProp(DM_DESCRIPTION_DB_PATH)->getValue32(); diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 045aba4e4..2ca15c4fa 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -249,7 +250,7 @@ void CBotChatPageTrade::begin() if (gc) { // set the title - gc->setUCTitle(_Title); + gc->setTitle(_Title); // show the buy mean CInterfaceGroup *money = dynamic_cast(gc->getGroup("money")); if (money) money->setActive((_BuyMean == Money) || (_BuyMean == MoneyFactionPoints)); @@ -333,7 +334,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); if (!ed) return std::numeric_limits::max(); uint32 intQuantity; - if (fromString(ed->getInputString().toString(), intQuantity)) + if (fromString(ed->getInputString(), intQuantity)) { return intQuantity; } @@ -894,7 +895,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall { confirmButton->setActive( true ); // no need any context help because too simple - confirmButton->setDefaultContextHelp(ucstring()); + confirmButton->setDefaultContextHelp(std::string()); if(isItem) { CItemSheet * itemSheet = dynamic_cast ( SheetMngr.get( CSheetId( sheet->getSheetId() ) ) ); @@ -1011,7 +1012,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal CViewText *itemNameView = dynamic_cast(ig->getView("object_name")); if (itemNameView) { - ucstring itemName; + string itemName; itemName = sheet->getItemActualName(); itemNameView->setText(itemName); } @@ -1678,21 +1679,21 @@ void CBotChatPageTrade::setupFactionPointPrice(bool /* sellMode */, uint default CViewText *vt= dynamic_cast(fpGroup->getView("unit_price_header")); if(vt) { - ucstring fmt= CI18N::get("uiUnitFPPrice"); + string fmt= CI18N::get("uiUnitFPPrice"); strFindReplace(fmt, "%fac", factionName); vt->setText(fmt); } vt= dynamic_cast(fpGroup->getView("total_price_header")); if(vt) { - ucstring fmt= CI18N::get("uiTotalFPPrice"); + string fmt= CI18N::get("uiTotalFPPrice"); strFindReplace(fmt, "%fac", factionName); vt->setText(fmt); } // setup icon according to pvp clan CInterfaceManager *pIM= CInterfaceManager::getInstance(); - factionName = NLMISC::toLower(factionName); + factionName = NLMISC::toLowerAscii(factionName); string factionIcon= CWidgetManager::getInstance()->getParser()->getDefine(toString("faction_icon_%s", factionName.c_str())); CViewBitmap *vBmp= dynamic_cast(fpGroup->getView("unit_price:item_price:icone")); if(vBmp) vBmp->setTexture(factionIcon); @@ -2429,7 +2430,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { // \todo yoyo: for now disable tooltip - CWidgetManager::getInstance()->setContextHelpText(ucstring()); + CWidgetManager::getInstance()->setContextHelpText(std::string()); } }; REGISTER_ACTION_HANDLER(CHandlerBotChatTTItemType, "botchat_tt_item_type"); @@ -2576,11 +2577,11 @@ static DECLARE_INTERFACE_USER_FCT(getPriceWithFame) sint value= (sint)args[0].getInteger(); sint valueFame= (sint)args[1].getInteger(); if(value==-1) - result.setUCString(CI18N::get("uiBadPrice")); + result.setString(CI18N::get("uiBadPrice")); else if(value==valueFame) - result.setUCString(NLMISC::formatThousands(toString(value))); + result.setString(NLMISC::formatThousands(toString(value))); else - result.setUCString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); + result.setString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); return true; } @@ -2596,7 +2597,7 @@ static DECLARE_INTERFACE_USER_FCT(getBonusOnResale) sint valueHigh= (sint)args[0].getInteger(); sint valueLow= (sint)args[1].getInteger(); sint diff = valueHigh - valueLow; - result.setUCString("+" + NLMISC::formatThousands(toString(diff))); + result.setString("+" + NLMISC::formatThousands(toString(diff))); return true; } diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.h b/ryzom/client/src/interface_v3/bot_chat_page_trade.h index ae11a2008..5023406af 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.h +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -72,7 +73,7 @@ public: // set the buy mean (must be called before 'begin' is called) void setBuyMean(TBuyMean buyMean) { _BuyMean = buyMean; } // set the title of the window (actually applied when 'begin' is called) - void setTitle(const ucstring &title) { _Title = title; } + void setTitle(const std::string &title) { _Title = title; } // update the 'buy' dialog window for the given sphrase sheet (the player has changed an equipped weapon => action stats change) void updateSPhraseBuyDialog(); // invalidate window coords @@ -134,7 +135,7 @@ private: uint32 _CurrItemInventory; bool _BuyOnly; TBuyMean _BuyMean; - ucstring _Title; + std::string _Title; bool _ResaleEdit; bool _QuantityEdit; sint32 _QuantityCheck; diff --git a/ryzom/client/src/interface_v3/character_3d.cpp b/ryzom/client/src/interface_v3/character_3d.cpp index edc300d19..30e592e7d 100644 --- a/ryzom/client/src/interface_v3/character_3d.cpp +++ b/ryzom/client/src/interface_v3/character_3d.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -486,7 +487,7 @@ void SCharacter3DSetup::setupFromCS_ModelCol (SLOTTYPE::EVisualSlot s, sint32 mo if (shapeLegs.find("_caster01_") != std::string::npos) { - std::string tmpName = toLower(Parts[part].Name); + std::string tmpName = toLowerAscii(Parts[part].Name); std::string::size_type posBottes = tmpName.find("_bottes"); @@ -898,7 +899,7 @@ void CCharacter3D::setup (const SCharacter3DSetup &c3ds) if (c3ds.People != EGSPD::CPeople::Undefined) if ((c3ds.People != _CurrentSetup.People) || bInstanceRebuilt || bQualityRebuilt) { - if (!_Instances[i].empty()) + if (!_Instances[i].empty() && i != Char3DPart_HandRightItem && i != Char3DPart_HandLeftItem) { ColorSlotManager.setInstanceSlot ( _Instances[i], 0u, // Slot 0 is for skin diff --git a/ryzom/client/src/interface_v3/chat_displayer.h b/ryzom/client/src/interface_v3/chat_displayer.h index a3218670d..b42ff339a 100644 --- a/ryzom/client/src/interface_v3/chat_displayer.h +++ b/ryzom/client/src/interface_v3/chat_displayer.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -97,7 +98,7 @@ public: std::vector &rVal = acces.value (); for (uint i = 0; i < rVal.size(); ++i) { - CInterfaceManager::getInstance()->displayDebugInfo(ucstring(rVal[i].Str), rVal[i].Mode); + CInterfaceManager::getInstance()->displayDebugInfo(rVal[i].Str, rVal[i].Mode); } rVal.clear(); } diff --git a/ryzom/client/src/interface_v3/chat_filter.cpp b/ryzom/client/src/interface_v3/chat_filter.cpp index a5fd04c5b..d1d6d78c2 100644 --- a/ryzom/client/src/interface_v3/chat_filter.cpp +++ b/ryzom/client/src/interface_v3/chat_filter.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -170,7 +171,7 @@ void CChatInputFilter::chatWindowRemoved(CChatWindow *cw) } //============================================================================================================= -void CChatInputFilter::displayMessage(const ucstring &msg, NLMISC::CRGBA col, uint numBlinks /*=0*/, bool *windowVisible) +void CChatInputFilter::displayMessage(const string &msg, NLMISC::CRGBA col, uint numBlinks /*=0*/, bool *windowVisible) { bool windowVisibleTmp = false; std::vector::iterator it; @@ -187,10 +188,9 @@ void CChatInputFilter::displayMessage(const ucstring &msg, NLMISC::CRGBA col, ui } //============================================================================================================= -void CChatInputFilter::displayTellMessage(/*TDataSetIndex &receiverIndex, */const ucstring &msg, const ucstring &sender, NLMISC::CRGBA col, uint numBlinks /*=0*/,bool *windowVisible /*=NULL*/) +void CChatInputFilter::displayTellMessage(/*TDataSetIndex &receiverIndex, */const string &msg, const string &sender, NLMISC::CRGBA col, uint numBlinks /*=0*/,bool *windowVisible /*=NULL*/) { - ucstring senderLwr; - senderLwr.fromUtf8(NLMISC::toLower(sender.toUtf8())); + string senderLwr = NLMISC::toLower(sender); // look in people lists std::vector::iterator peopleListIt; @@ -290,7 +290,7 @@ void CChatTargetFilter::setChat(CChatWindow *w) } //============================================================================================================= -void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow) +void CChatTargetFilter::msgEntered(const string &msg, CChatWindow *chatWindow) { // Common Target case if (ClientCfg.Local) @@ -307,9 +307,9 @@ void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow) else if (!_TargetPlayer.empty()) { // the target must be a player, make a tell on him - ChatMngr.tell(_TargetPlayer.toString(), msg); + ChatMngr.tell(_TargetPlayer, msg); // direct output in the chat - chatWindow->displayLocalPlayerTell(_TargetPlayer.toString(), msg); + chatWindow->displayLocalPlayerTell(_TargetPlayer, msg); } else { @@ -334,7 +334,7 @@ void CChatTargetFilter::setTargetPartyChat(CChatWindow *w) } //============================================================================================================= -void CChatTargetFilter::setTargetPlayer(const ucstring &targetPlayer) +void CChatTargetFilter::setTargetPlayer(const string &targetPlayer) { _TargetPlayer = targetPlayer; if (_TargetPartyChat) @@ -345,7 +345,7 @@ void CChatTargetFilter::setTargetPlayer(const ucstring &targetPlayer) // set the prompt if (_Chat) { - _Chat->setPrompt(targetPlayer + (ucchar) '>'); + _Chat->setPrompt(targetPlayer + '>'); } } @@ -364,8 +364,7 @@ void CChatTargetFilter::setTargetGroup(CChatGroup::TGroupType groupType, uint32 if (_Chat) { // set the prompt - const ucstring prompt(""); - _Chat->setPrompt(prompt + (ucchar) '>'); + _Chat->setPrompt(">"); // set the color string entry="UI:SAVE:CHAT:COLORS:"; diff --git a/ryzom/client/src/interface_v3/chat_filter.h b/ryzom/client/src/interface_v3/chat_filter.h index aeff77afc..eb644f586 100644 --- a/ryzom/client/src/interface_v3/chat_filter.h +++ b/ryzom/client/src/interface_v3/chat_filter.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -42,10 +45,10 @@ public: * Listening windows will blick only if there isnt a single visible listening window, so that the player can know if there's a message * \param windowVisible is not NULL, points a bool that will be filled with true if one of the window on the which the msg was displayed is visible. */ - void displayMessage(const ucstring &msg, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); + void displayMessage(const std::string &msg, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); /** The same as displayMessage, but with sender name, so that the msg will be displayed in attached people lists as well */ - void displayTellMessage(/*TDataSetIndex &senderIndex, */const ucstring &msg, const ucstring &sender, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); + void displayTellMessage(/*TDataSetIndex &senderIndex, */const std::string &msg, const std::string &sender, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); /** Clear the messages in all registered chat windows */ void clearMessages(); @@ -134,8 +137,8 @@ public: /** Set a player as the target. This remove any previous window target * NB : this replace any previous party chat or target group or player */ - void setTargetPlayer(const ucstring &targetPlayer); - const ucstring &getTargetPlayer() const { return _TargetPlayer; } + void setTargetPlayer(const std::string &targetPlayer); + const std::string &getTargetPlayer() const { return _TargetPlayer; } //@} private: @@ -148,14 +151,14 @@ private: // @{ CChatWindow *_TargetPartyChat; // the target party chat CChatGroup::TGroupType _TargetGroup; - ucstring _TargetPlayer; + std::string _TargetPlayer; // relevant only if _TargetGroup==dyn_chat uint32 _TargetDynamicChannelDbIndex; // @} private: // from IChatWindowListener void chatWindowRemoved(CChatWindow *cw); - void msgEntered(const ucstring &msg, CChatWindow *chatWindow); + void msgEntered(const std::string &msg, CChatWindow *chatWindow); // copy not supported CChatTargetFilter(const CChatTargetFilter &/* other */):NLMISC::CRefCount() { nlassert(0); } CChatTargetFilter& operator=(const CChatTargetFilter &/* other */) { nlassert(0); return *this; } diff --git a/ryzom/client/src/interface_v3/chat_text_manager.cpp b/ryzom/client/src/interface_v3/chat_text_manager.cpp index e2dbdcd9c..e2474b6a2 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -105,15 +106,13 @@ bool CChatTextManager::showTimestamps() const } //================================================================================= -static CInterfaceGroup *parseCommandTag(ucstring &line) +static CInterfaceGroup *parseCommandTag(string &line) { - string::size_type start = line.find(ucstring("/$$")); + string::size_type start = line.find("/$$"); if (start == string::npos) return NULL; - string::size_type end = line.find(ucstring("$$/"), start + 3); + string::size_type end = line.find("$$/", start + 3); if (end == string::npos) return NULL; - std::string commandLine; - ucstring ucCommandLine = line.substr(start + 3, end - start - 3); - ucCommandLine.toString(commandLine); + std::string commandLine = line.substr(start + 3, end - start - 3); line = line.substr(0, start) + line.substr(end +3); vector params; explode(commandLine, std::string("|"), params); @@ -157,14 +156,14 @@ static CInterfaceGroup *buildLineWithCommand(CInterfaceGroup *commandGroup, CVie return group; } -static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstring::size_type textSize) +static inline bool isUrlTag(const string &s, string::size_type index, string::size_type textSize) { // Format http://, https:// // or markdown style (title)[http://..] if(textSize > index+7) { bool markdown = false; - ucstring::size_type i = index; + string::size_type i = index; // advance index to url section if markdown style link is detected if (s[i] == '(') { @@ -189,7 +188,7 @@ static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstri if (textSize > i + 7) { - bool isUrl = (toLower(s.substr(i, 7)) == ucstring("http://") || toLower(s.substr(i, 8)) == ucstring("https://")); + bool isUrl = (toLowerAscii(s.substr(i, 7)) == "http://" || toLowerAscii(s.substr(i, 8)) == "https://"); // match "text http://" and not "texthttp://" if (isUrl && i > 0 && !markdown) { @@ -220,11 +219,11 @@ static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstri // *************************************************************************** // isUrlTag must match -static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucstring &url, ucstring &title) +static inline void getUrlTag(const string &s, string::size_type &index, string &url, string &title) { bool isMarkdown = false; - ucstring::size_type textSize = s.size(); - ucstring::size_type pos; + string::size_type textSize = s.size(); + string::size_type pos; // see if we have markdown format if (s[index] == '(') @@ -249,8 +248,8 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst } } - ucchar chOpen = ' '; - ucchar chClose = ' '; + char chOpen = ' '; + char chClose = ' '; if (isMarkdown) { chOpen = '['; @@ -271,7 +270,7 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst pos = s.find_first_of(chClose, index); // handle common special case: 'text http://.../, text' - if (pos != ucstring::npos && index > 0) + if (pos != string::npos && index > 0) { if (s[index-1] == ' ' && (s[pos-1] == ',' || s[pos-1] == '.')) { @@ -307,7 +306,7 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst } // fallback to full string length as we did match http:// already and url spans to the end probably - if (pos == ucstring::npos) + if (pos == string::npos) { pos = textSize; } @@ -320,22 +319,22 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst } //================================================================================= -static void prependTimestamp(ucstring &msg) +static void prependTimestamp(string &msg) { - ucstring cur_time; + string cur_time; CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_CLOCK_12H", false); if (node && node->getValueBool()) cur_time = CInterfaceManager::getTimestampHuman("[%I:%M:%S %p] "); else cur_time = CInterfaceManager::getTimestampHuman(); - ucstring::size_type codePos = msg.find(ucstring("@{")); - if (codePos != ucstring::npos) + string::size_type codePos = msg.find("@{"); + if (codePos != string::npos) { // Prepend the current time (do it after the color if the color at first position. if (codePos == 0) { - codePos = msg.find(ucstring("}")); + codePos = msg.find(string("}")); msg = msg.substr(0, codePos + 1) + cur_time + msg.substr(codePos + 1, msg.length() - codePos); } else @@ -350,9 +349,9 @@ static void prependTimestamp(ucstring &msg) } //================================================================================= -CViewBase *CChatTextManager::createMsgText(const ucstring &cstMsg, NLMISC::CRGBA col, bool justified /*=false*/, bool plaintext /*=false*/) +CViewBase *CChatTextManager::createMsgText(const string &cstMsg, NLMISC::CRGBA col, bool justified /*=false*/, bool plaintext /*=false*/) { - ucstring msg = cstMsg; + string msg = cstMsg; CInterfaceGroup *commandGroup = parseCommandTag(msg); if (showTimestamps()) @@ -364,7 +363,7 @@ CViewBase *CChatTextManager::createMsgText(const ucstring &cstMsg, NLMISC::CRGBA } //================================================================================= -CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CRGBA col, bool justified, CInterfaceGroup *commandGroup) +CViewBase *CChatTextManager::createMsgTextSimple(const string &msg, NLMISC::CRGBA col, bool justified, CInterfaceGroup *commandGroup) { CViewText *vt = new CViewText(CViewText::TCtorParam()); // get parameters from config.xml @@ -378,7 +377,7 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR // if text contain any color code, set the text formated and white, // otherwise, set text normal and apply global color - if (msg.find(ucstring("@{")) != ucstring::npos) + if (msg.find("@{") != string::npos) { vt->setTextFormatTaged(msg); vt->setColor(NLMISC::CRGBA::White); @@ -400,9 +399,9 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR } //================================================================================= -CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::CRGBA col, bool justified, bool plaintext, CInterfaceGroup *commandGroup) +CViewBase *CChatTextManager::createMsgTextComplex(const string &msg, NLMISC::CRGBA col, bool justified, bool plaintext, CInterfaceGroup *commandGroup) { - ucstring::size_type textSize = msg.size(); + string::size_type textSize = msg.size(); CGroupParagraph *para = new CGroupParagraph(CViewBase::TCtorParam()); para->setId("line"); @@ -411,7 +410,7 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C // use right click because left click might be used to activate chat window para->setRightClickHandler("copy_chat_popup"); - para->setRightClickHandlerParams(msg.toUtf8()); + para->setRightClickHandlerParams(msg); if (plaintext) { @@ -422,19 +421,15 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C return para; } - ucstring::size_type pos = 0; + string::size_type pos = 0; - // Manage Translations - CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false); - bool originalFirst = node ? node->getValueBool() : true; - - string::size_type startTr = msg.find(ucstring("{:")); - string::size_type endOfOriginal = msg.find(ucstring("}@{")); + string::size_type startTr = msg.find("{:"); + string::size_type endOfOriginal = msg.find("}@{"); // Original/Translated case, example: {:enHello the world!}@{ Bonjour le monde ! if (startTr != string::npos && endOfOriginal != string::npos) { - string lang = toUpper(msg.substr(startTr+2, 2)).toString(); + string lang = toUpperAscii(msg.substr(startTr+2, 2)); bool inverse = false; bool hideFlag = false; @@ -448,9 +443,9 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C CViewBase *vt = createMsgTextSimple(msg.substr(0, startTr), col, justified, NULL); para->addChild(vt); - string texture = "flag-"+toLower(msg.substr(startTr+2, 2)).toString()+".tga"; - ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5); - ucstring translation = msg.substr(endOfOriginal+4); + string texture = "flag-"+toLowerAscii(msg.substr(startTr+2, 2))+".tga"; + string original = msg.substr(startTr+5, endOfOriginal-startTr-5); + string translation = msg.substr(endOfOriginal+3); CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam()); ctrlButton->setTexture(texture); ctrlButton->setTextureOver(texture); @@ -477,11 +472,11 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C // quickly check if text has links or not bool hasUrl; { - ucstring s = toLower(msg); - hasUrl = (s.find(ucstring("http://")) || s.find(ucstring("https://"))); + string s = toLowerAscii(msg); + hasUrl = (s.find("http://") || s.find("https://")); } - for (ucstring::size_type i = pos; i< textSize;) + for (string::size_type i = pos; i< textSize;) { if (hasUrl && isUrlTag(msg, i, textSize)) { @@ -491,8 +486,8 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C para->addChild(vt); } - ucstring url; - ucstring title; + string url; + string title; getUrlTag(msg, i, url, title); if (url.size() > 0) { @@ -514,29 +509,29 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C if (title.size() > 0) { - vt->LinkTitle = title.toUtf8(); - vt->setText(title); + vt->LinkTitle = title; + vt->setText(vt->LinkTitle); } else { - vt->LinkTitle = url.toUtf8(); - vt->setText(url); + vt->LinkTitle = url; + vt->setText(vt->LinkTitle); } if (url.find_first_of('\'') != string::npos) { - ucstring clean; + string clean; for(string::size_type i = 0; i< url.size(); ++i) { if (url[i] == '\'') - clean += ucstring("%27"); + clean += "%27"; else clean += url[i]; } url = clean; } vt->setActionOnLeftClick("lua"); - vt->setParamsOnLeftClick("game:chatUrl('" + url.toUtf8() + "')"); + vt->setParamsOnLeftClick("game:chatUrl('" + url + "')"); para->addChildLink(vt); diff --git a/ryzom/client/src/interface_v3/chat_text_manager.h b/ryzom/client/src/interface_v3/chat_text_manager.h index 2f7e380be..5fb05999b 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.h +++ b/ryzom/client/src/interface_v3/chat_text_manager.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -30,7 +31,6 @@ namespace NLGUI class CInterfaceGroup; } -class ucstring; namespace NLMISC{ class CCDBNodeLeaf; } @@ -55,7 +55,7 @@ public: * \param justified Should be true for justified text (stretch spaces of line to fill the full width) * \param plaintext Text will not be parsed for uri markup links */ - NLGUI::CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false, bool plaintext = false); + NLGUI::CViewBase *createMsgText(const std::string &msg, NLMISC::CRGBA col, bool justified = false, bool plaintext = false); // Singleton access static CChatTextManager &getInstance(); @@ -79,8 +79,8 @@ private: bool showTimestamps() const; - NLGUI::CViewBase *createMsgTextSimple(const ucstring &msg, NLMISC::CRGBA col, bool justified, NLGUI::CInterfaceGroup *commandGroup); - NLGUI::CViewBase *createMsgTextComplex(const ucstring &msg, NLMISC::CRGBA col, bool justified, bool plaintext, NLGUI::CInterfaceGroup *commandGroup); + NLGUI::CViewBase *createMsgTextSimple(const std::string &msg, NLMISC::CRGBA col, bool justified, NLGUI::CInterfaceGroup *commandGroup); + NLGUI::CViewBase *createMsgTextComplex(const std::string &msg, NLMISC::CRGBA col, bool justified, bool plaintext, NLGUI::CInterfaceGroup *commandGroup); }; // shortcut to get text manager instance diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index f1335b95d..19e244979 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -134,10 +135,7 @@ bool CChatWindow::create(const CChatWindowDesc &desc, const std::string &chatId) return false; } _Chat->setLocalize (desc.Localize); - if (desc.Localize) - _Chat->setTitle(desc.Title.toString()); - else - _Chat->setUCTitle(desc.Title); + _Chat->setTitle(desc.Title); _Chat->setSavable(desc.Savable); // groups like system info don't have edit box. @@ -203,11 +201,12 @@ bool CChatWindow::isVisible() const } //================================================================================= -void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks /* = 0*/, bool *windowVisible /*= NULL*/) +void CChatWindow::displayMessage(const string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks /* = 0*/, bool *windowVisible /*= NULL*/) { if (!_Chat) { - nlwarning(" There's no global chat"); + if (msg != "WRN: There's no global chat") + nlwarning(" There's no global chat"); return; } CGroupList *gl; @@ -223,11 +222,11 @@ void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGr if (nodeNoTranslation) noTranslation = nodeNoTranslation->getValueBool(); - ucstring msgNoTranslate = msg; + string msgNoTranslate = msg; if (noTranslation) { - string::size_type startTr = msg.find(ucstring("{:")); - string::size_type endOfOriginal = msg.find(ucstring("}@{")); + string::size_type startTr = msg.find("{:"); + string::size_type endOfOriginal = msg.find("}@{"); if (startTr != string::npos && endOfOriginal != string::npos) { msgNoTranslate = msg.substr(0, startTr) + msg.substr(startTr+5, endOfOriginal-startTr-5); @@ -280,7 +279,7 @@ void CChatWindow::setMenu(const std::string &menuName) } //================================================================================= -void CChatWindow::setPrompt(const ucstring &prompt) +void CChatWindow::setPrompt(const string &prompt) { if (!_Chat) return; CGroupEditBox *eb = dynamic_cast(_Chat->getGroup("eb")); @@ -333,7 +332,7 @@ void CChatWindow::deleteContainer() } //================================================================================= -bool CChatWindow::rename(const ucstring &newName, bool newNameLocalize) +bool CChatWindow::rename(const string &newName, bool newNameLocalize) { return getChatWndMgr().rename(getTitle(), newName, newNameLocalize); } @@ -370,35 +369,28 @@ void CChatWindow::enableBlink(uint numBlinks) //================================================================================= void CChatWindow::setCommand(const std::string &command, bool execute) -{ - if (!_EB) return; - _EB->setCommand(ucstring(command), execute); -} - -void CChatWindow::setCommand(const ucstring &command,bool execute) { if (!_EB) return; _EB->setCommand(command, execute); } - //================================================================================= -void CChatWindow::setEntry(const ucstring &entry) +void CChatWindow::setEntry(const string &entry) { if (!_EB) return; _EB->setInputString(entry); } //================================================================================= -ucstring CChatWindow::getTitle() const +string CChatWindow::getTitle() const { if (!_Chat) { - return ucstring(""); + return string(); } else { - return _Chat->getUCTitle(); + return _Chat->getTitle(); } } @@ -493,27 +485,27 @@ void CChatWindow::setHeaderColor(const std::string &n) } //================================================================================= -void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks /*= 0*/) +void CChatWindow::displayLocalPlayerTell(const string &receiver, const string &msg, uint numBlinks /*= 0*/) { - ucstring finalMsg; + string finalMsg; CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); encodeColorTag(prop.getRGBA(), finalMsg, false); - ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); + string csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); finalMsg += csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); encodeColorTag(prop.getRGBA(), finalMsg, true); finalMsg += msg; - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", receiver); strFindReplace(finalMsg, CI18N::get("youTell"), s); displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks); CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell)); } -void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append) +void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, std::string &text, bool append) { // WARNING : The lookup table MUST contains 17 element (with the last doubled) // because we add 7 to the 8 bit color before shifting to right in order to match color @@ -521,8 +513,8 @@ void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, boo // Have 17 entry remove the need for a %16 for each color component. // By the way, this comment is more longer to type than to add the %16... // - static ucchar ConvTable[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'F'}; - ucstring str; + static char ConvTable[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'F'}; + string str; if (append) { str.reserve(7 + str.size()); @@ -559,11 +551,12 @@ void CChatWindow::clearMessages(CChatGroup::TGroupType /* gt */, uint32 /* dynam // CChatGroupWindow // ////////////////////// -void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks, bool *windowVisible) +void CChatGroupWindow::displayMessage(const string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks, bool *windowVisible) { if (!_Chat) { - nlwarning(" There's no global chat"); + if (msg != "WRN: There's no global chat") + nlwarning(" There's no global chat"); return; } @@ -583,8 +576,8 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC CInterfaceManager *pIM= CInterfaceManager::getInstance(); CRGBA newMsgColor= CRGBA::stringToRGBA(CWidgetManager::getInstance()->getParser()->getDefine("chat_group_tab_color_newmsg").c_str()); - ucstring newmsg = msg; - ucstring prefix; + string newmsg = msg; + string prefix; bool noTranslation = false; CCDBNodeLeaf *nodeNoTranslation = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + toUpper(CChatGroup::groupTypeToString(gt)) + ":DISABLE", false); @@ -592,8 +585,8 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC noTranslation = nodeNoTranslation->getValueBool(); if (noTranslation) { - string::size_type startTr = msg.find(ucstring("{:")); - string::size_type endOfOriginal = msg.find(ucstring("}@{")); + string::size_type startTr = msg.find("{:"); + string::size_type endOfOriginal = msg.find("}@{"); if (startTr != string::npos && endOfOriginal != string::npos) { newmsg = newmsg.substr(0, startTr) + newmsg.substr(startTr+5, endOfOriginal-startTr-5); @@ -638,20 +631,20 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC gl = gl2; // Add dyn chan number before string - ucstring prefix("[" + NLMISC::toString(dynamicChatDbIndex) + "]"); + string prefix = "[" + NLMISC::toString(dynamicChatDbIndex) + "]"; // Find position to put the new string // After timestamp? - size_t pos = newmsg.find(ucstring("]")); - size_t colonpos = newmsg.find(ucstring(": @{")); + size_t pos = newmsg.find("]"); + size_t colonpos = newmsg.find(": @{"); // If no ] found or if found but after the colon (so part of the user chat) - if (pos == ucstring::npos || (colonpos < pos)) + if (pos == string::npos || (colonpos < pos)) { // No timestamp, so put it right after the color and add a space - pos = newmsg.find(ucstring("}")); + pos = newmsg.find("}"); prefix += " "; } - if (pos == ucstring::npos) + if (pos == string::npos) newmsg = prefix + newmsg; else newmsg = newmsg.substr(0, pos + 1) + prefix + newmsg.substr(pos + 1); @@ -661,12 +654,12 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC if (node && node->getValueBool()) { uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChatDbIndex); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - prefix = title.empty() ? ucstring("") : ucstring(" ") + title; - pos = newmsg.find(ucstring("] ")); + prefix = (title.empty() ? "" : " ") + title; + pos = newmsg.find("] "); - if (pos == ucstring::npos) + if (pos == string::npos) newmsg = prefix + newmsg; else newmsg = newmsg.substr(0, pos) + prefix + newmsg.substr(pos); @@ -712,7 +705,7 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC } //================================================================================= -void CChatGroupWindow::displayTellMessage(const ucstring &msg, NLMISC::CRGBA col, const ucstring &sender) +void CChatGroupWindow::displayTellMessage(const string &msg, NLMISC::CRGBA col, const string &sender) { // If we are here with a tell message this is because the teller doesn't belong to any people list CGroupContainer *gcChat = createFreeTeller(sender); @@ -776,13 +769,13 @@ const string CChatGroupWindow::getValidUiStringId(const string &stringId) } //================================================================================= -CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, const string &winColor) +CGroupContainer *CChatGroupWindow::createFreeTeller(const string &winNameIn, const string &winColor) { // must parse the entity name, and eventually make it Full with shard name (eg: 'ani.yoyo' becomes 'yoyo(Aniro)') - string winNameFull= CShardNames::getInstance().makeFullNameFromRelative(PlayerSelectedMainland, winNameIn.toString()); + string winNameFull= CShardNames::getInstance().makeFullNameFromRelative(PlayerSelectedMainland, winNameIn); // remove shard name if necessary - ucstring winName= CEntityCL::removeShardFromName(winNameFull); + string winName= CEntityCL::removeShardFromName(winNameFull); // get the color string sWinColor = winColor; @@ -791,12 +784,12 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c // Look if the free teller do not already exists uint32 i; - string sWinName = winName.toString(); + string sWinName = winName; sWinName = toLower(sWinName); for (i = 0; i < _FreeTellers.size(); ++i) { CGroupContainer *pGC = _FreeTellers[i]; - if (toLower(pGC->getUCTitle().toString()) == sWinName) + if (toLower(pGC->getTitle()) == sWinName) break; } // Create container if not present @@ -818,11 +811,11 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c if (!pGC) { delete pIG; - nlwarning(" group is not a container.(%s)", winName.toString().c_str()); + nlwarning(" group is not a container.(%s)", winName.c_str()); return NULL; } // set title from the name - pGC->setUCTitle(winName); + pGC->setTitle(winName); // pGC->setSavable(true); pGC->setEscapable(true); @@ -880,7 +873,7 @@ void CChatGroupWindow::updateAllFreeTellerHeaders() //================================================================================= void CChatGroupWindow::updateFreeTellerHeader(CGroupContainer &ft) { - ucstring name = ft.getUCTitle(); + string name = ft.getTitle(); CCtrlBaseButton *newFriendBut = dynamic_cast(ft.getCtrl("new_friend")); CCtrlBaseButton *ignoreBut = dynamic_cast(ft.getCtrl("ignore")); CCtrlBaseButton *inviteBut = dynamic_cast(ft.getCtrl("invite")); @@ -914,7 +907,7 @@ void CChatGroupWindow::updateFreeTellerHeader(CGroupContainer &ft) } //================================================================================= -void CChatGroupWindow::setActiveFreeTeller(const ucstring &winName, bool bActive) +void CChatGroupWindow::setActiveFreeTeller(const string &winName, bool bActive) { CGroupContainer *pGC = createFreeTeller(winName); if (pGC != NULL) @@ -922,7 +915,7 @@ void CChatGroupWindow::setActiveFreeTeller(const ucstring &winName, bool bActive } //================================================================================= -ucstring CChatGroupWindow::getFreeTellerName(const std::string &containerID) +string CChatGroupWindow::getFreeTellerName(const std::string &containerID) { uint32 i; for (i = 0; i < _FreeTellers.size(); ++i) @@ -932,8 +925,8 @@ ucstring CChatGroupWindow::getFreeTellerName(const std::string &containerID) break; } if (i == _FreeTellers.size()) - return ucstring(""); - return _FreeTellers[i]->getUCTitle(); + return string(); + return _FreeTellers[i]->getTitle(); } //================================================================================= @@ -978,7 +971,7 @@ void CChatGroupWindow::removeAllFreeTellers() //================================================================================= void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) { - f.serialVersion(2); + f.serialVersion(3); // Save the free teller only if it is present in the friend list to avoid the only-growing situation // because free tellers are never deleted in game if we save/load all the free tellers, we just create more @@ -986,7 +979,7 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) uint32 i, nNbFreeTellerSaved = 0; for (i = 0; i < _FreeTellers.size(); ++i) - if (PeopleInterraction.FriendList.getIndexFromName(_FreeTellers[i]->getUCTitle()) != -1) + if (PeopleInterraction.FriendList.getIndexFromName(_FreeTellers[i]->getTitle()) != -1) nNbFreeTellerSaved++; f.serial(nNbFreeTellerSaved); @@ -995,9 +988,9 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) { CGroupContainer *pGC = _FreeTellers[i]; - if (PeopleInterraction.FriendList.getIndexFromName(pGC->getUCTitle()) != -1) + if (PeopleInterraction.FriendList.getIndexFromName(pGC->getTitle()) != -1) { - ucstring sTitle = pGC->getUCTitle(); + string sTitle = pGC->getTitle(); f.serial(sTitle); } } @@ -1006,7 +999,7 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) //================================================================================= void CChatGroupWindow::loadFreeTeller(NLMISC::IStream &f) { - sint ver = f.serialVersion(2); + sint ver = f.serialVersion(3); if (ver == 1) { @@ -1026,10 +1019,15 @@ void CChatGroupWindow::loadFreeTeller(NLMISC::IStream &f) string sID; f.serial(sID); } - ucstring sTitle; - f.serial(sTitle); + string title; + if (ver < 3) + { + ucstring sTitle; // Old UTF-16 serial + f.serial(sTitle); + title = sTitle.toUtf8(); + } - CGroupContainer *pGC = createFreeTeller(sTitle, ""); + CGroupContainer *pGC = createFreeTeller(title, ""); // With version 1 all tells are active because windows information have "title based" ids and no "sID based". if ((ver == 1) && (pGC != NULL)) @@ -1139,10 +1137,7 @@ CChatWindow *CChatWindowManager::createChatWindow(const CChatWindowDesc &desc) if (desc.Id.empty()) _WindowID++; - if (desc.Localize) - _ChatWindowMap[CI18N::get(desc.Title.toString())] = w; - else - _ChatWindowMap[desc.Title] = w; + _ChatWindowMap[desc.Title] = w; w->setAHOnActive(desc.AHOnActive); w->setAHOnActiveParams(desc.AHOnActiveParams); @@ -1181,10 +1176,7 @@ CChatWindow *CChatWindowManager::createChatGroupWindow(const CChatWindowDesc &de if (desc.Id.empty()) _WindowID++; - if (desc.Localize) - _ChatWindowMap[CI18N::get(desc.Title.toString())] = w; - else - _ChatWindowMap[desc.Title] = w; + _ChatWindowMap[desc.Title] = w; w->setAHOnActive(desc.AHOnActive); w->setAHOnActiveParams(desc.AHOnActiveParams); @@ -1213,7 +1205,7 @@ CChatWindow *CChatWindowManager::createChatGroupWindow(const CChatWindowDesc &de } //================================================================================= -CChatWindow *CChatWindowManager::getChatWindow(const ucstring &title) +CChatWindow *CChatWindowManager::getChatWindow(const string &title) { TChatWindowMap::iterator it = _ChatWindowMap.find(title); if (it == _ChatWindowMap.end()) @@ -1226,12 +1218,12 @@ CChatWindow *CChatWindowManager::getChatWindow(const ucstring &title) } //================================================================================= -void CChatWindowManager::removeChatWindow(const ucstring &title) +void CChatWindowManager::removeChatWindow(const string &title) { TChatWindowMap::iterator it = _ChatWindowMap.find(title); if (it == _ChatWindowMap.end()) { - nlwarning("unknwown window %s", title.toString().c_str()); + nlwarning("Unknown chat window '%s'", title.c_str()); return; } it->second->deleteContainer(); @@ -1260,29 +1252,20 @@ CChatWindow *CChatWindowManager::getChatWindowFromCaller(CCtrlBase *caller) } if (!father) return NULL; - return getChatWindow(father->getUCTitle()); + return getChatWindow(father->getTitle()); } //================================================================================= -bool CChatWindowManager::rename(const ucstring &oldName, const ucstring &newName, bool newNameLocalize) +bool CChatWindowManager::rename(const string &oldName, const string &newName, bool newNameLocalize) { // if (oldName == newName) return true; CChatWindow *newWin = getChatWindow(newName); if (newWin != NULL) return false; // target window exists TChatWindowMap::iterator it = _ChatWindowMap.find(oldName); if (it == _ChatWindowMap.end()) return false; - if (newNameLocalize) - { - _ChatWindowMap[CI18N::get(newName.toString())] = it->second; - it->second->getContainer()->setLocalize(true); - it->second->getContainer()->setTitle(newName.toString()); - } - else - { - _ChatWindowMap[newName] = it->second; - it->second->getContainer()->setLocalize(false); - it->second->getContainer()->setUCTitle(newName); - } + _ChatWindowMap[newName] = it->second; + it->second->getContainer()->setLocalize(newNameLocalize); + it->second->getContainer()->setTitle(newName); _ChatWindowMap.erase(it); return true; } @@ -1322,7 +1305,7 @@ public: { CGroupEditBox *pEB = dynamic_cast(pCaller); if (pEB == NULL) return; - ucstring text = pEB->getInputString(); + string text = pEB->getInputString(); // If the line is empty, do nothing if(text.empty()) return; @@ -1338,7 +1321,7 @@ public: // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) { - pEB->setInputString (string("")); + pEB->setInputString(std::string()); return; } @@ -1346,7 +1329,7 @@ public: if(text[0] == '/') { CChatWindow::_ChatWindowLaunchingCommand = chat; - string str = text.toUtf8(); + string str = text; string cmdWithArgs = str.substr(1); // Get the command name from the string, can contain spaces @@ -1367,7 +1350,7 @@ public: else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (cmd + ": " + CI18N::get ("uiCommandNotExists")); } } else @@ -1378,7 +1361,7 @@ public: } } // Clear input string - pEB->setInputString (ucstring("")); + pEB->setInputString (std::string()); CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() ); if (gc) @@ -1395,13 +1378,13 @@ REGISTER_ACTION_HANDLER(CHandlerChatBoxEntry, "chat_box_entry"); -static ucstring getFreeTellerName(CInterfaceElement *pCaller) +static string getFreeTellerName(CInterfaceElement *pCaller) { - if (!pCaller) return ucstring(); + if (!pCaller) return string(); CChatGroupWindow *cgw = PeopleInterraction.getChatGroupWindow(); - if (!cgw) return ucstring(); + if (!cgw) return string(); CInterfaceGroup *freeTeller = pCaller->getParentContainer(); - if (!freeTeller) return ucstring(); + if (!freeTeller) return string(); return cgw->getFreeTellerName( freeTeller->getId() ); } @@ -1411,7 +1394,7 @@ class CHandlerAddTellerToFriendList : public IActionHandler public: void execute (CCtrlBase *pCaller, const std::string &/* sParams */) { - ucstring playerName = ::getFreeTellerName(pCaller); + string playerName = ::getFreeTellerName(pCaller); if (!playerName.empty()) { sint playerIndex = PeopleInterraction.IgnoreList.getIndexFromName(playerName); @@ -1439,7 +1422,7 @@ public: CInterfaceManager *im = CInterfaceManager::getInstance(); std::string callerId = getParam(sParams, "id"); CInterfaceElement *prevCaller = CWidgetManager::getInstance()->getElementFromId(callerId); - ucstring playerName = ::getFreeTellerName(prevCaller); + string playerName = ::getFreeTellerName(prevCaller); if (!playerName.empty()) { // if already in friend list, ask to move rather than add @@ -1471,16 +1454,16 @@ class CHandlerInviteToRingSession : public IActionHandler public: void execute (CCtrlBase *pCaller, const std::string &/* sParams */) { - ucstring playerName = ::getFreeTellerName(pCaller); + string playerName = ::getFreeTellerName(pCaller); if (!playerName.empty()) { // ask the SBS to invite the character in the session - CSessionBrowserImpl::getInstance().inviteCharacterByName(CSessionBrowserImpl::getInstance().getCharId(), playerName.toUtf8()); + CSessionBrowserImpl::getInstance().inviteCharacterByName(CSessionBrowserImpl::getInstance().getCharId(), playerName); // additionaly, send a tell to signal the player he has been invited to a ring session - ChatMngr.tell(playerName.toUtf8(), CI18N::get("uiRingInviteNotification")); + ChatMngr.tell(playerName, CI18N::get("uiRingInviteNotification")); // CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo(ucstring("@{6F6F}") + playerName +ucstring(" @{FFFF}") + CI18N::get("uiRingInvitationSent"), "BC"); + im->displaySystemInfo("@{6F6F}" + playerName +" @{FFFF}" + CI18N::get("uiRingInvitationSent"), "BC"); // force a refresh of the ui CLuaManager::getInstance().executeLuaScript("CharTracking:forceRefresh()"); } diff --git a/ryzom/client/src/interface_v3/chat_window.h b/ryzom/client/src/interface_v3/chat_window.h index 278824753..88104e4f9 100644 --- a/ryzom/client/src/interface_v3/chat_window.h +++ b/ryzom/client/src/interface_v3/chat_window.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -22,7 +23,6 @@ #ifndef CL_CHAT_WINDOW_H #define CL_CHAT_WINDOW_H -#include "nel/misc/ucstring.h" #include "nel/misc/smart_ptr.h" #include "game_share/chat_group.h" @@ -46,7 +46,7 @@ class CChatWindow; struct IChatWindowListener { // the user entered a msg in the given chat box - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) = 0; + virtual void msgEntered(const std::string &msg, CChatWindow *chatWindow) = 0; }; @@ -56,7 +56,7 @@ struct CChatWindowDesc { typedef std::vector > TTemplateParams; - ucstring Title; // unique title for the window + std::string Title; // unique title for the window std::string FatherContainer; // name of the father container. If empty, the chat box must be added manually in the hierarchy std::string ChatTemplate; // Template for the chat interface, or "" to use the default one TTemplateParams ChatTemplateParams; // optional template parameters @@ -93,12 +93,12 @@ public: // called by a CChatWindow when it is deleted virtual void chatWindowRemoved(CChatWindow * /* cw */) {} // called by a CChatWindow when a msg has been displayed in it ('displayMessage' has been called) - //virtual void displayMessage(CChatWindow *cw, const ucstring &msg, NLMISC::CRGBA col, uint numBlinks = 0) {} + //virtual void displayMessage(CChatWindow *cw, const std::string &msg, NLMISC::CRGBA col, uint numBlinks = 0) {} }; public: // display a message in this chat box with the given color - virtual void displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); - virtual void displayTellMessage(const ucstring &/* msg */, NLMISC::CRGBA /* col */, const ucstring &/* sender */) {} + virtual void displayMessage(const std::string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); + virtual void displayTellMessage(const std::string &/* msg */, NLMISC::CRGBA /* col */, const std::string &/* sender */) {} virtual void clearMessages(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex); // Test if the window is visible bool isVisible() const; @@ -108,17 +108,15 @@ public: void enableBlink(uint numBlinks); // set a command to be displayed and eventually executed in this chat window. std::string version for backward compatibility void setCommand(const std::string &command, bool execute); - // set a command to be displayed and eventually executed in this chat window - void setCommand(const ucstring &command, bool execute); // set a string to be displayed in the edit box of this window (if it has one) - void setEntry(const ucstring &entry); + void setEntry(const std::string &entry); // Set listener to react to a chat entry void setListener(IChatWindowListener *listener) { _Listener = listener; } IChatWindowListener *getListener() const { return _Listener; } // Set the menu for the chat void setMenu(const std::string &menuName); // Set a new prompt for the chat window - void setPrompt(const ucstring &prompt); + void setPrompt(const std::string &prompt); // Set the color for the chat window void setPromptColor(NLMISC::CRGBA col); /** Get the container associated with this chat window @@ -130,7 +128,7 @@ public: /** try to rename the chat window * \return true if success */ - bool rename(const ucstring &newName, bool newNameLocalize); + bool rename(const std::string &newName, bool newNameLocalize); /** delete the container * Don't do it in the dtor, because done automatically at the end of the app by the interface manager. * Useful only if querried by the user @@ -139,7 +137,7 @@ public: // get the last chat window from which a command has been called static CChatWindow *getChatWindowLaunchingCommand() { return _ChatWindowLaunchingCommand; } // get the title of this chat window - ucstring getTitle() const; + std::string getTitle() const; // observers void addObserver(IObserver *obs); void removeObserver(IObserver *obs); @@ -153,10 +151,10 @@ public: void setAHOnCloseButtonParams(const std::string &n); void setHeaderColor(const std::string &n); // - void displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks = 0); + void displayLocalPlayerTell(const std::string &receiver, const std::string &msg, uint numBlinks = 0); /// Encode a color tag '@{RGBA}' in the text. If append is true, append at end of text, otherwise, replace the text - static void encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append=true); + static void encodeColorTag(const NLMISC::CRGBA &color, std::string &text, bool append=true); /////////////////////////////////////////////////////////////////////////////////////// protected: @@ -188,16 +186,16 @@ class CChatGroupWindow : public CChatWindow public: CChatGroupWindow() {} // display a message in this chat box with the given color (callback from chat input filter) - virtual void displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); - virtual void displayTellMessage(const ucstring &msg, NLMISC::CRGBA col, const ucstring &sender); + virtual void displayMessage(const std::string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); + virtual void displayTellMessage(const std::string &msg, NLMISC::CRGBA col, const std::string &sender); virtual void clearMessages(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex); sint32 getTabIndex(); void setTabIndex(sint32 n); // Free Teller - NLGUI::CGroupContainer *createFreeTeller(const ucstring &winName, const std::string &winColor=""); - void setActiveFreeTeller(const ucstring &winName, bool bActive=true); - ucstring getFreeTellerName(const std::string &containerID); + NLGUI::CGroupContainer *createFreeTeller(const std::string &winName, const std::string &winColor=""); + void setActiveFreeTeller(const std::string &winName, bool bActive=true); + std::string getFreeTellerName(const std::string &containerID); bool removeFreeTeller(const std::string &containerID); // Return true if free teller found void removeAllFreeTellers(); void saveFreeTeller(NLMISC::IStream &f); @@ -244,9 +242,9 @@ public: CChatWindow *createChatGroupWindow(const CChatWindowDesc &desc); // Get a chat window by its title - CChatWindow *getChatWindow(const ucstring &title); + CChatWindow *getChatWindow(const std::string &title); /// Remove a chat window by its title - void removeChatWindow(const ucstring &title); + void removeChatWindow(const std::string &title); // Remove a chat window by its pointer void removeChatWindow(CChatWindow *cw); /// from a ctrl of a chat box that triggered a menu, or an event, retrieve the associated chat box @@ -254,14 +252,14 @@ public: // Singleton pattern applied to the chat window manager static CChatWindowManager &getInstance(); // try to rename a window - bool rename(const ucstring &oldName, const ucstring &newName, bool newNameLocalize); + bool rename(const std::string &oldName, const std::string &newName, bool newNameLocalize); // warning : this is slow uint getNumChatWindow() const { return (uint)_ChatWindowMap.size(); } // warning : this is slow : for debug only CChatWindow *getChatWindowByIndex(uint index); /////////////////////////////////////////////////////////////////////////////////////// private: - typedef std::map > TChatWindowMap; + typedef std::map > TChatWindowMap; private: // TChatWindowMap _ChatWindowMap; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 63e1ce682..599e99716 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1,8 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2011 Jan BOON (Kaetemi) +// Copyright (C) 2011-2020 Jan BOON (Kaetemi) // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // @@ -103,9 +103,13 @@ void CControlSheetInfoWaiter::infoReceived() } -ucstring CControlSheetInfoWaiter::infoValidated() const +string CControlSheetInfoWaiter::infoValidated() const { - ucstring help; +#ifdef RYZOM_LUA_UCSTRING + ucstring help; // Compatibility +#else + string help; +#endif if (CtrlSheet && !LuaMethodName.empty()) { // delegate setup of context he help ( & window ) to lua @@ -123,7 +127,12 @@ ucstring CControlSheetInfoWaiter::infoValidated() const // retrieve result from stack if (!ls->empty()) { +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::pop(*ls, help); +#else + help = ls->toString(-1); + ls->pop(); +#endif } else { @@ -132,7 +141,11 @@ ucstring CControlSheetInfoWaiter::infoValidated() const } } +#ifdef RYZOM_LUA_UCSTRING + return help.toUtf8(); +#else return help; +#endif } // *************************************************************************** @@ -180,7 +193,11 @@ int CDBCtrlSheet::luaGetItemInfo(CLuaState &ls) // *************************************************************************** int CDBCtrlSheet::luaGetName(CLuaState &ls) { - CLuaIHM::push(ls, getItemActualName()); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(ls, ucstring::makeFromUtf8(getItemActualName())); +#else + ls.push(getItemActualName()); +#endif return 1; } @@ -208,9 +225,13 @@ int CDBCtrlSheet::luaGetCreatorName(CLuaState &ls) { uint32 itemSlotId = getInventory().getItemSlotId(this); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ucstring creatorName; + string creatorName; STRING_MANAGER::CStringManagerClient::instance()->getString(itemInfo.CreatorName, creatorName); - CLuaIHM::push(ls, creatorName); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(ls, ucstring::makeFromUtf8(creatorName)); // FIXME: Lua UTF-8 +#else + ls.push(creatorName); +#endif return 1; } @@ -326,29 +347,30 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr prop = (char*) xmlGetProp( cur, (xmlChar*)"nature" ); if (prop) { - if (NLMISC::toLower(prop.str()) == "item") + std::string lwrProp = NLMISC::toLower(prop.str()); + if (lwrProp == "item") _Type = CCtrlSheetInfo::SheetType_Item; - else if (NLMISC::toLower(prop.str()) == "pact") + else if (lwrProp == "pact") _Type = CCtrlSheetInfo::SheetType_Pact; - else if (NLMISC::toLower(prop.str()) == "skill") + else if (lwrProp == "skill") _Type = CCtrlSheetInfo::SheetType_Skill; - else if (NLMISC::toLower(prop.str()) == "auto") + else if (lwrProp == "auto") _Type = CCtrlSheetInfo::SheetType_Auto; - else if (NLMISC::toLower(prop.str()) == "macro") + else if (lwrProp == "macro") _Type = CCtrlSheetInfo::SheetType_Macro; - else if (NLMISC::toLower(prop.str()) == "guild_flag") + else if (lwrProp == "guild_flag") _Type = CCtrlSheetInfo::SheetType_GuildFlag; - else if (NLMISC::toLower(prop.str()) == "mission") + else if (lwrProp == "mission") _Type = CCtrlSheetInfo::SheetType_Mission; - else if (NLMISC::toLower(prop.str()) == "sbrick") + else if (lwrProp == "sbrick") _Type = CCtrlSheetInfo::SheetType_SBrick; - else if (NLMISC::toLower(prop.str()) == "sphraseid") + else if (lwrProp == "sphraseid") _Type = CCtrlSheetInfo::SheetType_SPhraseId; - else if (NLMISC::toLower(prop.str()) == "sphrase") + else if (lwrProp == "sphrase") _Type = CCtrlSheetInfo::SheetType_SPhrase; - else if (NLMISC::toLower(prop.str()) == "elevator_destination") + else if (lwrProp == "elevator_destination") _Type = CCtrlSheetInfo::SheetType_ElevatorDestination; - else if (NLMISC::toLower(prop.str()) == "outpost_building") + else if (lwrProp == "outpost_building") _Type = CCtrlSheetInfo::SheetType_OutpostBuilding; } @@ -356,7 +378,7 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_noitem" ); if (prop) { - string TxName = toLower((const char *) prop); + string TxName = toLowerAscii((const char *) prop); CViewRenderer &rVR = *CViewRenderer::getInstance(); _DispNoSheetBmpId = rVR.getTextureIdFromName (TxName); } @@ -402,23 +424,23 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" ); if (prop) { - _ListMenuLeft = toLower((const char *) prop); + _ListMenuLeft = toLowerAscii((const char *) prop); } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); if (prop) { - _ListMenuRight = toLower((const char *) prop); + _ListMenuRight = toLowerAscii((const char *) prop); } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r_empty_slot" ); if (prop) { - _ListMenuRightEmptySlot = toLower((const char *) prop); + _ListMenuRightEmptySlot = toLowerAscii((const char *) prop); } // list menu on both clicks prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" ); if (prop) { - setListMenuBoth(toLower((const char *) prop)); + setListMenuBoth(toLowerAscii((const char *) prop)); } // _BrickTypeBitField @@ -431,7 +453,7 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr // The string may have multiple brick type separated by | string brickTypeArray= (const char*)prop; vector strList; - NLMISC::splitString(NLMISC::toUpper(brickTypeArray), "|", strList); + NLMISC::splitString(NLMISC::toUpperAscii(brickTypeArray), "|", strList); // Test All words for(uint i=0;i &bricks, const ucstring &phraseName) +void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector &bricks, const string &phraseName) { CSBrickManager *pBM = CSBrickManager::getInstance(); @@ -1762,7 +1784,7 @@ void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector &bri { // Compute the text from the phrase only if needed // string iconName= phraseName.toString(); - string iconName= phraseName.toUtf8(); + const string &iconName = phraseName; if( _NeedSetup || iconName != _OptString ) { // recompute text @@ -1785,7 +1807,7 @@ void CDBCtrlSheet::setupSPhrase() CSPhraseSheet *pSPS = dynamic_cast(SheetMngr.get(CSheetId(sheet))); if (pSPS && !pSPS->Bricks.empty()) { - const ucstring phraseName(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(CSheetId(sheet))); + const char *phraseName = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(CSheetId(sheet)); setupDisplayAsPhrase(pSPS->Bricks, phraseName); } else @@ -1843,7 +1865,7 @@ void CDBCtrlSheet::setupSPhraseId () } else { - setupDisplayAsPhrase(phrase.Bricks, phrase.Name); + setupDisplayAsPhrase(phrase.Bricks, phrase.Name.toUtf8()); // FIXME: UTF-8 (serial) } } @@ -1950,9 +1972,9 @@ void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown) if (text.size() > 4 && text[0] == 'u' && text[1] == 'i' && text[2] == 'i' && text[3] == 't' && CI18N::hasTranslation(text)) { // NOTE: translated text is expected to be us-ascii only - text = CI18N::get(text).toUtf8(); + text = CI18N::get(text); } - text = toLower(text); + text = toLowerAscii(text); CViewRenderer &rVR = *CViewRenderer::getInstance(); @@ -2215,7 +2237,7 @@ void CDBCtrlSheet::drawRegenText() } else { - _RegenText->setText(ucstring()); + _RegenText->setText(""); } } else @@ -3519,7 +3541,7 @@ void CDBCtrlSheet::setupItemInfoWaiter() } // *************************************************************************** -void CDBCtrlSheet::getContextHelp(ucstring &help) const +void CDBCtrlSheet::getContextHelp(std::string &help) const { if (getType() == CCtrlSheetInfo::SheetType_Skill) { @@ -3534,22 +3556,22 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const if (!macro) return; - ucstring macroName = macro->Name; + string macroName = macro->Name; if (macroName.empty()) macroName = CI18N::get("uiNotAssigned"); - ucstring assignedTo = macro->Combo.toUCString(); + string assignedTo = macro->Combo.toString(); if (assignedTo.empty()) assignedTo = CI18N::get("uiNotAssigned"); - ucstring dispText; - ucstring dispCommands; + string dispText; + string dispCommands; const CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); uint nb = 0; for (uint i = 0; i < macro->Commands.size(); ++i) { - ucstring commandName; + string commandName; for (uint j = 0; j < pMCM->ActionManagers.size(); ++j) { CAction::CName c(macro->Commands[i].Name.c_str(), macro->Commands[i].Params.c_str()); @@ -3565,13 +3587,13 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } } // formats - dispText = ucstring("%n (@{6F6F}%k@{FFFF})\n%c"); + dispText = "%n (@{6F6F}%k@{FFFF})\n%c"; if (nb > 5) // more? dispCommands += toString(" ... @{6F6F}%i@{FFFF}+", nb-5); - strFindReplace(dispText, ucstring("%n"), macroName); - strFindReplace(dispText, ucstring("%k"), assignedTo); - strFindReplace(dispText, ucstring("%c"), dispCommands); + strFindReplace(dispText, "%n", macroName); + strFindReplace(dispText, "%k", assignedTo); + strFindReplace(dispText, "%c", dispCommands); help = dispText; } else if(getType() == CCtrlSheetInfo::SheetType_Item) @@ -3594,7 +3616,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } else { - help = getItemActualName(); + help = getItemActualName();; } } else @@ -3634,7 +3656,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const sint32 phraseId= getSheetId(); if (phraseId == 0) { - help = ucstring(); + help = std::string(); } else { @@ -3652,10 +3674,16 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const game = game["game"]; game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1); // retrieve result from stack - help = ucstring(); if (!ls->empty()) { - CLuaIHM::pop(*ls, help); +#ifdef RYZOM_LUA_UCSTRING + ucstring tmpHelp; // Compatibility + CLuaIHM::pop(*ls, tmpHelp); + help = tmpHelp.toUtf8(); +#else + help = ls->toString(); + ls->pop(); +#endif } else { @@ -3676,10 +3704,10 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const if (phraseSheetID != 0) { // is it a built-in phrase? - ucstring desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID)); + string desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID)); if (!desc.empty()) { - help += ucstring("\n\n@{CCCF}") + desc; + help += "\n\n@{CCCF}" + desc; } } */ @@ -3703,7 +3731,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } // *************************************************************************** -void CDBCtrlSheet::getContextHelpToolTip(ucstring &help) const +void CDBCtrlSheet::getContextHelpToolTip(std::string &help) const { // Special case for buff items and spell crystals, only for tooltips if (getType() == CCtrlSheetInfo::SheetType_Item) @@ -4703,14 +4731,14 @@ void CDBCtrlSheet::initArmourColors() // *************************************************************************** -ucstring CDBCtrlSheet::getItemActualName() const +string CDBCtrlSheet::getItemActualName() const { const CItemSheet *pIS= asItemSheet(); if(!pIS) - return ucstring(); + return string(); else { - ucstring ret; + string ret; // If NameId not 0, get from StringManager uint32 nameId= getItemNameId(); if(nameId) @@ -4727,7 +4755,7 @@ ucstring CDBCtrlSheet::getItemActualName() const if (pIS->Family == ITEMFAMILY::SCROLL_R2) { const R2::TMissionItem *mi = R2::getEditor().getPlotItemInfos(getSheetId()); - if (mi) return mi->Name; + if (mi) return mi->Name.toUtf8(); } // if item is not a mp, append faber_quality & faber_stat_type // Don't append quality and stat type for Named Items!!! @@ -4742,21 +4770,21 @@ ucstring CDBCtrlSheet::getItemActualName() const { // get description string for item format std::string formatID = getItemRMFaberStatType() != RM_FABER_STAT_TYPE::Unknown ? "uihelpItemFaberPrefixAndSuffix" : "uihelpItemFaberPrefix"; - ucstring format; + string format; if (!CI18N::hasTranslation(formatID)) { - format = ucstring("%p %n %s"); // not found, uses default string + format = "%p %n %s"; // not found, uses default string } else { format = CI18N::get(formatID); } // suffix - strFindReplace(format, ucstring("%p"), RM_CLASS_TYPE::toLocalString(getItemRMClassType())); + strFindReplace(format, "%p", RM_CLASS_TYPE::toLocalString(getItemRMClassType())); // name - strFindReplace(format, ucstring("%n"), ret); + strFindReplace(format, "%n", ret); // prefix - strFindReplace(format, ucstring("%s"), CI18N::get(toString("mpstatItemQualifier%d", (int) getItemRMFaberStatType()).c_str())); + strFindReplace(format, "%s", CI18N::get(toString("mpstatItemQualifier%d", (int) getItemRMFaberStatType()).c_str())); ret = format; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.h b/ryzom/client/src/interface_v3/dbctrl_sheet.h index 4e3032b3a..2ccbdf00a 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -1,8 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2011 Jan BOON (Kaetemi) +// Copyright (C) 2011-2020 Jan BOON (Kaetemi) // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // @@ -73,7 +73,7 @@ public: : IItemInfoWaiter(), Requesting(false) { } public: - ucstring infoValidated() const; + std::string infoValidated() const; void sendRequest(); virtual void infoReceived(); }; @@ -393,9 +393,9 @@ public: NLMISC::CRGBA getSheetColor() const {return _SheetColor;} /// Special ContextHelp for ctrl sheet. - virtual void getContextHelp(ucstring &help) const; + virtual void getContextHelp(std::string &help) const; - virtual void getContextHelpToolTip(ucstring &help) const; + virtual void getContextHelpToolTip(std::string &help) const; /** true if an item of another ctrlSheet can be dropped on this slot. @@ -582,7 +582,7 @@ public: void setItemColor(sint32 val) {if(_UserColor) _UserColor->setValue32(val);} // Get the Actual item name. Localized version of SheetId, or given by server through NAMEID. - ucstring getItemActualName() const; + std::string getItemActualName() const; /// true if support drag copy (with CTRL). action handler has to check control. bool canDragCopy() const {return _DragCopy;} @@ -645,7 +645,7 @@ protected: // optSheet is for special faber void setupDisplayAsSBrick(sint32 sheet, sint32 optSheet= 0); // setup icon from phrases - void setupDisplayAsPhrase(const std::vector &bricks, const ucstring &phraseName); + void setupDisplayAsPhrase(const std::vector &bricks, const std::string &phraseName); // draw a number and returns the width of the drawn number sint32 drawNumber(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, NLMISC::CRGBA color, sint32 value, bool rightAlign=true); diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index 3cd8e759c..43c03d5fc 100644 --- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -279,7 +280,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase() // Empty the name if(_UserSentenceName) { - _UserSentenceName->setInputString(ucstring()); + _UserSentenceName->setInputString(std::string()); } // update Display @@ -295,7 +296,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase) CSBrickManager *pBM= CSBrickManager::getInstance(); - ucstring name; + string name; // if phrase empty (new phrase), invent a new name if(phrase.empty()) @@ -309,7 +310,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase) else { // copy name - name= phrase.Name; + name= phrase.Name.toUtf8(); // get the root Brick. Must exist. CSBrickSheet *rootBrick= pBM->getBrick(phrase.Bricks[0]); @@ -1074,7 +1075,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) float relative_cost; cost= pBM->getSabrinaCom().getPhraseBrickAndParamCost(phrase.Bricks, i); relative_cost = pBM->getSabrinaCom().getPhraseBrickAndParamRelativeCost(phrase.Bricks, i); - ucstring costText; + std::string costText; if( cost == 0 && relative_cost != 0.f ) { cost = (sint32)(relative_cost * 100.f); @@ -1241,7 +1242,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) // **** Setup the phrase Desc if(_TextPhraseDesc) { - ucstring text; + string text; pPM->buildPhraseDesc(text, phrase, 0, false, "composition"); _TextPhraseDesc->setTextFormatTaged(text); } @@ -1790,7 +1791,7 @@ void CDBGroupBuildPhrase::buildCurrentPhrase(CSPhraseCom &newPhrase) // Set the Name if(_UserSentenceName) { - newPhrase.Name= _UserSentenceName->getInputString(); + newPhrase.Name= ucstring::makeFromUtf8(_UserSentenceName->getInputString()); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index c2074ee03..487b77c99 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2014 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index f6f4bbc8d..211d872dc 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2014 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp index f41dd3085..405a83868 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h index d63e664ed..382b8e216 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp index be89ead3d..e0d4654c8 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -135,7 +136,7 @@ void CDBGroupListSheetIconPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin CViewText *name = dynamic_cast(pIG->getView("name")); if (name != NULL) { - ucstring sectionText= CI18N::get("uiPhraseSectionFmt"); + string sectionText= CI18N::get("uiPhraseSectionFmt"); uint32 minLevel, maxLevel; CSPhraseManager *pPM= CSPhraseManager::getInstance(); pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index da46e9e7b..188e06225 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -56,7 +57,7 @@ CViewText *CDBGroupListSheetMission::CSheetChildMission::createViewText() const CViewTextIDFormated *vti = new CViewTextIDFormated(CViewBase::TCtorParam()); if (Ctrl) vti->setDBLeaf(dynamic_cast(Ctrl->getRootBranch()->getNode(ICDBNode::CTextId("TEXT")))); else vti->setDBLeaf(NULL); - vti->setFormatString(ucstring("$t")); + vti->setFormatString("$t"); return vti; } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h index b2781eff6..da29a753e 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -36,7 +39,7 @@ public: // A child node struct CSheetChildMission : public CDBGroupListSheetText::CSheetChild { - virtual void updateText(CDBGroupListSheetText * /* pFather */, ucstring &/* text */) {} + //virtual void updateText(CDBGroupListSheetText * /* pFather */, std::string &/* text */) {} virtual CViewText *createViewText() const; virtual void updateViewText(CDBGroupListSheetText *pFather); virtual bool isInvalidated(CDBGroupListSheetText *pFather); diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index f34053396..8cc114508 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2014 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2015 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -313,7 +313,7 @@ void CDBGroupListSheetText::updateCoords () else { // if not received, must insert in list of pending dynstring to check each frame - ucstring result; + string result; if( !STRING_MANAGER::CStringManagerClient::instance()->getDynString ( curNameId, result) ) _NameIdToUpdate.insert( _SheetChildren[i] ); } @@ -492,7 +492,7 @@ void CDBGroupListSheetText::checkCoords () { CSheetChild * cst = (*it); // String result - ucstring result; + string result; if( STRING_MANAGER::CStringManagerClient::instance()->getDynString ( cst->NameId, result) ) { set< CSheetChild *>::iterator itTmp = it; @@ -1051,7 +1051,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem() if(Ctrl && Text && Ctrl->getSheetCategory() == CDBCtrlSheet::Item) { // get the text - ucstring text; + std::string text; Ctrl->getContextHelp(text); // Text color red if requirement not met @@ -1070,7 +1070,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem() // Add craft info for MP if(pIS->Family==ITEMFAMILY::RAW_MATERIAL) { - ucstring ipList; + string ipList; pIS->getItemPartListAsText(ipList); if(ipList.empty()) { diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index 2486bfc29..329d7bcea 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2014 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -133,7 +134,7 @@ public: // Called at updateCoords to remake the text virtual void updateViewText(CDBGroupListSheetText * /* pFather */) { - ucstring text; + std::string text; Ctrl->getContextHelp(text); Text->setText(text); } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp index 490c36b85..842cb4ba7 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -110,11 +110,11 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::init(CDBGroupListS // *************************************************************************** -bool hasOnlyBlankChars(const ucstring &str) +bool hasOnlyBlankChars(const char *str) { - for(uint i=0;i!=str.size();++i) + for (ptrdiff_t i = 0; str[i]; ++i) { - if(str[i]!=' ') + if (str[i] != ' ') return false; } @@ -128,15 +128,15 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB CSBrickManager *pBM= CSBrickManager::getInstance(); CDBGroupListSheetTextBrickComposition *compoList= (CDBGroupListSheetTextBrickComposition*)pFather; - ucstring text; + string text; if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SBrick) return; // Get the compo description of the phrase (Desc2) CSheetId brickSheetId= CSheetId(Ctrl->getSheetId()); // Temp if the Desc2 is empty, set Name - ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); - if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation + const char *desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); + if( *desc2 && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation Text->setText(desc2); else { @@ -159,7 +159,7 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB { // Special Case for the "Remove Brick" brick. No Cost (not revelant) if( brick->Id==pBM->getInterfaceRemoveBrick() ) - CostView->setText( ucstring() ); + CostView->setText( std::string() ); else if( brick->SabrinaCost == 0 && brick->SabrinaRelativeCost != 0.f ) CostView->setText( toString("%+d", (sint32)(brick->SabrinaRelativeCost * 100.f) ) + string("%") ); else diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp index ec1bfbaed..80209c99e 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -77,7 +78,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::init(CDBGroupListSheetText // *************************************************************************** void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */) { - ucstring text; + std::string text; if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhrase) return; @@ -87,7 +88,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupList // append the level if possible if(LevelDB) { - ucstring fmt= CI18N::get("uiPhraseLevelFmt"); + std::string fmt= CI18N::get("uiPhraseLevelFmt").toUtf8(); strFindReplace(fmt, "%d", toString(LevelCache)); text+= "\n" + fmt; } @@ -167,7 +168,7 @@ void CDBGroupListSheetTextPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin CViewText *name = dynamic_cast(pIG->getView("name")); if (name != NULL) { - ucstring sectionText= CI18N::get("uiPhraseSectionFmt"); + string sectionText= CI18N::get("uiPhraseSectionFmt"); uint32 minLevel, maxLevel; CSPhraseManager *pPM= CSPhraseManager::getInstance(); pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp index 45a78980e..6e5e19d9e 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -41,7 +44,7 @@ CDBGroupListSheetTextPhraseId::CSheetChildPhrase::CSheetChildPhrase() // *************************************************************************** void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */) { - ucstring text; + std::string text; if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhraseId) return; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 618507ff5..0d93baccb 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -248,7 +249,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::update(CDBGroupListSheetText *pFa void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetText *pFather) { H_AUTO(CDBGroupListSheetTrade_updateViewText); - ucstring text; + std::string text; Ctrl->getContextHelp(text); // Append first the type of the sheet to select switch ( Ctrl->getSheetCategory() ) @@ -280,7 +281,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT if(Ctrl->getSheetCategory() == CDBCtrlSheet::Phrase) { // For combat action, Append weapon restriction - ucstring weaponRestriction; + string weaponRestriction; CSPhraseManager *pPM= CSPhraseManager::getInstance(); bool melee,range; pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range); @@ -293,7 +294,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT } // Get the Text color - ucstring colorTag("@{FFFF}"); + std::string colorTag("@{FFFF}"); if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item) { if(!Ctrl->checkItemRequirement()) @@ -309,7 +310,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT // Add craft info for MP if(pIS->Family==ITEMFAMILY::RAW_MATERIAL) { - ucstring ipList; + string ipList; pIS->getItemPartListAsText(ipList); if(ipList.empty()) { @@ -412,7 +413,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT else text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(factor * LastPriceRetire)); // set resale time left - ucstring fmt= CI18N::get("uiBotChatResaleTimeLeft"); + std::string fmt= CI18N::get("uiBotChatResaleTimeLeft"); strFindReplace(fmt, "%d", toString(LastResaleTimeLeft/RYZOM_DAY_IN_HOUR)); strFindReplace(fmt, "%h", toString(LastResaleTimeLeft%RYZOM_DAY_IN_HOUR)); text+= "\n" + fmt; @@ -475,7 +476,7 @@ bool CDBGroupListSheetTrade::CSheetChildTrade::isSheetValid(CDBGroupListSheetTex if ((pIS != NULL) && (!pIS->DropOrSell)) return false; // test if this whole family of items can be sold - if( !ITEMFAMILY::isSellableByPlayer(pIS->Family) ) + if((pIS != NULL) && !ITEMFAMILY::isSellableByPlayer(pIS->Family) ) return false; } @@ -653,7 +654,7 @@ bool CDBGroupListSheetTrade::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup prop= (char*) xmlGetProp( cur, (xmlChar*)"filter_seller_type" ); if(prop) { - string lwrFilter= toLower(std::string((const char *)prop)); + string lwrFilter= toLowerAscii(std::string((const char *)prop)); if(lwrFilter=="npc") _SellerTypeFilter= NPC; else if(lwrFilter=="resale") @@ -688,7 +689,7 @@ void CDBGroupListSheetTrade::checkCoords () { CSheetChildTrade * cst = (*it); // String result - ucstring result; + string result; if( pSMC->getString ( cst->LastVendorNameId, result) ) { cst->VendorNameString = CEntityCL::removeShardFromName(result); diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h index 5d6e121d5..c7123957d 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -96,7 +97,7 @@ public: CInterfaceProperty CurrentVendorNameId; CInterfaceProperty CurrentFactionType; CInterfaceProperty CurrentFactionPointPrice; - ucstring VendorNameString; + std::string VendorNameString; virtual void init(CDBGroupListSheetText *pFather, uint index); virtual bool isInvalidated(CDBGroupListSheetText *pFather); diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index ec82b5c8d..7d435b64f 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -193,7 +194,7 @@ void CEncyclopediaManager::rebuildAlbumList() nlassert(pTree != NULL); CGroupTree::SNode *pRoot = new CGroupTree::SNode; - ucstring res; + string res; // Add all albums for (uint32 i = 0; i < _Albums.size(); ++i) @@ -303,8 +304,8 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName) if (pRBVT != NULL) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); - pRBVT->setText(desc); + CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); + pRBVT->setText(desc.toUtf8()); } } @@ -359,18 +360,15 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) { if (pES->type() == CEntitySheet::ITEM) { - const ucstring desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + pRBVT->setText(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SBRICK) { - const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + pRBVT->setText(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SPHRASE) { - const ucstring desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + pRBVT->setText(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); } } @@ -401,7 +399,7 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) // setup task NPC name CStringPostProcessNPCRemoveTitle *pSPPRT = new CStringPostProcessNPCRemoveTitle; - pIM->addServerID (sTmp+":npc:uc_hardtext", pThema->TaskNPCName[i], pSPPRT); + pIM->addServerID (sTmp+":npc:hardtext", pThema->TaskNPCName[i], pSPPRT); // If the task is not known gray it if (pThema->getTaskState((uint8)i) == 0) @@ -428,7 +426,7 @@ bool CEncyclopediaManager::isStringWaiting() for (uint32 i = 0; i < _Albums.size(); ++i) { - ucstring res; + string res; if (!pSMC->getDynString(_Albums[i].Name, res)) return true; for (uint32 j = 0; j < _Albums[i].Themas.size(); ++j) diff --git a/ryzom/client/src/interface_v3/flying_text_manager.cpp b/ryzom/client/src/interface_v3/flying_text_manager.cpp index 23e6e963e..37daf2f9e 100644 --- a/ryzom/client/src/interface_v3/flying_text_manager.cpp +++ b/ryzom/client/src/interface_v3/flying_text_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -120,7 +121,7 @@ void CFlyingTextManager::releaseInGame() } // *************************************************************************** -void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NLMISC::CVector &pos, CRGBA color, float scale, sint offsetX) +void CFlyingTextManager::addFlyingText(void *key, const string &text, const NLMISC::CVector &pos, CRGBA color, float scale, sint offsetX) { // key exist in the map? TInSceneCurrentMap::iterator it= _InSceneCurrent.find(key); diff --git a/ryzom/client/src/interface_v3/flying_text_manager.h b/ryzom/client/src/interface_v3/flying_text_manager.h index 95746b6c0..d3d4c8957 100644 --- a/ryzom/client/src/interface_v3/flying_text_manager.h +++ b/ryzom/client/src/interface_v3/flying_text_manager.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -49,7 +52,7 @@ public: /** add a flying text at a position (called during entity display). NB: may fail if no more free groups * \param offsetx: screen offsetx of the group in scene */ - void addFlyingText(void *key, const ucstring &text, const NLMISC::CVector &pos, NLMISC::CRGBA color, float scale, sint offsetX=0); + void addFlyingText(void *key, const std::string &text, const NLMISC::CVector &pos, NLMISC::CRGBA color, float scale, sint offsetX=0); /// release no more used flying text (called by CEntityManager at each draw) void releaseNotUsedFlyingText(); diff --git a/ryzom/client/src/interface_v3/group_career.cpp b/ryzom/client/src/interface_v3/group_career.cpp index d3f3e2563..56ac4e1d2 100644 --- a/ryzom/client/src/interface_v3/group_career.cpp +++ b/ryzom/client/src/interface_v3/group_career.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -63,13 +64,13 @@ bool CGroupCareer::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (Career >= ROLES::NB_ROLES) Career = ROLES::fighter; - ucstring sTmp = ROLES::roleToUCString(Career); + string sTmp = ROLES::roleToUCString(Career); for (uint32 i= 0; i < sTmp.size(); ++i) if (sTmp[i] < 128) if ( (sTmp[i] >= 'a') && (sTmp[i] <= 'z') ) sTmp[i] = sTmp[i] - 'a' + 'A'; - setUCTitle (sTmp); + setTitle (sTmp); return true; } @@ -128,12 +129,12 @@ bool CGroupJob::parse (xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */ // return false; // } // -// ucstring sTmp = JOBS::jobToUCString(Job); +// string sTmp = JOBS::jobToUCString(Job); // for (uint32 i= 0; i < sTmp.size(); ++i) // if (sTmp[i] < 128) // if ( (sTmp[i] >= 'a') && (sTmp[i] <= 'z') ) // sTmp[i] = sTmp[i] - 'a' + 'A'; -// setUCTitle (sTmp); +// seUCTitle (sTmp); // // return true; } diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index 87fcec6ce..97eb64bcb 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -74,12 +75,21 @@ void CCompassTarget::serial(NLMISC::IStream &f) } } f.serialCheck(NELID("CTAR")); - f.serialVersion(0); + sint version = f.serialVersion(1); f.serial(Pos); // for the name, try to save a string identifier if possible, because language may be changed between // save & reload - f.serial(Name); - std::string language = toLower(ClientCfg.LanguageCode); + if (version < 1) + { + ucstring name; // Serial old version + f.serial(name); + Name = name.toUtf8(); + } + else + { + f.serial(Name); + } + std::string language = toLowerAscii(ClientCfg.LanguageCode); f.serial(language); f.serialEnum(_Type); if (_Type == PosTracker) @@ -105,7 +115,7 @@ void CCompassTarget::serial(NLMISC::IStream &f) // reset the compass to north to avoid incoherency if (f.isReading()) { - if (toLower(ClientCfg.LanguageCode) != language) + if (toLowerAscii(ClientCfg.LanguageCode) != language) { *this = CCompassTarget(); } @@ -393,18 +403,18 @@ void CGroupCompas::draw() // The text char message[50]; - ucstring distText; + string distText; if (displayedTarget.getType() != CCompassTarget::North) { if (dist > 999.0f) { smprintf (message, 50, "%.1f ", dist/1000.0f); - distText = ucstring (message) + CI18N::get("uiKilometerUnit"); + distText = message + CI18N::get("uiKilometerUnit"); } else { smprintf (message, 50, "%.0f ", dist); - distText = ucstring (message) + CI18N::get("uiMeterUnit"); + distText = message + CI18N::get("uiMeterUnit"); } distText = distText + " - " + displayedTarget.Name; } @@ -424,11 +434,10 @@ void CGroupCompas::draw() CCtrlBase *toolTip = getCtrl("tt"); if (toolTip) { - ucstring text; if (displayedTarget.getType() != CCompassTarget::North) toolTip->setDefaultContextHelp(CI18N::get("uittCompassDistance")); else - toolTip->setDefaultContextHelp(text); + toolTip->setDefaultContextHelp(std::string()); } if (displayedTarget.Name != _CurrTargetName) @@ -558,7 +567,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) ct.setPositionState(tracker); CStringManagerClient *pSMC = CStringManagerClient::instance(); - ucstring name; + string name; if (pSMC->getString(nameNode->getValue32(), name)) ct.Name = CEntityCL::removeTitleAndShardFromName(name); // TODO : dynamic support for name else @@ -741,8 +750,8 @@ void CGroupCompasMenu::setActive (bool state) /*CEntityCL *entity = EntitiesMngr.entity(UserEntity->selection()); if (entity != NULL) {*/ - //ucstring targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); - ucstring targetName = CI18N::get("uiTarget"); + //string targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); + string targetName = CI18N::get("uiTarget"); ct.setType(CCompassTarget::Selection); ct.Name = targetName; Targets.push_back(ct); @@ -777,7 +786,7 @@ void CGroupCompasMenu::setActive (bool state) CCDBNodeLeaf *textIDLeaf = NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:TITLE", (int) k, (int) l), false); if (textIDLeaf) { - ucstring name; + string name; if (CStringManagerClient::instance()->getDynString(textIDLeaf->getValue32(), name)) { CCDBNodeLeaf *leafPosX= NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:X", (int) k, (int) l), false); @@ -868,7 +877,7 @@ void CGroupCompasMenu::setActive (bool state) CCompassTarget ct; ct.setType(CCompassTarget::UserLandMark); ct.Pos = sortedLandmarks[k].Pos; - ct.Name = sortedLandmarks[k].Title; + ct.Name = sortedLandmarks[k].Title.toUtf8(); Targets.push_back(ct); landMarkSubMenus[sortedLandmarks[k].Type]->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; @@ -1047,12 +1056,12 @@ REGISTER_ACTION_HANDLER( CHandlerSetCompassNorth, "set_compass_north"); class CCompassDialogsStringCallback : public IStringWaitCallback { - virtual void onDynStringAvailable(uint /* stringId */, const ucstring &value) + virtual void onDynStringAvailable(uint /* stringId */, const std::string &value) { uint size = (uint)CCompassDialogsManager::getInstance()._Entries.size(); for ( uint i = 0; i < size; i++) { - ucstring name; + std::string name; if ( CStringManagerClient::instance()->getDynString(CCompassDialogsManager::getInstance()._Entries[i].Text, name) ) { if ( value == name ) diff --git a/ryzom/client/src/interface_v3/group_compas.h b/ryzom/client/src/interface_v3/group_compas.h index c9ba106ef..804c36cb9 100644 --- a/ryzom/client/src/interface_v3/group_compas.h +++ b/ryzom/client/src/interface_v3/group_compas.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -46,7 +47,7 @@ class CCompassTarget public: enum TType { North = 0, Selection, Home, Respawn, ContinentLandMark, UserLandMark, PosTracker, NumTypes }; NLMISC::CVector2f Pos; // Used for static target (ie not the current selection, a team member ...) - ucstring Name; + std::string Name; CCompassTarget(); TType getType() const { return _Type; } void setType(TType type) { if (type == _Type) return; setPositionState(NULL); _Type = type; } @@ -124,11 +125,11 @@ private: bool _Blinking; double _StartBlinkTime; - ucstring _CurrTargetName; + std::string _CurrTargetName; // The dist text CViewText *_DistView; - ucstring _DistViewText; + std::string _DistViewText; CViewRadar *_RadarView; CViewText *_RadarRangeView; diff --git a/ryzom/client/src/interface_v3/group_html_cs.cpp b/ryzom/client/src/interface_v3/group_html_cs.cpp index ba20123e1..34b91f81c 100644 --- a/ryzom/client/src/interface_v3/group_html_cs.cpp +++ b/ryzom/client/src/interface_v3/group_html_cs.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_cs.h b/ryzom/client/src/interface_v3/group_html_cs.h index 76a066e6d..c4dead71b 100644 --- a/ryzom/client/src/interface_v3/group_html_cs.h +++ b/ryzom/client/src/interface_v3/group_html_cs.h @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_forum.cpp b/ryzom/client/src/interface_v3/group_html_forum.cpp index fe218c215..37ba77891 100644 --- a/ryzom/client/src/interface_v3/group_html_forum.cpp +++ b/ryzom/client/src/interface_v3/group_html_forum.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -57,9 +58,9 @@ CGroupHTMLForum::~CGroupHTMLForum() void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); const SGuild &guild = CGuildManager::getInstance()->getGuild(); - string gname = guild.Name.toUtf8(); + string gname = guild.Name; if (!gname.empty()) { @@ -75,7 +76,7 @@ void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) url += ((url.find('?') != string::npos) ? "&" : "?") + string("shard=") + toString(CharacterHomeSessionId) + - string("&user_login=") + user_name.toString() + + string("&user_login=") + user_name + string("&forum=") + gname + string("&session_cookie=") + NetMngr.getLoginCookie().toString(); } @@ -89,14 +90,14 @@ void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) void CGroupHTMLForum::addHTTPPostParams (SFormFields &formfields, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); const SGuild &guild = CGuildManager::getInstance()->getGuild(); - string gname = guild.Name.toUtf8(); + string gname = guild.Name; if (!gname.empty()) { formfields.add("shard", toString(CharacterHomeSessionId)); - formfields.add("user_login", user_name.toString()); + formfields.add("user_login", user_name); formfields.add("forum", gname); formfields.add("session_cookie", NetMngr.getLoginCookie().toString()); } diff --git a/ryzom/client/src/interface_v3/group_html_forum.h b/ryzom/client/src/interface_v3/group_html_forum.h index 31e5308be..33d759faa 100644 --- a/ryzom/client/src/interface_v3/group_html_forum.h +++ b/ryzom/client/src/interface_v3/group_html_forum.h @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_mail.cpp b/ryzom/client/src/interface_v3/group_html_mail.cpp index 8627a8573..61105e085 100644 --- a/ryzom/client/src/interface_v3/group_html_mail.cpp +++ b/ryzom/client/src/interface_v3/group_html_mail.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -56,10 +57,10 @@ CGroupHTMLMail::~CGroupHTMLMail() void CGroupHTMLMail::addHTTPGetParams (string &url, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); url += ((url.find('?') != string::npos) ? "&" : "?") + string("shard=") + toString(CharacterHomeSessionId) + - string("&user_login=") + user_name.toString() + + string("&user_login=") + user_name + // FIXME: UrlEncode string("&session_cookie=") + NetMngr.getLoginCookie().toString() + string("&lang=") + CI18N::getCurrentLanguageCode(); } @@ -68,9 +69,9 @@ void CGroupHTMLMail::addHTTPGetParams (string &url, bool /*trustedDomain*/) void CGroupHTMLMail::addHTTPPostParams (SFormFields &formfields, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); formfields.add("shard", toString(CharacterHomeSessionId)); - formfields.add("user_login", user_name.toString()); + formfields.add("user_login", user_name); // FIXME: UrlEncode formfields.add("session_cookie", NetMngr.getLoginCookie().toString()); formfields.add("lang", CI18N::getCurrentLanguageCode()); } diff --git a/ryzom/client/src/interface_v3/group_html_mail.h b/ryzom/client/src/interface_v3/group_html_mail.h index 59cf4c852..14cba4586 100644 --- a/ryzom/client/src/interface_v3/group_html_mail.h +++ b/ryzom/client/src/interface_v3/group_html_mail.h @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_webig.cpp b/ryzom/client/src/interface_v3/group_html_webig.cpp index 985ae3f20..95ec3aa0e 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -1,10 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -66,7 +66,7 @@ static string getWebAuthKey() // authkey = uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; string rawKey = toString(CharacterHomeSessionId) + - UserEntity->getLoginName().toString() + + UserEntity->getLoginName() + toString(cid) + NetMngr.getLoginCookie().toString(); string key = getMD5((const uint8*)rawKey.c_str(), (uint32)rawKey.size()).toString(); @@ -85,7 +85,7 @@ void addWebIGParams (string &url, bool trustedDomain) uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; url += ((url.find('?') != string::npos) ? "&" : "?") + string("shardid=") + toString(CharacterHomeSessionId) + - string("&name=") + UserEntity->getLoginName().toUtf8() + + string("&name=") + UserEntity->getLoginName() + // FIXME: UrlEncode string("&lang=") + CI18N::getCurrentLanguageCode() + string("&datasetid=") + toString(UserEntity->dataSetId()) + string("&ig=1"); @@ -97,7 +97,7 @@ void addWebIGParams (string &url, bool trustedDomain) if (url.find('$') != string::npos) { strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); - strFindReplace(url, "$displayName$", UserEntity->getDisplayName().toString()); + strFindReplace(url, "$displayName$", UserEntity->getDisplayName()); // FIXME: UrlEncode... strFindReplace(url, "$posx$", toString(UserEntity->pos().x)); strFindReplace(url, "$posy$", toString(UserEntity->pos().y)); strFindReplace(url, "$posz$", toString(UserEntity->pos().z)); @@ -113,7 +113,7 @@ void addWebIGParams (string &url, bool trustedDomain) if (target) { strFindReplace(url, "$tdatasetid$", toString(target->dataSetId())); - strFindReplace(url, "$tdisplayName$", target->getDisplayName().toString()); + strFindReplace(url, "$tdisplayName$", target->getDisplayName()); // FIXME: UrlEncode... strFindReplace(url, "$tposx$", toString(target->pos().x)); strFindReplace(url, "$tposy$", toString(target->pos().y)); strFindReplace(url, "$tposz$", toString(target->pos().z)); @@ -384,7 +384,7 @@ void CGroupHTMLAuth::addHTTPPostParams (SFormFields &formfields, bool trustedDom uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; formfields.add("shardid", toString(CharacterHomeSessionId)); - formfields.add("name", UserEntity->getLoginName().toUtf8()); + formfields.add("name", UserEntity->getLoginName()); formfields.add("lang", CI18N::getCurrentLanguageCode()); formfields.add("ig", "1"); if (trustedDomain) diff --git a/ryzom/client/src/interface_v3/group_html_webig.h b/ryzom/client/src/interface_v3/group_html_webig.h index a339dd3dc..dfa7fcc3c 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.h +++ b/ryzom/client/src/interface_v3/group_html_webig.h @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_in_scene.cpp b/ryzom/client/src/interface_v3/group_in_scene.cpp index e0d36fd7f..6bfbe7518 100644 --- a/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2016 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index a4135122e..d60a20bf8 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -456,7 +457,7 @@ void CGroupInSceneBubbleManager::update () { if (_DynBubbles[i].DescWaiting != 0) { - ucstring res; + string res; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC->getDynString(_DynBubbles[i].DescWaiting,res)) { @@ -472,11 +473,11 @@ void CGroupInSceneBubbleManager::update () // Send to the around me window // TODO must get the name of the bot etc... /* - ucstring finalString = res; + string finalString = res; for(;;) { - std::string::size_type index = finalString.find (ucstring("{break}")); - if (index == ucstring::npos) break; + std::string::size_type index = finalString.find ("{break}"); + if (index == string::npos) break; finalString = finalString.substr (0, index) + finalString.substr(index+7,finalString.size()); } @@ -488,7 +489,7 @@ void CGroupInSceneBubbleManager::update () // *************************************************************************** -CGroupInSceneBubble *CGroupInSceneBubbleManager::newBubble (const ucstring &text) +CGroupInSceneBubble *CGroupInSceneBubbleManager::newBubble (const string &text) { if (!text.empty() && !_Bubbles.empty()) { @@ -531,10 +532,9 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t if (group) { // Skill name - const ucstring sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); CViewText *pViewSkillName = dynamic_cast(group->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName); + pViewSkillName->setText (STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); // Skill value CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); @@ -577,7 +577,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t // *************************************************************************** -void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA color, uint time) +void CGroupInSceneBubbleManager::addMessagePopup (const string &message, CRGBA color, uint time) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -626,7 +626,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA // *************************************************************************** -void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, CRGBA color, uint time) +void CGroupInSceneBubbleManager::addMessagePopupCenter (const string &message, CRGBA color, uint time) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -645,26 +645,24 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, "ui:interface", templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); if (group) { - ucstring finalMessage = message; + string finalMessage = message; - ucstring::size_type pos = message.find(ucstring("|")); + string::size_type pos = message.find("|"); if (pos != std::string::npos) { CViewBitmap *pViewIcon = dynamic_cast(group->getView("iconA")); if (pViewIcon != NULL) { - string texture = message.substr(0, pos).toString(); - pViewIcon->setTexture(texture); + pViewIcon->setTexture(message.substr(0, pos)); } - ucstring::size_type end = message.find(ucstring("|"), pos+1); + string::size_type end = message.find("|", pos+1); if (end != std::string::npos) { CViewBitmap *pViewIcon = dynamic_cast(group->getView("iconZ")); if (pViewIcon != NULL) { - string texture = message.substr(end+1).toString(); - pViewIcon->setTexture(texture); + pViewIcon->setTexture(message.substr(end+1)); } finalMessage = message.substr(pos+1, end-pos-1); } @@ -786,9 +784,9 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont // *************************************************************************** -void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const string &targetName, uint time) +void CGroupInSceneBubbleManager::addContextHelp (const string &message, const string &targetName, uint time) { - ucstring finalMessage = message; + std::string finalMessage = message; CInterfaceElement *target; CPopupContext *context = CGroupInSceneBubbleManager::buildContextHelp ("context_help_", targetName, target, time); if (context) @@ -864,7 +862,7 @@ void CGroupInSceneBubbleManager::ignoreContextHelp (CInterfaceGroup *groupToRemo // *************************************************************************** -void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, uint bubbleTimer) +void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const std::string &ucsText, uint bubbleTimer) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -876,14 +874,14 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, // Clean bubble from translation system - ucstring::size_type pos = 0; - ucstring::size_type textSize = ucsText.size(); - string::size_type startTr = ucsText.find(ucstring("{:")); - string::size_type endOfOriginal = ucsText.find(ucstring("}@{")); + string::size_type pos = 0; + string::size_type textSize = ucsText.size(); + string::size_type startTr = ucsText.find(string("{:")); + string::size_type endOfOriginal = ucsText.find(string("}@{")); if (startTr != string::npos && endOfOriginal != string::npos) { bool inverse = false; - string lang = toUpper(ucsText.substr(startTr+2, 2)).toString(); + string lang = toUpper(ucsText.substr(startTr+2, 2)); CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + lang + ":INVERSE_DISPLAY", false); if (node) inverse = node->getValueBool(); @@ -1121,9 +1119,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con // Update the bubble's texts - ucstring ucText; - ucText.fromUtf8(text); - bubble->setText(ucText); + bubble->setText(text); id = bubble->getId() + ":header_opened:window:"; CViewText *pVT; CCtrlLink *pCL; @@ -1136,7 +1132,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con if (pVT != NULL) { pVT->setActive(false); - pVT->setText(ucstring("")); + pVT->setText(std::string()); } pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j))); if (pCL != NULL) pCL->setActive(false); @@ -1148,8 +1144,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con if (pVT != NULL) { pVT->setActive(true); - ucstring optionText; - optionText.fromUtf8(strs[j]); + string optionText = strs[j]; pVT->setText(optionText); pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j))); if (pCL != NULL) @@ -1370,17 +1365,18 @@ class CAHDynChatClickOption : public IActionHandler uint32 optStrId = InSceneBubbleManager.dynChatGetOptionStringId(nBubbleNb, nOpt); if (!optStrId) return; +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring result; + string result; if (!pSMC->getDynString(optStrId, result)) { return; // shouldn't happen since the button isn't visible as long as the text has not been received ... } static volatile bool forceWarning = false; // for debug - ucstring::size_type pos= result.find(ucstring("{ros_exit}")); - if(pos != ucstring::npos || forceWarning) + string::size_type pos= result.find("{ros_exit}"); + if(pos != string::npos || forceWarning) { if (AvailablePatchs != 0) { @@ -1389,8 +1385,9 @@ class CAHDynChatClickOption : public IActionHandler } } } +#endif - const string sMsg = "BOTCHAT:DYNCHAT_SEND"; + static const string sMsg = "BOTCHAT:DYNCHAT_SEND"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -1481,19 +1478,19 @@ void CGroupInSceneBubble::unlink () // *************************************************************************** -void CGroupInSceneBubble::setText (const ucstring &text) +void CGroupInSceneBubble::setText (const string &text) { if (text.empty()) return; _TextParts.clear(); // Look for "{break}" in the message - ucstring finalMsg = text; - ucstring tmpMsg; + string finalMsg = text; + string tmpMsg; for(;;) { - ucstring::size_type index = finalMsg.find (ucstring("{break}")); - if (index == ucstring::npos) break; + string::size_type index = finalMsg.find ("{break}"); + if (index == string::npos) break; tmpMsg = finalMsg.substr (0, index); if (!tmpMsg.empty()) _TextParts.push_back(tmpMsg); @@ -1534,7 +1531,7 @@ void CGroupInSceneBubble::skip() // *************************************************************************** -void CGroupInSceneBubble::setRawText (const ucstring &text) +void CGroupInSceneBubble::setRawText (const string &text) { _CanBeShown = !text.empty(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -1640,8 +1637,7 @@ class CHandlerCharacterBubble : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); uint entityId; fromString(getParam (sParams, "entity"), entityId); - ucstring text; - text.fromUtf8(getParam (sParams, "text")); + string text = getParam (sParams, "text"); string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) @@ -1689,10 +1685,8 @@ class CHandlerMessagePopup : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring text0; - text0.fromUtf8(getParam (sParams, "text0").c_str()); - ucstring text1; - text1.fromUtf8(getParam (sParams, "text1").c_str()); + string text0 = getParam (sParams, "text0"); + string text1 = getParam (sParams, "text1"); string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) @@ -1716,8 +1710,7 @@ class CHandlerContextHelp : public IActionHandler string targetName = getParam (sParams, "target"); string text = getParam (sParams, "text"); - ucstring itext; - itext.fromUtf8 (getParam (sParams, "itext")); + string itext = getParam (sParams, "itext"); if (itext.empty()) itext = CI18N::get(text); diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.h b/ryzom/client/src/interface_v3/group_in_scene_bubble.h index 288853488..cd7e6c57e 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.h +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -39,19 +40,19 @@ public: void update (); // Get a CGroupBubble - class CGroupInSceneBubble *newBubble (const ucstring &text); + class CGroupInSceneBubble *newBubble (const std::string &text); // Add a message popup. if 0, get the OptionTimeoutMessages - void addMessagePopup (const ucstring &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); + void addMessagePopup (const std::string &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); // The same as previous but centered in the screen. if 0, get the OptionTimeoutMessages - void addMessagePopupCenter (const ucstring &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); + void addMessagePopupCenter (const std::string &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); // Add a skill popup void addSkillPopup (uint skillId, sint delta, uint time); // Add a context help with a string - void addContextHelp (const ucstring &message, const std::string &target, uint time); + void addContextHelp (const std::string &message, const std::string &target, uint time); // Add a context help void addContextHelpHTML (const std::string &filename, const std::string &target, uint time); @@ -60,7 +61,7 @@ public: void ignoreContextHelp (CInterfaceGroup *groupToRemove); // Open a bubble chat (with next and skip button) - void chatOpen (uint32 nUID, const ucstring &ucsText, uint bubbleTimer = 0); + void chatOpen (uint32 nUID, const std::string &ucsText, uint bubbleTimer = 0); // Dynamic Chat @@ -199,7 +200,7 @@ public: void unlink (); // Set text - void setText (const ucstring &text); + void setText (const std::string &text); // Called from action handler void next(); @@ -217,7 +218,7 @@ public: private: - void setRawText (const ucstring &text); + void setRawText (const std::string &text); void displayNextAndSkip (bool show); private: @@ -233,7 +234,7 @@ private: CCharacterCL *_Character; // Multi part bubble - std::vector _TextParts; + std::vector _TextParts; uint32 _CurrentPart; }; diff --git a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index aebc7cb4a..58aad93fa 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -1,10 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -200,9 +200,9 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Names const char *templateName; - ucstring theTribeName; - ucstring entityName = entity->getDisplayName(); - ucstring entityTitle = entity->getTitle(); + const char *theTribeName = ""; + std::string entityName = entity->getDisplayName(); + std::string entityTitle = entity->getTitle(); // For some NPC's the name is empty and only a title is given, // in that case, treat the title as the name. @@ -212,10 +212,10 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) entityTitle.clear(); } - ucstring entityTag1 = entity->getTag(1); - ucstring entityTag2 = entity->getTag(2); - ucstring entityTag3 = entity->getTag(3); - ucstring entityTag4 = entity->getTag(4); + string entityTag1 = entity->getTag(1); + string entityTag2 = entity->getTag(2); + string entityTag3 = entity->getTag(3); + string entityTag4 = entity->getTag(4); string entityPermanentContent = entity->getPermanentStatutIcon(); @@ -472,10 +472,10 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) CViewBitmap *rp3 = dynamic_cast(info->getView ("rp_logo_3")); CViewBitmap *rp4 = dynamic_cast(info->getView ("rp_logo_4")); - if (entityTag1.toString() == "_") entityTag1.clear(); - if (entityTag2.toString() == "_") entityTag2.clear(); - if (entityTag3.toString() == "_") entityTag3.clear(); - if (entityTag4.toString() == "_") entityTag4.clear(); + if (entityTag1 == "_") entityTag1.clear(); + if (entityTag2 == "_") entityTag2.clear(); + if (entityTag3 == "_") entityTag3.clear(); + if (entityTag4 == "_") entityTag4.clear(); if (pPlayer && (pPlayer->getPvpMode() == PVP_MODE::None)) { @@ -483,10 +483,10 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) entityTag2.clear(); } - if (rp1) rp1->setTexture(entityTag1.toString()); - if (rp2) rp2->setTexture(entityTag2.toString()); - if (rp3) rp3->setTexture(entityTag3.toString()); - if (rp4) rp4->setTexture(entityTag4.toString()); + if (rp1) rp1->setTexture(entityTag1); + if (rp2) rp2->setTexture(entityTag2); + if (rp3) rp3->setTexture(entityTag3); + if (rp4) rp4->setTexture(entityTag4); // hide if texture is empty if (rp1) rp1->setActive(!entityTag1.empty()); @@ -973,7 +973,7 @@ void CGroupInSceneUserInfo::updateDynamicData () { _Name->setColor(entityColor); _Name->setModulateGlobalColor(false); - ucstring entityName = _Entity->getDisplayName(); + string entityName = _Entity->getDisplayName(); if (entityName.empty()) entityName = _Entity->getTitle(); @@ -1006,7 +1006,7 @@ void CGroupInSceneUserInfo::updateDynamicData () if (_GuildName) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; + string ucsTmp; if (pSMC->getString (_Entity->getGuildNameID(), ucsTmp)) _GuildName->setText(ucsTmp); @@ -1032,8 +1032,8 @@ void CGroupInSceneUserInfo::updateDynamicData () if (_EventFaction) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; - if (pSMC->getString (_Entity->getEventFactionID(), ucsTmp)) + string ucsTmp; + if (pSMC->getString(_Entity->getEventFactionID(), ucsTmp)) _EventFaction->setText(ucsTmp); // guildname color depends of PVP faction or not @@ -1136,7 +1136,7 @@ void CGroupInSceneUserInfo::updateDynamicData () { CInterfaceGroup *group = getGroup ("right"); CForageSourceCL *forageSource = static_cast(_Entity); - ucstring txt( CI18N::get( "uittForageContent" ) + toString( ": %u", forageSource->getCurrentQuantity() ) ); + string txt( CI18N::get( "uittForageContent" ) + toString( ": %u", forageSource->getCurrentQuantity() ) ); CCtrlBase *toolTip = group->getCtrl ("tt1"); if ( toolTip ) toolTip->setDefaultContextHelp( txt ); diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index 35a1fc4e6..3d1902ef2 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -141,12 +141,12 @@ static void popupLandMarkNameDialog() const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark); NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(userLM.Type)); - eb->setInputString(userLM.Title); + eb->setInputString(userLM.Title.toUtf8()); } else { NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(CUserLandMark::Misc)); - eb->setInputString(ucstring()); + eb->setInputString(string()); } CWidgetManager::getInstance()->setCaptureKeyboard(eb); @@ -1177,7 +1177,7 @@ void CGroupMap::checkCoords() // update text if needed if (!_MissionTargetTextReceived[k]) { - ucstring result; + string result; if (STRING_MANAGER::CStringManagerClient::instance()->getDynString(_MissionTargetTextIDs[k], result)) { _MissionLM[k]->setDefaultContextHelp(result); @@ -1241,9 +1241,7 @@ void CGroupMap::checkCoords() _RespawnLM[i] = createArkPointButton(_ArkPoints[i]); _RespawnLM[i]->setId(this->getId() + ":arklm_" + NLMISC::toString(i)); _RespawnLM[i]->setParent(this); - ucstring title; - title.fromUtf8(_ArkPoints[i].Title); - _RespawnLM[i]->setDefaultContextHelp(title); + _RespawnLM[i]->setDefaultContextHelp(_ArkPoints[i].Title); _RespawnLM[i]->HandleEvents = true; addCtrl(_RespawnLM[i]); updateLMPosFromDBPos(_RespawnLM[i], _ArkPoints[i].x, _ArkPoints[i].y); @@ -1404,12 +1402,12 @@ void CGroupMap::checkCoords() CInterfaceManager *im = CInterfaceManager::getInstance(); uint32 val = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring res; + string res; - if (pSMC->getString(val,res)) + if (pSMC->getString(val, res)) { - res = CEntityCL::removeTitleAndShardFromName(res); - _TeammateLM[i]->setDefaultContextHelp(res); + std::string res2 = CEntityCL::removeTitleAndShardFromName(res); + _TeammateLM[i]->setDefaultContextHelp(res2); } } updateLMPosFromDBPos(_TeammateLM[i], px, py); @@ -2484,7 +2482,7 @@ void CGroupMap::updateMatchedLandmarks() CViewText* t = dynamic_cast(g->getView("title")); if (t) { - t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title); + t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title.toUtf8()); } CViewBitmap* b = dynamic_cast(g->getView("icon")); @@ -2533,19 +2531,19 @@ void CGroupMap::createLMWidgets(const std::vector &lms) NLMISC::CVector2f mapPos; worldToMap(mapPos, rCLM.Pos); - const ucstring ucsTmp(CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID)); - const ucstring lcTitle = toLower(ucsTmp); + const char *ucsTmp = CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID); + const std::string lcTitle = toLower(ucsTmp); bool searchMatch = notWorldMode && _LandmarkFilter.size() > 0 && filterLandmark(lcTitle); if (searchMatch) - _MatchedLandmarks.push_back(SMatchedLandmark(rCLM.Pos, ucsTmp, _ContinentLMOptions)); + _MatchedLandmarks.push_back(SMatchedLandmark(rCLM.Pos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions)); // Add button if not a region nor a place if ((rCLM.Type != CContLandMark::Region) && (rCLM.Type != CContLandMark::Place) && (rCLM.Type != CContLandMark::Street)) { if (rCLM.Type != CContLandMark::Stable) - addLandMark(_ContinentLM, mapPos, ucsTmp, _ContinentLMOptions); + addLandMark(_ContinentLM, mapPos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions); else addLandMark(_ContinentLM, mapPos, CI18N::get("uiStable"), _ContinentLMOptions); _ContinentLM.back()->Type = rCLM.Type; @@ -2679,9 +2677,7 @@ void CGroupMap::setLandmarkFilter(const std::string &s) _LandmarkFilter.clear(); if (!s.empty()) { - ucstring ucs; - ucs.fromUtf8(s); - splitUCString(toLower(ucs), ucstring(" "), _LandmarkFilter); + splitUCString(ucstring::makeFromUtf8(toLower(s)), ucstring(" "), _LandmarkFilter); } // recreate landmarks @@ -2818,7 +2814,7 @@ void CGroupMap::addLandMark(TLandMarkButtonVect &destList, const NLMISC::CVector CLandMarkButton *lmb = createLandMarkButton(options); lmb->setParent(this); lmb->Pos = pos; - lmb->setDefaultContextHelp(title); + lmb->setDefaultContextHelp(title.toUtf8()); destList.push_back(lmb); addCtrl(lmb); } @@ -2840,7 +2836,7 @@ void CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &ti CLandMarkButton *lmb = createLandMarkButton(options); lmb->setParent(this); lmb->Pos = pos; - lmb->setDefaultContextHelp(title); + lmb->setDefaultContextHelp(title.toUtf8()); _UserLM.push_back(lmb); addCtrl(lmb); invalidateCoords(); @@ -2944,7 +2940,7 @@ void CGroupMap::updateUserLandMark(CCtrlButton *button, const ucstring &newTitle _CurContinent->UserLandMarks[k].Type = (uint8)lmType; updateLandMarkButton(_UserLM[k], getUserLandMarkOptions(k)); - button->setDefaultContextHelp(newTitle); + button->setDefaultContextHelp(newTitle.toUtf8()); CInterfaceManager::getInstance()->saveLandmarks(); return; @@ -3364,7 +3360,7 @@ void CGroupMap::targetLandmarkResult(uint32 index) CCompassTarget ct; ct.Pos = _MatchedLandmarks[index].Pos; - ct.Name = _MatchedLandmarks[index].Title; + ct.Name = _MatchedLandmarks[index].Title.toUtf8(); // type sets compass arrow color ct.setType(CCompassTarget::UserLandMark); @@ -3395,9 +3391,10 @@ CGroupMap::CLandMarkButton* CGroupMap::findClosestLandmark(const CVector2f ¢ closest = std::numeric_limits::max(); for(TLandMarkButtonVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) { - ucstring lc; + std::string lc; (*it)->getContextHelp(lc); - if(filterLandmark(lc, keywords, startsWith)) { + ucstring ulc = ucstring::makeFromUtf8(lc); + if(filterLandmark(ulc, keywords, startsWith)) { CVector2f pos; mapToWorld(pos, (*it)->Pos); float dist = distsqr(center, pos); @@ -3427,7 +3424,7 @@ CGroupMap::CLandMarkText* CGroupMap::findClosestLandmark(const CVector2f ¢er for(TLandMarkTextVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) { ucstring lc; - lc = (*it)->getText(); + lc = CUtfStringView((*it)->getText()).toUtf16(); if(filterLandmark(lc, keywords, startsWith)) { CVector2f pos; mapToWorld(pos, (*it)->Pos); @@ -3730,13 +3727,13 @@ std::string CGroupMap::getContinentName() const { if (_CurMap == NULL) return ""; - return toLower(_CurMap->ContinentName); + return toLowerAscii(_CurMap->ContinentName); } //========================================================================================================= std::string CGroupMap::getMapTexture() const { - return toLower(_MapTexture); + return toLowerAscii(_MapTexture); } //========================================================================================================= @@ -3830,10 +3827,10 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC: std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i); std::string ahParams = toString("type=user|map=%s|index=%d", _Id.c_str(), index); - CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); + CViewTextMenu* vt = rootMenu->addLine(std::string(), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); if (!vt) break; - vt->setSingleLineTextFormatTaged(name); + vt->setSingleLineTextFormatTaged(name.toUtf8()); // TODO: should calculate from mouse pos and client width vt->setLineMaxW(800); @@ -3901,7 +3898,7 @@ class CAHLandMarkFilter : public IActionHandler CGroupEditBox* eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(group)); if (!eb) return; - text = eb->getInputString().toUtf8(); + text = eb->getInputString(); } map->setLandmarkFilter(text); @@ -4009,7 +4006,7 @@ class CAHValidateUserLandMarkName : public IActionHandler CGroupMap *map = dynamic_cast(LastSelectedLandMark->getParent()); if (!map) return; // update existing landmark - map->updateUserLandMark(LastSelectedLandMark, eb->getInputString(), landMarkType); + map->updateUserLandMark(LastSelectedLandMark, ucstring::makeFromUtf8(eb->getInputString()), landMarkType); } else { @@ -4017,11 +4014,11 @@ class CAHValidateUserLandMarkName : public IActionHandler if (!LastClickedMap) return; if( UseUserPositionForLandMark ) { - LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputString(), landMarkType); + LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), ucstring::makeFromUtf8(eb->getInputString()), landMarkType); } else { - LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputString(), landMarkType); + LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), ucstring::makeFromUtf8(eb->getInputString()), landMarkType); } LastClickedMap->invalidateCoords(); } diff --git a/ryzom/client/src/interface_v3/group_map.h b/ryzom/client/src/interface_v3/group_map.h index 9cfc5bae6..5a5d5624e 100644 --- a/ryzom/client/src/interface_v3/group_map.h +++ b/ryzom/client/src/interface_v3/group_map.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2018 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/ryzom/client/src/interface_v3/group_modal_get_key.cpp index c2d29df78..1bd1f0936 100644 --- a/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -89,7 +90,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) // Setup the text ! CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); - if (pVT != NULL) pVT->setText(Combo.toUCString()); + if (pVT != NULL) pVT->setText(Combo.toString()); // Check if in use CActionsManager *pCurAM = NULL; @@ -110,13 +111,13 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) const CBaseAction *baseAction = pCurAM->getBaseAction(it->second); if (baseAction && pCurAM->isActionPresentInContext(it->second)) { - ucstring shortcutName = baseAction->getActionLocalizedText(it->second); + string shortcutName = baseAction->getActionLocalizedText(it->second); if (pVT != NULL) pVT->setText(shortcutName); } } else { - if (pVT != NULL) pVT->setText(string("")); + if (pVT != NULL) pVT->setText(string()); } } diff --git a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index 04d05e6f2..48d3bd8d4 100644 --- a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -190,9 +191,9 @@ void CGroupPhraseSkillFilter::rebuild() uint nCounter = 0; // local variable (avoid realloc in loop) - vector< pair > tempVec(2); - ucstring sSkillName; - string sDBNameSkillValue; + // vector< pair > tempVec(2); + // string sSkillName; + // string sDBNameSkillValue; // Build the hierarchy while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop @@ -224,7 +225,7 @@ void CGroupPhraseSkillFilter::rebuild() // just text pNode->DisplayText = true; pNode->Template = NULL; - pNode->Text= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i);; + pNode->Text = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); // Action handler? if(!_AHCtrlNode.empty()) diff --git a/ryzom/client/src/interface_v3/group_quick_help.cpp b/ryzom/client/src/interface_v3/group_quick_help.cpp index e89967193..a75fb2c39 100644 --- a/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -169,8 +170,8 @@ void CGroupQuickHelp::setGroupTextSize (CInterfaceGroup *group, bool selected) { bool globalColor = selected ? TextColorGlobalColor : _NonSelectedGlobalColor; bool linkGlobalColor = selected ? LinkColorGlobalColor : _NonSelectedGlobalColor; - uint fontSize = selected ? TextFontSize : _NonSelectedSize; - NLMISC::CRGBA color = selected ? TextColor : _NonSelectedColor; + uint fontSize = selected ? _BrowserStyle.Current.FontSize : _NonSelectedSize; + NLMISC::CRGBA color = selected ? _BrowserStyle.Current.TextColor : _NonSelectedColor; NLMISC::CRGBA linkColor = selected ? LinkColor : _NonSelectedLinkColor; // Look for text in this group @@ -246,7 +247,7 @@ void CGroupQuickHelp::beginElement(CHtmlElement &elm) CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (elm.getAttribute("z_action_shortcut").c_str(), params.c_str())); if (ite != actionCombo.end()) { - addString (ite->second.toUCString()); + addString (ite->second.toString()); } } } diff --git a/ryzom/client/src/interface_v3/group_quick_help.h b/ryzom/client/src/interface_v3/group_quick_help.h index 0d897d014..8c7b42973 100644 --- a/ryzom/client/src/interface_v3/group_quick_help.h +++ b/ryzom/client/src/interface_v3/group_quick_help.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_skills.cpp b/ryzom/client/src/interface_v3/group_skills.cpp index f2586401a..146117d17 100644 --- a/ryzom/client/src/interface_v3/group_skills.cpp +++ b/ryzom/client/src/interface_v3/group_skills.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -245,11 +246,11 @@ static DECLARE_INTERFACE_USER_FCT(getSkillBaseText) if(skillValue!=skillBase) { - result.setUCString( toString("(%d)", skillBase) ); + result.setString( toString("(%d)", skillBase) ); } else { - result.setUCString( ucstring() ); + result.setString( std::string() ); } return true; @@ -335,7 +336,7 @@ void CGroupSkills::createAllTreeNodes() // local variable (avoid realloc in loop) vector< pair > tempVec(2); - ucstring sSkillName; + const char *sSkillName; while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop { diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp index 5190404ab..83dbbdeea 100644 --- a/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/ryzom/client/src/interface_v3/guild_manager.cpp @@ -1,9 +1,10 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -245,11 +246,11 @@ bool CGuildManager::isLeaderOfTheGuild() } // *************************************************************************** -ucstring CGuildManager::getGuildName() +string CGuildManager::getGuildName() { if (_InGuild) return _Guild.Name; - return ucstring(""); + return string(); } // *************************************************************************** @@ -369,13 +370,13 @@ void CGuildManager::update() if (node && node->getValueBool()) { // See if we need to show any online/offline messages - static map CachedGuildMembers; - ucstring onlineMessage = CI18N::get("uiPlayerOnline"); - ucstring offlineMessage = CI18N::get("uiPlayerOffline"); + static map CachedGuildMembers; + const string &onlineMessage = CI18N::get("uiPlayerOnline"); + const string &offlineMessage = CI18N::get("uiPlayerOffline"); for (uint i = 0; i < _GuildMembers.size(); ++i) { - map::const_iterator it = CachedGuildMembers.find(_GuildMembers[i].Name); + map::const_iterator it = CachedGuildMembers.find(_GuildMembers[i].Name); if ( it != CachedGuildMembers.end() ) { if ( (*it).second.Online == _GuildMembers[i].Online) @@ -390,12 +391,12 @@ void CGuildManager::update() continue; } - ucstring msg = (_GuildMembers[i].Online != ccs_offline) ? onlineMessage : offlineMessage; + string msg = (_GuildMembers[i].Online != ccs_offline) ? onlineMessage : offlineMessage; strFindReplace(msg, "%s", _GuildMembers[i].Name); string cat = getStringCategory(msg, msg); map::const_iterator it; NLMISC::CRGBA col = CRGBA::Yellow; - it = ClientCfg.SystemInfoParams.find(toLower(cat)); + it = ClientCfg.SystemInfoParams.find(toLowerAscii(cat)); if (it != ClientCfg.SystemInfoParams.end()) { col = it->second.Color; @@ -418,7 +419,7 @@ void CGuildManager::update() { uint i; _Grade = EGSPD::CGuildGrade::Member; - ucstring sUserName = toLower(UserEntity->getEntityName()); + string sUserName = toLower(UserEntity->getEntityName()); for (i = 0; i < _GuildMembers.size(); ++i) { if (toLower(_GuildMembers[i].Name) == sUserName) @@ -722,7 +723,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); uint32 nameID = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":NAME")->getValue32(); - ucstring name; + string name; if (nameID && pSMC->getDynString(nameID, name)) { Text->setText(name); @@ -734,7 +735,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT { LIFT_ICONS::TLiftIcon li = (LIFT_ICONS::TLiftIcon)(icon & UINT64_CONSTANT(0x7FFFFFFFFFFFFFFF)); - string str = toLower(LIFT_ICONS::toString(li)); + string str = toLowerAscii(LIFT_ICONS::toString(li)); Ctrl->setType(CCtrlSheetInfo::SheetType_Teleport_Location); Ctrl->setSlot("asc_"+str+".tga"); } @@ -886,7 +887,7 @@ class CAHGuildSheetOpen : public IActionHandler { CRyzomTime rt; rt.updateRyzomClock(rGuildMembers[i].EnterDate); - ucstring str = toString("%04d", rt.getRyzomYear()) + " "; + string str = toString("%04d", rt.getRyzomYear()) + " "; str += CI18N::get("uiJenaYear") + " : "; str += CI18N::get("uiAtysianCycle") + " "; str += toString("%01d", rt.getRyzomCycle()+1) +", "; @@ -998,12 +999,12 @@ class CAHGuildSheetMenuOpen : public IActionHandler public: // Current selection static sint32 MemberIndexSelected; // Index of the member selected when right clicked - static ucstring MemberNameSelected; // Name of the member selected when right clicked (for extra check) + static std::string MemberNameSelected; // Name of the member selected when right clicked (for extra check) }; REGISTER_ACTION_HANDLER (CAHGuildSheetMenuOpen, "guild_member_menu_open"); sint32 CAHGuildSheetMenuOpen::MemberIndexSelected= -1; -ucstring CAHGuildSheetMenuOpen::MemberNameSelected; +std::string CAHGuildSheetMenuOpen::MemberNameSelected; // *************************************************************************** @@ -1098,12 +1099,12 @@ public: // Current selection static sint32 MemberIndexSelected; // Index of the member selected when left clicked - static ucstring MemberNameSelected; // Name of the member selected when lef clicked + static std::string MemberNameSelected; // Name of the member selected when lef clicked }; REGISTER_ACTION_HANDLER(CAHGuildSheetTellMember, "guild_tell_member"); sint32 CAHGuildSheetTellMember::MemberIndexSelected= -1; -ucstring CAHGuildSheetTellMember::MemberNameSelected; +string CAHGuildSheetTellMember::MemberNameSelected; // *************************************************************************** class CAHGuildSheetSetLeader : public IActionHandler @@ -1275,7 +1276,7 @@ class CHandlerInvGuildToBag : public IActionHandler if (!bPlaceFound) { - ucstring msg = CI18N::get("msgCantPutItemInBag"); + string msg = CI18N::get("msgCantPutItemInBag"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; diff --git a/ryzom/client/src/interface_v3/guild_manager.h b/ryzom/client/src/interface_v3/guild_manager.h index 7b8b94df2..301932e51 100644 --- a/ryzom/client/src/interface_v3/guild_manager.h +++ b/ryzom/client/src/interface_v3/guild_manager.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -37,7 +38,7 @@ struct SGuildMember { uint32 Index; // Index in the DB uint32 NameID; - ucstring Name; + std::string Name; EGSPD::CGuildGrade::TGuildGrade Grade; TCharConnectionState Online; uint32 EnterDate; @@ -54,7 +55,7 @@ struct SGuildMember struct SGuild { uint32 NameID; - ucstring Name; + std::string Name; uint64 Icon; bool QuitGuildAvailable; @@ -131,7 +132,7 @@ public: bool isLeaderOfTheGuild(); /// If the player is in a guild get the guild name else return empty - ucstring getGuildName(); + std::string getGuildName(); /// If the player is in a guild get the amount of money the guild owns else return zero uint64 getMoney(); @@ -270,7 +271,7 @@ private: // Join Proposal handling uint32 _JoinPropPhraseID; - ucstring _JoinPropPhrase; + std::string _JoinPropPhrase; bool _JoinPropUpdate; }; diff --git a/ryzom/client/src/interface_v3/input_handler_manager.cpp b/ryzom/client/src/interface_v3/input_handler_manager.cpp index 67a1b2350..28420dff4 100644 --- a/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/input_handler_manager.h b/ryzom/client/src/interface_v3/input_handler_manager.h index 4b078ee84..b587fecef 100644 --- a/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/ryzom/client/src/interface_v3/input_handler_manager.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 6fcba9eac..cd2160489 100644 --- a/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -298,7 +298,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) CXMLAutoPtr ptr((const char*)xmlGetProp (cur, (xmlChar*)"name")); string animName; if (ptr) - animName = toLower(CFile::getFilenameWithoutExtension(ptr.str())); + animName = toLowerAscii(CFile::getFilenameWithoutExtension(ptr.str())); if (!animName.empty()) { @@ -1108,7 +1108,7 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (ptr) _Rot = convertVector(ptr); ptr = xmlGetProp (cur, (xmlChar*)"name"); - if (ptr) _Name = toLower((const char*)ptr); + if (ptr) _Name = toLowerAscii((const char*)ptr); _IG = UInstanceGroup::createInstanceGroup(_Name); if (_IG == NULL) @@ -1223,7 +1223,7 @@ std::string CInterface3DIG::getName() const // ---------------------------------------------------------------------------- void CInterface3DIG::setName (const std::string &ht) { - string lwrname = toLower(ht); + string lwrname = toLowerAscii(ht); if (lwrname != _Name) { CInterface3DScene *pI3DS = dynamic_cast(_Parent); @@ -1271,7 +1271,7 @@ bool CInterface3DShape::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (ptr) _Rot = convertVector(ptr); ptr = xmlGetProp (cur, (xmlChar*)"name"); - if (ptr) _Name = toLower((const char*)ptr); + if (ptr) _Name = toLowerAscii((const char*)ptr); _Instance = dynamic_cast(parentGroup)->getScene()->createInstance(_Name); if (_Instance.empty()) @@ -1417,7 +1417,7 @@ void CInterface3DShape::setName (const std::string &ht) _Name.clear(); } - string lwrname = toLower(ht); + string lwrname = toLowerAscii(ht); if (lwrname != _Name) { CInterface3DScene *pI3DS = dynamic_cast(_Parent); @@ -1583,7 +1583,7 @@ bool CInterface3DFX::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (ptr) _Rot = convertVector(ptr); ptr = xmlGetProp (cur, (xmlChar*)"name"); - if (ptr) _Name = toLower((const char*)ptr); + if (ptr) _Name = toLowerAscii((const char*)ptr); return true; } diff --git a/ryzom/client/src/interface_v3/interface_ddx.cpp b/ryzom/client/src/interface_v3/interface_ddx.cpp index 347a0d94d..230b7a2c2 100644 --- a/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -350,7 +351,7 @@ void CInterfaceDDX::CParam::updateScrollView(sint32 nVal) { if(ResultView) { - ResultView->setText(ucstring(toString(nVal)) + ResultUnit); + ResultView->setText(toString(nVal) + ResultUnit); } } @@ -361,7 +362,7 @@ void CInterfaceDDX::CParam::updateScrollView(double nVal) { // allow N digits string fmt= toString("%%.%df", ResultDecimal); - ResultView->setText(ucstring(toString(fmt.c_str(), nVal)) + ResultUnit); + ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit); } } diff --git a/ryzom/client/src/interface_v3/interface_ddx.h b/ryzom/client/src/interface_v3/interface_ddx.h index 48f329053..e15f44381 100644 --- a/ryzom/client/src/interface_v3/interface_ddx.h +++ b/ryzom/client/src/interface_v3/interface_ddx.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -79,7 +80,7 @@ private: // The tex view, result of the scroll CViewTextPtr ResultView; // The unit to append to the result string - ucstring ResultUnit; + std::string ResultUnit; // For ScrollBarFloat widget only uint8 ResultDecimal; // For ScrollBarFloat widget only diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 30126c0d9..4c21fee47 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -176,7 +177,7 @@ static DECLARE_INTERFACE_USER_FCT(getCompassText) "uiWNW", }; - result.setUCString( CI18N::get(txts[direction]) ); + result.setString( CI18N::get(txts[direction]) ); return true; } REGISTER_INTERFACE_USER_FCT("getCompassText", getCompassText); @@ -251,7 +252,7 @@ static DECLARE_INTERFACE_USER_FCT(getDifficultyText) } SENTENCE_APPRAISAL::ESentenceAppraisal sa = (SENTENCE_APPRAISAL::ESentenceAppraisal)args[0].getInteger(); - result.setUCString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); + result.setString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); return true; } @@ -625,11 +626,11 @@ static DECLARE_INTERFACE_USER_FCT(getChatWin) CChatWindowManager &rCWM = CChatWindowManager::getInstance(); - ucstring title = CI18N::get(args[0].getString()); + string title = CI18N::get(args[0].getString()); CChatWindow *window = rCWM.getChatWindow(title); if (!window) { - nlwarning("Can't find window named %s", title.toString().c_str()); + nlwarning("Can't find window named %s", title.c_str()); return false; } string sTmp = window->getContainer()->getId(); @@ -665,14 +666,14 @@ static DECLARE_INTERFACE_USER_FCT(getKey) CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName(name.c_str(),param.c_str())); if (it != acmap.end()) { - result.setUCString (it->second.toUCString()); + result.setString (it->second.toString()); } else { if (notna) - result.setUCString (ucstring("")); + result.setString (std::string()); else - result.setUCString (CI18N::get("uiNotAssigned")); + result.setString (CI18N::get("uiNotAssigned")); } return true; @@ -1025,9 +1026,9 @@ static DECLARE_INTERFACE_USER_FCT(getBotChatBuyFilterMPText) RM_FABER_TYPE::TRMFType faberType= (RM_FABER_TYPE::TRMFType)args[0].getInteger(); if(faberType>=RM_FABER_TYPE::Unknown) - result.setUCString(CI18N::get("uittBCNoItemPartFilter")); + result.setString(CI18N::get("uittBCNoItemPartFilter")); else - result.setUCString(RM_FABER_TYPE::toLocalString(faberType)); + result.setString(RM_FABER_TYPE::toLocalString(faberType)); return true; } @@ -1076,15 +1077,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostLocalizedName(CSheetId(nSheet))); + const char *name = pSMC->getOutpostLocalizedName(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1103,15 +1104,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))); + const char *name = pSMC->getOutpostLocalizedDescription(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1130,15 +1131,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))); + const char *name = pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1157,18 +1158,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name - ucstring name; + const char *name; CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); COutpostBuildingSheet *pOBS = dynamic_cast(pSheet); if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) { // Don't display description if the building is an empty slot - name.clear(); + name = ""; } else { @@ -1177,7 +1178,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) } - result.setUCString(name); + result.setString(name); return true; } @@ -1196,15 +1197,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getSquadLocalizedName(CSheetId(nSheet))); + const char *name = pSMC->getSquadLocalizedName(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1223,15 +1224,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))); + const char *name = pSMC->getSquadLocalizedDescription(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1284,7 +1285,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) // if status wanted is peace or unknow, then "N/A", because there is no attack period in peace mode if( status==OUTPOSTENUMS::Peace || status==OUTPOSTENUMS::UnknownOutpostState ) { - result.setUCString(string(" - ")); + result.setString(string(" - ")); return true; } @@ -1292,7 +1293,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) if( (isAttackPeriod && status>OUTPOSTENUMS::AttackRound) || (!isAttackPeriod && status>OUTPOSTENUMS::DefenseRound) ) { - result.setUCString(CI18N::get("uiOutpostPeriodEnded")); + result.setString(CI18N::get("uiOutpostPeriodEnded")); return true; } @@ -1312,7 +1313,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) tstruct= gmtime(&tval); if(!tstruct) { - result.setUCString(string("Bad Date Received")); + result.setString(string("Bad Date Received")); return true; } dname= tstruct->tm_wday; // 0-6 (Sunday==0!!) @@ -1325,21 +1326,21 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) tstruct= gmtime(&tval); if(!tstruct) { - result.setUCString(string("Bad Date Received")); + result.setString(string("Bad Date Received")); return true; } hend= tstruct->tm_hour; // 0-23 mend= tstruct->tm_min; // 0-59 // translate - ucstring res= CI18N::get("uiOutpostPeriodFormat"); + string res= CI18N::get("uiOutpostPeriodFormat"); strFindReplace( res, "%dayname", CI18N::get(toString("uiDay%d", dname)) ); strFindReplace( res, "%daynumber", toString(dnumber) ); strFindReplace( res, "%month", CI18N::get(toString("uiMonth%02d", month+1)) ); strFindReplace( res, "%timestart", toString("%02d:%02d", hstart, mstart) ); strFindReplace( res, "%timeend", toString("%02d:%02d", hend, mend) ); - result.setUCString(res); + result.setString(res); return true; } REGISTER_INTERFACE_USER_FCT("getOutpostPeriod", getOutpostPeriod) diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 9aeec4e5f..7744be7eb 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -312,16 +313,16 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName) // if from ctrlSheet, then take the correct ACTUAL name (ie from NAMEID if not 0) if(ctrlSheet) { - result.setUCString(ctrlSheet->getItemActualName()); + result.setString(ctrlSheet->getItemActualName()); return true; } // Standard (but less accurate) way else { const CItemSheet *itemSheet = getItemSheet(args); - ucstring tmp; + const char *tmp = ""; if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id); - result.setUCString(tmp); + result.setString(tmp); return true; } } @@ -345,9 +346,9 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName) return false; } - ucstring tmp; + const char *tmp = ""; tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet); - result.setUCString(tmp); + result.setString(tmp); return true; } REGISTER_INTERFACE_USER_FCT("getItemTranslatedName", getItemTranslatedName) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 5231dc19a..643ca959e 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1,8 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2017 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2010-2019 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2011 Robert TIMM (rti) // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) @@ -310,12 +310,12 @@ public: class CStringManagerTextProvider : public CViewTextID::IViewTextProvider { - bool getString( uint32 stringId, ucstring &result ) + bool getString( uint32 stringId, string &result ) { return STRING_MANAGER::CStringManagerClient::instance()->getString( stringId, result ); } - bool getDynString( uint32 dynStringId, ucstring &result ) + bool getDynString( uint32 dynStringId, string &result ) { return STRING_MANAGER::CStringManagerClient::instance()->getDynString( dynStringId, result ); } @@ -324,112 +324,119 @@ class CStringManagerTextProvider : public CViewTextID::IViewTextProvider class CRyzomTextFormatter : public CViewTextFormated::IViewTextFormatter { public: - ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) + std::string formatString( const std::string &inputString, const std::string ¶mString ) { - ucstring formatedResult; + std::string formatedResult; // Apply the format - for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();) + for(std::string::const_iterator it = inputString.begin(); it != inputString.end();) { if (*it == '$') { ++it; if (it == inputString.end()) + { + formatedResult += '$'; + --it; break; + } switch(*it) { case 't': // add text ID + { formatedResult += paramString; break; - + } case 'P': case 'p': // add player name - if (ClientCfg.Local) + { + if (ClientCfg.Local || !UserEntity) { - formatedResult += ucstring("player"); + if (*it == 'P') formatedResult += "PLAYER"; + else formatedResult += "Player"; } else { - if(UserEntity) - { - ucstring name = UserEntity->getEntityName(); - if (*it == 'P') setCase(name, CaseUpper); - formatedResult += name; - } + std::string name = UserEntity->getEntityName(); + if (*it == 'P') name = toUpper(name); + formatedResult += name; } break; - // + } case 's': case 'b': // add bot name + { + string botName; + bool womanTitle = false; + if (ClientCfg.Local) { - ucstring botName; - bool womanTitle = false; - if (ClientCfg.Local) - { - botName = ucstring("NPC"); - } - else + botName = "NPC"; + } + else + { + CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; + if(UserEntity) + trader = UserEntity->trader(); + if (trader != CLFECOMMON::INVALID_SLOT) { - CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; - if(UserEntity) - trader = UserEntity->trader(); - if (trader != CLFECOMMON::INVALID_SLOT) + CEntityCL *entity = EntitiesMngr.entity(trader); + if (entity != NULL) { - CEntityCL *entity = EntitiesMngr.entity(trader); - if (entity != NULL) + uint32 nDBid = entity->getNameId(); + if (nDBid != 0) + { + STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); + pSMC->getString(nDBid, botName); + } + else { - uint32 nDBid = entity->getNameId(); - if (nDBid != 0) - { - STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - pSMC->getString(nDBid, botName); - } - else - { - botName = entity->getDisplayName(); - } - CCharacterCL *pChar = dynamic_cast(entity); - if (pChar != NULL) - womanTitle = pChar->getGender() == GSGENDER::female; + botName = entity->getDisplayName(); } + CCharacterCL *pChar = dynamic_cast(entity); + if (pChar != NULL) + womanTitle = pChar->getGender() == GSGENDER::female; } } - // get the title translated - ucstring sTitleTranslated = botName; - CStringPostProcessRemoveName spprn; - spprn.Woman = womanTitle; - spprn.cbIDStringReceived(sTitleTranslated); - - botName = CEntityCL::removeTitleAndShardFromName(botName); + } + // get the title translated + string sTitleTranslated = botName; // FIXME: UTF-8 + CStringPostProcessRemoveName spprn; + spprn.Woman = womanTitle; + spprn.cbIDStringReceived(sTitleTranslated); - // short name (with no title such as 'guard', 'merchant' ...) - if (*it == 's') - { - // But if there is no name, display only the title - if (botName.empty()) - botName = sTitleTranslated; - } - else - { - // Else we want the title ! - if (!botName.empty()) - botName += " "; - botName += sTitleTranslated; - } + botName = CEntityCL::removeTitleAndShardFromName(botName); - formatedResult += botName; + // short name (with no title such as 'guard', 'merchant' ...) + if (*it == 's') + { + // But if there is no name, display only the title + if (botName.empty()) + botName = sTitleTranslated; } + else + { + // Else we want the title ! + if (!botName.empty()) + botName += " "; + botName += sTitleTranslated; + } + + formatedResult += botName; break; - default: - formatedResult += (ucchar) '$'; + } + default: + { + formatedResult += '$'; + --it; break; } + } ++it; } else { - formatedResult += (ucchar) *it; + formatedResult += *it; ++it; } } @@ -1520,7 +1527,7 @@ void CInterfaceManager::updateFrameEvents() if ((T0 - _UpdateWeatherTime) > (1 * 3 * 1000)) { _UpdateWeatherTime = T0; - ucstring str = CI18N::get ("uiTheSeasonIs") + + string str = CI18N::get ("uiTheSeasonIs") + CI18N::get ("uiSeason"+toStringEnum(computeCurrSeason())) + CI18N::get ("uiAndTheWeatherIs") + CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName) + @@ -1535,7 +1542,7 @@ void CInterfaceManager::updateFrameEvents() CCtrlBase *pTooltip= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt")); if (pTooltip != NULL) { - ucstring tt = toString("%02d", WeatherManager.getNextWeatherHour()) + CI18N::get("uiMissionTimerHour") + + string tt = toString("%02d", WeatherManager.getNextWeatherHour()) + CI18N::get("uiMissionTimerHour") + " - " + CI18N::get("uiHumidity") + " " + toString("%d", (uint)(roundWeatherValue(WeatherManager.getNextWeatherValue()) * 100.f)) + "%"; pTooltip->setDefaultContextHelp(tt); @@ -1598,7 +1605,9 @@ void CInterfaceManager::updateFrameEvents() // handle gc for lua CLuaManager::getInstance().getLuaState()->handleGC(); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().update(); +#endif CItemGroupManager::getInstance()->update(); @@ -2302,7 +2311,7 @@ void CInterfaceManager::addServerString (const std::string &sTarget, uint32 id, if (id == 0) { CInterfaceExprValue val; - val.setUCString (ucstring("")); + val.setString (std::string()); CInterfaceLink::setTargetProperty (sTarget, val); return; } @@ -2320,7 +2329,7 @@ void CInterfaceManager::addServerID (const std::string &sTarget, uint32 id, IStr if (id == 0) { CInterfaceExprValue val; - val.setUCString (ucstring("")); + val.setString (std::string()); CInterfaceLink::setTargetProperty (sTarget, val); return; } @@ -2340,7 +2349,7 @@ void CInterfaceManager::processServerIDString() for (uint32 i = 0; i < _IDStringWaiters.size(); ++i) { bool bAffect = false; - ucstring ucstrToAffect; + string ucstrToAffect; SIDStringWaiter *pISW = _IDStringWaiters[i]; if (pISW->IdOrString == true) // ID ! { @@ -2367,7 +2376,7 @@ void CInterfaceManager::processServerIDString() if (bValid) { ucstrToAffect = STRING_MANAGER::CStringManagerClient::getLocalizedName(ucstrToAffect); - val.setUCString (ucstrToAffect); + val.setString (ucstrToAffect); CInterfaceLink::setTargetProperty (pISW->Target, val); } @@ -2380,7 +2389,7 @@ void CInterfaceManager::processServerIDString() } // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucstring &text, const string &masterGroup, TCaseMode caseMode) +void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const string &text, const string &masterGroup, TCaseMode caseMode) { CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + msgBoxGroup)); CViewText *viewText= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + msgBoxGroup + ":text")); @@ -2397,14 +2406,14 @@ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucst } // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBox(const ucstring &text, const string &masterGroup, TCaseMode caseMode) +void CInterfaceManager::messageBox(const string &text, const string &masterGroup, TCaseMode caseMode) { messageBoxInternal("message_box", text, masterGroup, caseMode); } // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, +void CInterfaceManager::messageBoxWithHelp(const std::string &text, const std::string &masterGroup, const std::string &ahOnOk, const std::string ¶msOnOk, TCaseMode caseMode) { @@ -2426,7 +2435,7 @@ void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::stri // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring &text, const std::string &ahOnOk, +void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const std::string &text, const std::string &ahOnOk, const std::string ¶msOnOk, const std::string &ahOnCancel, const std::string ¶msOnCancel, const string &masterGroup) { CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":valid_message_box")); @@ -2488,7 +2497,7 @@ bool CInterfaceManager::getCurrentValidMessageBoxOnOk(string &ahOnOk, const std: // *************************************************************************** -void CInterfaceManager::displayDebugInfo(const ucstring &str, TSystemInfoMode mode /*=InfoMsg*/) +void CInterfaceManager::displayDebugInfo(const string &str, TSystemInfoMode mode /*=InfoMsg*/) { if (PeopleInterraction.DebugInfo) PeopleInterraction.ChatInput.DebugInfo.displayMessage(str, getDebugInfoColor(mode), 2); @@ -2518,16 +2527,16 @@ NLMISC::CRGBA CInterfaceManager::getDebugInfoColor(TSystemInfoMode mode) } // *************************************************************************** -void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat) +void CInterfaceManager::displaySystemInfo(const string &str, const string &cat) { CClientConfig::SSysInfoParam::TMode mode = CClientConfig::SSysInfoParam::Normal; CRGBA color = CRGBA::White; - ucstring cleanStr = str; - ucstring::size_type pos = str.find(ucstring("|")); + string cleanStr = str; + string::size_type pos = str.find("|"); if (pos != std::string::npos) { - ucstring::size_type end = str.find(ucstring("|"), pos+1); + string::size_type end = str.find("|", pos+1); if (end != std::string::npos) cleanStr = str.substr(pos+1, end-pos-1); else @@ -2537,13 +2546,13 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat // If broadcast, parse lua code if (toLower(cat) == "bc" && str.size() > 3 && str[0]=='@' && str[1]=='L' && str[2]=='U' && str[3]=='A') { - string code = str.substr(4, str.size()-4).toString(); + string code = str.substr(4, str.size()-4); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); return; } - map::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat)); + map::const_iterator it = ClientCfg.SystemInfoParams.find(toLowerAscii(cat)); if (it != ClientCfg.SystemInfoParams.end()) { mode = it->second.Mode; @@ -2579,7 +2588,7 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat CRGBA CInterfaceManager::getSystemInfoColor(const std::string &cat) { CRGBA col = CRGBA::White; - map::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat)); + map::const_iterator it = ClientCfg.SystemInfoParams.find(toLowerAscii(cat)); if (it != ClientCfg.SystemInfoParams.end()) col = it->second.Color; return col; @@ -2989,7 +2998,7 @@ bool CInterfaceManager::deletePlayerKeys (const std::string &playerFileIdent) } // *************************************************************************** -void CInterfaceManager::log(const ucstring &str, const std::string &cat) +void CInterfaceManager::log(const std::string &str, const std::string &cat) { if (_LogState) { @@ -2998,10 +3007,10 @@ void CInterfaceManager::log(const ucstring &str, const std::string &cat) FILE *f = nlfopen(fileName, "at"); if (f != NULL) { - const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8(); + const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpperAscii(cat) + ") * " + str; fprintf(f, "%s\n", finalString.c_str()); + fclose(f); } - fclose(f); } } @@ -3074,7 +3083,7 @@ NLMISC_COMMAND( localCounter, "Get value of local counter", "" ) { if (args.size() != 0) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo(ucstring(toString(im->getLocalSyncActionCounter()))); + im->displaySystemInfo(toString(im->getLocalSyncActionCounter())); return true; } @@ -3187,8 +3196,8 @@ struct CEmoteEntry string::size_type pos1 = path1.find('|'); string::size_type pos2 = path2.find('|'); - ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); - ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); + string s1 = toUpper(CI18N::get(path1.substr(0, pos1))); + string s2 = toUpper(CI18N::get(path2.substr(0, pos2))); sint result = s1.compare(s2); if (result != 0) @@ -3206,14 +3215,14 @@ struct CEmoteEntry } }; -static bool translateEmote(const std::string &id, ucstring &translatedName, std::string &commandName, std::string &commandNameAlt) +static bool translateEmote(const std::string &id, std::string &translatedName, std::string &commandName, std::string &commandNameAlt) { if (CI18N::hasTranslation(id)) { translatedName = CI18N::get(id); // convert command to utf8 since emote translation can have strange chars - commandName = toLower(translatedName).toUtf8(); + commandName = toLower(translatedName); // replace all spaces by _ while (strFindReplace(commandName, " ", "_")); @@ -3312,7 +3321,7 @@ void CInterfaceManager::initEmotes() CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); nlassert(pMenu); - ucstring sTranslatedName; + std::string sTranslatedName; std::string sCommandName; std::string sCommandNameAlt; @@ -3356,7 +3365,7 @@ void CInterfaceManager::initEmotes() translateEmote(sTmp, sTranslatedName, sCommandName, sCommandNameAlt); // Create a line - pMenu->addLine (sTranslatedName + " (/" + ucstring::makeFromUtf8(sCommandName) + ")", "emote", + pMenu->addLine (sTranslatedName + " (/" + sCommandName + ")", "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), sTmp); } } @@ -3412,7 +3421,7 @@ void CInterfaceManager::initEmotes() { // Yeah that's a quick emote too; set command pMenu->addLineAtIndex (i, - "@{FFFF}/" + ucstring::makeFromUtf8(sCommandName), + "@{FFFF}/" + sCommandName, "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), "", "", "", false, false, true); @@ -4060,11 +4069,11 @@ char* CInterfaceManager::getTimestampHuman(const char* format /* "[%H:%M:%S] " * * * All \d's in default parameter remove a following character. */ -bool CInterfaceManager::parseTokens(ucstring& ucstr) +bool CInterfaceManager::parseTokens(string& ucstr) { - ucstring str = ucstr; - ucstring start_token("$"); - ucstring end_token("$"); + string str = ucstr; + string start_token("$"); + string end_token("$"); size_t start_pos = 0; size_t end_pos = 1; @@ -4081,8 +4090,8 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) // Get the whole token substring first end_pos = str.find(end_token, start_pos + 1); - if ((start_pos == ucstring::npos) || - (end_pos == ucstring::npos) || + if ((start_pos == string::npos) || + (end_pos == string::npos) || (end_pos <= start_pos + 1)) { // Wrong formatting; give up on this one. @@ -4100,19 +4109,19 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) continue; } - ucstring token_whole = str.luabind_substr(start_pos, end_pos - start_pos + 1); - ucstring token_string = token_whole.luabind_substr(1, token_whole.length() - 2); - ucstring token_replacement = token_whole; - ucstring token_default = token_whole; + string token_whole = str.substr(start_pos, end_pos - start_pos + 1); + string token_string = token_whole.substr(1, token_whole.length() - 2); + string token_replacement = token_whole; + string token_default = token_whole; - ucstring token_subject; - ucstring token_param; + string token_subject; + string token_param; // Does the token have a parameter? // If not it is 'name' by default - vector token_vector; - vector param_vector; - splitUCString(token_string, ucstring("."), token_vector); + vector token_vector; + vector param_vector; + splitString(token_string, ".", token_vector); if (token_vector.empty()) { // Wrong formatting; give up on this one. @@ -4122,23 +4131,23 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) token_subject = token_vector[0]; if (token_vector.size() == 1) { - splitUCString(token_subject, ucstring("/"), param_vector); - token_subject = !param_vector.empty() ? param_vector[0] : ucstring(""); - token_param = ucstring("name"); + splitString(token_subject, "/", param_vector); + token_subject = !param_vector.empty() ? param_vector[0] : string(); + token_param = string("name"); } else if (token_vector.size() > 1) { token_param = token_vector[1]; - if (token_param.luabind_substr(0, 3) != ucstring("gs(")) + if (token_param.substr(0, 3) != "gs(") { - splitUCString(token_vector[1], ucstring("/"), param_vector); - token_param = !param_vector.empty() ? param_vector[0] : ucstring(""); + splitString(token_vector[1], "/", param_vector); + token_param = !param_vector.empty() ? param_vector[0] : string(); } } // Get any default value, if not gs sint extra_replacement = 0; - if (token_param.luabind_substr(0, 3) != ucstring("gs(")) + if (token_param.substr(0, 3) != "gs(") { if (param_vector.size() == 2) { @@ -4146,9 +4155,9 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) token_replacement = param_vector[1]; // Delete following chars for every '\d' in default string::size_type token_replacement_pos; - while ((token_replacement_pos = token_replacement.find(ucstring("\\d"))) != string::npos) + while ((token_replacement_pos = token_replacement.find(string("\\d"))) != string::npos) { - token_replacement.replace(token_replacement_pos, 2, ucstring("")); + token_replacement.replace(token_replacement_pos, 2, string()); extra_replacement++; } token_default = token_replacement; @@ -4157,17 +4166,17 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) CEntityCL *pTokenSubjectEntity = NULL; - if (token_subject == ucstring("me")) + if (token_subject == "me") { pTokenSubjectEntity = static_cast(UserEntity); } - else if (token_subject == ucstring("t")) + else if (token_subject == "t") { // Target uint targetSlot = UserEntity->targetSlot(); pTokenSubjectEntity = EntitiesMngr.entity(targetSlot); } - else if (token_subject == ucstring("tt")) + else if (token_subject == "tt") { // Target's target uint targetSlot = UserEntity->targetSlot(); @@ -4185,11 +4194,11 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) } } else if ((token_subject.length() == 3) && - (token_subject.luabind_substr(0, 2) == ucstring("tm"))) + (token_subject.substr(0, 2) == "tm")) { // Teammate uint indexInTeam = 0; - fromString(token_subject.luabind_substr(2, 1).toString(), indexInTeam); + fromString(token_subject.substr(2, 1), indexInTeam); // Make 0-based --indexInTeam; @@ -4225,9 +4234,9 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) if (pTokenSubjectEntity != NULL) { // Parse the parameter - if (token_param == ucstring("name")) + if (token_param == "name") { - ucstring name = pTokenSubjectEntity->getDisplayName(); + string name = pTokenSubjectEntity->getDisplayName(); // special case where there is only a title, very rare case for some NPC if (name.empty()) { @@ -4235,12 +4244,12 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) } token_replacement = name.empty() ? token_replacement : name; } - else if (token_param == ucstring("title")) + else if (token_param == "title") { - ucstring title = pTokenSubjectEntity->getTitle(); + string title = pTokenSubjectEntity->getTitle(); token_replacement = title.empty() ? token_replacement : title; } - else if (token_param == ucstring("race")) + else if (token_param == "race") { CCharacterCL *pC = dynamic_cast(pTokenSubjectEntity); if (pC) @@ -4248,27 +4257,27 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) EGSPD::CPeople::TPeople race = pC->people(); if (race >= EGSPD::CPeople::Playable && race <= EGSPD::CPeople::EndPlayable) { - ucstring srace = NLMISC::CI18N::get("io" + EGSPD::CPeople::toString(race)); + string srace = NLMISC::CI18N::get("io" + EGSPD::CPeople::toString(race)); token_replacement = srace.empty() ? token_replacement : srace; } } } - else if (token_param == ucstring("guild")) + else if (token_param == "guild") { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucGuildName; + string ucGuildName; if (pSMC->getString(pTokenSubjectEntity->getGuildNameID(), ucGuildName)) { token_replacement = ucGuildName.empty() ? token_replacement : ucGuildName; } } - else if (token_param.luabind_substr(0, 3) == ucstring("gs(") && - token_param.luabind_substr(token_param.length() - 1 , 1) == ucstring(")")) + else if (token_param.substr(0, 3) == "gs(" && + token_param.substr(token_param.length() - 1 , 1) == ")") { // Gender string - vector strList; - ucstring gender_string = token_param.luabind_substr(3, token_param.length() - 4); - splitUCString(gender_string, ucstring("/"), strList); + vector strList; + string gender_string = token_param.substr(3, token_param.length() - 4); + splitString(gender_string, "/", strList); if (strList.size() <= 1) { @@ -4297,8 +4306,8 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) { // Nothing to replace; show message and exit CInterfaceManager *im = CInterfaceManager::getInstance(); - ucstring message = ucstring(CI18N::get("uiUntranslatedToken")); - message.replace(message.find(ucstring("%s")), 2, token_whole); + string message = CI18N::get("uiUntranslatedToken"); + message.replace(message.find("%s"), 2, token_whole); im->displaySystemInfo(message); return false; } diff --git a/ryzom/client/src/interface_v3/interface_manager.h b/ryzom/client/src/interface_v3/interface_manager.h index 0b89584bc..efdee3046 100644 --- a/ryzom/client/src/interface_v3/interface_manager.h +++ b/ryzom/client/src/interface_v3/interface_manager.h @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2018 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -241,7 +241,7 @@ public: // Log system (all chat/tell void setLogState(bool state) { _LogState = state; } bool getLogState() const { return _LogState; } - void log(const ucstring &str, const std::string &cat = ""); + void log(const std::string &str, const std::string &cat = ""); /// Text from here and from server @@ -249,7 +249,7 @@ public: { public: virtual ~IStringProcess() { } - virtual bool cbIDStringReceived(ucstring &inOut) = 0; // called when string or id is received (return true if valid the change) + virtual bool cbIDStringReceived(std::string &inOut) = 0; // called when string or id is received (return true if valid the change) }; void addServerString (const std::string &sTarget, uint32 id, IStringProcess *cb = NULL); @@ -292,12 +292,12 @@ public: void drawViews (NL3D::UCamera camera); // display a debug info - void displayDebugInfo(const ucstring &str, TSystemInfoMode mode = InfoMsg); + void displayDebugInfo(const std::string &str, TSystemInfoMode mode = InfoMsg); // get the color associated with the given system info mode NLMISC::CRGBA getDebugInfoColor(TSystemInfoMode mode); // display a system info string - void displaySystemInfo(const ucstring &str, const std::string &Category = "SYS"); + void displaySystemInfo(const std::string &str, const std::string &Category = "SYS"); NLMISC::CRGBA getSystemInfoColor(const std::string &Category = "SYS"); void setupOptions(); @@ -305,12 +305,12 @@ public: /** Open a MessageBox. this is a simple ModalWindow with a Ok button * ui:interface:message_box must be defined in xml, with a "text" ViewText son */ - void messageBox(const ucstring &text, const std::string &masterGroup="ui:interface", TCaseMode caseMode = CaseFirstSentenceLetterUp); + void messageBox(const std::string &text, const std::string &masterGroup="ui:interface", TCaseMode caseMode = CaseFirstSentenceLetterUp); /** Open a MessageBox. this is a simple ModalWindow with a Ok and a HELP button. * The help button with open a browser on ryzom.com faq * ui:interface:message_box_with_help must be defined in xml, with a "text" ViewText son */ - void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup="ui:interface", + void messageBoxWithHelp(const std::string &text, const std::string &masterGroup="ui:interface", const std::string &ahOnOk = std::string(), const std::string ¶msOnOk= std::string(), TCaseMode caseMode = CaseFirstSentenceLetterUp); @@ -321,7 +321,7 @@ public: * \param ahOnCancel => the action handler to call if cancel is pressed. NB: you don't have to call leave_modal in this ah (auto done). * \param paramsOnCancel => params passed to ahOnCancel. */ - void validMessageBox(TValidMessageIcon icon, const ucstring &text, const std::string &ahOnOk, const std::string ¶msOnOk= std::string(), + void validMessageBox(TValidMessageIcon icon, const std::string &text, const std::string &ahOnOk, const std::string ¶msOnOk= std::string(), const std::string &ahOnCancel= std::string(), const std::string ¶msOnCancel= std::string(), const std::string &masterGroup="ui:interface"); /** Get the current running validMessageBox OnOk action. empty if no validMessageBox currently opened @@ -446,9 +446,9 @@ public: */ static char* getTimestampHuman(const char* format = "[%H:%M:%S] "); - /** Parses any tokens in the ucstring like $t$ or $g()$ + /** Parses any tokens in the utf-8 string like $t$ or $g()$ */ - static bool parseTokens(ucstring& ucstr); + static bool parseTokens(std::string& ucstr); // ------------------------------------------------------------------------------------------------ private: @@ -672,7 +672,7 @@ private: CServerToLocalAutoCopy ServerToLocalAutoCopyDMGift; // Pop a new message box. If the message box was found, returns a pointer on it - void messageBoxInternal(const std::string &msgBoxGroup, const ucstring &text, const std::string &masterGroup, TCaseMode caseMode); + void messageBoxInternal(const std::string &msgBoxGroup, const std::string &text, const std::string &masterGroup, TCaseMode caseMode); CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater; }; diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp index 99f18241c..1bb3c478f 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015-2019 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2021,11 +2021,11 @@ void CTempInvManager::updateForageQQ( uint whichOne ) break; default:; } - ucstring title = CI18N::get( WIN_TEMPINV_TITLE_FORAGING ); + string title = CI18N::get( WIN_TEMPINV_TITLE_FORAGING ); strFindReplace( title, "%qt", toString( "%.1f", qt ) ); strFindReplace( title, "%ql", toString( "%.1f", ql ) ); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); - pGC->setUCTitle( title ); + pGC->setTitle( title ); } isInUpdateForageQQ = false; @@ -2199,7 +2199,7 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */) } // *************************************************************************** -void SBagOptions::setSearchFilter(const ucstring &s) +void SBagOptions::setSearchFilter(const string &s) { SearchQualityMin = 0; SearchQualityMax = 999; @@ -2208,13 +2208,13 @@ void SBagOptions::setSearchFilter(const ucstring &s) if (!s.empty()) { - std::vector words; - splitUCString(toLower(s), ucstring(" "), words); + std::vector words; + splitString(toLower(s), string(" "), words); size_t pos; for(int i = 0; i 0) { bool match = true; - ucstring lcName = toLower(pCS->getItemActualName()); + string lcName = toLower(pCS->getItemActualName()); // add item quality as a keyword to match if (pCS->getQuality() > 1) { - lcName += ucstring(" " + toString(pCS->getQuality())); + lcName += string(" " + toString(pCS->getQuality())); } for (uint i = 0; i< SearchFilter.size(); ++i) { - if (lcName.find(SearchFilter[i]) == ucstring::npos) + if (lcName.find(SearchFilter[i]) == string::npos) { return false; } @@ -2741,7 +2741,7 @@ class CHandlerInvSearchButton : public IActionHandler return; } - ucstring filter; + string filter; std::string id = btn->getParent()->getId() + ":" + sParams + ":eb"; CGroupEditBox *eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id)); if (!eb) @@ -3236,7 +3236,7 @@ class CHandlerInvTempToBag : public IActionHandler // If we cant find place display a message and dont send the request to the server if (!getInventory().isSpaceInAllBagsForItem(pCSDst)) { - ucstring msg = CI18N::get("msgCantPutItemInBag"); + string msg = CI18N::get("msgCantPutItemInBag"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; @@ -3322,7 +3322,7 @@ class CHandlerInvTempAll : public IActionHandler if (!bPlaceFound) { - ucstring msg = CI18N::get("msgCantPutItemInBag"); + string msg = CI18N::get("msgCantPutItemInBag"); string cat = getStringCategory(msg, msg); CInterfaceManager::getInstance()->displaySystemInfo(msg, cat); return; @@ -3662,6 +3662,15 @@ void CInventoryManager::updateItemInfoQueue() TItemInfoWaiters::iterator it; for(it= _ItemInfoWaiters.begin();it!=_ItemInfoWaiters.end();it++) { + /* yoyo remove: temp patch to be sure that the client does not send messages before the + CONNECTION:READY is sent + Ulukyn: this only happens if player ask to reselect a char before end of update items. + On this case, skip it... + */ + + if (!ConnectionReadySent) + continue; + IItemInfoWaiter *waiter=*it; uint itemSlotId= waiter->ItemSlotId; TItemInfoMap::iterator it= _ItemInfoMap.find(itemSlotId); @@ -4027,7 +4036,7 @@ const CItemImage *CInventoryManager::getServerItem(uint slotId) const // *************************************************************************** CInventoryManager::TInvType CInventoryManager::invTypeFromString(const string &str) { - string sTmp = toLower(str); + string sTmp = toLowerAscii(str); if (sTmp == "inv_bag") return InvBag; if (sTmp == "inv_pa0") return InvPA0; if (sTmp == "inv_pa1") return InvPA1; diff --git a/ryzom/client/src/interface_v3/inventory_manager.h b/ryzom/client/src/interface_v3/inventory_manager.h index 160b7c1aa..d5bd763f1 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.h +++ b/ryzom/client/src/interface_v3/inventory_manager.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -520,7 +521,7 @@ struct SSortStruct { CDBGroupListSheetText::CSheetChild *SheetText; CDBGroupListSheet::CSheetChild *SheetIcon; - ucstring Pos; + std::string Pos; bool operator < (const SSortStruct &o) const { return Pos < o.Pos; } }; @@ -558,7 +559,7 @@ struct SBagOptions bool SearchFilterChanged; uint16 SearchQualityMin; uint16 SearchQualityMax; - std::vector SearchFilter; + std::vector SearchFilter; // ----------------------- SBagOptions() @@ -576,7 +577,7 @@ struct SBagOptions bool isSomethingChanged(); // From last call ? bool isSearchFilterChanged() const { return SearchFilterChanged; } - void setSearchFilter(const ucstring &s); + void setSearchFilter(const std::string &s); bool getFilterArmor() const { @@ -674,7 +675,7 @@ public: // Return true if the sheet can be displayed due to filters bool canDisplay(CDBCtrlSheet *pCS) { return _BO.canDisplay(pCS); } - void setSearchFilter(const ucstring &s) { _BO.setSearchFilter(s); } + void setSearchFilter(const std::string &s) { _BO.setSearchFilter(s); } private: @@ -707,7 +708,7 @@ public: // Return true if the sheet can be displayed due to filters bool canDisplay(CDBCtrlSheet *pCS) const { return _BO.canDisplay(pCS); } - void setSearchFilter(const ucstring &s) { _BO.setSearchFilter(s); } + void setSearchFilter(const std::string &s) { _BO.setSearchFilter(s); } ////////////////////////////////////////////////////////////////////////// diff --git a/ryzom/client/src/interface_v3/item_consumable_effect.cpp b/ryzom/client/src/interface_v3/item_consumable_effect.cpp index a91394390..2e4499228 100644 --- a/ryzom/client/src/interface_v3/item_consumable_effect.cpp +++ b/ryzom/client/src/interface_v3/item_consumable_effect.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -33,10 +36,10 @@ CItemConsumableEffectHelper* CItemConsumableEffectHelper::getInstance() return instance; } -void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet *pIS, ucstring &itemText, sint32 itemQuality) +void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet *pIS, string &itemText, sint32 itemQuality) { // check if some effects are present on this item - ucstring effects(""); + string effects(""); uint i; for( i=0; iConsumable.Properties.size(); ++i ) @@ -47,7 +50,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * continue; // Get name id of effect - CSString name = toUpper(eff.splitTo(':', true)); + CSString name = toUpperAscii(eff.splitTo(':', true)); // Extract parameters from sheet vector params; @@ -71,7 +74,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 timeInSec; fromString(params[3].c_str(), timeInSec); - ucstring result; + string result; if (bonus >= 0) result = CI18N::get("uiItemConsumableEffectUpCharac"); @@ -101,7 +104,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectLifeAura"); + string result = CI18N::get("uiItemConsumableEffectLifeAura"); strFindReplace(result, "%modifier", toString(regenMod)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -128,7 +131,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectLifeAura"); + string result = CI18N::get("uiItemConsumableEffectLifeAura"); strFindReplace(result, "%modifier", toString(bonus)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -154,7 +157,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectStaminaAura"); + string result = CI18N::get("uiItemConsumableEffectStaminaAura"); strFindReplace(result, "%modifier", toString(regenMod)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -182,7 +185,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectStaminaAura"); + string result = CI18N::get("uiItemConsumableEffectStaminaAura"); strFindReplace(result, "%modifier", toString(bonus)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -208,7 +211,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectSapAura"); + string result = CI18N::get("uiItemConsumableEffectSapAura"); strFindReplace(result, "%modifier", toString(regenMod)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -235,7 +238,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectSapAura"); + string result = CI18N::get("uiItemConsumableEffectSapAura"); strFindReplace(result, "%modifier", toString(bonus)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -249,14 +252,14 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * // skill modifier consumables //--------------------------- - ucstring result(""); + string result(""); uint8 paramIdx = 0; if( name == "SP_MOD_DEFENSE" ) { - if( toLower(params[0]) == "dodge" ) + if( toLowerAscii(params[0]) == "dodge" ) result = CI18N::get("uiItemConsumableEffectModDodgeSuccess"); else - if( toLower(params[0]) == "parry" ) + if( toLowerAscii(params[0]) == "parry" ) result = CI18N::get("uiItemConsumableEffectModParrySuccess"); else result = CI18N::get("uiItemConsumableEffectModDefenseSuccess"); @@ -280,17 +283,17 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * } if( name == "SP_MOD_FORAGE_SUCCESS" ) { - if( toLower(params[0]) == "commonecosystem" ) + if( toLowerAscii(params[0]) == "commonecosystem" ) result = CI18N::get("uiItemConsumableEffectModForageSuccess"); - if( toLower(params[0]) == "desert" ) + if( toLowerAscii(params[0]) == "desert" ) result = CI18N::get("uiItemConsumableEffectModDesertForageSuccess"); - if( toLower(params[0]) == "forest" ) + if( toLowerAscii(params[0]) == "forest" ) result = CI18N::get("uiItemConsumableEffectModForestForageSuccess"); - if( toLower(params[0]) == "lacustre" ) + if( toLowerAscii(params[0]) == "lacustre" ) result = CI18N::get("uiItemConsumableEffectModLacustreForageSuccess"); - if( toLower(params[0]) == "jungle" ) + if( toLowerAscii(params[0]) == "jungle" ) result = CI18N::get("uiItemConsumableEffectModJungleForageSuccess"); - if( toLower(params[0]) == "primaryroot" ) + if( toLowerAscii(params[0]) == "primaryroot" ) result = CI18N::get("uiItemConsumableEffectModPrimaryRootForageSuccess"); paramIdx++; } diff --git a/ryzom/client/src/interface_v3/item_consumable_effect.h b/ryzom/client/src/interface_v3/item_consumable_effect.h index 69a0472ad..a34d26503 100644 --- a/ryzom/client/src/interface_v3/item_consumable_effect.h +++ b/ryzom/client/src/interface_v3/item_consumable_effect.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -32,7 +35,7 @@ public: static CItemConsumableEffectHelper* getInstance(); // Fill itemText with consumable effects from item sheet - void getItemConsumableEffectText(const CItemSheet *pIS, ucstring &itemText, sint32 itemQuality); + void getItemConsumableEffectText(const CItemSheet *pIS, std::string &itemText, sint32 itemQuality); private: CItemConsumableEffectHelper() {} diff --git a/ryzom/client/src/interface_v3/item_info_waiter.h b/ryzom/client/src/interface_v3/item_info_waiter.h index 7976f94f2..74da340cd 100644 --- a/ryzom/client/src/interface_v3/item_info_waiter.h +++ b/ryzom/client/src/interface_v3/item_info_waiter.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/item_special_effect.cpp b/ryzom/client/src/interface_v3/item_special_effect.cpp index 5d696738a..dd4485f9d 100644 --- a/ryzom/client/src/interface_v3/item_special_effect.cpp +++ b/ryzom/client/src/interface_v3/item_special_effect.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -51,8 +54,8 @@ void CItemSpecialEffectHelper::registerItemSpecialEffect(const string &name) vector params; // get ui string - ucstring ucs = CI18N::get("uiItemFX_" + name); - CSString p, s = ucs.toString(); + string ucs = CI18N::get("uiItemFX_" + name); + CSString p, s = ucs; // locate and store parameters // %p : percent @@ -66,7 +69,7 @@ void CItemSpecialEffectHelper::registerItemSpecialEffect(const string &name) { string tmp = "%"; tmp += s[0]; - if (s.size() >=2 && isdigit(s[1])) + if (s.size() >=2 && (uint8)s[1] < (uint8)'\x80' && isdigit(s[1])) tmp += s[1]; params.push_back(tmp); } @@ -76,11 +79,11 @@ void CItemSpecialEffectHelper::registerItemSpecialEffect(const string &name) effectMap.insert(make_pair(name, params)); } -void CItemSpecialEffectHelper::getItemSpecialEffectText(const CItemSheet *pIS, ucstring &itemText) +void CItemSpecialEffectHelper::getItemSpecialEffectText(const CItemSheet *pIS, string &itemText) { // check if some effects are present on this item bool firstEffect = false; - ucstring effects; + string effects; effects += getEffect(pIS->getEffect1(), firstEffect); effects += getEffect(pIS->getEffect2(), firstEffect); effects += getEffect(pIS->getEffect3(), firstEffect); @@ -92,16 +95,16 @@ void CItemSpecialEffectHelper::getItemSpecialEffectText(const CItemSheet *pIS, u strFindReplace(itemText, "%special_effects", effects); } -ucstring CItemSpecialEffectHelper::getEffect(const std::string &effect, bool &first) +string CItemSpecialEffectHelper::getEffect(const std::string &effect, bool &first) { - ucstring result; + string result; CSString eff = effect; if (eff.empty()) return result; // Get name id of effect - CSString name = toUpper(eff.splitTo(':', true)); + CSString name = toUpperAscii(eff.splitTo(':', true)); // Extract parameters from sheet vector params; diff --git a/ryzom/client/src/interface_v3/item_special_effect.h b/ryzom/client/src/interface_v3/item_special_effect.h index a97437958..df97f539c 100644 --- a/ryzom/client/src/interface_v3/item_special_effect.h +++ b/ryzom/client/src/interface_v3/item_special_effect.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -32,7 +35,7 @@ public: static CItemSpecialEffectHelper* getInstance(); // Fill itemText with special effects from item sheet - void getItemSpecialEffectText(const CItemSheet *pIS, ucstring &itemText); + void getItemSpecialEffectText(const CItemSheet *pIS, std::string &itemText); // Register a new item special effect void registerItemSpecialEffect(const std::string &name); @@ -42,7 +45,7 @@ private: CItemSpecialEffectHelper(const CItemSpecialEffectHelper&); // Get UI text with values filled from 'effect' string - ucstring getEffect(const std::string &effect, bool &first); + std::string getEffect(const std::string &effect, bool &first); // Map effects name with parameters typedef std::vector stringVector; diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 3f016326d..1b3ea8c67 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -286,17 +286,19 @@ static DECLARE_INTERFACE_USER_FCT(lua) // NB: the value is poped in obj.set() (no need to do ls.pop()); // try with ucstring +#ifdef RYZOM_LUA_UCSTRING ucstring ucstrVal; if (CLuaIHM::pop(ls, ucstrVal)) { - result.setUCString(ucstrVal); + result.setString(ucstrVal.toUtf8()); ok = true; } - // try with RGBA if (!ok) +#endif { + // try with RGBA NLMISC::CRGBA rgbaVal; if (CLuaIHM::pop(ls, rgbaVal)) @@ -552,20 +554,26 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(dumpCallStack), LUABIND_FUNC(getDefine), LUABIND_FUNC(setContextHelpText), +#ifdef RYZOM_LUA_UCSTRING luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox), luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), +#endif luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), +#ifdef RYZOM_LUA_UCSTRING + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), // TODO: Lua UTF-8 + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), // TODO: Lua UTF-8 + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), // TODO: Lua UTF-8 +#endif luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), LUABIND_FUNC(replacePvpEffectParam), LUABIND_FUNC(secondsSince1970ToHour), +#ifdef RYZOM_BG_DOWNLOADER LUABIND_FUNC(pauseBGDownloader), LUABIND_FUNC(unpauseBGDownloader), LUABIND_FUNC(requestBGDownloaderPriority), LUABIND_FUNC(getBGDownloaderPriority), +#endif LUABIND_FUNC(loadBackground), LUABIND_FUNC(getPatchLastErrorMessage), LUABIND_FUNC(getPlayerSelectedSlot), @@ -856,16 +864,24 @@ int CLuaIHMRyzom::validMessageBox(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_validMessageBox) const char *funcName = "validMessageBox"; CLuaIHM::checkArgCount(ls, funcName, 6); +#ifdef RYZOM_LUA_UCSTRING ucstring msg; ls.pushValue(1); // copy ucstring at the end of stack to pop it CLuaIHM::check(ls, CLuaIHM::pop(ls, msg), "validMessageBox : ucstring wanted as first parameter"); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 6, LUA_TSTRING); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg, ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); +#ifdef RYZOM_LUA_UCSTRING + im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); +#else + im->validMessageBox(CInterfaceManager::QuestionIconMsg, ls.toString(1), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); +#endif return 0; } @@ -901,6 +917,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); // *** check and retrieve param 2. must be a string or a ucstring +#ifdef RYZOM_LUA_UCSTRING ucstring text; if (ls.isString(2)) @@ -918,6 +935,13 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) CLuaIHM::check(ls, false, "setTextFormatTaged() requires a string or a ucstring in param 2"); } } +#else + string text; + if (ls.isString(2)) + { + ls.toString(2, text); + } +#endif // must be a view text CViewText *vt = dynamic_cast(pIE); @@ -926,7 +950,11 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); // Set the text as format +#ifdef RYZOM_LUA_UCSTRING + vt->setTextFormatTaged(text.toUtf8()); +#else vt->setTextFormatTaged(text); +#endif return 0; } @@ -949,8 +977,8 @@ struct CEmoteStruct string::size_type pos1 = path1.find('|'); string::size_type pos2 = path2.find('|'); - ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); - ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); + std::string s1 = toUpper(CI18N::get(path1.substr(0, pos1))); + std::string s2 = toUpper(CI18N::get(path2.substr(0, pos2))); sint result = s1.compare(s2); @@ -1092,7 +1120,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls) // Create a line pMenu->addLine(CI18N::get(sTmp), "lua", luaParams + "('" + sEmoteId + "', '" + toString(CI18N::get(sTmp)) + "')", sTmp); - emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))).toUtf8(); + emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))); } } @@ -1464,7 +1492,7 @@ int CLuaIHMRyzom::getPlayerGender(CLuaState &ls) int CLuaIHMRyzom::getPlayerName(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerName", 0); - ls.push(UserEntity->getEntityName().toUtf8()); + ls.push(UserEntity->getEntityName()); return 1; } @@ -1472,7 +1500,7 @@ int CLuaIHMRyzom::getPlayerName(CLuaState &ls) int CLuaIHMRyzom::getPlayerTitleRaw(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerTitleRaw", 0); - ls.push(UserEntity->getTitleRaw().toUtf8()); + ls.push(UserEntity->getTitleRaw()); return 1; } @@ -1480,7 +1508,7 @@ int CLuaIHMRyzom::getPlayerTitleRaw(CLuaState &ls) int CLuaIHMRyzom::getPlayerTitle(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerTitle", 0); - ls.push(UserEntity->getTitle().toUtf8()); + ls.push(UserEntity->getTitle()); return 1; } @@ -1542,7 +1570,7 @@ int CLuaIHMRyzom::getTargetName(CLuaState &ls) if (!target) return 0; - ls.push(target->getEntityName().toUtf8()); + ls.push(target->getEntityName()); return 1; } @@ -1554,7 +1582,7 @@ int CLuaIHMRyzom::getTargetTitleRaw(CLuaState &ls) if (!target) return 0; - ls.push(target->getTitleRaw().toUtf8()); + ls.push(target->getTitleRaw()); return 1; } @@ -1566,7 +1594,7 @@ int CLuaIHMRyzom::getTargetTitle(CLuaState &ls) if (!target) return 0; - ls.push(target->getTitle().toUtf8()); + ls.push(target->getTitle()); return 1; } @@ -1813,12 +1841,22 @@ int CLuaIHMRyzom::displaySystemInfo(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_displaySystemInfo) const char *funcName = "displaySystemInfo"; CLuaIHM::checkArgCount(ls, funcName, 2); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 1); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); +#ifdef RYZOM_LUA_UCSTRING ucstring msg; nlverify(CLuaIHM::getUCStringOnStack(ls, 1, msg)); +#endif CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->displaySystemInfo(msg, ls.toString(2)); +#ifdef RYZOM_LUA_UCSTRING + pIM->displaySystemInfo(msg.toUtf8(), ls.toString(2)); +#else + pIM->displaySystemInfo(ls.toString(1), ls.toString(2)); +#endif return 0; } @@ -3048,18 +3086,27 @@ std::string CLuaIHMRyzom::getDefine(const std::string &def) return CWidgetManager::getInstance()->getParser()->getDefine(def); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CLuaIHMRyzom::setContextHelpText(const ucstring &text) +{ + CWidgetManager::getInstance()->setContextHelpText(text.toUtf8()); +} +#else +// *************************************************************************** +void CLuaIHMRyzom::setContextHelpText(const std::string &text) { CWidgetManager::getInstance()->setContextHelpText(text); } +#endif +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CLuaIHMRyzom::messageBox(const ucstring &text) { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBox(text); + pIM->messageBox(text.toUtf8()); } // *************************************************************************** @@ -3067,7 +3114,7 @@ void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGr { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBox(text, masterGroup); + pIM->messageBox(text.toUtf8(), masterGroup); } // *************************************************************************** @@ -3080,8 +3127,9 @@ void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGr //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBox(text, masterGroup, (TCaseMode) caseMode); + pIM->messageBox(text.toUtf8(), masterGroup, (TCaseMode) caseMode); } +#endif // *************************************************************************** void CLuaIHMRyzom::messageBox(const std::string &text) @@ -3099,23 +3147,45 @@ void CLuaIHMRyzom::messageBox(const std::string &text) } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) +void CLuaIHMRyzom::messageBox(const std::string &text, const std::string &masterGroup) { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text); + pIM->messageBox(text, masterGroup); } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) +void CLuaIHMRyzom::messageBox(const std::string &text, const std::string &masterGroup, int caseMode) { + if (caseMode < 0 || caseMode >= CaseCount) + { + throw ELuaIHMException("messageBox: case mode value is invalid."); + } + //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup); + pIM->messageBox(text, masterGroup, (TCaseMode) caseMode); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) // TODO: Lua UTF-8 +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text.toUtf8()); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) // TODO: Lua UTF-8 +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text.toUtf8(), masterGroup); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) // TODO: Lua UTF-8 { if (caseMode < 0 || caseMode >= CaseCount) { @@ -3124,8 +3194,9 @@ void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string & //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup, "" , "", (TCaseMode) caseMode); + pIM->messageBoxWithHelp(text.toUtf8(), masterGroup, "" , "", (TCaseMode) caseMode); } +#endif // *************************************************************************** void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text) @@ -3142,6 +3213,27 @@ void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text) pIM->messageBoxWithHelp(text); } +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text, const std::string &masterGroup) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text, masterGroup); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text, const std::string &masterGroup, int caseMode) +{ + if (caseMode < 0 || caseMode >= CaseCount) + { + throw ELuaIHMException("messageBoxWithHelp: case mode value is invalid."); + } + + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text, masterGroup, "" , "", (TCaseMode) caseMode); +} + // *************************************************************************** bool CLuaIHMRyzom::executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet) { @@ -3184,11 +3276,20 @@ bool CLuaIHMRyzom::executeFunctionOnStack(CLuaState &ls, int numArgs, int nu } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 parameter) +#else +std::string CLuaIHMRyzom::replacePvpEffectParam(const std::string &str, sint32 parameter) +#endif { //H_AUTO(Lua_CLuaIHM_replacePvpEffectParam) +#ifdef RYZOM_LUA_UCSTRING ucstring result = str; CSString s = str.toString(); +#else + std::string result = str; + CSString s = str; +#endif std::string p, paramString; // Locate parameter and store it @@ -3226,7 +3327,11 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet break; default: +#ifdef RYZOM_LUA_UCSTRING debugInfo("Bad arguments in " + str.toString() + " : " + paramString); +#else + debugInfo("Bad arguments in " + str + " : " + paramString); +#endif } strFindReplace(result, paramString.c_str(), p); @@ -3252,6 +3357,7 @@ sint32 CLuaIHMRyzom::secondsSince1970ToHour(sint32 seconds) return tstruct->tm_hour; // 0-23 } +#ifdef RYZOM_BG_DOWNLOADER // *************************************************************************** void CLuaIHMRyzom::pauseBGDownloader() { @@ -3280,6 +3386,7 @@ sint CLuaIHMRyzom::getBGDownloaderPriority() { return CBGDownloaderAccess::getInstance().getDownloadThreadPriority(); } +#endif // *************************************************************************** void CLuaIHMRyzom::loadBackground(const std::string &bg) @@ -3290,13 +3397,19 @@ void CLuaIHMRyzom::loadBackground(const std::string &bg) // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getPatchLastErrorMessage() +#else +std::string CLuaIHMRyzom::getPatchLastErrorMessage() +#endif { +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { return CBGDownloaderAccess::getInstance().getLastErrorMessage(); } else +#endif { CPatchManager *pPM = CPatchManager::getInstance(); return pPM->getLastErrorMessage(); @@ -3355,11 +3468,19 @@ sint32 CLuaIHMRyzom::getSkillIdFromName(const std::string &def) } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getSkillLocalizedName(sint32 skillId) { //H_AUTO(Lua_CLuaIHM_getSkillLocalizedName) return ucstring(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); } +#else +std::string CLuaIHMRyzom::getSkillLocalizedName(sint32 skillId) +{ + //H_AUTO(Lua_CLuaIHM_getSkillLocalizedName) + return STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId); +} +#endif // *************************************************************************** sint32 CLuaIHMRyzom::getMaxSkillValue(sint32 skillId) @@ -3446,11 +3567,9 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string if (UserEntity) { - userName = UserEntity->getDisplayName().toString(); + userName = UserEntity->getDisplayName(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; - pSMC->getString(UserEntity->getGuildNameID(), ucsTmp); - guildName = ucsTmp.toString(); + pSMC->getString(UserEntity->getGuildNameID(), guildName); while (guildName.find(' ') != string::npos) { @@ -3498,19 +3617,29 @@ void CLuaIHMRyzom::clearHtmlUndoRedo(const std::string &htmlId) } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getDynString(sint32 dynStringId) { //H_AUTO(Lua_CLuaIHM_getDynString) - ucstring result; + string result; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); + return ucstring::makeFromUtf8(result); // Compatibility +} +#else +std::string CLuaIHMRyzom::getDynString(sint32 dynStringId) +{ + //H_AUTO(Lua_CLuaIHM_getDynString) + string result; STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); return result; } +#endif // *************************************************************************** bool CLuaIHMRyzom::isDynStringAvailable(sint32 dynStringId) { //H_AUTO(Lua_CLuaIHM_isDynStringAvailable) - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); return res; } @@ -3694,7 +3823,7 @@ string CLuaIHMRyzom::getGuildMemberName(sint32 nMemberId) if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers())) return ""; - return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name.toString(); + return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name; } // *************************************************************************** @@ -3849,7 +3978,11 @@ void setMouseCursor(const std::string &texture) } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) +#else +void CLuaIHMRyzom::tell(const std::string &player, const std::string &msg) +#endif { //H_AUTO(Lua_CLuaIHM_tell) // display a /tell command in the main chat @@ -3858,7 +3991,11 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) if (!msg.empty()) { // Parse any tokens in the message. - ucstring msg_modified = msg; +#ifdef RYZOM_LUA_UCSTRING + string msg_modified = msg.toUtf8(); +#else + string msg_modified = msg; +#endif // Parse any tokens in the text if (! CInterfaceManager::parseTokens(msg_modified)) @@ -3866,7 +4003,11 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) return; } +#ifdef RYZOM_LUA_UCSTRING ChatMngr.tell(player.toUtf8(), msg_modified); +#else + ChatMngr.tell(player, msg_modified); +#endif } else { @@ -3877,7 +4018,11 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) CInterfaceManager *im = CInterfaceManager::getInstance(); w->setKeyboardFocus(); w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player) + ucstring(" "), false); +#ifdef RYZOM_LUA_UCSTRING + w->setCommand("tell " + CEntityCL::removeTitleFromName(player.toUtf8()) + " ", false); +#else + w->setCommand("tell " + CEntityCL::removeTitleFromName(player) + " ", false); +#endif CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) @@ -3930,11 +4075,19 @@ bool CLuaIHMRyzom::isCtrlKeyDown() // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING std::string CLuaIHMRyzom::encodeURLUnicodeParam(const ucstring &text) { //H_AUTO(Lua_CLuaIHM_encodeURLUnicodeParam) return convertToHTML(text.toUtf8()); } +#else +std::string CLuaIHMRyzom::encodeURLUnicodeParam(const std::string &text) +{ + //H_AUTO(Lua_CLuaIHM_encodeURLUnicodeParam) + return convertToHTML(text); +} +#endif // *************************************************************************** std::string CLuaIHMRyzom::encodeURLParam(const string &text) @@ -4048,6 +4201,7 @@ sint32 CLuaIHMRyzom::getTargetLevel() } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getTargetSheet() { CEntityCL *target = getTargetEntity(); @@ -4055,6 +4209,15 @@ ucstring CLuaIHMRyzom::getTargetSheet() return target->sheetId().toString(); } +#else +std::string CLuaIHMRyzom::getTargetSheet() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return std::string(); + + return target->sheetId().toString(); +} +#endif // *************************************************************************** std::string CLuaIHMRyzom::getTargetVpaHex() @@ -4553,31 +4716,31 @@ int CLuaIHMRyzom::displayChatMessage(CLuaState &ls) if (ls.type(2) == LUA_TSTRING) { - std::string input = toLower(ls.toString(2)); + std::string input = toLowerAscii(ls.toString(2)); if (input == "around") { prop.readRGBA(std::string(dbPath + ":SAY").c_str(), " "); - ci.AroundMe.displayMessage(ucstring(msg), prop.getRGBA()); + ci.AroundMe.displayMessage(msg, prop.getRGBA()); } else if (input == "region") { prop.readRGBA(std::string(dbPath + ":REGION").c_str(), " "); - ci.Region.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Region.displayMessage(msg, prop.getRGBA()); } else if (input == "universe") { prop.readRGBA(std::string(dbPath + ":UNIVERSE_NEW").c_str(), " "); - ci.Universe.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Universe.displayMessage(msg, prop.getRGBA()); } else if (input == "guild") { prop.readRGBA(std::string(dbPath + ":CLADE").c_str(), " "); - ci.Guild.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Guild.displayMessage(msg, prop.getRGBA()); } else if (input == "team") { prop.readRGBA(std::string(dbPath + ":GROUP").c_str(), " "); - ci.Team.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Team.displayMessage(msg, prop.getRGBA()); } } if (ls.type(2) == LUA_TNUMBER) @@ -4585,7 +4748,7 @@ int CLuaIHMRyzom::displayChatMessage(CLuaState &ls) sint64 id = ls.toInteger(2); prop.readRGBA(toString("%s:DYN:%i", dbPath.c_str(), id).c_str(), " "); if (id >= 0 && id < CChatGroup::MaxDynChanPerPlayer) - ci.DynamicChat[id].displayMessage(ucstring(msg), prop.getRGBA()); + ci.DynamicChat[id].displayMessage(msg, prop.getRGBA()); } return 1; } diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 320d78544..5cb95e3a5 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -168,26 +168,48 @@ private: static void getCallStackAsString(int startStackLevel, std::string &result); static std::string getDefine(const std::string &def); +#ifdef RYZOM_LUA_UCSTRING static void setContextHelpText(const ucstring &text); +#else + static void setContextHelpText(const std::string &text); +#endif +#ifdef RYZOM_LUA_UCSTRING static void messageBox(const ucstring &text); static void messageBox(const ucstring &text, const std::string &masterGroup); static void messageBox(const ucstring &text, const std::string &masterGroup, int caseMode); +#endif static void messageBox(const std::string &text); + static void messageBox(const std::string &text, const std::string &masterGroup); + static void messageBox(const std::string &text, const std::string &masterGroup, int caseMode); +#ifdef RYZOM_LUA_UCSTRING static void messageBoxWithHelp(const ucstring &text); static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup); static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode); +#endif static void messageBoxWithHelp(const std::string &text); + static void messageBoxWithHelp(const std::string &text, const std::string &masterGroup); + static void messageBoxWithHelp(const std::string &text, const std::string &masterGroup, int caseMode); - static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); +#ifdef RYZOM_LUA_UCSTRING + static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); // TODO: UTF-8 Lua +#else + static std::string replacePvpEffectParam(const std::string &str, sint32 parameter); // TODO: UTF-8 Lua +#endif static sint32 secondsSince1970ToHour(sint32 seconds); +#ifdef RYZOM_BG_DOWNLOADER static void pauseBGDownloader(); static void unpauseBGDownloader(); static void requestBGDownloaderPriority(uint priority); static sint getBGDownloaderPriority(); +#endif static void loadBackground(const std::string &bg); +#ifdef RYZOM_LUA_UCSTRING static ucstring getPatchLastErrorMessage(); +#else + static std::string getPatchLastErrorMessage(); +#endif static bool isInGame(); static uint32 getPlayerSelectedSlot(); static bool isPlayerSlotNewbieLand(uint32 slot); // test if one of the player slot is a newbieland one, if not so, client must be patched in order to continue @@ -196,14 +218,22 @@ private: static ucstring getSheetLocalizedName(const std::string &sheet); static ucstring getSheetLocalizedDesc(const std::string &sheet); static sint32 getSkillIdFromName(const std::string &def); +#ifdef RYZOM_LUA_UCSTRING static ucstring getSkillLocalizedName(sint32 skillId); +#else + static std::string getSkillLocalizedName(sint32 skillId); +#endif static sint32 getMaxSkillValue(sint32 skillId); static sint32 getBaseSkillValueMaxChildren(sint32 skillId); static sint32 getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl); static sint32 getDodgeParryChance(sint32 attLvl, sint32 defLvl); static void browseNpcWebPage(const std::string &htmlId, const std::string &url, bool addParameters, double timeout); static void clearHtmlUndoRedo(const std::string &htmlId); +#ifdef RYZOM_LUA_UCSTRING static ucstring getDynString(sint32 dynStringId); +#else + static std::string getDynString(sint32 dynStringId); +#endif static bool isDynStringAvailable(sint32 dynStringId); static bool isFullyPatched(); static std::string getSheetType(const std::string &sheet); @@ -260,13 +290,21 @@ private: // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // else, current command of the chat window will be replaced with tell 'player' +#ifdef RYZOM_LUA_UCSTRING static void tell(const ucstring &player, const ucstring &msg); +#else + static void tell(const std::string &player, const std::string &msg); +#endif static bool isRingAccessPointInReach(); static void updateTooltipCoords(); // test if the ctrl key is down (NB nico : I didn't add other key, // because it would be too easy to write a key recorder ...) static bool isCtrlKeyDown(); +#ifdef RYZOM_LUA_UCSTRING static std::string encodeURLUnicodeParam(const ucstring &text); +#else + static std::string encodeURLUnicodeParam(const std::string &text); +#endif static std::string encodeURLParam(const std::string &text); static std::string encodeToHexa(const std::string &text); @@ -281,8 +319,12 @@ private: static uint64 getPlayerVpc(); static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target - static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target + static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target +#ifdef RYZOM_LUA_UCSTRING static ucstring getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') +#else + static std::string getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') +#endif static std::string getTargetVpaHex(); static std::string getTargetVpbHex(); static std::string getTargetVpcHex(); diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp index 7f4c26c08..0f8055043 100644 --- a/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -86,7 +87,7 @@ using namespace NLMISC; // *************************************************************************** // Add the template key to the parent -void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &shortcutName, bool grayed) +void addKeyLine (CGroupList *pParent, const string &keyName, const string &shortcutName, bool grayed) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); @@ -124,7 +125,7 @@ struct CComboActionName CCombo Combo; // KeyCount <=> action name unbound CAction::CName ActionName; }; -void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, map &remaped) +void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, map &remaped) { CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); CActionsManager *pAM = pMCM->ActionManagers[nAM]; @@ -147,7 +148,7 @@ void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, // see if action active in current context if (pAM->isActionPresentInContext(it->second)) { - pair value; + pair value; // Don't take any risk: avoid any bug if the localisation is buggy and give same text for 2 differents CAction::CName // Use the localized text first, to have correct sort according to language value.first= pAM->getActionLocalizedText(rName) + rName.Name + rName.Argu; @@ -176,7 +177,7 @@ void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, // see if action active in current context if (pAM->isActionPresentInContext(rName)) { - pair value; + pair value; // Don't take any risk: avoid any bug if the localisation is buggy and give same text for 2 differents CAction::CName // Use the localized text first, to have correct sort according to language value.first= pAM->getActionLocalizedText(rName) + rName.Name + rName.Argu; @@ -196,23 +197,23 @@ void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, // Get all the couple (combo,action) from the action manager nAM and insert them into pList (with the template) -void getAllComboAction(uint8 nAM, CGroupList *pList, const map &remaped) +void getAllComboAction(uint8 nAM, CGroupList *pList, const map &remaped) { CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); CActionsManager *pAM = pMCM->ActionManagers[nAM]; // *** Fill Actions - map::const_iterator remapIT = remaped.begin(); + map::const_iterator remapIT = remaped.begin(); while (remapIT != remaped.end()) { - ucstring keyName; + string keyName; if(remapIT->second.Combo.Key==KeyCount) keyName= CI18N::get("uiNotAssigned"); else - keyName= remapIT->second.Combo.toUCString(); + keyName= remapIT->second.Combo.toString(); const CBaseAction *baseAction = pAM->getBaseAction(remapIT->second.ActionName); if (baseAction) { - ucstring shortcutName = baseAction->getActionLocalizedText(remapIT->second.ActionName); + string shortcutName = baseAction->getActionLocalizedText(remapIT->second.ActionName); addKeyLine(pList, keyName, shortcutName, remapIT->second.Combo.Key==KeyCount); CModalContainerEditCmd::CLine line; @@ -273,7 +274,7 @@ public: pList->clearGroups(); pList->setDynamicDisplaySize(true); - map remaped; + map remaped; buildActionToComboMap(nAM, pList, rCats[i].Name, remaped); if (!remaped.empty()) { @@ -403,7 +404,7 @@ CModalContainerEditCmd::CModalContainerEditCmd() void CModalContainerEditCmd::create(const std::string &name, bool bDefKey, bool allowAllActions) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string prefix = NLMISC::toUpper(name); + string prefix = NLMISC::toUpperAscii(name); CanDefineKey = bDefKey; _AllowAllActions = allowAllActions; prefix = string(DB_EDITCMD_PREFIX) + string(":") + prefix + string(":"); @@ -492,7 +493,7 @@ void CModalContainerEditCmd::activate() } if (found) { - pCB->addText( CI18N::get(rVCat[i].LocalizedName) ); + pCB->addText(CI18N::get(rVCat[i].LocalizedName)); CurrentEditCmdCategories.push_back(rVCat[i].Name); } } @@ -512,9 +513,9 @@ void CModalContainerEditCmd::activate() NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params CViewText *pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); invalidCurrentCommand(); } @@ -679,7 +680,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBox)); // sTmp is utf8 - pEB->setInputStringAsUtf8(sTmp); + pEB->setInputString(sTmp); } // Setup the param name if any @@ -711,7 +712,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(true); // setup the text of the key - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toString()); // There is already a shortcut so we can display ok button pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); @@ -863,7 +864,7 @@ void CModalContainerEditCmd::validCurrentCommand() CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); // convert to utf8 if (pEB != NULL) - CurrentEditCmdLine.ActionName.Argu += pEB->getInputStringAsUtf8(); + CurrentEditCmdLine.ActionName.Argu += pEB->getInputString(); noParam++; } } @@ -887,7 +888,7 @@ void CModalContainerEditCmd::validCurrentCommand() { CurrentEditCmdLine.Combo = it->second; // Yes ok let setup the text of the key - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toString()); // There is already a shortcut so we can display ok button CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1033,7 +1034,7 @@ void CModalContainerEditCmd::onChangeCategory() { if (rBA.isUsableInCurrentContext()) { - pCB->addText( CI18N::get(rBA.LocalizedName) ); + pCB->addText(CI18N::get(rBA.LocalizedName)); } } } @@ -1048,9 +1049,9 @@ void CModalContainerEditCmd::onChangeCategory() // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); // Reset key invalidCurrentCommand(); } @@ -1086,9 +1087,9 @@ void CModalContainerEditCmd::onChangeAction() // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); uint noParam = 0; for (uint i = 0; i < rVParams.size(); ++i) @@ -1130,11 +1131,10 @@ void CModalContainerEditCmd::onChangeAction() if (ActionsContext.matchContext(rVal.Contexts)) { - if ((rVal.LocalizedValue.size() >= 2) && - (rVal.LocalizedValue[0] == 'u') && (rVal.LocalizedValue[1] == 'i')) + if (NLMISC::startsWith(rVal.LocalizedValue, "ui")) pCB->addText(CI18N::get(rVal.LocalizedValue)); else - pCB->addText(ucstring(rVal.LocalizedValue)); + pCB->addText(rVal.LocalizedValue); } } } @@ -1148,7 +1148,7 @@ void CModalContainerEditCmd::onChangeAction() CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); if( pEB ) { - pEB->setInputString(ucstring("")); + pEB->setInputString(std::string()); } NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1); } @@ -1354,7 +1354,7 @@ public: pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); - if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString()); + if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toString()); CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1366,7 +1366,7 @@ public: pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); - if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString()); + if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toString()); } } }; diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 4ffb2bb17..f942ae7e1 100644 --- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -64,7 +65,7 @@ void CMacroCmd::writeTo (xmlNodePtr node) const xmlNodePtr macroNode = xmlNewChild ( node, NULL, (const xmlChar*)"macro", NULL ); // Props - xmlSetProp (macroNode, (const xmlChar*)"name", (const xmlChar*)ucstring(Name).toUtf8().c_str()); + xmlSetProp (macroNode, (const xmlChar*)"name", (const xmlChar*)Name.c_str()); xmlSetProp (macroNode, (const xmlChar*)"id", (const xmlChar*)toString(ID).c_str()); xmlSetProp (macroNode, (const xmlChar*)"back", (const xmlChar*)toString(BitmapBack).c_str()); xmlSetProp (macroNode, (const xmlChar*)"icon", (const xmlChar*)toString(BitmapIcon).c_str()); @@ -85,12 +86,7 @@ bool CMacroCmd::readFrom (xmlNodePtr node) CXMLAutoPtr ptrName; ptrName = (char*) xmlGetProp( node, (xmlChar*)"name" ); - if (ptrName) - { - ucstring ucName; - ucName.fromUtf8((const char*)ptrName); - Name = ucName.toString(); - } + if (ptrName) Name = (const char *)ptrName; ptrName = (char*) xmlGetProp( node, (xmlChar*)"id" ); if (ptrName) fromString((const char*)ptrName, ID); @@ -636,7 +632,7 @@ public: CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (pCS == NULL) return; - pCS->setMacroText(pEB->getInputStringAsStdString()); + pCS->setMacroText(pEB->getInputString()); } }; REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text"); @@ -703,10 +699,10 @@ public: CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT)); if (pEB != NULL) { - pEB->setInputStringAsStdString(pMCM->CurrentEditMacro.DispText); + pEB->setInputString(pMCM->CurrentEditMacro.DispText); CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON)); if (pCS != NULL) - pCS->setMacroText(pEB->getInputStringAsStdString()); + pCS->setMacroText(pEB->getInputString()); } CAHManager::getInstance()->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back)); @@ -817,7 +813,7 @@ public: REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdDelete, "new_macro_cmd_delete"); // *************************************************************************** -void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName) +void addCommandLine (CGroupList *pParent, uint cmdNb, const string &cmdName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -862,7 +858,7 @@ public: if (pEB == NULL) return; CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - pMCM->CurrentEditMacro.Name = pEB->getInputStringAsStdString(); + pMCM->CurrentEditMacro.Name = pEB->getInputString(); if ((pMCM->CurrentEditMacro.Name.size() >= 2) && (pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i')) pMCM->CurrentEditMacro.Name[0] = 'U'; @@ -897,7 +893,7 @@ public: if (pMCM->CurrentEditMacro.Combo.Key == KeyCount) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); else - pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString()); + pVT->setText(pMCM->CurrentEditMacro.Combo.toString()); } pList->clearGroups(); @@ -905,7 +901,7 @@ public: for (uint i = 0; i < pMCM->CurrentEditMacro.Commands.size(); ++i) { - ucstring commandName; + string commandName; for (uint j = 0; j < pMCM->ActionManagers.size(); ++j) { CAction::CName c(pMCM->CurrentEditMacro.Commands[i].Name.c_str(), pMCM->CurrentEditMacro.Commands[i].Params.c_str()); @@ -1003,7 +999,7 @@ void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd ¯o) if (pVT != NULL) { if (macro.Combo.Key != KeyCount) - pVT->setText(macro.Combo.toUCString()); + pVT->setText(macro.Combo.toString()); else pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); } diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.h b/ryzom/client/src/interface_v3/macrocmd_manager.h index 37f2f7bee..0bc2eec03 100644 --- a/ryzom/client/src/interface_v3/macrocmd_manager.h +++ b/ryzom/client/src/interface_v3/macrocmd_manager.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2016 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp index 56f97b554..e406b83a8 100644 --- a/ryzom/client/src/interface_v3/music_player.cpp +++ b/ryzom/client/src/interface_v3/music_player.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -326,9 +327,7 @@ void CMusicPlayer::rebuildPlaylist() CViewText *pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_TITLE)); if (pVT) { - ucstring title; - title.fromUtf8(_Songs[i].Title); - pVT->setText(title); + pVT->setText(_Songs[i].Title); } pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION)); @@ -483,7 +482,7 @@ void CMusicPlayer::updatePlayingInfo(const std::string info) CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text")); if (pVT) { - pVT->setText(ucstring::makeFromUtf8(info)); + pVT->setText(info); } } @@ -492,7 +491,7 @@ void CMusicPlayer::clearPlayingInfo() { if (_Songs.empty()) { - updatePlayingInfo(CI18N::get("uiNoFiles").toUtf8()); + updatePlayingInfo(CI18N::get("uiNoFiles")); } else { @@ -583,19 +582,26 @@ static void addFromPlaylist(const std::string &playlist, const std::vector= 3 && memcmp(line, utf8Header, 3) == 0) + { useUtf8 = true; + lineStr = trim(std::string(line + 3)); + } if (!useUtf8) { - lineStr = ucstring(line).toUtf8(); + lineStr = NLMISC::mbcsToUtf8(line); // Attempt local codepage first + if (lineStr.empty()) + lineStr = CUtfStringView::fromAscii(std::string(line)); // Fallback lineStr = trim(lineStr); } + lineStr = CUtfStringView(lineStr).toUtf8(true); // Re-encode external string + // Not a comment line if (lineStr[0] != '#') { std::string filename = CPath::makePathAbsolute(CFile::getPath(lineStr), basePlaylist) + CFile::getFilename(lineStr); - std::string ext = toLower(CFile::getExtension(filename)); + std::string ext = toLowerAscii(CFile::getExtension(filename)); if (std::find(extensions.begin(), extensions.end(), ext) != extensions.end()) { if (CFile::fileExists(filename)) @@ -622,9 +628,9 @@ void CMusicPlayer::createPlaylistFromMusic() if (extensions.empty()) { // in the very unlikely scenario - const ucstring message("Sound driver has no support for music."); + static const string message("Sound driver has no support for music."); CInterfaceManager::getInstance()->displaySystemInfo(message, "SYS"); - nlinfo("%s", message.toUtf8().c_str()); + nlinfo("%s", message.c_str()); return; } std::string newPath = CPath::makePathAbsolute(CPath::standardizePath(ClientCfg.MediaPlayerDirectory), CPath::getCurrentPath(), true); @@ -632,9 +638,9 @@ void CMusicPlayer::createPlaylistFromMusic() join(extensions, ", ", extlist); extlist += ", m3u, m3u8"; - std::string msg(CI18N::get("uiMk_system6").toUtf8()); + std::string msg(CI18N::get("uiMk_system6")); msg += ": " + newPath + " (" + extlist + ")"; - CInterfaceManager::getInstance()->displaySystemInfo(ucstring::makeFromUtf8(msg), "SYS"); + CInterfaceManager::getInstance()->displaySystemInfo(msg, "SYS"); nlinfo("%s", msg.c_str()); // Recursive scan for files from media directory @@ -647,7 +653,7 @@ void CMusicPlayer::createPlaylistFromMusic() for (i = 0; i < filesToProcess.size(); ++i) { - std::string ext = toLower(CFile::getExtension(filesToProcess[i])); + std::string ext = toLowerAscii(CFile::getExtension(filesToProcess[i])); if (std::find(extensions.begin(), extensions.end(), ext) != extensions.end()) { filenames.push_back(filesToProcess[i]); diff --git a/ryzom/client/src/interface_v3/music_player.h b/ryzom/client/src/interface_v3/music_player.h index febfde719..e9c73a88c 100644 --- a/ryzom/client/src/interface_v3/music_player.h +++ b/ryzom/client/src/interface_v3/music_player.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/obs_huge_list.cpp b/ryzom/client/src/interface_v3/obs_huge_list.cpp index d28499791..0c0da5677 100644 --- a/ryzom/client/src/interface_v3/obs_huge_list.cpp +++ b/ryzom/client/src/interface_v3/obs_huge_list.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/obs_huge_list.h b/ryzom/client/src/interface_v3/obs_huge_list.h index 664f2ab46..d37c35867 100644 --- a/ryzom/client/src/interface_v3/obs_huge_list.h +++ b/ryzom/client/src/interface_v3/obs_huge_list.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/parser_modules.cpp b/ryzom/client/src/interface_v3/parser_modules.cpp index 37f93eda5..17be41bb4 100644 --- a/ryzom/client/src/interface_v3/parser_modules.cpp +++ b/ryzom/client/src/interface_v3/parser_modules.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/parser_modules.h b/ryzom/client/src/interface_v3/parser_modules.h index 780991ccc..112803cc0 100644 --- a/ryzom/client/src/interface_v3/parser_modules.h +++ b/ryzom/client/src/interface_v3/parser_modules.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index 9164a78ea..1424b782c 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -91,7 +91,7 @@ static const sint PARTY_CHAT_SPAWN_DELTA = 20; // to avoid that all party chat a /** Display an error msg in the system info window, and also in the last window that triggered the command (so that the user is sure to see it) */ -static void displayVisibleSystemMsg(const ucstring &msg, const string &cat = "CHK"); +static void displayVisibleSystemMsg(const std::string &msg, const string &cat = "CHK"); ////////////////////////////// @@ -102,7 +102,7 @@ static void displayVisibleSystemMsg(const ucstring &msg, const string &cat = "CH struct CPartyChatEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -120,7 +120,7 @@ struct CPartyChatEntryHandler : public IChatWindowListener // handler to manage user entry in 'around me' window struct CAroundMeEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -138,7 +138,7 @@ struct CAroundMeEntryHandler : public IChatWindowListener // handler to manage user entry in 'region' window struct CRegionEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -156,7 +156,7 @@ struct CRegionEntryHandler : public IChatWindowListener // handler to manage user entry in 'universe' window struct CUniverseEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -174,7 +174,7 @@ struct CUniverseEntryHandler : public IChatWindowListener // handler to manage user entry in 'guild chat' window struct CGuildChatEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -191,7 +191,7 @@ struct CGuildChatEntryHandler : public IChatWindowListener // handler to manage user entry in 'team chat' window struct CTeamChatEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -208,7 +208,7 @@ struct CTeamChatEntryHandler : public IChatWindowListener // handler to manage user entry in a 'talk with friend' window struct CFriendTalkEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -225,10 +225,9 @@ struct CFriendTalkEntryHandler : public IChatWindowListener // handler to manage user entry in a debug console window struct CDebugConsoleEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow * /* chatWindow */) + virtual void msgEntered(const string &msg, CChatWindow * /* chatWindow */) { - std::string str = msg.toString(); - NLMISC::ICommand::execute( str, g_log ); + NLMISC::ICommand::execute( msg, g_log ); } }; @@ -242,7 +241,7 @@ public: DbIndex= 0; } - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -358,7 +357,7 @@ void CPeopleInterraction::release() uint numCW = cwm.getNumChatWindow(); for(uint k = 0; k < numCW; ++k) { - nlwarning("Window %d : %s", (int) k, (cwm.getChatWindowByIndex(k)->getTitle().toString()).c_str()); + nlwarning("Window %d : %s", (int) k, (cwm.getChatWindowByIndex(k)->getTitle()).c_str()); } } } @@ -937,7 +936,7 @@ class CHandlerChatGroupFilter : public IActionHandler case CChatGroup::dyn_chat: uint32 index = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex(); uint32 textId = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DYN_CHAT:CHANNEL"+toString(index)+":NAME")->getValue32(); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); if (title.empty()) { @@ -947,7 +946,7 @@ class CHandlerChatGroupFilter : public IActionHandler } else { - pUserBut->setHardText(title.toUtf8()); + pUserBut->setHardText(title); } break; } @@ -1092,7 +1091,7 @@ CFilteredChat *CPeopleInterraction::getFilteredChatFromChatWindow(CChatWindow *c } //=========================================================================================================== -void CPeopleInterraction::askAddContact(const ucstring &contactName, CPeopleList *pl) +void CPeopleInterraction::askAddContact(const string &contactName, CPeopleList *pl) { if (pl == NULL) return; @@ -1112,7 +1111,7 @@ void CPeopleInterraction::askAddContact(const ucstring &contactName, CPeopleList } // add into server (NB: will be added by the server response later) - const std::string sMsg = "TEAM:CONTACT_ADD"; + const char *sMsg = "TEAM:CONTACT_ADD"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -1124,14 +1123,14 @@ void CPeopleInterraction::askAddContact(const ucstring &contactName, CPeopleList if (pl == &FriendList) list = 0; - ucstring temp = contactName; + ucstring temp = ucstring::makeFromUtf8(contactName); // TODO: UTF-8 (serial) out.serial(temp); out.serial(list); NetMngr.push(out); //nlinfo("impulseCallBack : %s %s %d sent", sMsg.c_str(), contactName.toString().c_str(), list); } else - nlwarning("impulseCallBack : unknown message name : '%s'.", sMsg.c_str()); + nlwarning("impulseCallBack : unknown message name : '%s'.", sMsg); // NB: no client prediction, will be added by server later @@ -1195,7 +1194,7 @@ void CPeopleInterraction::askMoveContact(uint peopleIndexInSrc, CPeopleList *plS // Fake Local simulation if (ClientCfg.Local) { - ucstring peopleName= plSRC->getName(peopleIndexInSrc); + string peopleName= plSRC->getName(peopleIndexInSrc); plSRC->removePeople(peopleIndexInSrc); sint dstIndex = plDST->addPeople(peopleName); plDST->setOnline(dstIndex, ccs_online); @@ -1254,8 +1253,8 @@ void CPeopleInterraction::askRemoveContact(uint peopleIndex, CPeopleList *pl) //================================================================================================================= void CPeopleInterraction::initContactLists( const std::vector &vFriendListName, - const std::vector &vFriendListOnline, - const std::vector &vIgnoreListName ) + const std::vector &vFriendListOnline, + const std::vector &vIgnoreListName ) // TODO: UTF-8 (serial) { // clear the current lists if any @@ -1267,7 +1266,7 @@ void CPeopleInterraction::initContactLists( const std::vector &vFriendLi for (uint i = 0; i < vFriendListName.size(); ++i) addContactInList(contactIdPool++, vFriendListName[i], vFriendListOnline[i], 0); for (uint i = 0; i < vIgnoreListName.size(); ++i) - addContactInList(contactIdPool++, vIgnoreListName[i], ccs_offline, 1); + addContactInList(contactIdPool++, vIgnoreListName[i].toUtf8(), ccs_offline, 1); FriendList.readContactGroups(); CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); FriendList.sortEx(order); @@ -1275,13 +1274,13 @@ void CPeopleInterraction::initContactLists( const std::vector &vFriendLi } //================================================================================================================= -void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nameIn, TCharConnectionState online, uint8 nList) +void CPeopleInterraction::addContactInList(uint32 contactId, const string &nameIn, TCharConnectionState online, uint8 nList) { // select correct people list CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + string name= CEntityCL::removeShardFromName(nameIn); @@ -1305,7 +1304,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam //================================================================================================================= void CPeopleInterraction::addContactInList(uint32 contactId, uint32 nameID, TCharConnectionState online, uint8 nList) { - ucstring name; + string name; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC->getString(nameID, name)) { @@ -1329,12 +1328,12 @@ void CPeopleInterraction::addContactInList(uint32 contactId, uint32 nameID, TCha } //================================================================================================================= -bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) const +bool CPeopleInterraction::isContactInList(const string &nameIn, uint8 nList) const { // select correct people list const CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + string name= CEntityCL::removeShardFromName(nameIn); return pl.getIndexFromName(name) != -1; } @@ -1365,7 +1364,7 @@ void CPeopleInterraction::updateWaitingContacts() for (uint32 i = 0; i < WaitingContacts.size();) { SWaitingContact &w = WaitingContacts[i]; - ucstring name; + string name; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC->getString(w.NameId, name)) { @@ -1401,7 +1400,7 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS // Only show the message if this player is not in my guild (because then the guild manager will show a message) std::vector GuildMembers = CGuildManager::getInstance()->getGuildMembers(); bool bOnlyFriend = true; - ucstring name = toLower(FriendList.getName(index)); + string name = toLower(FriendList.getName(index)); for (uint i = 0; i < GuildMembers.size(); ++i) { if (toLower(GuildMembers[i].Name) == name) @@ -1417,12 +1416,12 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS // Player is not in my guild, and the status change is from offline to online/abroad online or vice versa. if (showMsg) { - ucstring msg = (online != ccs_offline) ? CI18N::get("uiPlayerOnline") : CI18N::get("uiPlayerOffline"); + string msg = (online != ccs_offline) ? CI18N::get("uiPlayerOnline") : CI18N::get("uiPlayerOffline"); strFindReplace(msg, "%s", FriendList.getName(index)); string cat = getStringCategory(msg, msg); map::const_iterator it; NLMISC::CRGBA col = CRGBA::Yellow; - it = ClientCfg.SystemInfoParams.find(toLower(cat)); + it = ClientCfg.SystemInfoParams.find(toLowerAscii(cat)); if (it != ClientCfg.SystemInfoParams.end()) { col = it->second.Color; @@ -1463,12 +1462,14 @@ void CPeopleInterraction::removeContactFromList(uint32 contactId, uint8 nList) } //================================================================================================================= -bool CPeopleInterraction::testValidPartyChatName(const ucstring &title) +bool CPeopleInterraction::testValidPartyChatName(const string &title) { if (title.empty()) return false; // shouldn't begin like 'user chat 1-5' - ucstring userChatStr = CI18N::get("uiUserChat"); - if (title.substr(0, userChatStr.length()) == userChatStr) return false; + const string &userChatStr = CI18N::get("uiUserChat"); + if (NLMISC::startsWith(title, userChatStr)) return false; + // can't match a translation identifier + if (CI18N::hasTranslation(title)) return false; for(uint k = 0; k < PartyChats.size(); ++k) // there shouldn't be that much party chat simultaneously so a linear search is ok { if (PartyChats[k].Window->getTitle() == title) return false; @@ -1534,7 +1535,7 @@ void CPeopleInterraction::assignPartyChatMenu(CChatWindow *partyChat) } //================================================================================================================= -bool CPeopleInterraction::createNewPartyChat(const ucstring &title) +bool CPeopleInterraction::createNewPartyChat(const string &title) { // now there are no party chat windows, party chat phrases must be filtered from the main chat @@ -1683,7 +1684,10 @@ bool CPeopleInterraction::saveUserChatsInfos(NLMISC::IStream &f) if (ver>=2) { CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow(); - pCGW->saveFreeTeller(f); + if (pCGW) + { + pCGW->saveFreeTeller(f); + } } } catch(const NLMISC::EStream &e) @@ -1859,8 +1863,8 @@ void CPeopleInterraction::createUserChat(uint index) return; } CChatWindowDesc chatDesc; - ucstring userChatStr = CI18N::get("uiUserChat"); - userChatStr += ucchar(' ') + ucstring(toString(index + 1)); + string userChatStr = CI18N::get("uiUserChat"); + userChatStr += ' ' + toString(index + 1); //chatDesc.FatherContainer = "ui:interface:communication"; chatDesc.FatherContainer = "ui:interface:contact_list"; chatDesc.Title = userChatStr; @@ -1890,7 +1894,7 @@ void CPeopleInterraction::refreshActiveUserChats() } //================================================================================================================= -void CPeopleInterraction::talkInDynamicChannel(uint32 channelNb,ucstring sentence) +void CPeopleInterraction::talkInDynamicChannel(uint32 channelNb,string sentence) { if(channelNb(gc->getGroup("add_contact_eb:eb")); - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); } @@ -2264,11 +2268,11 @@ public: else { PeopleInterraction.askAddContact(geb->getInputString(), peopleList); - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } } } - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } } } @@ -2330,7 +2334,7 @@ public: if (gc) { CGroupEditBox *geb = dynamic_cast(gc->getGroup("change_contact_group_eb:eb")); - geb->setInputString(ucstring("")); + geb->setInputString(std::string("")); } CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); } @@ -2355,7 +2359,7 @@ public: { PeopleInterraction.FriendList.changeGroup(lastPeopleIndexChangeGroup, geb->getInputString()); - geb->setInputString(ucstring("")); + geb->setInputString(std::string("")); CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); PeopleInterraction.FriendList.sortEx(order); } @@ -2446,7 +2450,7 @@ public: if (eb) { CWidgetManager::getInstance()->setCaptureKeyboard(eb); - eb->setInputString(ucstring("")); + eb->setInputString(std::string()); } // if (gc->getActive()) @@ -2473,7 +2477,7 @@ class CHandlerValidatePartyChatName : public IActionHandler if (!gc) return; CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb")); if (!eb) return; - ucstring title = eb->getInputString(); + string title = eb->getInputString(); // TODO GAMEDEV : create (or join ?) a new channel. Each channel (party chat) should have a unique name in the game // moreover, it should not have the name of another available chat window (for example, it shouldn't be named 'Around Me') @@ -2482,7 +2486,7 @@ class CHandlerValidatePartyChatName : public IActionHandler if (!PeopleInterraction.testValidPartyChatName(title)) { - displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiInvalidPartyChatName")); + displayVisibleSystemMsg(title + " : " + CI18N::get("uiInvalidPartyChatName")); return; } @@ -2693,11 +2697,11 @@ public: uint32 canWrite = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":WRITE_RIGHT")->getValue32(); if (canWrite != 0) { - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); // replace dynamic channel name and shortcut - ucstring res = CI18N::get("uiFilterMenuDynamic"); + string res = CI18N::get("uiFilterMenuDynamic"); strFindReplace(res, "%channel", title); strFindReplace(res, "%shortcut", s); @@ -2886,7 +2890,7 @@ class CHandlerSelectChatSource : public IActionHandler pVTM->setActive(active); if (active) { - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); pVTM->setText("["+s+"] " + title); } @@ -3011,7 +3015,7 @@ class CHandlerSelectChatSource : public IActionHandler bool active = (textId != 0); if (active) { - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); menu->addLineAtIndex(insertionIndex, "["+s+"] " + title, FILTER_TOGGLE, "dyn"+s); menu->setUserGroupLeft(insertionIndex, createMenuCheckBox(FILTER_TOGGLE, "dyn"+s, pi.ChatInput.DynamicChat[i].isListeningWindow(cw))); @@ -3234,7 +3238,7 @@ NLMISC_COMMAND(ignore, "add or remove a player from the ignore list", "") { -if (args.size() != 1) -{ -displayVisibleSystemMsg(CI18N::get("uiPartyChatCmd")); -return true; -} -CPeopleInterraction &pi = PeopleInterraction; -ucstring title = args[0]; + if (args.size() != 1) + { + displayVisibleSystemMsg(CI18N::get("uiPartyChatCmd")); + return true; + } + CPeopleInterraction &pi = PeopleInterraction; + string title = args[0]; if (!pi.testValidPartyChatName(title)) { @@ -3272,24 +3276,24 @@ return true; // Remove the party chat with the given name NLMISC_COMMAND(remove_party_chat, "Remove a party chat", "") { -if (args.size() != 1) -{ -displayVisibleSystemMsg(CI18N::get("uiRemovePartyChatCmd")); -return true; -} -ucstring title = ucstring(args[0]); -CChatWindow *chat = getChatWndMgr().getChatWindow(title); -if (!chat) -{ -displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiBadPartyChatName")); -return true; -} -if (!PeopleInterraction.removePartyChat(chat)) -{ -displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiCantRemovePartyChat")); -return true; -} -return true; + if (args.size() != 1) + { + displayVisibleSystemMsg(CI18N::get("uiRemovePartyChatCmd")); + return true; + } + string title = ucstring(args[0]); + CChatWindow *chat = getChatWndMgr().getChatWindow(title); + if (!chat) + { + displayVisibleSystemMsg(title + " : " + CI18N::get("uiBadPartyChatName")); + return true; + } + if (!PeopleInterraction.removePartyChat(chat)) + { + displayVisibleSystemMsg(title + " : " + CI18N::get("uiCantRemovePartyChat")); + return true; + } + return true; } @@ -3372,7 +3376,7 @@ REGISTER_INTERFACE_USER_FCT("getNumUserChatLeft", getNumUserChatLeft) // STATIC FUNCTIONS IMPLEMENTATIONS // ////////////////////////////////////// -static void displayVisibleSystemMsg(const ucstring &msg, const string &cat) +static void displayVisibleSystemMsg(const string &msg, const string &cat) { CInterfaceManager *im = CInterfaceManager::getInstance(); im->displaySystemInfo(msg, cat); @@ -3385,7 +3389,7 @@ static void displayVisibleSystemMsg(const ucstring &msg, const string &cat) #if !FINAL_VERSION NLMISC_COMMAND(testSI, "tmp", "tmp") { - PeopleInterraction.ChatInput.DebugInfo.displayMessage(ucstring("test"), CRGBA::Red); + PeopleInterraction.ChatInput.DebugInfo.displayMessage("test", CRGBA::Red); return true; } #endif diff --git a/ryzom/client/src/interface_v3/people_interraction.h b/ryzom/client/src/interface_v3/people_interraction.h index 591a005e2..5c58f4d34 100644 --- a/ryzom/client/src/interface_v3/people_interraction.h +++ b/ryzom/client/src/interface_v3/people_interraction.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -156,12 +159,12 @@ public: CFilteredChat UserChat[MaxNumUserChats]; CFilteredChat TheUserChat; // Id of last people who talked - ucstring LastSenderName; + std::string LastSenderName; // system message struct CSysMsg { - ucstring Str; + std::string Str; std::string Cat; }; // system message buffer @@ -195,31 +198,31 @@ public: */ CFilteredChat *getFilteredChatFromChatWindow(CChatWindow *cw); - bool testValidPartyChatName(const ucstring &name); + bool testValidPartyChatName(const std::string &name); bool removePartyChat(CChatWindow *window); void removeAllPartyChat(); /** * create a named party chat. */ - bool createNewPartyChat(const ucstring &title); + bool createNewPartyChat(const std::string &title); static void assignPartyChatMenu(CChatWindow *partyChat); /// \name CONTACT LIST // @{ // ask the server to add/move/remove a contact - void askAddContact(const ucstring &contactName, CPeopleList *pl); + void askAddContact(const std::string &contactName, CPeopleList *pl); void askMoveContact(uint peopleIndexInSrc, CPeopleList *plSRC, CPeopleList *plDST); void askRemoveContact(uint peopleIndex, CPeopleList *pl); // init contact list (from server typically) void initContactLists( const std::vector &vFriendListName, const std::vector &vFriendListOnline, - const std::vector &vIgnoreListName ); + const std::vector &vIgnoreListName ); // TODO: UTF-8 (serial) // Friend list == 0 // Ignore list == 1 void addContactInList(uint32 contactId, uint32 nameID, TCharConnectionState Online, uint8 nList); - void addContactInList(uint32 contactId, const ucstring &name, TCharConnectionState Online, uint8 nList); - bool isContactInList(const ucstring &name, uint8 nList) const; + void addContactInList(uint32 contactId, const std::string &name, TCharConnectionState Online, uint8 nList); + bool isContactInList(const std::string &name, uint8 nList) const; // Called each frame to receive name from IOS void updateWaitingContacts(); // server decide to remove a contact (if it does not exists anymore) @@ -250,14 +253,14 @@ public: // Test if the given chat is a user chat (this includes the main chat) bool isUserChat(CChatWindow *cw) const; - void talkInDynamicChannel(uint32 channelNb,ucstring sentence); + void talkInDynamicChannel(uint32 channelNb,std::string sentence); CChatGroupWindow *getChatGroupWindow() const; void updateAllFreeTellerHeaders(); void removeAllFreeTellers(); - static void displayTellInMainChat(const ucstring &playerName); + static void displayTellInMainChat(const std::string &playerName); private: // create various chat & people lists void createTeamChat(); diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp index 8728c0e77..463013fa7 100644 --- a/ryzom/client/src/interface_v3/people_list.cpp +++ b/ryzom/client/src/interface_v3/people_list.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2021 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -127,10 +128,7 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha _BaseContainer->setSavable(desc.Savable); _BaseContainer->setLocalize(desc.Localize); - if (desc.Localize) - _BaseContainer->setTitle(desc.PeopleListTitle.toString()); - else - _BaseContainer->setUCTitle(desc.PeopleListTitle); + _BaseContainer->setTitle(desc.PeopleListTitle); //_BaseContainer->setId("ui:interface:" + desc.Id); // create the chat window if there's one @@ -157,12 +155,12 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha } //================================================================== -sint CPeopleList::getIndexFromName(const ucstring &name) const +sint CPeopleList::getIndexFromName(const string &name) const { - string sNameIn = toLower(name.toString()); + string sNameIn = toLowerAscii(name); for(uint k = 0; k < _Peoples.size(); ++k) { - string sPeopleName = toLower(_Peoples[k].getName().toString()); + string sPeopleName = toLowerAscii(_Peoples[k].getName()); if (sPeopleName == sNameIn) return k; } return -1; @@ -202,25 +200,22 @@ bool CPeopleList::sortExByContactId(const CPeople& a, const CPeople& b) bool CPeopleList::sortExByName(const CPeople& a, const CPeople& b) { if (a.Group == b.Group) { - ucstring name_a = toUpper(a.getName()); - ucstring name_b = toUpper(b.getName()); - return (name_a < name_b); + return NLMISC::compareCaseInsensitive(a.getName(), b.getName()) < 0; // FIXME: Locale-dependent sort } else - return (a.Group < b.Group); + { + return NLMISC::compareCaseInsensitive(a.Group, b.Group) < 0; // FIXME: Locale-dependent sort + } } //================================================================== bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b) { if (a.Group == b.Group) { - ucstring name_a = toUpper(a.getName()); - ucstring name_b = toUpper(b.getName()); - // We want order: online/alpha, offworld/alpha, offline/alpha if (a.Online == b.Online) { - return (name_a < name_b); + return NLMISC::compareCaseInsensitive(a.getName(), b.getName()) < 0; // FIXME: Locale-dependent sort } else { @@ -244,7 +239,9 @@ bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b) } } else - return (a.Group < b.Group); + { + return -NLMISC::compareCaseInsensitive(a.Group, b.Group); // FIXME: Locale-dependent sort + } } //================================================================== @@ -290,7 +287,7 @@ void CPeopleList::sortEx(TSortOrder order) { newGroup = true; } - while (groupIndex < _GroupContainers.size() && _GroupContainers[groupIndex].first != _Peoples[k].Group.toString()) + while (groupIndex < _GroupContainers.size() && _GroupContainers[groupIndex].first != _Peoples[k].Group) { newGroup = true; ++groupIndex; @@ -363,13 +360,13 @@ bool CPeopleList::isPeopleChatVisible(uint index) const */ //================================================================== -sint CPeopleList::addPeople(const ucstring &name, uint teamMateIndex /*= 0*/) +sint CPeopleList::addPeople(const string &name, uint teamMateIndex /*= 0*/) { if (!_BaseContainer) return - 1; // check if not already inserted if (getIndexFromName(name) != -1) { - nlwarning(" people %s inserted twice.", name.toString().c_str()); + nlwarning(" people %s inserted twice.", name.c_str()); } vector > properties; @@ -403,11 +400,11 @@ sint CPeopleList::addPeople(const ucstring &name, uint teamMateIndex /*= 0*/) if (!gc) { delete group; - nlwarning(" group is not a container.", name.toString().c_str()); + nlwarning(" group is not a container.", name.c_str()); return -1; } // set title from the name - gc->setUCTitle(name); + gc->setTitle(name); // People inside list are not savable ! gc->setSavable(false); // @@ -482,44 +479,44 @@ void CPeopleList::setContactId(uint index, uint32 contactId) } //================================================================== -void CPeopleList::changeGroup(uint index, const ucstring &groupName) +void CPeopleList::changeGroup(uint index, const std::string &groupName) { if (index >= _Peoples.size()) { nlwarning(" bad index."); return; } - ucstring group = groupName; - if (group.toString() == "General") - group = ucstring(""); + std::string group = groupName; + if (group == "General") + group.clear(); _Peoples[index].Group = group; for (uint k = 0; k < _GroupContainers.size(); ++k) { - if (_GroupContainers[k].first == group.toString()) + if (_GroupContainers[k].first == group) return; } vector > properties; properties.push_back(make_pair(string("posparent"), string("parent"))); properties.push_back(make_pair(string("id"), _ContainerID + "_group_" + toString(_GroupContainers.size()))); - if (group.toString() == "") + if (group.empty()) properties.push_back(make_pair(string("title"), "General")); else - properties.push_back(make_pair(string("title"), group.toString())); + properties.push_back(make_pair(string("title"), group)); CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getParser()->createGroupInstance("people_list_group_header", "ui:interface", properties, false)); - if (group.toString() == "") - gc->setUCTitle(ucstring("General")); + if (group.empty()) + gc->setTitle(std::string("General")); else - gc->setUCTitle(group.toString()); + gc->setTitle(group); gc->setSavable(false); CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->addGroup (gc); _BaseContainer->attachContainer(gc); - _GroupContainers.push_back(make_pair(group.toString(), gc)); + _GroupContainers.push_back(make_pair(group, gc)); std::sort(_GroupContainers.begin(), _GroupContainers.end()); } @@ -630,8 +627,8 @@ void CPeopleList::saveContactGroups() { xmlNodePtr newNode = xmlNewChild(node, NULL, (const xmlChar*)"contact", NULL); - xmlSetProp(newNode, (const xmlChar*)"name", (const xmlChar*)_Peoples[k].getName().toString().c_str()); - xmlSetProp(newNode, (const xmlChar*)"group", (const xmlChar*)_Peoples[k].Group.toString().c_str()); + xmlSetProp(newNode, (const xmlChar*)"name", (const xmlChar*)_Peoples[k].getName().c_str()); + xmlSetProp(newNode, (const xmlChar*)"group", (const xmlChar*)_Peoples[k].Group.c_str()); } stream.flush(); fd.close(); @@ -645,7 +642,7 @@ void CPeopleList::saveContactGroups() } //================================================================== -void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, const ucstring &msg,uint numBlinks /*=0*/) +void CPeopleList::displayLocalPlayerTell(const string &receiver, uint index, const string &msg,uint numBlinks /*=0*/) { if (_ContactType == CPeopleListDesc::Ignore) { @@ -668,13 +665,13 @@ void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, c return; } - ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); - ucstring finalMsg = csr + CI18N::get("youTell") + ": " + msg; + string csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + string finalMsg = csr + CI18N::get("youTell") + ": " + msg; // display msg with good color CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", receiver); strFindReplace(finalMsg, CI18N::get("youTell"), s); CViewBase *child = getChatTextMngr().createMsgText(finalMsg, prop.getRGBA()); @@ -697,7 +694,7 @@ void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, c //================================================================== -void CPeopleList::displayMessage(uint index, const ucstring &msg, NLMISC::CRGBA col, uint /* numBlinks */ /*= 0*/) +void CPeopleList::displayMessage(uint index, const string &msg, NLMISC::CRGBA col, uint /* numBlinks */ /*= 0*/) { if (_ContactType == CPeopleListDesc::Ignore) { @@ -893,12 +890,12 @@ void CPeopleList::updatePeopleMenu(uint index) } //================================================================== -ucstring CPeopleList::getName(uint index) const +std::string CPeopleList::getName(uint index) const { if (index >= _Peoples.size()) { nlwarning("bad index"); - return ucstring("BAD INDEX!"); + return "BAD INDEX!"; } return _Peoples[index].getName(); } @@ -1083,7 +1080,7 @@ class CHandlerContactEntry : public IActionHandler { CGroupEditBox *pEB = dynamic_cast(pCaller); if (pEB == NULL) return; - ucstring text = pEB->getInputString(); + string text = pEB->getInputString(); // If the line is empty, do nothing if(text.empty()) return; @@ -1091,7 +1088,7 @@ class CHandlerContactEntry : public IActionHandler // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) { - pEB->setInputString (string("")); + pEB->setInputString (std::string()); return; } @@ -1099,10 +1096,9 @@ class CHandlerContactEntry : public IActionHandler if(text[0] == '/') { CChatWindow::_ChatWindowLaunchingCommand = NULL; // no CChatWindow instance there .. - // TODO : have NLMISC::ICommand accept unicode strings - std::string str = text.toUtf8().substr(1); + std::string str = text.substr(1); NLMISC::ICommand::execute( str, g_log ); - pEB->setInputString (string("")); + pEB->setInputString (std::string()); return; } // Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now @@ -1111,11 +1107,11 @@ class CHandlerContactEntry : public IActionHandler CGroupContainer *gc = static_cast< CGroupContainer* >( pCaller->getParent()->getEnclosingContainer() ); // title gives the name of the player - ucstring playerName = gc->getUCTitle(); + string playerName = gc->getTitle(); // Simply do a tell on the player - ChatMngr.tell(playerName.toString(), text); - pEB->setInputString (string("")); + ChatMngr.tell(playerName, text); + pEB->setInputString (std::string()); if (gc) { // Restore position of enclosing container if it hasn't been moved/scaled/poped by the user @@ -1147,17 +1143,17 @@ class CHandlerContactEntry : public IActionHandler CChatGroupWindow *pWin = PeopleInterraction.getChatGroupWindow(); CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); - ucstring final; + string final; CChatWindow::encodeColorTag(prop.getRGBA(), final, false); - ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); + string csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); final += csr + CI18N::get("youTell")+": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), final, true); final += text; pWin->displayTellMessage(final, prop.getRGBA(), pWin->getFreeTellerName(str)); - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", pWin->getFreeTellerName(str)); strFindReplace(final, CI18N::get("youTell"), s); CInterfaceManager::getInstance()->log(final, CChatGroup::groupTypeToString(CChatGroup::tell)); diff --git a/ryzom/client/src/interface_v3/people_list.h b/ryzom/client/src/interface_v3/people_list.h index 682b1a6e5..aebb98673 100644 --- a/ryzom/client/src/interface_v3/people_list.h +++ b/ryzom/client/src/interface_v3/people_list.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -28,7 +29,6 @@ #include "chat_window.h" #include "interface_pointer.h" // NeL -#include "nel/misc/ucstring.h" #include "nel/misc/rgba.h" @@ -40,7 +40,7 @@ struct CPeopleListDesc { enum TContactType { Team, Contact, Ignore, Unknown }; - ucstring PeopleListTitle; // title of the people list + std::string PeopleListTitle; // title of the people list TContactType ContactType; std::string FatherContainer; // name of the father container std::string BaseContainerTemplateName; // name of the template for the base container @@ -75,13 +75,13 @@ public: */ bool create(const CPeopleListDesc &desc, const CChatWindowDesc *chat = NULL); // Get index from the name of a people, or -1 if not found - sint getIndexFromName(const ucstring &name) const; + sint getIndexFromName(const std::string &name) const; // Get index from the id of the container that represent the people sint getIndexFromContainerID(const std::string &id) const; // Get the number of people in this list uint getNumPeople() const { return (uint)_Peoples.size(); } // Get name of a people - ucstring getName(uint index) const; + std::string getName(uint index) const; // Sort people alphabetically void sort(); @@ -99,7 +99,7 @@ public: /** Add a people to the list, and returns its index or -1 if the creation failed * If this is a team mate, tells its index so that ic can be bound to the database in the right location */ - sint addPeople(const ucstring &name, uint teamMateIndex = 0); + sint addPeople(const std::string &name, uint teamMateIndex = 0); // swap people position between the 2 given indexs void swapPeople(uint index1, uint index2); // Remove the people at the given index @@ -111,15 +111,15 @@ public: sint getIndexFromContactId(uint32 contactId); // For Friend Groups management - void changeGroup(uint index, const ucstring &groupName); + void changeGroup(uint index, const std::string &groupName); void readContactGroups(); void saveContactGroups(); /** Display a message for the given people * If the window is closed, it causes it to blink (and also the parent window) */ - void displayMessage(uint index, const ucstring &msg, NLMISC::CRGBA col, uint numBlinks = 0); - void displayLocalPlayerTell(const ucstring &receiver, uint index, const ucstring &msg, uint numBlinks = 0); + void displayMessage(uint index, const std::string &msg, NLMISC::CRGBA col, uint numBlinks = 0); + void displayLocalPlayerTell(const std::string &receiver, uint index, const std::string &msg, uint numBlinks = 0); // Is the given people window visible ? bool isPeopleChatVisible(uint index) const; // reset remove everything from the interface @@ -163,9 +163,9 @@ private: TCharConnectionState Online; bool Blocked; uint32 ContactId; - ucstring Group; + std::string Group; bool operator < (const CPeople &other) const { return getName() < other.getName(); } - ucstring getName() const { return Container->getUCTitle(); } + std::string getName() const { return Container->getTitle(); } }; typedef std::vector TPeopleVect; private: diff --git a/ryzom/client/src/interface_v3/register_interface_elements.cpp b/ryzom/client/src/interface_v3/register_interface_elements.cpp index c425f8401..dc2c731e6 100644 --- a/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/interface_v3/req_skill_formula.cpp b/ryzom/client/src/interface_v3/req_skill_formula.cpp index 1165dccc5..c661a61b5 100644 --- a/ryzom/client/src/interface_v3/req_skill_formula.cpp +++ b/ryzom/client/src/interface_v3/req_skill_formula.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -343,7 +346,7 @@ void CReqSkillFormula::log(const char *prefix) const } // *************************************************************************** -void CReqSkillFormula::getInfoText(ucstring &info) const +void CReqSkillFormula::getInfoText(string &info) const { info.clear(); @@ -363,7 +366,7 @@ void CReqSkillFormula::getInfoText(ucstring &info) const { const CSkillValue &sv= *itSv; // get the colored line if the skill don't reach the req level - ucstring line; + string line; if(!isSkillValueTrained(sv)) line= CI18N::get("uihelpPhraseRequirementNotMetLine"); else diff --git a/ryzom/client/src/interface_v3/req_skill_formula.h b/ryzom/client/src/interface_v3/req_skill_formula.h index 7286172ce..90ec882e3 100644 --- a/ryzom/client/src/interface_v3/req_skill_formula.h +++ b/ryzom/client/src/interface_v3/req_skill_formula.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -101,7 +104,7 @@ public: void log(const char *prefix) const; // For SPhrase Info - void getInfoText(ucstring &info) const; + void getInfoText(std::string &info) const; // return true if the requirement formula completes regarding the actual player state (through CSkillMananger). return true if empty() bool evaluate() const; diff --git a/ryzom/client/src/interface_v3/sbrick_manager.cpp b/ryzom/client/src/interface_v3/sbrick_manager.cpp index d12ed783c..6bf830ecd 100644 --- a/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -408,7 +408,7 @@ void CSBrickManager::compileBrickProperties() string::size_type pos = prop.Text.find(':'); if (pos != string::npos) { - string key = toLower(prop.Text.substr(0, pos)); + string key = toLowerAscii(prop.Text.substr(0, pos)); string value = prop.Text.substr(pos + 1); // get key id. if (_BrickPropIdMap.find(key) == _BrickPropIdMap.end()) @@ -436,7 +436,7 @@ void CSBrickManager::compileBrickProperties() // **** for all bricks, recompute localized text with formated version - ucstring textTemp; + string textTemp; textTemp.reserve(1000); for (std::vector::size_type ib = 0; ib < _BrickVector.size(); ++ib) { @@ -445,7 +445,7 @@ void CSBrickManager::compileBrickProperties() continue; // Get the Brick texts - ucstring texts[3]; + std::string texts[3]; texts[0]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheet->Id); texts[1]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedDescription(brickSheet->Id); texts[2]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheet->Id); @@ -453,7 +453,7 @@ void CSBrickManager::compileBrickProperties() // For alls texts, parse format for(uint i=0;i<3;i++) { - ucstring &text= texts[i]; + string &text= texts[i]; textTemp.erase(); // Parse the text @@ -486,7 +486,7 @@ void CSBrickManager::compileBrickProperties() k++; } // Param Id modifier? (ie read not the 0th value, but the 1th etc... up to 9) - else if(k +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -587,8 +588,8 @@ void CSkillManager::checkTitleUnblocked(CHARACTER_TITLE::ECharacterTitle i, bool // This is a new title, send a message string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); - const ucstring newtitle(CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle)); - CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+newtitle.toUtf8()+"|text0="+CI18N::get("uiNewTitleBold").toUtf8()); + const char *newtitle(CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle)); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, string("text1=") + newtitle + "|text0=" + CI18N::get("uiNewTitleBold")); } else { @@ -1096,7 +1097,7 @@ public: { string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); - const ucstring s(CStringManagerClient::getTitleLocalizedName(titleStr,womenTitle)); + const char *s = CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle); pCB->addText(s); pSM->_UIUnblockedTitles.push_back((CHARACTER_TITLE::ECharacterTitle)i); } diff --git a/ryzom/client/src/interface_v3/sphrase_manager.cpp b/ryzom/client/src/interface_v3/sphrase_manager.cpp index f9dd511d5..7e2585eb4 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -960,7 +960,7 @@ bool CSPhraseManager::isPhraseKnown(const CSPhraseCom &phrase) const } // *************************************************************************** -ucstring CSPhraseManager::formatMalus(sint base, sint malus) +string CSPhraseManager::formatMalus(sint base, sint malus) { if(malus) return toString("@{F80F}%d@{FFFF} (%d)", base+malus, base); @@ -969,7 +969,7 @@ ucstring CSPhraseManager::formatMalus(sint base, sint malus) } // *************************************************************************** -ucstring CSPhraseManager::formatMalus(float base, float malus) +string CSPhraseManager::formatMalus(float base, float malus) { if(malus) return toString("@{F80F}%.1f@{FFFF} (%.1f)", base+malus, base); @@ -1008,7 +1008,7 @@ string CSPhraseManager::formatBonusMalus(sint32 base, sint32 mod) } // *************************************************************************** -void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat) +void CSPhraseManager::buildPhraseDesc(string &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat) { CSBrickManager *pBM= CSBrickManager::getInstance(); CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -1029,7 +1029,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, if(rootBrick) { static const string compoId= "composition"; - static const ucstring compoTag("%compostart"); + static const string compoTag("%compostart"); bool isComposition= specialPhraseFormat==compoId; // if format not given by user, auto select it. @@ -1053,14 +1053,14 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // if composition, cut the text before the tag (including) if(isComposition) { - ucstring::size_type pos= text.find(compoTag); - if(pos!=ucstring::npos) + string::size_type pos= text.find(compoTag); + if(pos!=string::npos) text.erase(0, pos+compoTag.size()); } // else just clear the tag else { - strFindReplace(text, compoTag, ucstring() ); + strFindReplace(text, compoTag, string() ); } } else @@ -1071,7 +1071,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // **** Phrase info basics // replace name - strFindReplace(text, "%name", phrase.Name); + strFindReplace(text, "%name", phrase.Name.toUtf8()); // replace Sabrina Cost and credit. uint32 cost, credit; pBM->getSabrinaCom().getPhraseCost(phrase.Bricks, cost, credit); @@ -1079,7 +1079,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, strFindReplace(text, "%credit", toString(credit)); // for combat, fill weapon compatibility - ucstring weaponRestriction; + string weaponRestriction; bool usableWithMelee; bool usableWithRange; if(rootBrick && rootBrick->isCombat()) @@ -1099,7 +1099,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, bool resistMagic[RESISTANCE_TYPE::NB_RESISTANCE_TYPE]; getResistMagic(resistMagic, phrase.Bricks); bool first= true; - ucstring resList; + string resList; for(uint i=0;iisForageExtraction()) { // Choose the fmt text - ucstring fmt= getForageExtractionPhraseEcotypeFmt(phrase); + string fmt= getForageExtractionPhraseEcotypeFmt(phrase); // Replace forage success rate in any ecotype successModifier = 0; @@ -1292,16 +1292,16 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, } // **** Special .sphrase description - if(phraseSheetId) + if (phraseSheetId) { // get the text - ucstring desc(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(CSheetId(phraseSheetId))); - if(desc.empty()) - strFindReplace(text, "%desc", ucstring()); + string desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(CSheetId(phraseSheetId)); + if (desc.empty()) + strFindReplace(text, "%desc", string()); else { // append an \n before, for clearness - desc= ucstring("\n") + desc; + desc= string("\n") + desc; // append \n at end if not done if(desc[desc.size()-1]!='\n') desc+= '\n'; @@ -1311,13 +1311,13 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, } else { - strFindReplace(text, "%desc", ucstring()); + strFindReplace(text, "%desc", string()); } // **** Special .sphrase requirement if(phraseSheetId && wantRequirement) { - ucstring reqText; + string reqText; reqText= CI18N::get("uihelpPhraseRequirementHeader"); // replace the skill point cost @@ -1331,7 +1331,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, const CReqSkillFormula &formula= it->second; // from this formula, build the requirement tex - ucstring textForm; + string textForm; formula.getInfoText(textForm); reqText+= textForm; } @@ -3576,13 +3576,12 @@ void CSPhraseManager::updatePhraseProgressionDB() break; } } - } - - // if show, but only if full learnt, skip it if not fully learnt - if(phrase->ShowInAPOnlyIfLearnt && !known) - { - continue; + // if show, but only if full learnt, skip it if not fully learnt + if (phrase->ShowInAPOnlyIfLearnt && !known) + { + continue; + } } @@ -3633,7 +3632,7 @@ public: bool Castable; uint32 Type; uint32 Icon; - ucstring Text; + string Text; bool operator<(const CPhraseSortEntry &pse) const { @@ -3849,20 +3848,20 @@ void CSPhraseManager::computePhraseProgression() // replace each number with 001 format. toLower for(uint k=0;kPhrase.Name); +#else + ls.push(this->Phrase.Name.toUtf8()); +#endif return 1; } @@ -4697,10 +4700,15 @@ int CSPhraseComAdpater::luaGetDesc(CLuaState &ls) if (phraseSheetID != 0) { // is it a built-in phrase? - ucstring desc(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID))); - if (!desc.empty()) + const char *desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID)); + if (*desc) { - CLuaIHM::push(ls, desc); +#ifdef RYZOM_LUA_UCSTRING + ucstring uc = ucstring::makeFromUtf8(desc); // Compatibility + CLuaIHM::push(ls, uc); +#else + ls.push(desc); +#endif return 1; } } diff --git a/ryzom/client/src/interface_v3/sphrase_manager.h b/ryzom/client/src/interface_v3/sphrase_manager.h index 03c0f1718..ad8abee80 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.h +++ b/ryzom/client/src/interface_v3/sphrase_manager.h @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2014 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -338,7 +338,7 @@ public: * \specialPhraseFormat if empty, format is auto selected. if "composition", same but the text is cut under the %compostart tag. * else take directly this format. */ - void buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat= std::string()); + void buildPhraseDesc(std::string &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat= std::string()); // Get the Phrase Success Rate % sint getPhraseSuccessRate(const CSPhraseCom &phrase); // Get the Phrase Success Rate %. Manually gives the Skill to do the comparison (for craft) @@ -346,7 +346,7 @@ public: // Get the Phrase Success Rate %. Manually gives the Skill to do the comparison (for Forage Extraction) sint getForageExtractionPhraseSuccessRate(const CSPhraseCom &phrase, SKILLS::ESkills skill); // return the fmt according to forage terrain specializing - ucstring getForageExtractionPhraseEcotypeFmt(const CSPhraseCom &phrase); + std::string getForageExtractionPhraseEcotypeFmt(const CSPhraseCom &phrase); // Get the Phrase Sap Cost void getPhraseSapCost(const CSPhraseCom &phrase, uint32 totalActionMalus, sint &cost, sint &costMalus); // Get the Phrase Sta Cost @@ -370,8 +370,8 @@ public: /// true if interesting to list the bricks of this phrase in help bool allowListBrickInHelp(const CSPhraseCom &phrase) const; /// return the combat restriction text (empty if not combat) - void getCombatWeaponRestriction(ucstring &text, const CSPhraseCom &phrase, bool& usableWithMelee, bool& usableWithRange); - void getCombatWeaponRestriction(ucstring &text, sint32 phraseSheetId, bool& usableWithMelee, bool& usableWithRange); + void getCombatWeaponRestriction(std::string &text, const CSPhraseCom &phrase, bool& usableWithMelee, bool& usableWithRange); + void getCombatWeaponRestriction(std::string &text, sint32 phraseSheetId, bool& usableWithMelee, bool& usableWithRange); // return true if any of the Bricks contains AvoidCyclic==true (the phrase cannot be cyclic) bool avoidCyclicForPhrase(const CSPhraseCom &phrase) const; bool avoidCyclicForPhrase(sint32 phraseSheetId) const; @@ -693,8 +693,8 @@ private: // @} - ucstring formatMalus(sint base, sint malus); - ucstring formatMalus(float base, float malus); + std::string formatMalus(sint base, sint malus); + std::string formatMalus(float base, float malus); std::string formatBonusMalus(sint32 base, sint32 mod); // Special for combat: Build the "phrase skill compatible" formula diff --git a/ryzom/client/src/interface_v3/task_bar_manager.cpp b/ryzom/client/src/interface_v3/task_bar_manager.cpp index 70d2d9fe7..713a9d07b 100644 --- a/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -180,7 +181,7 @@ public: if (pVT != NULL) { if (it != acmap.end()) - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toString()); else pVT->setText(CI18N::get("uiNotAssigned")); } diff --git a/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp b/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp index cbfdf8f42..83b413b7d 100644 --- a/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp +++ b/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -62,7 +63,7 @@ bool CViewBitmapFaberMp::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_noitem" ); if (prop) { - _TextureNoItemName = toLower((const char *) prop); + _TextureNoItemName = toLowerAscii((const char *) prop); _TextureNoItemId = -2; } @@ -110,13 +111,13 @@ void CViewBitmapFaberMp::draw () ///\todo nico : draw icon /*xOffset+=_XReal; yOffset+=_YReal; - _SheetText->setText(ucstring(toString(_SheetId.getSInt32()))); + _SheetText->setText(toString(_SheetId.getSInt32())); _SheetText->draw(xOffset,yOffset+20); - _QuantityText->setText(ucstring(toString(_Quantity.getSInt32()))); + _QuantityText->setText(toString(_Quantity.getSInt32())); _QuantityText->draw(xOffset,yOffset+10); - _QualityText->setText(ucstring(toString(_Quality.getSInt32()))); + _QualityText->setText(toString(_Quality.getSInt32())); _QualityText->draw(xOffset,yOffset); */ diff --git a/ryzom/client/src/interface_v3/view_radar.cpp b/ryzom/client/src/interface_v3/view_radar.cpp index ea9f5286b..eb50cc664 100644 --- a/ryzom/client/src/interface_v3/view_radar.cpp +++ b/ryzom/client/src/interface_v3/view_radar.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -104,7 +105,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)spotTextureNames[i] ); if (prop) { - txName = toLower((const char *) prop); + txName = toLowerAscii((const char *) prop); } _SpotDescriptions[i].TextureId.setTexture(txName.c_str()); rVR.getTextureSizeFromId (_SpotDescriptions[i].TextureId, _SpotDescriptions[i].TxW, _SpotDescriptions[i].TxH); @@ -113,7 +114,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)spotMiniTextureNames[i] ); if (prop) { - txName = toLower((const char *) prop); + txName = toLowerAscii((const char *) prop); } _SpotDescriptions[i].MiniTextureId.setTexture(txName.c_str()); rVR.getTextureSizeFromId (_SpotDescriptions[i].MiniTextureId, _SpotDescriptions[i].MTxW, _SpotDescriptions[i].MTxH); diff --git a/ryzom/client/src/interface_v3/view_radar.h b/ryzom/client/src/interface_v3/view_radar.h index cc0ffc1dc..fb11150bd 100644 --- a/ryzom/client/src/interface_v3/view_radar.h +++ b/ryzom/client/src/interface_v3/view_radar.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2015 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/item_group_manager.cpp b/ryzom/client/src/item_group_manager.cpp index 82a60f478..38461cc56 100644 --- a/ryzom/client/src/item_group_manager.cpp +++ b/ryzom/client/src/item_group_manager.cpp @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -93,7 +96,7 @@ void CItemGroup::addItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlot void CItemGroup::addRemove(std::string slotName) { - SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::stringToSlotEquipment(NLMISC::toUpper(slotName)); + SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::stringToSlotEquipment(NLMISC::toUpperAscii(slotName)); if(slot != SLOT_EQUIPMENT::UNDEFINED) addRemove(slot); } @@ -158,7 +161,7 @@ void CItemGroup::readFrom(xmlNodePtr node) ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"slot"); std::string slot; if (ptrName) NLMISC::fromString((const char*)ptrName, slot); - item.slot = SLOT_EQUIPMENT::stringToSlotEquipment(NLMISC::toUpper(slot)); + item.slot = SLOT_EQUIPMENT::stringToSlotEquipment(NLMISC::toUpperAscii(slot)); // Old read, keep for compatibility reasons ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"sheetName"); if (ptrName) NLMISC::fromString((const char*)ptrName, item.sheetName); @@ -301,10 +304,18 @@ bool CItemGroupManager::loadGroups() NLMISC::CIFile f; f.open(userGroupFileName); NLMISC::CIXml xmlStream; - xmlStream.init(f); - // Actual loading xmlNodePtr globalEnclosing; - globalEnclosing = xmlStream.getRootNode(); + try + { + xmlStream.init(f); + // Actual loading + globalEnclosing = xmlStream.getRootNode(); + } + catch (const NLMISC::EXmlParsingError &ex) + { + nlwarning("Failed to parse '%s', skip", userGroupFileName.c_str()); + return false; + } if(!globalEnclosing) { nlwarning("no root element in item_group xml, skipping xml parsing"); @@ -686,10 +697,9 @@ void CItemGroupManager::listGroup() for(int i=0;i<_Groups.size();i++) { CItemGroup group = _Groups[i]; - ucstring msg = NLMISC::CI18N::get("cmdListGroupLine"); - //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(group.name); + string msg = NLMISC::CI18N::get("cmdListGroupLine"); + //Use utf-8 string because group name can contain accentued characters (and stuff like that) + string nameUC = group.name; NLMISC::strFindReplace(msg, "%name", nameUC); NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size())); pIM->displaySystemInfo(msg); diff --git a/ryzom/client/src/light_cycle_manager.cpp b/ryzom/client/src/light_cycle_manager.cpp index 40b784cf2..2448bf1ae 100644 --- a/ryzom/client/src/light_cycle_manager.cpp +++ b/ryzom/client/src/light_cycle_manager.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index 244bb593c..e8ee2cbe4 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -203,7 +203,7 @@ void setLoginFinished( bool f ) // *************************************************************************** // Pop a fatal error message box, giving the option to 'quit' the client, plus a help button -static void fatalMessageBox(const ucstring &msg) +static void fatalMessageBox(const std::string &msg) { CInterfaceManager *im = CInterfaceManager::getInstance(); im->messageBoxWithHelp(msg, "ui:login", "login_quit"); @@ -211,7 +211,7 @@ static void fatalMessageBox(const ucstring &msg) // *************************************************************************** // Pop an error message box, giving the option to go back to main menu, plus a help button -static void errorMessageBox(const ucstring &msg) +static void errorMessageBox(const std::string &msg) { CInterfaceManager *im = CInterfaceManager::getInstance(); im->messageBoxWithHelp(msg, "ui:login", "on_back_to_login"); @@ -285,7 +285,7 @@ void initEula() } // *************************************************************************** -static void setDataScanLog(const ucstring &text) +static void setDataScanLog(const std::string &text) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log")); @@ -296,7 +296,7 @@ static void setDataScanLog(const ucstring &text) } // *************************************************************************** -static void setDataScanState(const ucstring &text, ucstring progress= ucstring()) +static void setDataScanState(const std::string &text, const std::string &progress = string()) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state")); @@ -336,7 +336,7 @@ void initReboot() // *************************************************************************** -static void setPatcherStateText(const std::string &baseUIPath, const ucstring &str) +static void setPatcherStateText(const std::string &baseUIPath, const std::string &str) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state")); @@ -347,7 +347,7 @@ static void setPatcherStateText(const std::string &baseUIPath, const ucstring &s } // *************************************************************************** -static void setPatcherProgressText(const std::string &baseUIPath, const ucstring &str) +static void setPatcherProgressText(const std::string &baseUIPath, const std::string &str) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress")); @@ -361,6 +361,7 @@ static void setPatcherProgressText(const std::string &baseUIPath, const ucstring static void updatePatchingInfoText(const std::string &baseUIPath) { CPatchManager *pPM = CPatchManager::getInstance(); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); if (isBGDownloadEnabled()) { @@ -368,7 +369,7 @@ static void updatePatchingInfoText(const std::string &baseUIPath) if (bgDownloader.getDownloadThreadPriority() == BGDownloader::ThreadPriority_Paused) { setPatcherStateText(baseUIPath, CI18N::get("uiBGD_Paused")); - setPatcherProgressText(baseUIPath, ucstring()); + setPatcherProgressText(baseUIPath, string()); } else { @@ -379,14 +380,15 @@ static void updatePatchingInfoText(const std::string &baseUIPath) } else { - setPatcherProgressText(baseUIPath, ucstring()); + setPatcherProgressText(baseUIPath, string()); } } } else +#endif { - ucstring state; - vector log; + string state; + vector log; if(pPM->getThreadState(state, log)) { setPatcherStateText(baseUIPath, state); @@ -396,7 +398,7 @@ static void updatePatchingInfoText(const std::string &baseUIPath) } else { - setPatcherProgressText(baseUIPath, ucstring()); + setPatcherProgressText(baseUIPath, string()); } } } @@ -410,7 +412,9 @@ void loginMainLoop() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance(); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); +#endif bool windowBlinkDone = false; bool fatalMessageBoxShown = false; @@ -467,21 +471,24 @@ void loginMainLoop() bool res = false; BGDownloader::TTaskResult taskResult = BGDownloader::TaskResult_Unknown; bool finished = false; - ucstring bgDownloaderError; +#ifdef RYZOM_BG_DOWNLOADER + string bgDownloaderError; if (isBGDownloadEnabled()) { finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); } else +#endif { finished = pPM->isCheckThreadEnded(res); } if (finished) { - setPatcherStateText("ui:login:checking", ucstring()); - setPatcherProgressText("ui:login:checking", ucstring()); + setPatcherStateText("ui:login:checking", string()); + setPatcherProgressText("ui:login:checking", string()); +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { AvailablePatchs = bgDownloader.getAvailablePatchs(); @@ -533,6 +540,7 @@ void loginMainLoop() } else +#endif { if(res) { @@ -557,7 +565,7 @@ void loginMainLoop() } else { - ucstring errMsg = CI18N::get("uiErrChecking"); + string errMsg = CI18N::get("uiErrChecking"); if (!pPM->getLastErrorMessage().empty()) { errMsg = pPM->getLastErrorMessage(); @@ -600,14 +608,14 @@ void loginMainLoop() setDataScanState(CI18N::get("uiScanDataSucess")); else { - ucstring fmt= CI18N::get("uiScanDataErrors"); + string fmt= CI18N::get("uiScanDataErrors"); strFindReplace(fmt, "%d", toString(numFiles)); setDataScanState(fmt); } } else { - ucstring errMsg = CI18N::get("uiErrDataScanning"); + string errMsg = CI18N::get("uiErrDataScanning"); if (!pPM->getLastErrorMessage().empty()) { errMsg = pPM->getLastErrorMessage(); @@ -616,7 +624,7 @@ void loginMainLoop() } // the log may have changed - ucstring dsLog; + string dsLog; if(pPM->getDataScanLog(dsLog)) setDataScanLog(dsLog); } @@ -624,8 +632,8 @@ void loginMainLoop() else { // update inteface content - ucstring state; - vector log; + string state; + vector log; // get state if(pPM->getThreadState(state, log)) { @@ -633,7 +641,7 @@ void loginMainLoop() setDataScanState(state, toString("%d/%d", pPM->getCurrentFilesToGet(), pPM->getTotalFilesToGet())); } // set special data scan log - ucstring dsLog; + string dsLog; if(pPM->getDataScanLog(dsLog)) setDataScanLog(dsLog); } @@ -646,14 +654,14 @@ void loginMainLoop() int currentPatchingSize; int totalPatchSize; - +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { currentPatchingSize = bgDownloader.getPatchingSize(); totalPatchSize = bgDownloader.getTotalSize(); BGDownloader::TTaskResult taskResult; bool finished = false; - ucstring bgDownloaderError; + string bgDownloaderError; finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); if (finished) { @@ -666,8 +674,8 @@ void loginMainLoop() if (taskResult == BGDownloader::TaskResult_Error) { - setPatcherStateText("ui:login:patching", ucstring()); - setPatcherProgressText("ui:login:patching", ucstring()); + setPatcherStateText("ui:login:patching", string()); + setPatcherProgressText("ui:login:patching", string()); if (!fatalMessageBoxShown) { @@ -687,6 +695,7 @@ void loginMainLoop() } } else +#endif { totalPatchSize = TotalPatchSize; currentPatchingSize = pPM->getPatchingSize(); @@ -699,7 +708,7 @@ void loginMainLoop() } else { - ucstring errMsg = CI18N::get("uiErrPatchApply"); + string errMsg = CI18N::get("uiErrPatchApply"); if (!pPM->getLastErrorMessage().empty()) { errMsg = pPM->getLastErrorMessage(); @@ -718,7 +727,7 @@ void loginMainLoop() } CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE_PATCH)); - ucstring sTmp; + string sTmp; sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); if (pVT != NULL) pVT->setText(sTmp); @@ -797,7 +806,7 @@ void initLoginScreen() // version std::string ext; - if (ClientApp.find("ryzom_") != ucstring::npos) + if (ClientApp.find("ryzom_") != string::npos) ext = " (" + ClientApp.substr(6) + ")"; CViewText *pV = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:ver_value")); @@ -1134,22 +1143,26 @@ void initPatchCheck() LoginShardId = Shards[ShardSelected].ShardId; } +#ifdef RYZOM_BG_DOWNLOADER if (!isBGDownloadEnabled()) +#endif { getPatchParameters(url, ver, patchURIs); pPM->init(patchURIs, url, ver); pPM->startCheckThread(true /* include background patchs */); } +#ifdef RYZOM_BG_DOWNLOADER else { BGDownloader::CTaskDesc taskDesc(BGDownloader::DLState_CheckPatch); CBGDownloaderAccess::getInstance().requestDownloadThreadPriority(BGDownloader::ThreadPriority_Normal, false); CBGDownloaderAccess::getInstance().startTask(taskDesc, getBGDownloaderCommandLine(), true /* showDownloader */); } +#endif NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); - setPatcherStateText("ui:login:checking", ucstring()); - setPatcherProgressText("ui:login:checking", ucstring()); + setPatcherStateText("ui:login:checking", string()); + setPatcherProgressText("ui:login:checking", string()); } void initShardDisplay() @@ -1215,9 +1228,10 @@ void initShardDisplay() { CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but")); if (pCB != NULL) + { pCB->setPushed(true); - CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); - + CAHManager::getInstance()->runActionHandler(pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); + } } pList->invalidateCoords(); } @@ -1382,8 +1396,8 @@ class CAHOnLogin : public IActionHandler return; } - LoginLogin = pGEBLog->getInputStringAsStdString(); - LoginPassword = pGEBPwd->getInputStringAsStdString(); + LoginLogin = pGEBLog->getInputString(); + LoginPassword = pGEBPwd->getInputString(); onlogin(); } @@ -1653,8 +1667,9 @@ void initPatch() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance(); - +#ifdef RYZOM_BG_DOWNLOADER if (!isBGDownloadEnabled()) +#endif { // Get the list of optional categories to patch vector vCategories; @@ -1689,6 +1704,7 @@ void initPatch() } pPM->startPatchThread(vCategories, true); } +#ifdef RYZOM_BG_DOWNLOADER else { // NB : here we only do a part of the download each time @@ -1698,14 +1714,15 @@ void initPatch() NLMISC::CBigFile::getInstance().removeAll(); NLMISC::CStreamedPackageManager::getInstance().unloadAll(); } +#endif NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); CInterfaceElement *closeBtn = CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CLOSE_PATCH); if (closeBtn) closeBtn->setActive(false); - setPatcherStateText("ui:login:patching", ucstring()); - setPatcherProgressText("ui:login:patching", ucstring()); + setPatcherStateText("ui:login:patching", string()); + setPatcherProgressText("ui:login:patching", string()); } // *************************************************************************** @@ -1843,11 +1860,13 @@ class CAHReboot : public IActionHandler CInterfaceManager *im = CInterfaceManager::getInstance(); try { +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { CBGDownloaderAccess::getInstance().reboot(); } else +#endif { CPatchManager::getInstance()->reboot(); } @@ -1863,7 +1882,7 @@ class CAHReboot : public IActionHandler } catch (const std::exception &e) { - im->messageBoxWithHelp(ucstring::makeFromUtf8(e.what()), "ui:login", "login_quit"); + im->messageBoxWithHelp(e.what(), "ui:login", "login_quit"); } } }; @@ -2265,7 +2284,7 @@ void initDataScan() CPatchManager *pPM = CPatchManager::getInstance(); // reset the log - setDataScanLog(ucstring()); + setDataScanLog(string()); // Start Scanning pPM->startScanDataThread(); @@ -2345,10 +2364,6 @@ inline string parseTooltip(const string & initString, const string & tagName) tooltip = tooltip.substr(0, tooltip.find("<")); } - ucstring uc; - uc.fromUtf8(tooltip);; - tooltip = uc.toString(); - return tooltip; } @@ -2368,10 +2383,6 @@ inline string parseCommentError(const string & initString, const string & tagNam error = error.substr(0, error.find("<")); } - ucstring uc; - uc.fromUtf8(error);; - error = uc.toString(); - return error; } @@ -2403,7 +2414,7 @@ bool initCreateAccount() { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); if(eb) - eb->setInputString(ucstring("")); + eb->setInputString(std::string()); } // conditions button @@ -2433,26 +2444,26 @@ bool initCreateAccount() if(!CurlHttpClient.sendGet(url, params, pPM->isVerboseLog())) { - ucstring errorMessage("Can't send (error code 60)"); + string errorMessage("Can't send (error code 60)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return false; } string res; if(!CurlHttpClient.receive(res, pPM->isVerboseLog())) { - ucstring errorMessage("Can't receive (error code 61)"); + string errorMessage("Can't receive (error code 61)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return false; } if(res.empty()) { - ucstring errorMessage("Empty result (error code 13)"); + string errorMessage("Empty result (error code 13)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return false; } @@ -2590,7 +2601,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); if(eb) - results[i] = eb->getInputString().toUtf8(); + results[i] = eb->getInputString(); } // text @@ -2609,9 +2620,9 @@ class CAHOnCreateAccountSubmit : public IActionHandler if (!CurlHttpClient.connect(url)) { - ucstring errorMessage("Can't connect"); + string errorMessage("Can't connect"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } @@ -2636,26 +2647,26 @@ class CAHOnCreateAccountSubmit : public IActionHandler if(!CurlHttpClient.sendPost(url, params, pPM->isVerboseLog())) { - ucstring errorMessage("Can't send (error code 60)"); + string errorMessage("Can't send (error code 60)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } string res; if(!CurlHttpClient.receive(res, pPM->isVerboseLog())) { - ucstring errorMessage("Can't receive (error code 61)"); + string errorMessage("Can't receive (error code 61)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } if(res.empty()) { - ucstring errorMessage("Empty result (error code 13)"); + string errorMessage("Empty result (error code 13)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } @@ -2744,11 +2755,11 @@ class CAHCreateAccountLogin : public IActionHandler { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId("eb_login:eb")); if(eb) - LoginLogin = eb->getInputString().toUtf8(); + LoginLogin = eb->getInputString(); eb = dynamic_cast(createAccountUI->findFromShortId("eb_password:eb")); if(eb) - LoginPassword = eb->getInputString().toUtf8(); + LoginPassword = eb->getInputString(); onlogin(false); } @@ -3294,7 +3305,7 @@ void loginIntro() if (i != 0) { beginLoading(IntroNVidia); - ucstring nmsg(""); + string nmsg(""); ProgressBar.newMessage (nmsg); } @@ -3320,7 +3331,7 @@ void loginIntro() Driver->AsyncListener.isKeyPushed (KeySPACE)) break; - const ucstring nmsg(""); + const string nmsg(""); ProgressBar.newMessage (nmsg); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); diff --git a/ryzom/client/src/login_patch.cpp b/ryzom/client/src/login_patch.cpp index f21d84bb7..a38791f7e 100644 --- a/ryzom/client/src/login_patch.cpp +++ b/ryzom/client/src/login_patch.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2014 Matthew LAGOE (Botanic) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -189,7 +189,7 @@ void CPatchManager::setClientRootPath(const std::string& clientRootPath) } // **************************************************************************** -void CPatchManager::setErrorMessage(const ucstring &message) +void CPatchManager::setErrorMessage(const std::string &message) { _ErrorMessage = message; } @@ -656,7 +656,7 @@ bool CPatchManager::isPatchThreadEnded (bool &ok) // **************************************************************************** // Called in main thread -bool CPatchManager::getThreadState (ucstring &stateOut, vector &stateLogOut) +bool CPatchManager::getThreadState (std::string &stateOut, vector &stateLogOut) { if ((PatchThread == NULL) && (CheckThread == NULL) && (ScanDataThread==NULL)) return false; @@ -685,7 +685,7 @@ bool CPatchManager::getThreadState (ucstring &stateOut, vector &stateL // verbose log if (isVerboseLog() && !stateLogOut.empty()) for (uint32 i = 0; i < stateLogOut.size(); ++i) - nlinfo("%s", stateLogOut[i].toUtf8().c_str()); + nlinfo("%s", stateLogOut[i].c_str()); return changed; } @@ -1035,6 +1035,7 @@ void CPatchManager::executeBatchFile() // make script executable CFile::setRWAccess(batchFilename); + CFile::setExecutable(batchFilename); // append login, password and shard if (!LoginLogin.empty()) @@ -1120,28 +1121,28 @@ float CPatchManager::getCurrentFileProgress() const // **************************************************************************** void CPatchManager::setRWAccess (const string &filename, bool bThrowException) { - ucstring s = CI18N::get("uiSetAttrib") + " " + CFile::getFilename(filename); + string s = CI18N::get("uiSetAttrib") + " " + CFile::getFilename(filename); setState(true, s); if (!NLMISC::CFile::setRWAccess(filename) && bThrowException) { s = CI18N::get("uiAttribErr") + " " + CFile::getFilename(filename) + " (" + toString(errno) + "," + strerror(errno) + ")"; setState(true, s); - throw Exception (s.toUtf8()); + throw Exception (s); } } // **************************************************************************** string CPatchManager::deleteFile (const string &filename, bool bThrowException, bool bWarning) { - ucstring s = CI18N::get("uiDelFile") + " " + CFile::getFilename(filename); + string s = CI18N::get("uiDelFile") + " " + CFile::getFilename(filename); setState(true, s); if (!NLMISC::CFile::fileExists(filename)) { s = CI18N::get("uiDelNoFile"); setState(true, s); - return s.toUtf8(); + return s; } if (!NLMISC::CFile::deleteFile(filename)) @@ -1150,8 +1151,8 @@ string CPatchManager::deleteFile (const string &filename, bool bThrowException, if(bWarning) setState(true, s); if(bThrowException) - throw Exception (s.toUtf8()); - return s.toUtf8(); + throw Exception (s); + return s; } return ""; } @@ -1159,20 +1160,20 @@ string CPatchManager::deleteFile (const string &filename, bool bThrowException, // **************************************************************************** void CPatchManager::renameFile (const string &src, const string &dst) { - ucstring s = CI18N::get("uiRenameFile") + " " + NLMISC::CFile::getFilename(src); + string s = CI18N::get("uiRenameFile") + " " + NLMISC::CFile::getFilename(src); setState(true, s); if (!NLMISC::CFile::moveFile(dst, src)) { s = CI18N::get("uiRenameErr") + " " + src + " -> " + dst + " (" + toString(errno) + "," + strerror(errno) + ")"; setState(true, s); - throw Exception (s.toUtf8()); + throw Exception (s); } } // **************************************************************************** // Take care this function is called by the thread -void CPatchManager::setState (bool bOutputToLog, const ucstring &ucsNewState) +void CPatchManager::setState (bool bOutputToLog, const string &ucsNewState) { { CSynchronized::CAccessor as(&State); @@ -1355,7 +1356,7 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const try { - ucstring s = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename(srcName); + string s = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename(srcName); setState(true, s); // get the new file @@ -1377,13 +1378,13 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const // if emergency patch server, this is a real issue, rethrow exception if (UsedServer < 0) { - ucstring s = CI18N::get("uiDLFailed"); + string s = CI18N::get("uiDLFailed"); setState(true, s); throw Exception(e.what()); } - ucstring s = CI18N::get("uiDLURIFailed") + " " + serverDisplayPath; + string s = CI18N::get("uiDLURIFailed") + " " + serverDisplayPath; setState(true, s); // this server is unavailable @@ -1397,7 +1398,7 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const // scanned all servers? use alternative if (nextServer == UsedServer) { - ucstring s = CI18N::get("uiNoMoreURI"); + string s = CI18N::get("uiNoMoreURI"); setState(true, s); UsedServer = -1; nlwarning("EXCEPTION CATCH: getServerFile() failed - no alternative found"); @@ -1422,7 +1423,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de try { #ifdef USE_CURL - ucstring s = CI18N::get("uiDLWithCurl") + " " + CFile::getFilename(dest); + string s = CI18N::get("uiDLWithCurl") + " " + CFile::getFilename(dest); setState(true, s); // user agent = nel_launcher @@ -1430,7 +1431,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de CURL *curl; CURLcode res; - ucstring sTranslate = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename (source); + string sTranslate = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename (source); setState(true, sTranslate); CurrentFile = NLMISC::CFile::getFilename (source); @@ -1551,7 +1552,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de void CPatchManager::downloadFile (const string &source, const string &dest, NLMISC::IProgressCallback *progress) { // For the moment use only curl - const string sourceLower = toLower(source.substr(0, 6)); + const string sourceLower = toLowerAscii(source.substr(0, 6)); if (startsWith(sourceLower, "http:") || startsWith(sourceLower, "https:") @@ -1579,7 +1580,7 @@ void CPatchManager::downloadFile (const string &source, const string &dest, NLMI void CPatchManager::decompressFile (const string &filename) { - ucstring sTranslate = CI18N::get("uiDecompressing") + " " + NLMISC::CFile::getFilename(filename); + string sTranslate = CI18N::get("uiDecompressing") + " " + NLMISC::CFile::getFilename(filename); setState(true, sTranslate); //if(isVerboseLog()) nlinfo("Calling gzopen('%s','rb')", filename.c_str()); @@ -1677,7 +1678,7 @@ void CPatchManager::applyDate (const string &sFilename, uint32 nDate) if(nDate != 0) { setRWAccess(sFilename, false); - ucstring s = CI18N::get("uiChangeDate") + " " + NLMISC::CFile::getFilename(sFilename) + " " + timestampToHumanReadable(NLMISC::CFile::getFileModificationDate (sFilename)) + + string s = CI18N::get("uiChangeDate") + " " + NLMISC::CFile::getFilename(sFilename) + " " + timestampToHumanReadable(NLMISC::CFile::getFileModificationDate (sFilename)) + " -> " + timestampToHumanReadable(nDate); setState(true,s); @@ -1799,7 +1800,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, // If the version cannot be found with size and time try with sha1 if (nVersionFound == 0xFFFFFFFF) { - ucstring sTranslate = CI18N::get("uiCheckInt") + " " + rFilename; + string sTranslate = CI18N::get("uiCheckInt") + " " + rFilename; setState(true, sTranslate); CHashKey hkLocalSHA1 = getSHA1(sFilePath); for (j = 0; j < rFile.versionCount(); ++j) @@ -1819,7 +1820,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, // No version available found if (nVersionFound == 0xFFFFFFFF) { - ucstring sTranslate = CI18N::get("uiNoVersionFound"); + string sTranslate = CI18N::get("uiNoVersionFound"); setState(true, sTranslate); // Get all patches from beginning (first patch is reference file) ftpOut.FileName = rFilename; @@ -1840,7 +1841,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, } else // A version of the file has been found { - ucstring sTranslate = CI18N::get("uiVersionFound") + " " + toString(nVersionFound); + string sTranslate = CI18N::get("uiVersionFound") + " " + toString(nVersionFound); setState(true, sTranslate); // Get All patches from this version ! ftpOut.FileName = rFilename; @@ -1896,7 +1897,7 @@ bool CPatchManager::bnpUnpack(const string &srcBigfile, const string &dstPath, v else DestPath = CPath::standardizePath (dstPath); - ucstring s = CI18N::get("uiUnpack") + " " + NLMISC::CFile::getFilename(SourceName); + string s = CI18N::get("uiUnpack") + " " + NLMISC::CFile::getFilename(SourceName); setState(true,s); // Read Header of the BNP File @@ -1905,7 +1906,7 @@ bool CPatchManager::bnpUnpack(const string &srcBigfile, const string &dstPath, v if (!bnpFile.readHeader()) { - ucstring s = CI18N::get("uiUnpackErrHead") + " " + CFile::getFilename(SourceName); + string s = CI18N::get("uiUnpackErrHead") + " " + CFile::getFilename(SourceName); setState(true,s); return false; } @@ -1944,15 +1945,15 @@ int CPatchManager::validateProgress(void *foo, double t, double d, double /* ult if (units.empty()) { - units.push_back(CI18N::get("uiByte").toUtf8()); - units.push_back(CI18N::get("uiKb").toUtf8()); - units.push_back(CI18N::get("uiMb").toUtf8()); + units.push_back(CI18N::get("uiByte")); + units.push_back(CI18N::get("uiKb")); + units.push_back(CI18N::get("uiMb")); } CPatchManager *pPM = CPatchManager::getInstance(); double pour1 = t!=0.0?d*100.0/t:0.0; - ucstring sTranslate = CI18N::get("uiLoginGetFile") + ucstring::makeFromUtf8(toString(" %s : %s / %s (%.02f %%)", NLMISC::CFile::getFilename(pPM->CurrentFile).c_str(), - NLMISC::bytesToHumanReadableUnits((uint64)d, units).c_str(), NLMISC::bytesToHumanReadableUnits((uint64)t, units).c_str(), pour1)); + string sTranslate = CI18N::get("uiLoginGetFile") + toString(" %s : %s / %s (%.02f %%)", NLMISC::CFile::getFilename(pPM->CurrentFile).c_str(), + NLMISC::bytesToHumanReadableUnits((uint64)d, units).c_str(), NLMISC::bytesToHumanReadableUnits((uint64)t, units).c_str(), pour1); pPM->setState(false, sTranslate); if (foo) { @@ -1966,7 +1967,7 @@ void CPatchManager::MyPatchingCB::progress(float f) { CPatchManager *pPM = CPatchManager::getInstance(); double p = 100.0*f; - ucstring sTranslate = CI18N::get("uiApplyingDelta") + ucstring::makeFromUtf8(toString(" %s (%.02f %%)", CFile::getFilename(patchFilename).c_str(), p)); + string sTranslate = CI18N::get("uiApplyingDelta") + toString(" %s (%.02f %%)", CFile::getFilename(patchFilename).c_str(), p); pPM->setState(false, sTranslate); } @@ -2092,7 +2093,7 @@ uint CPatchManager::applyScanDataResult() } // *************************************************************************** -bool CPatchManager::getDataScanLog(ucstring &text) +bool CPatchManager::getDataScanLog(string &text) { text.clear(); bool changed= false; @@ -2105,7 +2106,7 @@ bool CPatchManager::getDataScanLog(ucstring &text) { for(uint i=0;igetClientVersion(); string sServerVersion = pPM->getServerVersion(); - ucstring sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; + string sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; sTranslate += CI18N::get("uiServerVersion") + " (" + sServerVersion + ")"; pPM->setState(true, sTranslate); @@ -2229,7 +2230,7 @@ void CCheckThread::run () for (i = 0; i < rDescFiles.fileCount(); ++i) { CPatchManager::SFileToPatch ftp; - sTranslate = CI18N::get("uiCheckingFile") + " " + ucstring::makeFromUtf8(rDescFiles.getFile(i).getFileName()); + sTranslate = CI18N::get("uiCheckingFile") + " " + rDescFiles.getFile(i).getFileName(); pPM->setState(true, sTranslate); // get list of patch to apply to this file. don't to a full checksum test if possible nlwarning(rDescFiles.getFile(i).getFileName().c_str()); @@ -2421,7 +2422,7 @@ void CCheckThread::run () catch (const Exception &e) { nlwarning("EXCEPTION CATCH: CCheckThread::run() failed"); - ucstring sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); + string sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); pPM->setState(true, CI18N::get("uiCheckEndWithErr")); pPM->setErrorMessage(sTranslate); CheckOk = false; @@ -2491,7 +2492,7 @@ void CPatchThread::run() CurrentFilePatched = 0.f; - ucstring sTranslate; + string sTranslate; try { // First do all ref files @@ -2549,7 +2550,7 @@ void CPatchThread::run() catch(const Exception &e) { nlwarning("EXCEPTION CATCH: CPatchThread::run() failed"); - pPM->setState(true, ucstring(e.what())); + pPM->setState(true, string(e.what())); sTranslate = CI18N::get("uiPatchEndWithErr"); bErr = true; } @@ -2662,7 +2663,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP) rFTP.LocalFileExists = false; } - ucstring sTranslate; + string sTranslate; sTranslate = CI18N::get("uiProcessing") + " " + rFTP.FileName; pPM->setState(true, sTranslate); @@ -3077,7 +3078,7 @@ void CScanDataThread::run () uint32 i; // Check if the client version is the same as the server version string sClientVersion = pPM->getClientVersion(); - ucstring sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; + string sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; pPM->setState(true, sTranslate); // For all bnp in the description file get all patches to apply @@ -3116,7 +3117,7 @@ void CScanDataThread::run () catch (const Exception &e) { nlwarning("EXCEPTION CATCH: CScanDataThread::run() failed"); - ucstring sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); + string sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); pPM->setState(true, sTranslate); CheckOk = false; Ended = true; @@ -3250,7 +3251,7 @@ bool CPatchManager::download(const std::string& patchFullname, const std::string catch ( const std::exception& e) { nlwarning("%s", e.what()); - pPM->setState(true, ucstring(e.what()) ); + pPM->setState(true, string(e.what()) ); return false; } @@ -3501,7 +3502,7 @@ void CDownloadThread::run() catch ( const std::exception& e) { nlwarning("%s", e.what()); - pPM->setState(true, ucstring(e.what()) ); + pPM->setState(true, string(e.what()) ); pPM->fatalError("uiCanNotDownload", patchName.c_str(), ""); } catch (...) @@ -3618,7 +3619,7 @@ void CInstallThread::run() catch ( const std::exception& e) { nlwarning("%s", e.what()); - pPM->setState(true, ucstring(e.what()) ); + pPM->setState(true, string(e.what()) ); pPM->fatalError("uiCanNotInstall", patchName.c_str(), ""); return; diff --git a/ryzom/client/src/login_patch.h b/ryzom/client/src/login_patch.h index 7c0a68b2d..89c848f0c 100644 --- a/ryzom/client/src/login_patch.h +++ b/ryzom/client/src/login_patch.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -56,7 +59,7 @@ public: class IPatchManagerStateListener { public: - virtual void setState (bool /* bOutputToLog */, const ucstring &/* ucsNewState */){} + virtual void setState (bool /* bOutputToLog */, const std::string &/* ucsNewState */){} }; // Get Info of file to install @@ -154,12 +157,12 @@ public: // Get the string information about what the threads are doing // Return true if the state has changed - bool getThreadState (ucstring &state, std::vector &stateLog); + bool getThreadState (std::string &state, std::vector &stateLog); /** Get the error message (filled after a patch of check) * May be empty if the cause of error is unknown or unhandled */ - const ucstring &getLastErrorMessage() { return _ErrorMessage; } + const std::string &getLastErrorMessage() { return _ErrorMessage; } // --------------------- // First Part : Checking @@ -235,7 +238,7 @@ public: uint applyScanDataResult(); // get the current info Log for data Scan (true if some change from last get, else text is not filled) - bool getDataScanLog(ucstring &text); + bool getDataScanLog(std::string &text); CProductDescriptionForClient &getDescFile() { return DescFile; } @@ -285,7 +288,7 @@ private: friend class CPatchThreadDownloadProgress; // Set the thread state (called by threads to let us know what they are doing) - void setState (bool bOutputToLog, const ucstring &ucsState); + void setState (bool bOutputToLog, const std::string &ucsState); void touchState(); /// Get the version of the server given during init() @@ -329,7 +332,7 @@ private: // add a file to the scan data log void addDataScanLogCorruptedFile(const SFileToPatch &ftp); void clearDataScanLog(); - static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate); + static void getCorruptedFileInfo(const SFileToPatch &ftp, std::string &sTranslate); static bool downloadAndUnpack(const std::string& patchPath, const std::string& sourceFilename, const std::string& extractPath, const std::string& tmpDirectory, uint32 timestamp); // Forward message to Installation Software @@ -403,7 +406,7 @@ private: std::vector FilesToPatch; std::vector OptionalCat; - ucstring _ErrorMessage; + std::string _ErrorMessage; // Threads CPatchThread *PatchThread; @@ -416,8 +419,8 @@ private: // State struct CState { - ucstring State; - std::vector StateLog; + std::string State; + std::vector StateLog; bool StateChanged; CState() { @@ -469,7 +472,7 @@ private: bool _StartRyzomAtEnd; public: // used by threads to signal error at the end of execution - void setErrorMessage(const ucstring &message); + void setErrorMessage(const std::string &message); }; /** diff --git a/ryzom/client/src/main_loop.cpp b/ryzom/client/src/main_loop.cpp index a62b72e73..492d54623 100644 --- a/ryzom/client/src/main_loop.cpp +++ b/ryzom/client/src/main_loop.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2016 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1100,6 +1100,7 @@ bool mainLoop() // Start Bench H_AUTO_USE ( RZ_Client_Main_Loop ) +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); @@ -1110,6 +1111,7 @@ bool mainLoop() unpauseBGDownloader(); } } +#endif FPU_CHECKER_ONCE @@ -1124,7 +1126,7 @@ bool mainLoop() // #define BAR_STEP_TP 2 ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.progress(0); ContinentMngr.select(UserEntity->pos(), ProgressBar); @@ -1165,7 +1167,7 @@ bool mainLoop() if (BanMsgCountdown < 0.f) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgPermanentlyBanned"); + string msg = CI18N::get("msgPermanentlyBanned"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); BanMsgCountdown = BanMsgRepeatTime; @@ -1281,7 +1283,9 @@ bool mainLoop() // Get Mouse Position. OldMouseX = MouseX; OldMouseY = MouseY; +#ifdef RYZOM_BG_DOWNLOADER updateBGDownloaderUI(); +#endif } // Get the pointer pos @@ -2532,9 +2536,6 @@ bool mainLoop() Actions.enable(true); EditActions.enable(true); - // For stoping the outgame music, start after 30 frames, and duration of 3 seconds - outgameFader = CMusicFader(60, 3); - // check for banned player if (testPermanentBanMarkers()) { @@ -2544,6 +2545,9 @@ bool mainLoop() } } + // For stoping the outgame music, start after 30 frames, and duration of 3 seconds + outgameFader = CMusicFader(60, 3); + // Short reinit of the main loop after farTP or character reselection Ping.init(); updateLightDesc(); @@ -3463,11 +3467,11 @@ NLMISC_COMMAND(dumpFontTexture, "Write font texture to file", "") { std::string fname = CFile::findNewFile("font-texture.tga"); TextContext->dumpCacheTexture(fname.c_str()); - im->displaySystemInfo(ucstring(fname + " created"), "SYS"); + im->displaySystemInfo(fname + " created", "SYS"); } else { - im->displaySystemInfo(ucstring("Error: TextContext == NULL"), "SYS"); + im->displaySystemInfo("Error: TextContext == NULL", "SYS"); } return true; } diff --git a/ryzom/client/src/main_loop_debug.cpp b/ryzom/client/src/main_loop_debug.cpp index ac29a3984..b4edaf5e9 100644 --- a/ryzom/client/src/main_loop_debug.cpp +++ b/ryzom/client/src/main_loop_debug.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2016 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -714,9 +714,9 @@ static std::string getActionKey(const char* name, const char* param = "") CActionsManager::TActionComboMap::const_iterator ite = acmap.find(CAction::CName(name, param)); if (ite != acmap.end()) - return ite->second.toUCString().toString(); + return ite->second.toString(); - return CI18N::get("uiNotAssigned").toString(); + return CI18N::get("uiNotAssigned"); } //--------------------------------------------------- diff --git a/ryzom/client/src/main_loop_utilities.cpp b/ryzom/client/src/main_loop_utilities.cpp index 4a4b2bc38..d93e24481 100644 --- a/ryzom/client/src/main_loop_utilities.cpp +++ b/ryzom/client/src/main_loop_utilities.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Jan BOON (Kaetemi) diff --git a/ryzom/client/src/mesh_camera_col_manager.cpp b/ryzom/client/src/mesh_camera_col_manager.cpp index 7a4452e38..96cedbf7e 100644 --- a/ryzom/client/src/mesh_camera_col_manager.cpp +++ b/ryzom/client/src/mesh_camera_col_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -108,7 +111,7 @@ void CMeshCameraColManager::instanceGroupAdded(NL3D::UInstanceGroup *ig) bool avoidCollisionInside= ig->dontCastShadowForInterior(i); bool avoidCollisionOutside= ig->dontCastShadowForExterior(i); // very special patch for the matis serre (grrrrrrrrrrrrr) - avoidCollisionOutside= avoidCollisionOutside || toLower(shapeName)== "ma_serre_interieur.shape"; + avoidCollisionOutside= avoidCollisionOutside || toLowerAscii(shapeName)== "ma_serre_interieur.shape"; // then send the result to the collision manager, and keep the mesh col id if succeed uint32 meshId= CollisionManager->addMeshInstanceCollision(colMesh, mat, avoidCollisionInside, avoidCollisionOutside); diff --git a/ryzom/client/src/misc.cpp b/ryzom/client/src/misc.cpp index ee247e921..2653c0e45 100644 --- a/ryzom/client/src/misc.cpp +++ b/ryzom/client/src/misc.cpp @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -871,21 +872,21 @@ bool setVect(CVector &vectToChange, const CVector &vect, bool compute, bool chec return true; }// setVect // -NLMISC::CRGBA interpClientCfgColor(const ucstring &src, ucstring &dest) +NLMISC::CRGBA interpClientCfgColor(const string &src, string &dest) { CRGBA color = CRGBA::White; if (src.size() >= 3) { - if (src[0] == (ucchar) '&') + if (src[0] == '&') { - ucstring::size_type nextPos = src.find((ucchar) '&', 1); - if (nextPos != ucstring::npos) + string::size_type nextPos = src.find('&', 1); + if (nextPos != string::npos) { std::string colorCode; colorCode.resize(nextPos - 1); for(uint k = 0; k < nextPos - 1; ++k) { - colorCode[k] = tolower((char) src[k + 1]); + colorCode[k] = tolower((char) src[k + 1]); // TODO: toLowerAscii } std::map::const_iterator it = ClientCfg.SystemInfoParams.find(colorCode); if (it != ClientCfg.SystemInfoParams.end()) @@ -911,7 +912,7 @@ NLMISC::CRGBA interpClientCfgColor(const ucstring &src, ucstring &dest) return color; } -std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAddSysByDefault) +std::string getStringCategory(const string &src, string &dest, bool alwaysAddSysByDefault) { std::string str = getStringCategoryIfAny(src, dest); if (alwaysAddSysByDefault) @@ -921,41 +922,41 @@ std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAd } -std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest) +std::string getStringCategoryIfAny(const string &src, string &dest) { std::string colorCode; if (src.size() >= 3) { - uint startPos = 0; + size_t startPos = 0; // Skip or if present at beginning - ucstring preTag; - const uint PreTagSize = 5; - const ucstring newTag(""); + string preTag; + const size_t PreTagSize = 5; + static const string newTag = ""; if ( (src.size() >= PreTagSize) && (src.substr( 0, PreTagSize ) == newTag) ) { startPos = PreTagSize; preTag = newTag; } - const ucstring chgTag(""); + static const string chgTag = ""; if ( (src.size() >= PreTagSize) && (src.substr( 0, PreTagSize ) == chgTag) ) { startPos = PreTagSize; preTag = chgTag; } - if (src[startPos] == (ucchar) '&') + if (src[startPos] == '&') { - ucstring::size_type nextPos = src.find((ucchar) '&', startPos+1); - if (nextPos != ucstring::npos) + string::size_type nextPos = src.find('&', startPos+1); + if (nextPos != string::npos) { - uint codeSize = (uint)nextPos - startPos - 1; + size_t codeSize = nextPos - startPos - 1; colorCode.resize( codeSize ); - for(uint k = 0; k < codeSize; ++k) + for(ptrdiff_t k = 0; k < (ptrdiff_t)codeSize; ++k) { - colorCode[k] = tolower((char) src[k + startPos + 1]); + colorCode[k] = tolower((char) src[k + startPos + 1]); // TODO: toLowerAscii } - ucstring destTmp; + string destTmp; if ( startPos != 0 ) destTmp = preTag; // leave or in the dest string destTmp += src.substr(nextPos + 1); @@ -980,7 +981,7 @@ std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest) // *************************************************************************** -sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1) +sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1) // OLD { // start const ucchar *start1= s1.c_str(); diff --git a/ryzom/client/src/misc.h b/ryzom/client/src/misc.h index 49127d100..6ac9c1730 100644 --- a/ryzom/client/src/misc.h +++ b/ryzom/client/src/misc.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -165,11 +165,11 @@ bool setVect(NLMISC::CVector &vectToChange, const NLMISC::CVector &vect, bool co // read color from client cfg system info colors -NLMISC::CRGBA interpClientCfgColor(const ucstring &src, ucstring &dest); +NLMISC::CRGBA interpClientCfgColor(const std::string &src, std::string &dest); // Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return "SYS" -std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAddSysByDefault = true); +std::string getStringCategory(const std::string &src, std::string &dest, bool alwaysAddSysByDefault = true); // Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return "" -std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest); +std::string getStringCategoryIfAny(const std::string &src, std::string &dest); bool getRelativeFloatFromString(const std::string src, float &dst); void updateVector(const std::string part, NLMISC::CVector &dst, float value, bool add = false); @@ -193,8 +193,8 @@ enum TFilter3d RYZOM_MAX_FILTER_3D, }; -// compare 2 ucstring s0 and s1, without regard to case. give start and size for sequence p0 -sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1); +// compare 2 ucstring s0 and s1, without regard to case. give start and size for sequence p0 // OLD +sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1); // OLD /** Compute a non-continuous noise with uniform repartition in [0, 1], with the given noise object * By default repartition is not uniform for noise diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index c7a24ae2a..549732372 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -148,7 +148,7 @@ extern bool CharNameValidArrived; extern bool CharNameValid; bool IsInRingSession = false; TSessionId HighestMainlandSessionId; // highest in the position stack -ucstring lastUniversMessage; +std::string lastUniversMessage; extern const char *CDBBankNames[INVALID_CDB_BANK+1]; @@ -406,7 +406,7 @@ void impulseUserChars(NLMISC::CBitMemStream &impulse) // if there's a new char for which a key set was wanted, create it now for (uint k = 0; k < CharacterSummaries.size(); ++k) { - if (toLower(CharacterSummaries[k].Name) == toLower(NewKeysCharNameValidated)) + if (toLower(CharacterSummaries[k].Name.toUtf8()) == toLower(NewKeysCharNameValidated)) { // first, stripes server name copyKeySet(lookupSrcKeyFile(GameKeySet), "save/keys_" + buildPlayerNameForSaveFile(NewKeysCharNameValidated) + ".xml"); @@ -602,24 +602,24 @@ void impulsePermanentUnban(NLMISC::CBitMemStream &impulse) class CInterfaceChatDisplayer : public CClientChatManager::IChatDisplayer { public: - virtual void displayChat(TDataSetIndex compressedSenderIndex, const ucstring &ucstr, const ucstring &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, ucstring &senderName, uint bubbleTimer=0); - virtual void displayTell(/*TDataSetIndex senderIndex, */const ucstring &ucstr, const ucstring &senderName); + virtual void displayChat(TDataSetIndex compressedSenderIndex, const std::string &ucstr, const std::string &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, std::string &senderName, uint bubbleTimer=0); + virtual void displayTell(/*TDataSetIndex senderIndex, */const std::string &ucstr, const std::string &senderName); virtual void clearChannel(CChatGroup::TGroupType mode, uint32 dynChatDbIndex); private: // Add colorization tag for sender name - void colorizeSender(ucstring &text, const ucstring &senderName, CRGBA baseColor); + void colorizeSender(string &text, const string &senderName, CRGBA baseColor); }; static CInterfaceChatDisplayer InterfaceChatDisplayer; -void CInterfaceChatDisplayer::colorizeSender(ucstring &text, const ucstring &senderName, CRGBA baseColor) +void CInterfaceChatDisplayer::colorizeSender(string &text, const string &senderName, CRGBA baseColor) { // find the sender/text separator to put color tags - ucstring::size_type pos = senderName.length() - 1; - if (pos != ucstring::npos) + string::size_type pos = senderName.length() - 1; + if (pos != string::npos) { - ucstring str; + string str; CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); @@ -632,30 +632,30 @@ void CInterfaceChatDisplayer::colorizeSender(ucstring &text, const ucstring &sen str += text.substr(pos+1); - text.swap(str); + text = str; } } // display a chat from network to interface -void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, const ucstring &ucstr, const ucstring &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, ucstring &senderName, uint bubbleTimer) +void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, const std::string &ucstr, const std::string &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, std::string &senderName, uint bubbleTimer) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring finalString; + string finalString; string stringCategory = getStringCategory(ucstr, finalString); bool bubbleWanted = true; // Subtract rawMessage from ucstr so that the 'sender' part remains. - ucstring senderPart = ucstr.luabind_substr(0, ucstr.length() - rawMessage.length()); + string senderPart = ucstr.substr(0, ucstr.length() - rawMessage.length()); // search a "{no_bubble}" tag { - ucstring::size_type index = finalString.find(ucstring("{no_bubble}")); + string::size_type index = finalString.find("{no_bubble}"); const size_t tokenSize= 11; // length of "{no_bubble}" - if (index != ucstring::npos) + if (index != string::npos) { bubbleWanted = false; - finalString = finalString.luabind_substr(0, index) + finalString.substr(index+tokenSize,finalString.size()); + finalString = finalString.substr(0, index) + finalString.substr(index+tokenSize,finalString.size()); } } @@ -667,9 +667,9 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // Remove all {break} for(;;) { - ucstring::size_type index = finalString.find(ucstring("{break}")); - if (index == ucstring::npos) break; - finalString = finalString.luabind_substr(0, index) + finalString.luabind_substr(index+7,finalString.size()); + string::size_type index = finalString.find("{break}"); + if (index == string::npos) break; + finalString = finalString.substr(0, index) + finalString.substr(index+7,finalString.size()); } // select DB @@ -700,7 +700,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (!stringCategory.empty() && stringCategory != "SYS") { map::const_iterator it; - it = ClientCfg.SystemInfoParams.find(toLower(stringCategory)); + it = ClientCfg.SystemInfoParams.find(toLowerAscii(stringCategory)); if (it != ClientCfg.SystemInfoParams.end()) { col = it->second.Color; @@ -718,10 +718,10 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // find the sender/text separator to put color tags if (senderPart.empty() && stringCategory == "emt") { - size_t pos = finalString.find(ucstring(": "), 0); - if (pos != ucstring::npos) + size_t pos = finalString.find(": ", 0); + if (pos != string::npos) { - senderPart = finalString.luabind_substr(0, pos + 2); + senderPart = finalString.substr(0, pos + 2); } } colorizeSender(finalString, senderPart, col); @@ -731,7 +731,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if( !stringCategory.empty() ) { map::const_iterator it; - it = ClientCfg.SystemInfoParams.find( toLower(stringCategory) ); + it = ClientCfg.SystemInfoParams.find( toLowerAscii(stringCategory) ); if( it != ClientCfg.SystemInfoParams.end() ) { if( !(*it).second.SysInfoFxName.empty() ) @@ -792,16 +792,16 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (pIM->getLogState()) { // Add dyn chan number before string - ucstring prefix("[" + NLMISC::toString(dbIndex) + "]"); + string prefix = "[" + NLMISC::toString(dbIndex) + "]"; // Find position to put the new string // After timestamp? - size_t pos = finalString.find(ucstring("]")); - size_t colonpos = finalString.find(ucstring(": @{")); + size_t pos = finalString.find("]"); + size_t colonpos = finalString.find(": @{"); // If no ] found or if found but after the colon (so part of the user chat) - if (pos == ucstring::npos || (colonpos < pos)) + if (pos == string::npos || (colonpos < pos)) { // No timestamp, so put it right after the color and add a space - pos = finalString.find(ucstring("}"));; + pos = finalString.find("}");; prefix += " "; } finalString = finalString.substr(0, pos + 1) + prefix + finalString.substr(pos + 1); @@ -809,28 +809,28 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (node && node->getValueBool()) { uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dbIndex); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - prefix = title.empty() ? ucstring("") : ucstring(" ") + title; - pos = finalString.find(ucstring("] ")); + prefix = (title.empty() ? "" : " ") + title; + pos = finalString.find("] "); finalString = finalString.substr(0, pos) + prefix + finalString.substr(pos); } } } else { - nlwarning("Dynamic chat %s not found for message: %s", dynChatId.toString().c_str(), finalString.toString().c_str()); + nlwarning("Dynamic chat %s not found for message: %s", dynChatId.toString().c_str(), finalString.c_str()); } } else { - ucstring::size_type index = finalString.find(ucstring("")); - if (index != ucstring::npos) + string::size_type index = finalString.find(""); + if (index != string::npos) { bubbleWanted = false; finalString = finalString.substr(index+6,finalString.size()); - ucstring::size_type index2 = finalString.find(ucstring(" ")); - ucstring playerName; + string::size_type index2 = finalString.find(string(" ")); + string playerName; if (index2 < (finalString.size()-3)) { playerName = finalString.substr(0,index2); @@ -846,7 +846,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (playerName.empty()) { senderEntity->removeStateFx(); - senderEntity->setStateFx(finalString.toString()); + senderEntity->setStateFx(finalString); nlinfo("empty"); } else @@ -855,7 +855,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (destEntity) { destEntity->removeStateFx(); - destEntity->setStateFx(finalString.toString()); + destEntity->setStateFx(finalString); nlinfo("no empty"); } } @@ -882,7 +882,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // **** Process chat entry for the bubbles // todo hulud : registering a chat callback would be better than calling this hardcoded action handler - ucstring finalRawMessage; + string finalRawMessage; // remove color qualifier from raw string getStringCategory(rawMessage, finalRawMessage); if (bubbleWanted) @@ -908,7 +908,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c channel = "#" + toString((uint32)mode); } } - if (!stringCategory.empty() && NLMISC::toUpper(stringCategory) != "SYS") + if (!stringCategory.empty() && NLMISC::compareCaseInsensitive(stringCategory.c_str(), "SYS")) // Not empty and not 'SYS' { channel = channel + "/" + stringCategory; } @@ -918,13 +918,13 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // display a tell from network to interface -void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const ucstring &ucstr, const ucstring &senderName) +void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const std::string &ucstr, const std::string &senderName) { - ucstring finalString = ucstr; + string finalString = ucstr; // for now, '&' are removed by server so use another format until a special msg is made - if (strFindReplace(finalString, ucstring(""), ucstring())) + if (strFindReplace(finalString, "", string())) { CLuaManager::getInstance().executeLuaScript("RingAccessPoint:forceRefresh()"); } @@ -934,13 +934,13 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); bool windowVisible; - ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + string goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); // The sender part is up to and including the first ":" after the goodSenderName - ucstring::size_type pos = finalString.find(goodSenderName); + string::size_type pos = finalString.find(goodSenderName); pos = finalString.find(':', pos); pos = finalString.find(' ', pos); - ucstring senderPart = finalString.substr(0, pos+1); + string senderPart = finalString.substr(0, pos+1); colorizeSender(finalString, senderPart, prop.getRGBA()); PeopleInterraction.ChatInput.Tell.displayTellMessage(/*senderIndex, */finalString, goodSenderName, prop.getRGBA(), 2, &windowVisible); @@ -1021,7 +1021,7 @@ void inpulseDynStringInChatGroup(NLMISC::CBitMemStream &impulse) // impulse.serialBit(huff); // // uint32 index; -// ucstring ucstr; +// ucstring ucstr; // OLD // // impulse.serial( index ); // impulse.serial( ucstr ); @@ -1115,15 +1115,15 @@ void setFakeNews () CViewText *inter2 = (CViewText *)inter->getView("title0"); nlassert (inter2 != NULL); - inter2->setText(ucstring(shortNews[rnd*3])); + inter2->setText(ucstring(shortNews[rnd*3])); // OLD CViewText *inter3 = (CViewText *)inter->getView("title1"); nlassert (inter3 != NULL); - inter3->setText(ucstring(shortNews[rnd*3+1])); + inter3->setText(ucstring(shortNews[rnd*3+1])); // OLD CViewText *inter4 = (CViewText *)inter->getView("title2"); nlassert (inter4 != NULL); - inter4->setText(ucstring(shortNews[rnd*3+2])); + inter4->setText(ucstring(shortNews[rnd*3+2])); // OLD } { // set test for the neutral main string iname; @@ -1140,11 +1140,11 @@ void setFakeNews () CViewText *inter2 = (CViewText *)inter->getView("title0"); nlassert (inter2 != NULL); - inter2->setText(ucstring(shortNews[rnd*3])); + inter2->setText(ucstring(shortNews[rnd*3])); // OLD CViewText *inter3 = (CViewText *)inter->getView("title1"); nlassert (inter3 != NULL); - inter3->setText(ucstring(shortNews[rnd*3+1])); + inter3->setText(ucstring(shortNews[rnd*3+1])); // OLD } { // set test for the more news string iname; @@ -1161,15 +1161,15 @@ void setFakeNews () CViewText *inter2 = (CViewText *)inter->getView("title0"); nlassert (inter2 != NULL); - inter2->setText(ucstring(longNews[rnd*3])); + inter2->setText(ucstring(longNews[rnd*3])); // OLD CViewText *inter3 = (CViewText *)inter->getView("title1"); nlassert (inter3 != NULL); - inter3->setText(ucstring(longNews[rnd*3+1])); + inter3->setText(ucstring(longNews[rnd*3+1])); // OLD CViewText *inter4 = (CViewText *)inter->getView("title2"); nlassert (inter4 != NULL); - inter4->setText(ucstring(longNews[rnd*3+2])); + inter4->setText(ucstring(longNews[rnd*3+2])); // OLD } } } @@ -1186,7 +1186,7 @@ void setFakeNews () static void setupBotChatChoiceList(CInterfaceGroup *botChatGroup) { // Temp for test. Should then be read from server msg - std::vector choices; + std::vector choices; for(uint k = 0; k < 90; ++k) { choices.push_back("Choice " + toString(k)); @@ -1201,7 +1201,7 @@ static void setupBotChatChoiceList(CInterfaceGroup *botChatGroup) /* static void setupBotChatDescription(CInterfaceGroup *botChatGroup) { - ucstring desc; + string desc; for(uint k = 0; k < 90; ++k) { desc += "This is a multi line description. "; @@ -1222,7 +1222,7 @@ static void setupBotChatBotGift(CInterfaceGroup *botChatGroup) NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:0:QUALITY")->setValue32(0); NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:1:SHEET")->setValue32(CSheetId("fyros_sword_lvl_01_05.item").asInt()); NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:1:QUALITY")->setValue32(2); - CBotChat::setBotGift(botChatGroup, ucstring("Thanks to have succeeded the mission"), ucstring("Here's your reward"), ucstring("The bot has taken the object quest from your inventory")); + CBotChat::setBotGift(botChatGroup, "Thanks to have succeeded the mission", "Here's your reward", "The bot has taken the object quest from your inventory"); } */ @@ -1533,7 +1533,7 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) // start progress bar and display background ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); @@ -1588,8 +1588,8 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) R2::TTeleportContext tpContext = R2::TPContext_Unknown; - ucstring tpReason; - ucstring tpCancelText; + string tpReason; + string tpCancelText; try { @@ -1603,14 +1603,14 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) uint32 size = (uint32)tpInfos.TpReasonParams.size(); uint32 first = 0; - CSString str(tpReason.toString()); + CSString str(tpReason); for (;first != size ; ++first) { std::string value = tpInfos.TpReasonParams[first]; std::string key = NLMISC::toString("%%%u", first +1); str = str.replace( key.c_str(), value.c_str()); } - tpReason = ucstring(str); + tpReason = string(str); tpCancelText = CI18N::get(tpInfos.TpCancelTextId); tpContext = tpInfos.TpContext; } @@ -1618,16 +1618,16 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) } catch (const EStream &) { - tpReason = ucstring("TP Reason"); - tpCancelText = ucstring("Cancel TP"); // for test + tpReason = "TP Reason"; + tpCancelText = "Cancel TP"; // for test // try to deduce tp context from current editor mode switch (R2::getEditor().getMode()) { case R2::CEditor::EditionMode: case R2::CEditor::NotInitialized: tpContext = R2::TPContext_Unknown; - tpReason = ucstring(); - tpCancelText = ucstring(); + tpReason = string(); + tpCancelText = string(); break; case R2::CEditor::GoingToDMMode: case R2::CEditor::TestMode: @@ -1673,7 +1673,7 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) //InitMouseWithCursor(oldHardwareCursor); // reset 'cancel' button - ProgressBar.setTPMessages(ucstring(), ucstring(), ""); + ProgressBar.setTPMessages(string(), string(), ""); // ProgressBar.enableQuitButton(false); // TMP TMP @@ -1804,7 +1804,7 @@ void impulseTeamContactInit(NLMISC::CBitMemStream &impulse) { vector vFriendListName; vector vFriendListOnline; - vector vIgnoreListName; + vector vIgnoreListName; // TODO: UTF-8 (serial) impulse.serialCont(vFriendListName); uint32 nbState; @@ -2131,7 +2131,7 @@ void impulseWhere(NLMISC::CBitMemStream &impulse) sprintf(buf,"Your server position is : X= %g Y= %g Z= %g",xf,yf,zf); nlinfo(buf); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(buf)); + CInterfaceManager::getInstance()->displaySystemInfo(buf); }// impulseWhere // //----------------------------------------------- @@ -2142,9 +2142,9 @@ void impulseWhere(NLMISC::CBitMemStream &impulse) void impulseWho(NLMISC::CBitMemStream &impulse) { nlinfo("impulseWho Received"); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Players currently in the game :")); + CInterfaceManager::getInstance()->displaySystemInfo("Players currently in the game :"); - ucstring name; + ucstring name; // OLD uint32 loginId; uint16 dist; uint8 dirshort; @@ -2182,7 +2182,7 @@ void impulseWho(NLMISC::CBitMemStream &impulse) }; str = toString (" - uid %d - distance %hu meters - direction ", loginId, dist); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name + ucstring(str) + CI18N::get(txts[direction]))); + CInterfaceManager::getInstance()->displaySystemInfo(name + str + CI18N::get(txts[direction])); } }// impulseWho // */ @@ -2191,9 +2191,9 @@ void impulseWho(NLMISC::CBitMemStream &impulse) void impulseWhoGM(NLMISC::CBitMemStream &impulse) { nlinfo("impulseWhoGM Received"); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Players currently in the game :")); + CInterfaceManager::getInstance()->displaySystemInfo("Players currently in the game :"); - ucstring name; + ucstring name; // OLD uint32 loginId; uint16 dist; uint8 dirshort; @@ -2231,7 +2231,7 @@ void impulseWhoGM(NLMISC::CBitMemStream &impulse) }; str = toString (" - uid %d - distance %hu meters - direction ", loginId, dist); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name + ucstring(str) + CI18N::get(txts[direction]))); + CInterfaceManager::getInstance()->displaySystemInfo(name + str + CI18N::get(txts[direction])); } }// impulseWho // */ @@ -2305,11 +2305,9 @@ void impulsePhraseSend(NLMISC::CBitMemStream &impulse) void impulseStringResp(NLMISC::CBitMemStream &impulse) { uint32 stringId; - string strUtf8; + string str; impulse.serial(stringId); - impulse.serial(strUtf8); - ucstring str; - str.fromUtf8(strUtf8); + impulse.serial(str); if (PermanentlyBanned) return; @@ -2502,7 +2500,7 @@ void impulseRemoteAdmin (NLMISC::CBitMemStream &impulse) impulse.serial (cmd); // remove the 2 first rc character if exists, only there to say to the EGS that is a remote command - if (cmd.size()>2 && tolower(cmd[0])=='r' && tolower(cmd[1])=='c') + if (cmd.size()>2 && tolower(cmd[0])=='r' && tolower(cmd[1])=='c') // FIXME: toLowerAscii cmd = cmd.substr(2); mdDisplayVars.clear (); @@ -3123,12 +3121,12 @@ void impulsePVPChooseClan(NLMISC::CBitMemStream &impulse) CCtrlTextButton * butClan1 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan1")); if( butClan1 == NULL ) return; - butClan1->setText( ucstring(EGSPD::CPeople::toString( clan1 )) ); + butClan1->setText( EGSPD::CPeople::toString( clan1 ) ); CCtrlTextButton * butClan2 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan2")); if( butClan2 == NULL ) return; - butClan2->setText( ucstring(EGSPD::CPeople::toString( clan2 )) ); + butClan2->setText( EGSPD::CPeople::toString( clan2 ) ); } */ @@ -3276,8 +3274,8 @@ private: STRING_MANAGER::CStringManagerClient *pSMC= STRING_MANAGER::CStringManagerClient::instance(); // get the content string (should have been received!) - ucstring contentStr; - ucstring titleStr; + string contentStr; + string titleStr; if(!pSMC->getDynString(_TextId[ContentType], contentStr)) return; @@ -3304,8 +3302,8 @@ private: } if(i != digitMaxEnd) { - ucstring web_app = contentStr.substr(digitStart, i-digitStart); - contentStr = ucstring(ClientCfg.WebIgMainDomain + "/") + web_app + ucstring("/index.php?") + contentStr.substr((size_t)i + 1); + string web_app = contentStr.substr(digitStart, i-digitStart); + contentStr = string(ClientCfg.WebIgMainDomain + "/") + web_app + string("/index.php?") + contentStr.substr((size_t)i + 1); } else { @@ -3326,8 +3324,8 @@ private: if(i!=digitMaxEnd) { // get the width - ucstring digitStr= contentStr.substr(digitStart, i-digitStart); - fromString(digitStr.toString(), w); + string digitStr= contentStr.substr(digitStart, i-digitStart); + fromString(digitStr, w); // remove the first tag contentStr= contentStr.substr(i+1); } @@ -3339,7 +3337,7 @@ private: if (is_webig) { CGroupHTML *groupHtml; - string group = titleStr.toString(); + string group = titleStr; // group = group.substr(9, group.size()-10); groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+group+":content:html")); @@ -3362,7 +3360,7 @@ private: { if (group == "webig") pGC->setActive(true); - string url = contentStr.toString(); + string url = contentStr; addWebIGParams(url, true); groupHtml->browse(url.c_str()); CWidgetManager::getInstance()->setTopWindow(pGC); @@ -3398,7 +3396,7 @@ private: public: // called when the string is available - virtual void onDynStringAvailable(uint stringId, const ucstring &value) + virtual void onDynStringAvailable(uint stringId, const std::string &value) { // don't care if already displayed if(_AlreadyDisplayed) @@ -3473,7 +3471,7 @@ void impulseCombatFlyingHpDelta(NLMISC::CBitMemStream &impulse) CRGBA color((uint8)(rgba>>24&255), (uint8)(rgba>>16&255), (uint8)(rgba>>8&255), (uint8)(rgba&255)); CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(entityID); if (entity) - entity->addHPOutput(ucstring(toString("%d", hpDelta)), color); + entity->addHPOutput(toString("%d", hpDelta), color); } void impulseCombatFlyingTextItemSpecialEffectProc(NLMISC::CBitMemStream &impulse) @@ -3487,7 +3485,7 @@ void impulseCombatFlyingTextItemSpecialEffectProc(NLMISC::CBitMemStream &impulse impulse.serial(effect); impulse.serial(param); CRGBA color((uint8)(rgba>>24&255), (uint8)(rgba>>16&255), (uint8)(rgba>>8&255), (uint8)(rgba&255)); - ucstring text = CI18N::get(toString("uiItemSpecialEffectFlyingText%s", ITEM_SPECIAL_EFFECT::toString((ITEM_SPECIAL_EFFECT::TItemSpecialEffect)effect).c_str())); + string text = CI18N::get(toString("uiItemSpecialEffectFlyingText%s", ITEM_SPECIAL_EFFECT::toString((ITEM_SPECIAL_EFFECT::TItemSpecialEffect)effect).c_str())); strFindReplace(text, "%param", toString("%d", param)); CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(entityID); if (entity) @@ -3503,7 +3501,7 @@ void impulseCombatFlyingText(NLMISC::CBitMemStream &impulse) COMBAT_FLYING_TEXT::TCombatFlyingText type = (COMBAT_FLYING_TEXT::TCombatFlyingText)tmp; CRGBA color(255, 255, 255); - ucstring text(""); + string text(""); float dt = 0.0f; switch (type) @@ -4214,7 +4212,7 @@ std::string WebServer; NLMISC_COMMAND(localTellTeam, "Temp : simulate a tell in local mode", " ") { if (args.empty()) return false; - ucstring player = args[0]; + string player = args[0]; std::string msg; if (args.size() >= 2) { @@ -4225,7 +4223,7 @@ NLMISC_COMMAND(localTellTeam, "Temp : simulate a tell in local mode", " ") { if (args.empty()) return false; - ucstring player = args[0]; + string player = args[0]; std::string msg; if (args.size() >= 2) { @@ -4244,7 +4242,7 @@ NLMISC_COMMAND(localTell, "Temp : simulate a tell in local mode", " } } // TDataSetIndex dsi = INVALID_DATASET_ROW; - InterfaceChatDisplayer.displayTell(/*dsi, */ucstring(msg), player); + InterfaceChatDisplayer.displayTell(/*dsi, */msg, player); return true; } @@ -4350,7 +4348,7 @@ NLMISC_COMMAND(testDuelInvite, "","") //{ // uint32 index; // fromString(args[0], index); -// ucstring ucstr = args[1]; +// ucstring ucstr = args[1]; // OLD // // vector code; // diff --git a/ryzom/client/src/network_connection.cpp b/ryzom/client/src/network_connection.cpp index 4778641c0..bad168a60 100644 --- a/ryzom/client/src/network_connection.cpp +++ b/ryzom/client/src/network_connection.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/network_connection.h b/ryzom/client/src/network_connection.h index 84bb26d43..99b1bf699 100644 --- a/ryzom/client/src/network_connection.h +++ b/ryzom/client/src/network_connection.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/outpost.cpp b/ryzom/client/src/outpost.cpp index b345d36cb..9f9723b62 100644 --- a/ryzom/client/src/outpost.cpp +++ b/ryzom/client/src/outpost.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -99,7 +102,7 @@ void COutpost::initOutpost () for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -146,7 +149,7 @@ UInstanceGroup *getCluster(const UGlobalPosition &gp) if(strPos.empty()) return 0; // try to find the ig in the loaded ig map - std::map::const_iterator igIt = IGLoaded.find(toLower(strPos)); + std::map::const_iterator igIt = IGLoaded.find(toLowerAscii(strPos)); if (igIt != IGLoaded.end()) { return igIt->second; @@ -192,7 +195,7 @@ void releaseLandscapeIGCallbacks() void addPacsPrim(const std::string &fileName) { - std::string ppName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fileName)); + std::string ppName = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(fileName)); if (PacsPrims.find(ppName) != PacsPrims.end()) { nlwarning(("Pacs primitive " + ppName + " already has been inserted").c_str()); diff --git a/ryzom/client/src/player_cl.cpp b/ryzom/client/src/player_cl.cpp index eafdec032..304dd5726 100644 --- a/ryzom/client/src/player_cl.cpp +++ b/ryzom/client/src/player_cl.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -602,7 +603,7 @@ void CPlayerCL::equip(SLOTTYPE::EVisualSlot slot, uint index, uint color) if (!shapeLegs.empty() && shapeLegs.find("_caster01_") != std::string::npos) { - std::string tmpName = toLower(shapeName); + std::string tmpName = toLowerAscii(shapeName); std::string::size_type posBottes = tmpName.find("_bottes"); @@ -742,7 +743,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle * } // update title when gender changed - const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, _Gender == GSGENDER::female)); + const string replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, _Gender == GSGENDER::female); if (!replacement.empty() || !ClientCfg.DebugStringManager) { // Get extended name diff --git a/ryzom/client/src/player_r2_cl.cpp b/ryzom/client/src/player_r2_cl.cpp index 138e7d8fa..4fb1e1afb 100644 --- a/ryzom/client/src/player_r2_cl.cpp +++ b/ryzom/client/src/player_r2_cl.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -446,7 +447,7 @@ void CPlayerR2CL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle } // update title when gender changed - const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female)); + const string replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female)); if (!replacement.empty()) { // Get extended name diff --git a/ryzom/client/src/progress.cpp b/ryzom/client/src/progress.cpp index 67aa774f9..377e06ec7 100644 --- a/ryzom/client/src/progress.cpp +++ b/ryzom/client/src/progress.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -50,7 +50,7 @@ extern NL3D::UMaterial LoadingMaterialFull; extern std::vector LogoBitmaps; extern uint TipsOfTheDayIndex; -extern ucstring TipsOfTheDay; +extern string TipsOfTheDay; extern string NewsAtProgress; extern bool UseEscapeDuringLoading; @@ -72,7 +72,7 @@ void CProgress::setFontFactor(float temp) _FontFactor = temp; } -void CProgress::newMessage (const ucstring& message) +void CProgress::newMessage (const string& message) { popCropedValues (); _CurrentRootStep++; @@ -250,7 +250,7 @@ void CProgress::internalProgress (float value) for(uint i = 0; i < ClientCfg.Logos.size(); i++) { std::vector res; - explode(ClientCfg.Logos[i], std::string(":"), res); + explode(ClientCfg.Logos[i], string(":"), res); if(res.size()==9 && isetFontSize((uint)(16.f * fontFactor)); TextContext->setHotSpot(UTextContext::MiddleTop); - ucstring::size_type index = 0; - ucstring::size_type end = TipsOfTheDay.find((ucchar)'\n'); + string::size_type index = 0; + string::size_type end = TipsOfTheDay.find('\n'); if (end == string::npos) end = TipsOfTheDay.size(); float fY = ClientCfg.TipsY; @@ -298,22 +298,22 @@ void CProgress::internalProgress (float value) while (index < end) { // Get the line - ucstring line = TipsOfTheDay.substr (index, end-index); + string line = TipsOfTheDay.substr (index, end-index); // Draw the line TextContext->printAt(0.5f, fY, line); fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); index=end+1; - end = TipsOfTheDay.find((ucchar)'\n', index); - if (end == ucstring::npos) + end = TipsOfTheDay.find('\n', index); + if (end == string::npos) end = TipsOfTheDay.size(); } // More help TextContext->setFontSize((uint)(12.f * fontFactor)); /* todo tips of the day uncomment - ucstring ucstr = CI18N::get ("uiTipsEnd"); + string ucstr = CI18N::get ("uiTipsEnd"); TextContext->printAt(0.5f, fY, ucstr); */ fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); @@ -339,7 +339,7 @@ void CProgress::internalProgress (float value) TextContext->setFontSize((uint)(15.f * fontFactor)); TextContext->setHotSpot(UTextContext::BottomLeft); - ucstring uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText + ") - " + CI18N::get("uiDelayedTPCancel"); + string uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText + ") - " + CI18N::get("uiDelayedTPCancel"); UTextContext::CStringInfo info = TextContext->getStringInfo(uc); float stringX = 0.5f - info.StringWidth/(ClientCfg.Width*2); TextContext->printAt(stringX, 7.f / ClientCfg.Height, uc); @@ -355,17 +355,15 @@ void CProgress::internalProgress (float value) // Print some more info uint32 day = RT.getRyzomDay(); - str = toString (CI18N::get ("uiTipsTeleport").toUtf8().c_str(), - CI18N::get (LoadingContinent->LocalizedName).toUtf8().c_str(), + str = toString (CI18N::get ("uiTipsTeleport").c_str(), + CI18N::get (LoadingContinent->LocalizedName).c_str(), day, (uint)RT.getRyzomTime(), - CI18N::get ("uiSeason"+toStringEnum(CRyzomTime::getSeasonByDay(day))).toUtf8().c_str(), - CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName).toUtf8().c_str()); - ucstring ucstr; - ucstr.fromUtf8 (str); + CI18N::get ("uiSeason"+toStringEnum(CRyzomTime::getSeasonByDay(day))).c_str(), + CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName).c_str()); TextContext->setHotSpot(UTextContext::MiddleBottom); TextContext->setColor(CRGBA(186, 179, 163, 255)); - TextContext->printAt(0.5f, 25/768.f, ucstr); + TextContext->printAt(0.5f, 25/768.f, str); } // apply text commands @@ -387,17 +385,17 @@ void CProgress::internalProgress (float value) // build the ucstr(s) string text = (*itpc).Text; - ucstring ucstr; + string ucstr; if (text == "NEWS") - ucstr.fromUtf8(NewsAtProgress); + ucstr = NewsAtProgress; else ucstr = CI18N::get(text); - vector vucstr; - ucstring sep("\n"); - splitUCString(ucstr,sep,vucstr); + vector vucstr; + string sep("\n"); + splitString(ucstr,sep,vucstr); // Letter size - UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); + UTextContext::CStringInfo si = TextContext->getStringInfo("|"); uint fontHeight = (uint) si.StringHeight + 2; // we add 2 pixels for the gap uint i; @@ -457,8 +455,9 @@ void CProgress::internalProgress (float value) _TPCancelFlag = true; } - +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().update(); +#endif // Display to screen. Driver->swapBuffers(); @@ -479,7 +478,7 @@ void CProgress::internalProgress (float value) } -void CProgress::setTPMessages(const ucstring &tpReason,const ucstring &tpCancelText, const std::string &/* iconName */) +void CProgress::setTPMessages(const string &tpReason,const string &tpCancelText, const string &/* iconName */) { _TPReason = tpReason; _TPCancelText = tpCancelText; @@ -502,7 +501,7 @@ bool CProgress::getTPCancelFlag(bool clearFlag /*=true*/) void CProgress::release() { - setTPMessages(ucstring(), ucstring(), ""); + setTPMessages(string(), string(), string()); _TPCancelFlag = false; } diff --git a/ryzom/client/src/progress.h b/ryzom/client/src/progress.h index 2d50b573f..69e9901d4 100644 --- a/ryzom/client/src/progress.h +++ b/ryzom/client/src/progress.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -64,7 +67,7 @@ public: void finish (); // New message - void newMessage (const ucstring& message); + void newMessage (const std::string& message); void setFontFactor(float f); @@ -72,7 +75,7 @@ public: bool ApplyTextCommands; // Set teleport specific message - void setTPMessages(const ucstring &tpReason, const ucstring &tpCancelText, const std::string &iconName); + void setTPMessages(const std::string &tpReason, const std::string &tpCancelText, const std::string &iconName); bool getTPCancelFlag(bool clearFlag = true); @@ -83,7 +86,7 @@ private: // Display a text to describe what is the application going to do. // this function can be call even if texture is NULL, driver or textcontext not initialised - ucstring _ProgressMessage; + std::string _ProgressMessage; // Time since last update sint64 _LastUpdate; @@ -92,8 +95,8 @@ private: uint _CurrentRootStep; uint _RootStepCount; - ucstring _TPReason; - ucstring _TPCancelText; + std::string _TPReason; + std::string _TPCancelText; bool _TPCancelFlag; diff --git a/ryzom/client/src/r2/auto_group.cpp b/ryzom/client/src/r2/auto_group.cpp index 7372d6e48..7da977b3d 100644 --- a/ryzom/client/src/r2/auto_group.cpp +++ b/ryzom/client/src/r2/auto_group.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -276,12 +279,12 @@ void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPos getEditor().getDMC().flushActions(); return; } - ucstring readableName; + string readableName; CLuaState &ls = getEditor().getLua(); R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push(); if (ls.isString(-1)) - readableName.fromUtf8(ls.toString(-1)); - ucstring ucGroupName = ucstring(readableName + " " + CI18N::get("uiR2EDNameGroup").toUtf8()); + readableName = ls.toString(-1); + string ucGroupName = readableName + " " + CI18N::get("uiR2EDNameGroup"); newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8()); getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(), diff --git a/ryzom/client/src/r2/displayer_visual_entity.cpp b/ryzom/client/src/r2/displayer_visual_entity.cpp index 6e09e580e..81c24342a 100644 --- a/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -968,9 +968,7 @@ void CDisplayerVisualEntity::updateName() //H_AUTO(R2_CDisplayerVisualEntity_updateName) if (!_Entity) return; - std::string name = getString(&getProps(), "Name"); - ucstring ucName; - ucName.fromUtf8(name); + std::string ucName = getString(&getProps(), "Name"); if (ucName.empty()) { ucName = CI18N::get("uiR2EDNoName"); @@ -994,7 +992,7 @@ void CDisplayerVisualEntity::updateName() } std::string firstPart; if(actNb>0) - firstPart = CI18N::get("uiR2EDDefaultActTitle").toString() + " " + NLMISC::toString(actNb); + firstPart = CI18N::get("uiR2EDDefaultActTitle") + " " + NLMISC::toString(actNb); if (act->isString("Name")) actName = act->toString("Name"); @@ -1006,14 +1004,12 @@ void CDisplayerVisualEntity::updateName() } else { - actName = CI18N::get("uiR2EDBaseAct").toString(); + actName = CI18N::get("uiR2EDBaseAct"); } actName = NLMISC::toString(" [%s]", actName.c_str()); - ucstring ucActName; - ucActName.fromUtf8(actName); - ucName += ucActName; + ucName += actName; { //BENCH(setEntityName) diff --git a/ryzom/client/src/r2/displayer_visual_group.cpp b/ryzom/client/src/r2/displayer_visual_group.cpp index 05e120e66..ba7249fd9 100644 --- a/ryzom/client/src/r2/displayer_visual_group.cpp +++ b/ryzom/client/src/r2/displayer_visual_group.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -73,10 +74,10 @@ public: return CCtrlPolygon::contains(CVector2f(mouseXInWindow + 0.5f, mouseYInWindow + 0.5f)); } // tooltip - virtual void getContextHelp(::ucstring &help) const + virtual void getContextHelp(std::string &help) const { - help = Instance.getDisplayName(); - if (std::operator==(help, NLMISC::CI18N::get("uiR2EDNoName") )) + help = Instance.getDisplayName().toUtf8(); + if (help == NLMISC::CI18N::get("uiR2EDNoName")) help.clear(); } bool emptyContextHelp() const { return true; } @@ -98,7 +99,7 @@ protected: { CGroupMap *gm = CTool::getWorldMap(); if (!gm) dest = CVector::Null; - gm->worldToWindow(dest, src); + else gm->worldToWindow(dest, src); } }; @@ -122,10 +123,10 @@ public: return CCtrlQuad::contains(CVector2f(mouseXInWindow + 0.5f, mouseYInWindow + 0.5f)); } // tooltip - virtual void getContextHelp(ucstring &help) const + virtual void getContextHelp(std::string &help) const { - help = Instance.getDisplayName(); - if (std::operator==(help, NLMISC::CI18N::get("uiR2EDNoName"))) + help = Instance.getDisplayName().toUtf8(); + if (help == NLMISC::CI18N::get("uiR2EDNoName")) help.clear(); } bool emptyContextHelp() const { return true; } diff --git a/ryzom/client/src/r2/dmc/action_historic.cpp b/ryzom/client/src/r2/dmc/action_historic.cpp index 19cab7384..7a018d10a 100644 --- a/ryzom/client/src/r2/dmc/action_historic.cpp +++ b/ryzom/client/src/r2/dmc/action_historic.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -586,7 +587,11 @@ void CActionHistoric::CRequestEraseNode::undo(IDynamicMapClient *dmc, CScenario dmc->doRequestInsertNode(_ParentInstanceId, _AttrNameInParent, _PositionInParent, "", _OldValue); _OldValue = NULL; - CLuaIHM::push(getEditor().getLua(), _InstanceId); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(getEditor().getLua(), ucstring::makeFromUtf8(_InstanceId)); +#else + getEditor().getLua().push(_InstanceId); +#endif getEditor().callEnvMethod("setUndoRedoInstances", 1, 0); } //==================================================================================== @@ -616,7 +621,11 @@ void CActionHistoric::CRequestInsertNode::redo(IDynamicMapClient *dmc, CScenario dmc->doRequestInsertNode(_InstanceId, _AttrName, _Position, _Key, _Value); CObject* nodeId = _Value->findAttr("InstanceId"); - CLuaIHM::push(getEditor().getLua(), nodeId->toString()); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(getEditor().getLua(), ucstring::makeFromUtf8(nodeId->toString())); +#else + getEditor().getLua().push(nodeId->toString()); +#endif getEditor().callEnvMethod("setUndoRedoInstances", 1, 0); } // @@ -641,7 +650,11 @@ void CActionHistoric::CRequestInsertNode::undo(IDynamicMapClient *dmc, CScenario // send to network dmc->doRequestEraseNode(instanceId, attrName, position); - CLuaIHM::push(getEditor().getLua(), instanceId); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(getEditor().getLua(), ucstring::makeFromUtf8(instanceId)); +#else + getEditor().getLua().push(instanceId); +#endif getEditor().callEnvMethod("setUndoRedoInstances", 1, 0); } else diff --git a/ryzom/client/src/r2/dmc/client_edition_module.cpp b/ryzom/client/src/r2/dmc/client_edition_module.cpp index f58a9f669..0898711eb 100644 --- a/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015-2018 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1154,6 +1154,15 @@ void CClientEditionModule::startingScenario(class NLNET::IModuleProxy * /* serve { ok = true; connectionState = "uiR2EDUploadScenario"; + +#if !FINAL_VERSION + string filename = CFile::findNewFile("scenario.rt.txt"); + COFile output(filename); + std::string ss; + rtDataPtr->serialize(ss); + output.serialBuffer((uint8*)ss.c_str(),(uint)ss.size()); + output.flush(); +#endif } else { @@ -1859,7 +1868,7 @@ void CClientEditionModule::onTpPositionSimulated(NLNET::IModuleProxy * /* sender beginLoading (LoadingBackground); #define BAR_STEP_TP 2 // fixme : this define is duplicated.... ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.progress(0); ContinentMngr.select(dest, ProgressBar); @@ -2227,6 +2236,7 @@ void CClientEditionModule::addToSaveList(const std::string& filename, const std: if (!ok) { delete sv; + return; } else { diff --git a/ryzom/client/src/r2/dmc/com_lua_module.cpp b/ryzom/client/src/r2/dmc/com_lua_module.cpp index 2ea3d91dd..9675a1e1c 100644 --- a/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -903,6 +903,7 @@ int CComLuaModule::luaRequestNewAction(lua_State* state, bool pending, uint coun } else { +#ifdef RYZOM_LUA_UCSTRING // try with ucstring CLuaState &ls = getEditor().getLua(); nlassert(ls.getStatePointer() == state); @@ -911,6 +912,9 @@ int CComLuaModule::luaRequestNewAction(lua_State* state, bool pending, uint coun nlwarning(" : ucstring or string expected as action name", funcName); return 0; } +#else + return 0; +#endif } } else diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp index 457cee562..e6cd487d2 100644 --- a/ryzom/client/src/r2/editor.cpp +++ b/ryzom/client/src/r2/editor.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2016 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2016 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -212,14 +212,24 @@ CDynamicMapClient(eid, clientGateway, luaState) void CDynamicMapClientEventForwarder::nodeErased(const std::string& instanceId, const std::string& attrName, sint32 position) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeErased) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode) + { + nlassert(getEditor().getMode() != CEditor::AnimationModeLoading); /* Probably should not happen */ + nldebug("Node erased, but not in edition mode"); + return; + } getEditor().nodeErased(instanceId, attrName, position); } void CDynamicMapClientEventForwarder::nodeSet(const std::string& instanceId, const std::string& attrName, CObject* value) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeSet) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode + && getEditor().getMode() != CEditor::AnimationModeLoading /* Loading animation scenario from terminal, ghost nodes created by translator */) + { + nldebug("Node set, but not in edition mode"); + return; + } getEditor().nodeSet(instanceId, attrName, value); } @@ -227,7 +237,12 @@ void CDynamicMapClientEventForwarder::nodeInserted(const std::string& instanceId const std::string& key, CObject* value) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeInserted) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode + && getEditor().getMode() != CEditor::AnimationModeLoading /* Loading animation scenario from terminal, ghost nodes created by translator */) + { + nldebug("Node inserted, but not in edition mode"); + return; + } getEditor().nodeInserted(instanceId, attrName, position, key, value); } @@ -236,7 +251,12 @@ void CDynamicMapClientEventForwarder::nodeMoved( const std::string& destInstanceId, const std::string& destAttrName, sint32 destPosition) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeMoved) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode) + { + nlassert(getEditor().getMode() != CEditor::AnimationModeLoading); /* Probably should not happen */ + nldebug("Node moved, but not in edition mode"); + return; + } getEditor().nodeMoved(instanceId, attrName, position, destInstanceId, destAttrName, destPosition); } @@ -1171,10 +1191,15 @@ int CEditor::luaGenInstanceName(CLuaState &ls) CHECK_EDITOR const char *funcName = "genInstanceName"; CLuaIHM::checkArgCount(ls, funcName, 2); // this is a method +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); // name ucstring baseName; nlverify(CLuaIHM::getUCStringOnStack(ls, 2, baseName)); CLuaIHM::push(ls, getEditor().genInstanceName(baseName)); +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + ls.push(getEditor().genInstanceName(ucstring::makeFromUtf8(ls.toString(2))).toUtf8()); // FIXME: Ring UTF-8 +#endif return 1; } @@ -1185,10 +1210,15 @@ int CEditor::luaIsPostFixedByNumber(CLuaState &ls) CHECK_EDITOR const char *funcName = "isPostFixedByNumber"; CLuaIHM::checkArgCount(ls, funcName, 2); // this is a method +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); // name ucstring baseName; nlverify(CLuaIHM::getUCStringOnStack(ls, 2, baseName)); ls.push(getEditor().isPostFixedByNumber(baseName)); +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + ls.push(getEditor().isPostFixedByNumber(ucstring::makeFromUtf8(ls.toString(2)))); // FIXME: Ring UTF-8 +#endif return 1; } @@ -1306,9 +1336,15 @@ int CEditor::luaSetPlotItemInfos(CLuaState &ls) const char *funcName = "setPlotItemInfos"; CLuaIHM::checkArgCount(ls, funcName, 5); // a method with 4 args CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 3); CLuaIHM::checkArgTypeUCString(ls, funcName, 4); CLuaIHM::checkArgTypeUCString(ls, funcName, 5); +#else + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); +#endif CItemSheet *item = dynamic_cast(SheetMngr.get(CSheetId((uint32) ls.toInteger(2)))); if (!item || item->Family != ITEMFAMILY::SCROLL_R2) { @@ -1316,9 +1352,15 @@ int CEditor::luaSetPlotItemInfos(CLuaState &ls) } R2::TMissionItem mi; mi.SheetId = (uint32) ls.toInteger(2); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::getUCStringOnStack(ls, 3, mi.Name); CLuaIHM::getUCStringOnStack(ls, 4, mi.Description); CLuaIHM::getUCStringOnStack(ls, 5, mi.Comment); +#else + mi.Name = ucstring::makeFromUtf8(ls.toString(3)); + mi.Description = ucstring::makeFromUtf8(ls.toString(4)); + mi.Comment = ucstring::makeFromUtf8(ls.toString(5)); +#endif getEditor().setPlotItemInfos(mi); return 0; } @@ -1551,12 +1593,12 @@ int CEditor::luaGetUserEntityName(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 1); // this is a method if (UserEntity) { - ucstring name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; - ls.push( name.toUtf8() ); + string name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; + ls.push( name ); } else { - ls.push(std::string("")); + ls.push(std::string()); } return 1; @@ -1741,7 +1783,7 @@ void CEditor::waitScenarioScreen() // Display the firewall alert string CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title")); if (pVT != NULL) - pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); + pVT->setText(CI18N::get("uiFirewallAlert")+"..."); // The mouse and fullscreen mode should be unlocked for the user to set the firewall permission nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts @@ -1833,8 +1875,8 @@ void CEditor::waitScenarioScreen() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ - CI18N::get("uiFirewallAlert")+ucstring(".")); + pVT->setText(CI18N::get("uiFirewallFail")+".\n"+ + CI18N::get("uiFirewallAlert")+"."); } } } @@ -4224,7 +4266,7 @@ sint CEditor::getGeneratedNameIndex(const std::string &nameUtf8, const std::stri { ++ strIt; const char *numberStart = &*strIt; - for (; strIt != endStrIt && isdigit(*strIt); ++strIt) {} + for (; strIt != endStrIt && (uint8)(*strIt) < (uint8)'\x80' && isdigit(*strIt); ++strIt) {} if (strIt == endStrIt) { sint ret; @@ -4246,7 +4288,7 @@ bool CEditor::isPostFixedByNumber(const ucstring &baseName) while (lastIndex > 0) { int currChar = (int) baseName[lastIndex]; - if (!isdigit(currChar) && + if (((uint8)currChar >= (uint8)'\x80' || !isdigit(currChar)) && currChar != ' ' && currChar != '\t') { @@ -4269,7 +4311,7 @@ ucstring CEditor::genInstanceName(const ucstring &baseName) while (lastIndex > 0) { int currChar = (int) strippedName[lastIndex]; - if (!isdigit(currChar) && + if (((uint8)currChar >= (uint8)'\x80' || !isdigit(currChar)) && currChar != ' ' && currChar != '\t') { @@ -5785,7 +5827,7 @@ void CEditor::scenarioUpdated(CObject* highLevel, bool willTP, uint32 initialAct } // projectInLua(_Scenario); // push on the lua stack - getLua().push(float(initialActIndex)); // example reconnect after test in act4 + getLua().push(initialActIndex); // example reconnect after test in act4 // update value in the framework callEnvFunc("onScenarioUpdated", 2); //nlwarning("Instance list now is :"); @@ -6302,7 +6344,7 @@ CInstance *CEditor::getInstanceUnderPos(float x, float y, float distSelection, b objectSelected= precInstanceUnderPos->getDisplayerVisual(); } - if (objectSelected->getSelectionType() == ISelectableObject::GroundProjected) + if (objectSelected && objectSelected->getSelectionType() == ISelectableObject::GroundProjected) { if (borderSelected && borderSelected != objectSelected) { @@ -7464,7 +7506,7 @@ class CAHInviteCharacter : public IActionHandler CGroupEditBox *geb = dynamic_cast(fatherGC->getGroup("add_contact_eb:eb")); if (geb && !geb->getInputString().empty()) { - string charName = geb->getInputString().toString(); + string charName = geb->getInputString(); CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance(); sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName); @@ -7486,7 +7528,7 @@ class CAHInviteCharacter : public IActionHandler CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer"); } - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } } } @@ -7602,7 +7644,11 @@ class CAHR2Undo : public IActionHandler getEditor().setCurrentTool(NULL); const ucstring *actionName = historic.getPreviousActionName(); nlassert(actionName); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(getEditor().getLua(), *actionName); +#else + getEditor().getLua().push((*actionName).toUtf8()); +#endif historic.undo(); getEditor().callEnvMethod("onUndo", 1, 0); } @@ -7631,7 +7677,11 @@ class CAHR2Redo : public IActionHandler getEditor().setCurrentTool(NULL); const ucstring *actionName = historic.getNextActionName(); nlassert(actionName); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(getEditor().getLua(), *actionName); +#else + getEditor().getLua().push((*actionName).toUtf8()); +#endif historic.redo(); getEditor().callEnvMethod("onRedo", 1, 0); } diff --git a/ryzom/client/src/r2/instance.cpp b/ryzom/client/src/r2/instance.cpp index 6f3d04a2f..1e2d785d1 100644 --- a/ryzom/client/src/r2/instance.cpp +++ b/ryzom/client/src/r2/instance.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -120,8 +121,14 @@ ucstring CInstance::getDisplayName() } if (getLuaProjection().callMethodByNameNoThrow("getDisplayName", 0, 1)) { +#ifdef RYZOM_LUA_UCSTRING ucstring result; if (CLuaIHM::pop(ls, result)) return result; +#else + std::string res = ls.toString(); + ls.pop(); + if (!res.empty()) return res; +#endif } TEST_LUA_PROJ; return ucstring("Can't find display name"); diff --git a/ryzom/client/src/r2/instance_map_deco.cpp b/ryzom/client/src/r2/instance_map_deco.cpp index cdc792dc5..46b1ad874 100644 --- a/ryzom/client/src/r2/instance_map_deco.cpp +++ b/ryzom/client/src/r2/instance_map_deco.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -40,11 +41,12 @@ namespace R2 { // ********************************************************************************************************* -void CInstanceMapDeco::CCtrlButtonEntity::getContextHelp(ucstring &help) const +void CInstanceMapDeco::CCtrlButtonEntity::getContextHelp(std::string &help) const { //H_AUTO(R2_CCtrlButtonEntity_getContextHelp) - help = _Instance.getDisplayName(); - if (help == NLMISC::CI18N::get("uiR2EDNoName")) help.clear(); + help = _Instance.getDisplayName().toUtf8(); + if (help == NLMISC::CI18N::get("uiR2EDNoName")) + help.clear(); } // ********************************************************************************************************* diff --git a/ryzom/client/src/r2/instance_map_deco.h b/ryzom/client/src/r2/instance_map_deco.h index cf1a2352c..dd7c719e4 100644 --- a/ryzom/client/src/r2/instance_map_deco.h +++ b/ryzom/client/src/r2/instance_map_deco.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -91,7 +92,7 @@ private: private: CInstance &_Instance; protected: - virtual void getContextHelp(ucstring &help) const; + virtual void getContextHelp(std::string &help) const; bool emptyContextHelp() const { return true; } bool wantInstantContextHelp() const { return true; } virtual bool isCapturable() const { return false; } diff --git a/ryzom/client/src/r2/prim_render.cpp b/ryzom/client/src/r2/prim_render.cpp index 59b05e1c4..93f610377 100644 --- a/ryzom/client/src/r2/prim_render.cpp +++ b/ryzom/client/src/r2/prim_render.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -202,7 +203,7 @@ CCtrlPolygon *CPrimRender::newCtrlPolygon() const { CGroupMap *gm = CTool::getWorldMap(); if (!gm) dest = CVector::Null; - gm->worldToWindow(dest, src); + else gm->worldToWindow(dest, src); } }; CViewBase::TCtorParam param; diff --git a/ryzom/client/src/r2/tool.cpp b/ryzom/client/src/r2/tool.cpp index 8620341d8..191ec1cba 100644 --- a/ryzom/client/src/r2/tool.cpp +++ b/ryzom/client/src/r2/tool.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -938,7 +938,11 @@ void CTool::setContextHelp(const ucstring &contextHelp) // forward the call to lua (all ui handling done bye lua) CLuaState &ls = getEditor().getLua(); CLuaStackChecker lsc(&ls); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(ls, contextHelp); +#else + ls.push(contextHelp.toUtf8()); +#endif getEditor().callEnvMethod("setToolContextHelp", 1, 0); } diff --git a/ryzom/client/src/r2/tool_draw_prim.cpp b/ryzom/client/src/r2/tool_draw_prim.cpp index c32682626..3cf05944f 100644 --- a/ryzom/client/src/r2/tool_draw_prim.cpp +++ b/ryzom/client/src/r2/tool_draw_prim.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -551,9 +552,9 @@ void CToolDrawPrim::commit() if (!_Extending) { // set readable name - ucstring readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); - readableName = getEditor().genInstanceName(readableName); - desc->set("Name", readableName.toUtf8()); + string readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); + readableName = getEditor().genInstanceName(readableName).toUtf8(); + desc->set("Name", readableName); // send creation command // tmp : static npc counter // add in component list of default feature diff --git a/ryzom/client/src/r2/tool_select_move.cpp b/ryzom/client/src/r2/tool_select_move.cpp index f9b9b9a1a..e23d969eb 100644 --- a/ryzom/client/src/r2/tool_select_move.cpp +++ b/ryzom/client/src/r2/tool_select_move.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -417,9 +420,9 @@ void CToolSelectMove::commitAction(CInstance &instance) } else { - ucstring instanceName = instance.getDisplayName(); + string instanceName = instance.getDisplayName().toUtf8(); if(instanceName == CI18N::get("uiR2EDNoName")) - instanceName = ucstring(instance.getClassName()); + instanceName = instance.getClassName(); //getDMC().newAction(CI18N::get("uiR2EDMoveAction") + instance.getDisplayName()); getDMC().newAction(CI18N::get("uiR2EDMoveAction") + instanceName); diff --git a/ryzom/client/src/release.cpp b/ryzom/client/src/release.cpp index 889bcee11..b23b2ae72 100644 --- a/ryzom/client/src/release.cpp +++ b/ryzom/client/src/release.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -30,6 +30,7 @@ #include "nel/misc/async_file_manager.h" #include "nel/misc/system_utils.h" #include "nel/misc/streamed_package_manager.h" +#include "nel/web/http_package_provider.h" // 3D Interface. #include "nel/3d/bloom_effect.h" #include "nel/3d/fxaa.h" @@ -42,6 +43,7 @@ #include "nel/3d/u_visual_collision_manager.h" #include "nel/3d/u_shape_bank.h" #include "nel/3d/stereo_hmd.h" +#include "nel/3d/async_file_manager_3d.h" // Client #include "global.h" #include "release.h" @@ -488,7 +490,9 @@ void releaseMainLoop(bool closeConnection) // Called when Quit from OutGame void releaseOutGame() { +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().release(); +#endif ProgressBar.release(); @@ -569,8 +573,12 @@ void release() { CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_GameExit, "login_step_game_exit&play_time=" + toString((NLMISC::CTime::getLocalTime() - StartPlayTime) / 1000))); } + + setCrashCallback(NULL); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().release(); +#endif ProgressBar.release(); @@ -624,6 +632,9 @@ void release() delete FXAA; FXAA = NULL; CBloomEffect::releaseInstance(); + // Release texture + endLoading(); + // Release Scene, textcontexts, materials, ... Driver->release(); @@ -696,6 +707,7 @@ void release() CIXml::releaseLibXml(); CHttpCache::release(); CStrictTransportSecurity::release(); + CAsyncFileManager3D::releaseInstance(); #if FINAL_VERSION // openURL ("http://ryzom.com/exit/"); diff --git a/ryzom/client/src/release.h b/ryzom/client/src/release.h index 56ceca73d..17610eb1d 100644 --- a/ryzom/client/src/release.h +++ b/ryzom/client/src/release.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/segement_heap.manifest b/ryzom/client/src/segement_heap.manifest new file mode 100644 index 000000000..0deedb1e7 --- /dev/null +++ b/ryzom/client/src/segement_heap.manifest @@ -0,0 +1,8 @@ + + + + + SegmentHeap + + + diff --git a/ryzom/client/src/session_browser.cpp b/ryzom/client/src/session_browser.cpp index 6d80c55cb..7b29f3023 100644 --- a/ryzom/client/src/session_browser.cpp +++ b/ryzom/client/src/session_browser.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/client/src/session_browser_impl.cpp b/ryzom/client/src/session_browser_impl.cpp index 9f3cc77a9..08a5dba3a 100644 --- a/ryzom/client/src/session_browser_impl.cpp +++ b/ryzom/client/src/session_browser_impl.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/sheet_manager.cpp b/ryzom/client/src/sheet_manager.cpp index 8d8045276..838807934 100644 --- a/ryzom/client/src/sheet_manager.cpp +++ b/ryzom/client/src/sheet_manager.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/sky.cpp b/ryzom/client/src/sky.cpp index ad9411189..bca0a0d3e 100644 --- a/ryzom/client/src/sky.cpp +++ b/ryzom/client/src/sky.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -288,7 +288,7 @@ CBitmap *buildSharedBitmap(const std::string &filename, { alreadyBuilt = false; if (filename.empty()) return NULL; - std::string lcBMFilename = toLower(CFile::getFilenameWithoutExtension(filename)); + std::string lcBMFilename = toLowerAscii(CFile::getFilenameWithoutExtension(filename)); std::map::iterator it = bitmapByName.find(lcBMFilename); if (it != bitmapByName.end()) { diff --git a/ryzom/client/src/streamable_ig.cpp b/ryzom/client/src/streamable_ig.cpp index dab7a3fa8..3e633cb73 100644 --- a/ryzom/client/src/streamable_ig.cpp +++ b/ryzom/client/src/streamable_ig.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -300,8 +300,8 @@ bool CStreamableIG::setIG(uint ig, const std::string &name, const std::string &p } // Load this IG - _IGs[ig].Name = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(name)); - _IGs[ig].ParentName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(parentName)); + _IGs[ig].Name = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(name)); + _IGs[ig].ParentName = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(parentName)); _IGs[ig].IG = NULL; _IGs[ig].Loading = false; _Linked = false; @@ -315,8 +315,8 @@ void CStreamableIG::addIG(const std::string &name,const std::string &parentName, { H_AUTO_USE(RZ_StremableIG) _IGs.push_back(CIGNode ()); - _IGs.back().Name = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(name)); - _IGs.back().ParentName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(parentName)); + _IGs.back().Name = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(name)); + _IGs.back().ParentName = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(parentName)); _IGs.back().IG = NULL; _IGs.back().Loading = false; _IGs.back().Pos = pos; @@ -381,7 +381,7 @@ void CStreamableIG::addLoadedIGToMap() if (_IGs[k].IG && _IGs[k].IG != (NL3D::UInstanceGroup *)-1) // is this a successfully loaded ig ? { // insert the new ig if it hasn't before.. - if( _IGMap->insert(std::make_pair(NLMISC::toLower(_IGs[k].Name), _IGs[k].IG)).second ) + if( _IGMap->insert(std::make_pair(NLMISC::toLowerAscii(_IGs[k].Name), _IGs[k].IG)).second ) // if inserted, must notify IG Added, else already notifiyed by loadAsync() this->notifyIGAdded(_IGs[k].IG); } diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index a10be8114..1ff55c54b 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2017 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -39,17 +42,17 @@ namespace STRING_MANAGER // *************************************************************************** map CStringManagerClient::_SpecItem_TempMap; - map CStringManagerClient::_DynStrings; - vector CStringManagerClient::_TitleWords; + map CStringManagerClient::_DynStrings; + vector CStringManagerClient::_TitleWords; bool CStringManagerClient::_SpecItem_MemoryCompressed = false; char *CStringManagerClient::_SpecItem_Labels = NULL; - ucchar *CStringManagerClient::_SpecItem_NameDesc = NULL; + char *CStringManagerClient::_SpecItem_NameDesc = NULL; vector CStringManagerClient::_SpecItems; bool MustReleaseStaticArrays = true; CStringManagerClient *CStringManagerClient::_Instance= NULL; - ucstring CStringManagerClient::_WaitString("???"); + string CStringManagerClient::_WaitString("???"); CStringManagerClient::CStringManagerClient() @@ -57,7 +60,7 @@ namespace STRING_MANAGER _CacheInited = false; _CacheLoaded = false; // insert the empty string. - _ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring())); + _ReceivedStrings.insert(make_pair((uint)EmptyStringId, string())); // reserve some place to avoid reallocation as possible _CacheStringToSave.reserve(1024); } @@ -122,16 +125,22 @@ namespace STRING_MANAGER { try { + const uint currentVersion = 1; _CacheFilename = std::string("save/") + _ShardId.substr(0, _ShardId.find(":")) + ".string_cache"; nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str()); - if (CFile::fileExists(_CacheFilename)) + if (CFile::fileExists(_CacheFilename) && CFile::getFileSize(_CacheFilename)) { // there is a cache file, check date reset it if needed { NLMISC::CIFile file(_CacheFilename); - file.serial(_Timestamp); + file.setVersionException(false, false); + file.serialVersion(currentVersion); + if (file.getPos() + sizeof(_Timestamp) > file.getFileSize()) + _Timestamp = ~timestamp; + else + file.serial(_Timestamp); } if (_Timestamp != timestamp) @@ -139,6 +148,7 @@ namespace STRING_MANAGER nlinfo("SM: Clearing string cache : outofdate"); // the cache is not sync, reset it NLMISC::COFile file(_CacheFilename); + file.serialVersion(currentVersion); file.serial(timestamp); } else @@ -151,6 +161,7 @@ namespace STRING_MANAGER nlinfo("SM: Creating string cache"); // cache file don't exist, create it with the timestamp NLMISC::COFile file(_CacheFilename); + file.serialVersion(currentVersion); file.serial(timestamp); } @@ -160,17 +171,19 @@ namespace STRING_MANAGER // NB : we keep the waiting strings and dyn strings // insert the empty string. - _ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring())); + _ReceivedStrings.insert(make_pair((uint)EmptyStringId, string())); // load the cache file NLMISC::CIFile file(_CacheFilename); + int version = file.serialVersion(currentVersion); file.serial(_Timestamp); nlassert(_Timestamp == timestamp); + nlassert(version >= 1); // Initial version while (!file.eof()) { uint32 id; - ucstring str; + string str; file.serial(id); file.serial(str); @@ -194,12 +207,12 @@ namespace STRING_MANAGER - void CStringManagerClient::waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result) + void CStringManagerClient::waitString(uint32 stringId, const IStringWaiterRemover *premover, string *result) { H_AUTO( CStringManagerClient_waitString ) nlassert(premover && result); - ucstring value; + string value; if (getString(stringId, value)) *result = value; else @@ -217,7 +230,7 @@ namespace STRING_MANAGER H_AUTO( CStringManagerClient_waitString2 ) nlassert(pcallback != 0); - ucstring value; + string value; if (getString(stringId, value)) { pcallback->onStringAvailable(stringId, value); @@ -230,12 +243,12 @@ namespace STRING_MANAGER } - void CStringManagerClient::waitDynString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result) + void CStringManagerClient::waitDynString(uint32 stringId, const IStringWaiterRemover *premover, string *result) { H_AUTO( CStringManagerClient_waitDynString ) nlassert(premover && result); - ucstring value; + string value; if (getDynString(stringId, value)) *result = value; else @@ -253,7 +266,7 @@ namespace STRING_MANAGER H_AUTO( CStringManagerClient_waitDynString2 ) nlassert(pcallback != 0); - ucstring value; + string value; if (getDynString(stringId, value)) { pcallback->onDynStringAvailable(stringId, value); @@ -330,7 +343,7 @@ restartLoop4: - bool CStringManagerClient::getString(uint32 stringId, ucstring &result) + bool CStringManagerClient::getString(uint32 stringId, string &result) { H_AUTO( CStringManagerClient_getString ) @@ -357,7 +370,7 @@ restartLoop4: _WaitingStrings.insert(stringId); // need to ask for this string. NLMISC::CBitMemStream bms; - const std::string msgType = "STRING_MANAGER:STRING_RQ"; + static const string msgType = "STRING_MANAGER:STRING_RQ"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( stringId ); @@ -374,7 +387,7 @@ restartLoop4: { char tmp[1024]; sprintf(tmp, "", stringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); // = _WaitString; @@ -385,14 +398,14 @@ restartLoop4: { char tmp[1024]; sprintf(tmp, "", stringId); - result = ucstring(tmp) + it->second; + result = tmp + it->second; } else { result = it->second; - if (result.size() > 9 && result.substr(0, 9) == ucstring(" 9 && result.substr(0, 9) == "::iterator itds = _DynStrings.find(result.substr(9, result.size()-10)); + map::iterator itds = _DynStrings.find(result.substr(9, result.size()-10)); if (itds != _DynStrings.end()) result = itds->second; } @@ -402,7 +415,7 @@ restartLoop4: return true; } - void CStringManagerClient::receiveString(uint32 stringId, const ucstring &str) + void CStringManagerClient::receiveString(uint32 stringId, const string &str) { H_AUTO( CStringManagerClient_receiveString ) @@ -419,8 +432,8 @@ restartLoop4: TStringsContainer::iterator it(_ReceivedStrings.find(stringId)); nlwarning("Receiving stringID %u (%s), already in received string (%s), replacing with new value.", stringId, - str.toString().c_str(), - it->second.toString().c_str()); + str.c_str(), + it->second.c_str()); if (it->second != str) it->second = str; @@ -484,7 +497,7 @@ restartLoop: last = _WaitingDynStrings.end(); for (; first != last; ++first) { - ucstring value; + string value; uint number = first->first; /// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop if (getDynString(number, value)) @@ -616,7 +629,7 @@ restartLoop: return false; } // ok, we have the base string, we can serial the parameters - ucstring::iterator first(dynInfo.String.begin()), last(dynInfo.String.end()); + string::iterator first(dynInfo.String.begin()), last(dynInfo.String.end()); for (; first != last; ++first) { if (*first == '%') @@ -699,10 +712,10 @@ restartLoop: if (dynInfo.Status == TDynStringInfo::serialized) { // try to retreive all string parameter to build the string. - ucstring temp; + string temp; temp.reserve(dynInfo.String.size() * 2); - ucstring::iterator src(dynInfo.String.begin()); - ucstring::iterator move = src; + string::iterator src(dynInfo.String.begin()); + string::iterator move = src; std::vector::iterator first(dynInfo.Params.begin()), last(dynInfo.Params.end()); for (; first != last; ++first) @@ -712,7 +725,7 @@ restartLoop: { case string_id: { - ucstring str; + string str; if (!getString(param.StringId, str)) return false; @@ -734,15 +747,15 @@ restartLoop: // If the shard name is the same as the player home shard name, remove it uint len= (uint)PlayerSelectedHomeShardNameWithParenthesis.size(); uint start= (uint)str.size()-len; - if(ucstrnicmp(str, start, len, PlayerSelectedHomeShardNameWithParenthesis)==0) + if(ucstrnicmp(str, start, len, PlayerSelectedHomeShardNameWithParenthesis)==0) // TODO: NLMISC::compareCaseInsensitive str.resize(start); } } } // If the string contains a title, then remove it - ucstring::size_type pos = str.find('$'); - if ( ! str.empty() && pos != ucstring::npos) + string::size_type pos = str.find('$'); + if ( ! str.empty() && pos != string::npos) { str = CEntityCL::removeTitleFromName(str); } @@ -765,13 +778,13 @@ restartLoop: char value[1024]; sprintf(value, "%d", param.Integer); temp.append(move, src+param.ReplacementPoint); - temp+=ucstring(value); + temp += value; move = dynInfo.String.begin()+param.ReplacementPoint+2; } break; case time: { - ucstring value; + string value; uint32 time = (uint32)param.Time; if( time >= (10*60*60) ) { @@ -802,7 +815,7 @@ restartLoop: char value[1024]; sprintf(value, "%u", (uint32)param.Money); temp.append(move, src+param.ReplacementPoint); - temp+=ucstring(value); + temp += value; move = dynInfo.String.begin()+param.ReplacementPoint+2; } // TODO @@ -811,7 +824,7 @@ restartLoop: break; case dyn_string_id: { - ucstring dynStr; + string dynStr; if (!getDynString(param.DynStringId, dynStr)) return false; temp.append(move, src+param.ReplacementPoint); @@ -829,8 +842,8 @@ restartLoop: // apply any 'delete' character in the string and replace double '%' { - uint i =0; - while (i < temp.size()) + ptrdiff_t i =0; + while (i < (ptrdiff_t)temp.size()) { if (temp[i] == 8) { @@ -859,7 +872,7 @@ restartLoop: } - bool CStringManagerClient::getDynString(uint32 dynStringId, ucstring &result) + bool CStringManagerClient::getDynString(uint32 dynStringId, std::string &result) { H_AUTO( CStringManagerClient_getDynString ) @@ -888,7 +901,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp) + it->second.String; + result = tmp + it->second.String; } else result = it->second.String; @@ -914,7 +927,7 @@ restartLoop: nlwarning("DynStringID %u is unknown !", dynStringId); char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); //_WaitString; @@ -926,7 +939,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp) + it->second.String; + result = tmp + it->second.String; } else result = it->second.String; @@ -939,7 +952,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); // = _WaitString; @@ -949,7 +962,7 @@ restartLoop: } // Tool fct to lookup a reference file - static string lookupReferenceFile(const std::string &fileName) + static string lookupReferenceFile(const string &fileName) { string referenceFile; // special location for the "wk" language @@ -970,14 +983,14 @@ restartLoop: return referenceFile; } - void CLoadProxy::loadStringFile(const std::string &filename, ucstring &text) + void CLoadProxy::loadStringFile(const string &filename, ucstring &text) // TODO: UTF-8 (serial) { vector reference; vector addition; vector diff; // get the correct path name of the ref file - std::string referenceFile= lookupReferenceFile(filename); + string referenceFile= lookupReferenceFile(filename); // load the reference file if (!referenceFile.empty()) @@ -1014,7 +1027,7 @@ restartLoop: context.Diff.push_back(context.Addition[addIndex]); //nldebug("Adding new string '%s' in CI18N", context.Addition[addIndex].Identifier.c_str()); if (ClientCfg.DebugStringManager) - context.Diff.back().Text = ucstring("")+context.Diff.back().Text; + context.Diff.back().Text = ucstring("")+context.Diff.back().Text; // TODO: UTF-8 (serial) } void CLoadProxy::onRemove(uint /* addIndex */, uint /* refIndex */, TStringDiffContext &/* context */) { @@ -1026,7 +1039,7 @@ restartLoop: context.Diff.push_back(context.Addition[addIndex]); //nldebug("Using changed string '%s' in CI18N", context.Addition[addIndex].Identifier.c_str()); if (ClientCfg.DebugStringManager) - context.Diff.back().Text = ucstring("")+context.Diff.back().Text; + context.Diff.back().Text = ucstring("")+context.Diff.back().Text; // TODO: UTF-8 (serial) } void CLoadProxy::onSwap(uint /* newIndex */, uint /* refIndex */, TStringDiffContext &/* context */) { @@ -1040,14 +1053,14 @@ restartLoop: class CReadWorkSheetFile : public TWorkSheetDiff::IDiffCallback { public: - void readWorkSheetFile(const string &filename, ucstring &text) + void readWorkSheetFile(const string &filename, ucstring &text) // TODO: UTF-8 (serial) { TWorksheet addition; TWorksheet reference; TWorksheet diff; // get the correct path name of the ref file - std::string referenceFile= lookupReferenceFile(filename); + string referenceFile= lookupReferenceFile(filename); // load the reference file if (!referenceFile.empty()) @@ -1140,7 +1153,7 @@ public: const string StringClientPackedFileName= "./save/string_client.pack"; // Must Increment this number if change are made to the code (else change not taken into account) const uint StringClientPackedVersion= 0; -bool CStringManagerClient::checkWordFileDates(vector &fileChecks, const std::vector &fileNames, const std::string &languageCode) +bool CStringManagerClient::checkWordFileDates(vector &fileChecks, const std::vector &fileNames, const string &languageCode) { fileChecks.resize(fileNames.size()); @@ -1148,7 +1161,7 @@ bool CStringManagerClient::checkWordFileDates(vector &fileChecks, co for(uint i=0;i &fileChecks, co // *************************************************************************** -void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) +void CStringManagerClient::initI18NSpecialWords(const string &languageCode) { - ucstring womenNameColIdent= string("women_name"); - ucstring descColIdent= string("description"); - ucstring descColIdent2= string("description2"); + ucstring womenNameColIdent = ucstring("women_name"); // TODO: UTF-8 (serial) + ucstring descColIdent = ucstring("description"); // TODO: UTF-8 (serial) + ucstring descColIdent2 = ucstring("description2"); // TODO: UTF-8 (serial) // List of words to append to the local CI18N system. static const char *specialWords[]= @@ -1218,11 +1231,11 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) { uint32 profile0= (uint32)ryzomGetLocalTime(); - ucstring ucs; - std::string fileName = fileNames[i]; - std::string keyExtenstion = specialWords[i*3+2]; + ucstring ucs; // TODO: UTF-8 (serial) + string fileName = fileNames[i]; + string keyExtenstion = specialWords[i*3+2]; - // read the ucstring and make diffs with data in ./translation/work. + // read the ucstring and make diffs with data in ./translation/work. // TODO: UTF-8 (serial) CReadWorkSheetFile rwsf; rwsf.readWorkSheetFile(fileName, ucs); if(ucs.empty()) @@ -1234,9 +1247,9 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) // Get the Key and Data ColIndex. uint nameColIndex = 0, keyColIndex = 0; - if( !ws.findCol(ucstring("name"), nameColIndex) ) + if( !ws.findCol(ucstring("name"), nameColIndex) ) // TODO: UTF-8 (serial) continue; - if( !ws.findCol(ucstring(specialWords[i*3+1]), keyColIndex) ) + if( !ws.findCol(ucstring(specialWords[i*3+1]), keyColIndex) ) // TODO: UTF-8 (serial) continue; // Get the women name index if possible. @@ -1256,17 +1269,17 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) for(uint j=1;j::iterator it; + std::map::iterator it; it= _SpecItem_TempMap.find( keyStr ); if ( it!=_SpecItem_TempMap.end() ) { @@ -1281,8 +1294,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) // insert in map of Women Name if OK. if(womenNameColIndex!=std::numeric_limits::max()) { - const ucstring &womenName= ws.getData(j, womenNameColIndex); - _SpecItem_TempMap[keyStr].WomenName= womenName; + const ucstring &womenName= ws.getData(j, womenNameColIndex); // TODO: UTF-8 (serial) + _SpecItem_TempMap[keyStr].WomenName= womenName.toUtf8(); // replace all \n in the women name with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n")); } @@ -1290,8 +1303,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) // insert in map of Description if OK. if(descColIndex!=std::numeric_limits::max()) { - const ucstring &desc= ws.getData(j, descColIndex); - _SpecItem_TempMap[keyStr].Desc= desc; + const ucstring &desc= ws.getData(j, descColIndex); // TODO: UTF-8 (serial) + _SpecItem_TempMap[keyStr].Desc= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n")); } @@ -1299,8 +1312,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) // insert in map of Description2 if OK. if(descColIndex2!=std::numeric_limits::max()) { - const ucstring &desc= ws.getData(j, descColIndex2); - _SpecItem_TempMap[keyStr].Desc2= desc; + const ucstring &desc= ws.getData(j, descColIndex2); // TODO: UTF-8 (serial) + _SpecItem_TempMap[keyStr].Desc2= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n")); } @@ -1364,7 +1377,7 @@ void CStringManagerClient::specialWordsMemoryCompress() // Make big strings _SpecItems.resize(nNbEntries); _SpecItem_Labels = new char[nLabelSize]; - _SpecItem_NameDesc = new ucchar[nNameDescSize]; + _SpecItem_NameDesc = new char[nNameDescSize]; nNbEntries = 0; nLabelSize = 0; @@ -1372,35 +1385,30 @@ void CStringManagerClient::specialWordsMemoryCompress() it = _SpecItem_TempMap.begin(); while (it != _SpecItem_TempMap.end()) { - - if (strnicmp(it->first.c_str(), "bf", 2) == 0) + if (NLMISC::startsWith(it->first.c_str(), "bf")) { uint nDbg = 0; nDbg++; } _SpecItems[nNbEntries].Label = _SpecItem_Labels+nLabelSize; - strcpy(_SpecItems[nNbEntries].Label, it->first.c_str()); + strcpy(_SpecItem_Labels+nLabelSize, it->first.c_str()); nLabelSize += (uint32)it->first.size() + 1; _SpecItems[nNbEntries].Name = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].Name, it->second.Name.c_str(), 2*(it->second.Name.size()+1)); - _SpecItems[nNbEntries].Name[it->second.Name.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Name.c_str()); nNameDescSize += (uint32)it->second.Name.size() + 1; _SpecItems[nNbEntries].WomenName = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].WomenName, it->second.WomenName.c_str(), 2*(it->second.WomenName.size()+1)); - _SpecItems[nNbEntries].WomenName[it->second.WomenName.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.WomenName.c_str()); nNameDescSize += (uint32)it->second.WomenName.size() + 1; _SpecItems[nNbEntries].Desc = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].Desc, it->second.Desc.c_str(), 2*(it->second.Desc.size()+1)); - _SpecItems[nNbEntries].Desc[it->second.Desc.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc.c_str()); nNameDescSize += (uint32)it->second.Desc.size() + 1; _SpecItems[nNbEntries].Desc2 = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].Desc2, it->second.Desc2.c_str(), 2*(it->second.Desc2.size()+1)); - _SpecItems[nNbEntries].Desc2[it->second.Desc2.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc2.c_str()); nNameDescSize += (uint32)it->second.Desc2.size() + 1; nNbEntries++; @@ -1412,23 +1420,22 @@ void CStringManagerClient::specialWordsMemoryCompress() } // *************************************************************************** -const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bool women) +const char *CStringManagerClient::getSpecialWord(const string &label, bool women) { if (label.empty()) { - static ucstring emptyString; + static string emptyString; return emptyString.c_str(); } if (label[0] == '#') { - static ucstring rawString; return getLocalizedName(label.substr(1, label.size()-1)); } // avoid case problems - static std::string lwrLabel; - lwrLabel = toLower(label); + static string lwrLabel; + lwrLabel = toLowerAscii(label); if (_SpecItem_MemoryCompressed) { @@ -1442,8 +1449,7 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo { if( UseFemaleTitles && women ) { - ucstring ustr(it->WomenName); - if( !ustr.empty() ) + if( !it->WomenName[0] ) return it->WomenName; } return it->Name; @@ -1462,28 +1468,26 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo } } - static ucstring badString; - - badString = ucstring(std::string(""); - + static string badString; + badString = ""; return badString.c_str(); } // *************************************************************************** -const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label) +const char *CStringManagerClient::getSpecialDesc(const string &label) { - static ucstring emptyString; + static string emptyString; if (label.empty()) return emptyString.c_str(); // avoid case problems - static std::string lwrLabel; - lwrLabel = toLower(label); + static string lwrLabel; + lwrLabel = toLowerAscii(label); if (_SpecItem_MemoryCompressed) { CItemLight tmp; - tmp.Label = (char*)lwrLabel.c_str(); + tmp.Label = lwrLabel.c_str(); vector::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); if (it != _SpecItems.end()) @@ -1503,20 +1507,20 @@ const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label) } // *************************************************************************** -const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label) +const char *CStringManagerClient::getSpecialDesc2(const string &label) { - static ucstring emptyString; + static string emptyString; if (label.empty()) return emptyString.c_str(); // avoid case problems - static std::string lwrLabel; - lwrLabel = toLower(label); + static string lwrLabel; + lwrLabel = toLowerAscii(label); if (_SpecItem_MemoryCompressed) { CItemLight tmp; - tmp.Label = (char*)lwrLabel.c_str(); + tmp.Label = lwrLabel.c_str(); vector::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); if (it != _SpecItems.end()) @@ -1545,87 +1549,88 @@ const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label) */ // *************************************************************************** -const ucchar *CStringManagerClient::getPlaceLocalizedName(const string &placeNameID) +const char *CStringManagerClient::getPlaceLocalizedName(const string &placeNameID) { return getSpecialWord(placeNameID); } // *************************************************************************** -const ucchar *CStringManagerClient::getFactionLocalizedName(const string &factionNameID) +const char *CStringManagerClient::getFactionLocalizedName(const string &factionNameID) { return getSpecialWord(factionNameID); } // *************************************************************************** -const ucchar *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e) +const char *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e) { return getSpecialWord(SKILLS::toString(e)); } // *************************************************************************** -const ucchar *CStringManagerClient::getItemLocalizedName(CSheetId id) +const char *CStringManagerClient::getItemLocalizedName(CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -/*const ucchar *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e) +/*const char *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e) { return getSpecialDesc(BRICK_FAMILIES::toString(e)); } */ // *************************************************************************** -const ucchar *CStringManagerClient::getSkillLocalizedDescription(SKILLS::ESkills e) +const char *CStringManagerClient::getSkillLocalizedDescription(SKILLS::ESkills e) { return getSpecialDesc(SKILLS::toString(e)); } // *************************************************************************** -const ucchar *CStringManagerClient::getItemLocalizedDescription(CSheetId id) +const char *CStringManagerClient::getItemLocalizedDescription(CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id) { return getSpecialDesc2(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleId, bool women) +const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, bool women) { - vector listInfos = getTitleInfos(titleId, women); + vector listInfos = getTitleInfos(titleId, women); + if (!listInfos.empty()) { _TitleWords.push_back(listInfos[0]); @@ -1636,13 +1641,13 @@ const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleI } -const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext) +const char *CStringManagerClient::getLocalizedName(const string &uctext) { - string text = uctext.toUtf8(); + string text = uctext; if (text[0] == '[') { vector textLocalizations; - static ucstring defaultText; + static string defaultText; splitString(text.substr(1), "[", textLocalizations); if (!textLocalizations.empty()) { @@ -1650,12 +1655,12 @@ const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext) { if (textLocalizations[i].substr(0, 3) == CI18N::getCurrentLanguageCode()+"]") { - defaultText.fromUtf8(textLocalizations[i].substr(3)); + defaultText = textLocalizations[i].substr(3); return defaultText.c_str(); } else if (textLocalizations[i].substr(0, 3) == "wk]") { - defaultText.fromUtf8(textLocalizations[i].substr(3)); + defaultText = textLocalizations[i].substr(3); } } } @@ -1667,18 +1672,16 @@ const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext) } // *************************************************************************** -vector CStringManagerClient::getTitleInfos(const ucstring &titleId, bool women) +vector CStringManagerClient::getTitleInfos(const string &titleId, bool women) { - //ucstring infosUC; - //infosUC.fromUtf8(titleId); - vector listInfos; - splitUCString(titleId, ucstring("#"), listInfos); + vector listInfos; + splitString(titleId, string("#"), listInfos); if (!listInfos.empty()) { if (titleId[0] != '#') { - listInfos[0] = getSpecialWord(listInfos[0].toUtf8(), women); + listInfos[0] = getSpecialWord(listInfos[0], women); } } @@ -1686,74 +1689,76 @@ vector CStringManagerClient::getTitleInfos(const ucstring &titleId, bo } // *************************************************************************** -const ucchar *CStringManagerClient::getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type) +const char *CStringManagerClient::getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type) { return getSpecialDesc(EGSPD::CClassificationType::toString(type)); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -void CStringManagerClient::replaceDynString(const ucstring &name, const ucstring &text) +void CStringManagerClient::replaceDynString(const std::string &name, const std::string &text) { _DynStrings[name] = text; } // *************************************************************************** -void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring &name, const ucstring &desc, const ucstring &desc2) +void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const std::string &name, const std::string &desc, const std::string &desc2) { - std::string label= id.toString(); + string label= id.toString(); if (label.empty()) { return; } // avoid case problems - static std::string lwrLabel; - lwrLabel = toLower(label); + static string lwrLabel; + lwrLabel = toLowerAscii(label); + nlassert(!_SpecItem_MemoryCompressed); // Not allowed, strings are released! if (_SpecItem_MemoryCompressed) { - ucchar *strName = (ucchar *)name.c_str(); - ucchar *strDesc = (ucchar *)desc.c_str(); - ucchar *strDesc2 = (ucchar *)desc2.c_str(); +#if 0 + const char *strName = name.c_str(); + const char *strDesc = desc.c_str(); + const char *strDesc2 = desc2.c_str(); CItemLight tmp; - tmp.Label = (char*)lwrLabel.c_str(); + tmp.Label = lwrLabel.c_str(); vector::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); if (it != _SpecItems.end()) @@ -1779,6 +1784,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring tmp.Desc2 = strDesc2; _SpecItems.push_back(tmp); } +#endif } else { diff --git a/ryzom/client/src/string_manager_client.h b/ryzom/client/src/string_manager_client.h index c977a8380..ef55b0367 100644 --- a/ryzom/client/src/string_manager_client.h +++ b/ryzom/client/src/string_manager_client.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2017 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,6 +46,7 @@ class CStringManagerClient public: // Singleton pattern implementation static CStringManagerClient *instance(); + static bool hasInstance() { return _Instance; } static void release(bool mustReleaseStaticArrays); /** Prepare the string manager to use a persistent string cache. @@ -60,14 +64,14 @@ public: // Force the cache to be saved void flushStringCache(); - bool getString(uint32 stringId, ucstring &result); - void waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); + bool getString(uint32 stringId, std::string &result); + void waitString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result); void waitString(uint32 stringId, IStringWaitCallback *pcallback); - bool getDynString(uint32 dynStringId, ucstring &result); - void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); + bool getDynString(uint32 dynStringId, std::string &result); + void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result); void waitDynString(uint32 stringId, IStringWaitCallback *pcallback); - void receiveString(uint32 stringId, const ucstring &str); + void receiveString(uint32 stringId, const std::string &str); void receiveDynString(NLMISC::CBitMemStream &bms); void releaseDynString(uint32 stringId); @@ -76,55 +80,55 @@ public: static void initI18NSpecialWords(const std::string &languageCode); static void specialWordsMemoryCompress(); // Yoyo: Replace the Brick Name with Filled stats (CSBrickManager work). No-Op if not found - static void replaceSBrickName(NLMISC::CSheetId id, const ucstring &name, const ucstring &desc, const ucstring &desc2); - static void replaceDynString(const ucstring &name, const ucstring &text); + static void replaceSBrickName(NLMISC::CSheetId id, const std::string &name, const std::string &desc, const std::string &desc2); + static void replaceDynString(const std::string &name, const std::string &text); // Get the Localized Name of the Places. - static const ucchar *getPlaceLocalizedName(const std::string &placeNameID); + static const char *getPlaceLocalizedName(const std::string &placeNameID); // Get the Localized Name of the faction (for the fame) - static const ucchar *getFactionLocalizedName(const std::string &factionNameID); + static const char *getFactionLocalizedName(const std::string &factionNameID); // Get the Localized Name of the Skill. - static const ucchar *getSkillLocalizedName(SKILLS::ESkills e); + static const char *getSkillLocalizedName(SKILLS::ESkills e); // Get the Localized Name of the Item. - static const ucchar *getItemLocalizedName(NLMISC::CSheetId id); + static const char *getItemLocalizedName(NLMISC::CSheetId id); // Get the Localized Name of the Creature. - static const ucchar *getCreatureLocalizedName(NLMISC::CSheetId id); + static const char *getCreatureLocalizedName(NLMISC::CSheetId id); // Get the Localized Name of the SBrick. - static const ucchar *getSBrickLocalizedName(NLMISC::CSheetId id); + static const char *getSBrickLocalizedName(NLMISC::CSheetId id); // Get the Localized Name of the SPhrase. - static const ucchar *getSPhraseLocalizedName(NLMISC::CSheetId id); + static const char *getSPhraseLocalizedName(NLMISC::CSheetId id); // Get the Localized Description of the Skill. - static const ucchar *getSkillLocalizedDescription(SKILLS::ESkills e); + static const char *getSkillLocalizedDescription(SKILLS::ESkills e); // Get the Localized Descriptionof the Item. - static const ucchar *getItemLocalizedDescription(NLMISC::CSheetId id); + static const char *getItemLocalizedDescription(NLMISC::CSheetId id); // Get the Localized Description of the SBrick. - static const ucchar *getSBrickLocalizedDescription(NLMISC::CSheetId id); + static const char *getSBrickLocalizedDescription(NLMISC::CSheetId id); // Get the Localized Composition Description of the SBrick. - static const ucchar *getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id); + static const char *getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id); // Get the Localized Description of the SPhrase. - static const ucchar *getSPhraseLocalizedDescription(NLMISC::CSheetId id); + static const char *getSPhraseLocalizedDescription(NLMISC::CSheetId id); // Get the Localized Title name - static const ucchar *getTitleLocalizedName(const ucstring &titleId, bool women); - static const ucchar *getLocalizedName(const ucstring &text); - static std::vector getTitleInfos(const ucstring &titleId, bool women); + static const char *getTitleLocalizedName(const std::string &titleId, bool women); + static const char *getLocalizedName(const std::string &text); + static std::vector getTitleInfos(const std::string &titleId, bool women); // Get the Localized name of a classification type - static const ucchar *getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type); + static const char *getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type); // Outpost name - static const ucchar *getOutpostLocalizedName(NLMISC::CSheetId id); + static const char *getOutpostLocalizedName(NLMISC::CSheetId id); // Outpost description - static const ucchar *getOutpostLocalizedDescription(NLMISC::CSheetId id); + static const char *getOutpostLocalizedDescription(NLMISC::CSheetId id); // Outpost building name - static const ucchar *getOutpostBuildingLocalizedName(NLMISC::CSheetId id); + static const char *getOutpostBuildingLocalizedName(NLMISC::CSheetId id); // Outpost building description - static const ucchar *getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id); + static const char *getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id); // Squad name - static const ucchar *getSquadLocalizedName(NLMISC::CSheetId id); + static const char *getSquadLocalizedName(NLMISC::CSheetId id); // Squad description - static const ucchar *getSquadLocalizedDescription(NLMISC::CSheetId id); + static const char *getSquadLocalizedDescription(NLMISC::CSheetId id); private: // constructor. @@ -149,8 +153,8 @@ private: struct TParamValue { - TParamType Type; - ucstring::size_type ReplacementPoint; + TParamType Type; + std::string::size_type ReplacementPoint; union { uint32 StringId; @@ -173,7 +177,7 @@ private: NLMISC::CBitMemStream Message; uint32 StringId; std::vector Params; - ucstring String; + std::string String; }; enum @@ -184,8 +188,8 @@ private: struct TStringWaiter { - /// Pointer to the ucstring to fill - ucstring *Result; + /// Pointer to the utf-8 string to fill + std::string *Result; /// Pointer to the remover that contains this string reference const IStringWaiterRemover *Remover; }; @@ -194,7 +198,7 @@ private: /// Container for simple strings - typedef CHashMap TStringsContainer; + typedef CHashMap TStringsContainer; /// Container for dyn strings typedef CHashMap TDynStringsContainer; /// Container of string reference waiting for value. @@ -220,7 +224,7 @@ private: TStringCallbacksContainer _DynStringsCallbacks; // Return value for waiting string.. - static ucstring _WaitString; + static std::string _WaitString; // Singleton pattern implementation static CStringManagerClient *_Instance; @@ -243,7 +247,7 @@ private: struct CCacheString { uint32 StringId; - ucstring String; + std::string String; }; std::vector _CacheStringToSave; //@} @@ -253,41 +257,60 @@ private: { public: // The Name of the item - ucstring Name; + std::string Name; // The Women Name of the item - ucstring WomenName; + std::string WomenName; // Description of the item - ucstring Desc; + std::string Desc; // Optional Second description (For SBrick composition for example) - ucstring Desc2; + std::string Desc2; void serial(NLMISC::IStream &f) { - sint ver= f.serialVersion(1); - f.serial(Name); - if (ver >= 1) + sint ver = f.serialVersion(2); + if (ver >= 2) + { + f.serial(Name); f.serial(WomenName); - f.serial(Desc); - f.serial(Desc2); + f.serial(Desc); + f.serial(Desc2); + } + else + { + nlassert(f.isReading()); + ucstring name; // Old UTF-16 serial + ucstring womenName; // Old UTF-16 serial + ucstring desc; // Old UTF-16 serial + ucstring desc2; // Old UTF-16 serial + f.serial(name); + if (ver >= 1) + f.serial(womenName); + f.serial(desc); + f.serial(desc2); + Name = name.toUtf8(); + WomenName = womenName.toUtf8(); + Desc = desc.toUtf8(); + Desc2 = desc2.toUtf8(); + } } }; static bool _SpecItem_MemoryCompressed; static std::map _SpecItem_TempMap; - static std::vector _TitleWords; - static std::map _DynStrings; + static std::vector _TitleWords; + static std::map _DynStrings; static char *_SpecItem_Labels; - static ucchar *_SpecItem_NameDesc; + static char *_SpecItem_NameDesc; struct CItemLight { - char *Label; - ucchar *Name; - ucchar *WomenName; - ucchar *Desc; - ucchar *Desc2; + const char *Label; + const char *Name; + const char *WomenName; + const char *Desc; + const char *Desc2; }; struct CItemLightComp { @@ -299,9 +322,9 @@ private: static std::vector _SpecItems; - static const ucchar *getSpecialWord(const std::string &label, bool women = false); - static const ucchar *getSpecialDesc(const std::string &label); - static const ucchar *getSpecialDesc2(const std::string &label); + static const char *getSpecialWord(const std::string &label, bool women = false); + static const char *getSpecialDesc(const std::string &label); + static const char *getSpecialDesc2(const std::string &label); // Check Files for the Packed string. class CFileCheck @@ -366,7 +389,8 @@ public: virtual ~IStringWaiterRemover() { // signal the string manager that this waiter is destroyed - CStringManagerClient::instance()->removeStringWaiter(this); + if (CStringManagerClient::hasInstance()) + CStringManagerClient::instance()->removeStringWaiter(this); } }; @@ -377,14 +401,15 @@ class IStringWaitCallback { public: /// Overide this method to receive callback for string. - virtual void onStringAvailable(uint /* stringId */, const ucstring &/* value */) {} + virtual void onStringAvailable(uint /* stringId */, const std::string &/* value */) {} /// Overide this method to receive callback for dynamic string. - virtual void onDynStringAvailable(uint /* stringId */, const ucstring &/* value */) {} + virtual void onDynStringAvailable(uint /* stringId */, const std::string &/* value */) {} virtual ~IStringWaitCallback() { // signal the string manager that this waiter is destroyed - CStringManagerClient::instance()->removeStringWaiter(this); + if (CStringManagerClient::hasInstance()) + CStringManagerClient::instance()->removeStringWaiter(this); } }; @@ -397,7 +422,7 @@ public: */ class CLoadProxy : public NLMISC::CI18N::ILoadProxy, public TStringDiff::IDiffCallback { - void loadStringFile(const std::string &filename, ucstring &text); + void loadStringFile(const std::string &filename, ucstring &text); // TODO: UTF-8 (serial) void onEquivalent(uint addIndex, uint refIndex, TStringDiffContext &context); void onAdd(uint addIndex, uint refIndex, TStringDiffContext &context); diff --git a/ryzom/client/src/teleport.cpp b/ryzom/client/src/teleport.cpp index 60d96c794..a30c2ab56 100644 --- a/ryzom/client/src/teleport.cpp +++ b/ryzom/client/src/teleport.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -107,7 +110,7 @@ void CTeleport::load(const std::string &/* filename */) && tpElmt->getValueByName(pos.z, "position.Z")) { // All in UPPER CASE to not be CASE SENSITIVE. - _Destinations.insert(make_pair(NLMISC::toLower(destName), pos)); + _Destinations.insert(make_pair(NLMISC::toLowerAscii(destName), pos)); } else nlwarning("CTeleport::load: Cannot find the one of the key 'position.X or Y or Z' for the element %d.", i); diff --git a/ryzom/client/src/text_manager.cpp b/ryzom/client/src/text_manager.cpp index bb78bffff..005013eae 100644 --- a/ryzom/client/src/text_manager.cpp +++ b/ryzom/client/src/text_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -15,7 +18,7 @@ // along with this program. If not, see . - +#if 0 #include "stdpch.h" @@ -55,14 +58,14 @@ CTextManager::CTextManager() //----------------------------------------------- /// Return the text according to the Id. //----------------------------------------------- -ucstring CTextManager::text(uint textId) +ucstring CTextManager::text(uint textId) // OLD { - map::iterator it = _Texts.find(textId); + map::iterator it = _Texts.find(textId); // OLD if(it != _Texts.end()) return (*it).second; // Return an empty string. - return ucstring(); + return ucstring(); // OLD } //----------------------------------------------- @@ -70,13 +73,14 @@ ucstring CTextManager::text(uint textId) //----------------------------------------------- void CTextManager::text(uint textId, const std::string &str) { - _Texts.insert(make_pair(textId, ucstring(str))); + _Texts.insert(make_pair(textId, ucstring(str))); // OLD } //----------------------------------------------- /// Set the text for 'textId'. //----------------------------------------------- -void CTextManager::text(uint textId, const ucstring &str) +void CTextManager::text(uint textId, const ucstring &str) // OLD { _Texts.insert(make_pair(textId, str)); } +#endif diff --git a/ryzom/client/src/text_manager.h b/ryzom/client/src/text_manager.h index 371d6bac9..579466d45 100644 --- a/ryzom/client/src/text_manager.h +++ b/ryzom/client/src/text_manager.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -14,8 +17,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// Lost code - +#if 0 #ifndef NL_TEXT_MANAGER_H #define NL_TEXT_MANAGER_H @@ -25,7 +29,7 @@ ///////////// // Misc #include "nel/misc/types_nl.h" -#include "nel/misc/ucstring.h" +#include "nel/misc/ucstring.h" // OLD // Std #include @@ -42,18 +46,18 @@ class CTextManager { protected: - std::map _Texts; + std::map _Texts; // OLD public: /// Constructor CTextManager(); /// Return the text according to the Id. - ucstring text(uint textId); + ucstring text(uint textId); // OLD /// Set the text for 'textId'. void text(uint textId, const std::string &str); /// Set the text for 'textId'. - void text(uint textId, const ucstring &str); + void text(uint textId, const ucstring &str); // OLD }; @@ -65,5 +69,6 @@ extern CTextManager TextMngr; #endif // NL_TEXT_MANAGER_H +#endif /* End of text_manager.h */ diff --git a/ryzom/client/src/timed_fx_manager.cpp b/ryzom/client/src/timed_fx_manager.cpp index b316f0ab5..c42928127 100644 --- a/ryzom/client/src/timed_fx_manager.cpp +++ b/ryzom/client/src/timed_fx_manager.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -204,7 +204,7 @@ CTimedFXManager::TFXGroupHandle CTimedFXManager::add(const std::vector //sint32 debugDay; if (!(fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::AlwaysStarted)) { - if (fi.FXSheet->Mode == CSeasonFXSheet::Spawn) + if (fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::Spawn) { // compute next spawn date float cycleLength = fi.FXSheet ? fi.FXSheet->CycleDuration : _DayLength; diff --git a/ryzom/client/src/user_entity.cpp b/ryzom/client/src/user_entity.cpp index 312fffca8..ca205c6de 100644 --- a/ryzom/client/src/user_entity.cpp +++ b/ryzom/client/src/user_entity.cpp @@ -1,9 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2674,17 +2674,6 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual { playerGiftNeeded->setValue32(0); } - // - missionOption = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); - if (missionOption) - { - missionOption->setValue32(0); - } - playerGiftNeeded = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PLAYER_GIFT_NEEDED", (int) k), false); - if (playerGiftNeeded) - { - playerGiftNeeded->setValue32(0); - } } /* TODO ULU : Add RP tags */ @@ -2952,7 +2941,7 @@ bool CUserEntity::sit(bool s) // autowalk disabled UserControls.autowalkState(false); - const string msgName = "COMMAND:SIT"; + static const string msgName = "COMMAND:SIT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -2967,7 +2956,7 @@ bool CUserEntity::sit(bool s) // display sit msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserIsSitting"); + string msg = CI18N::get("msgUserIsSitting"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -2980,7 +2969,7 @@ bool CUserEntity::sit(bool s) { if(mode(MBEHAV::NORMAL)) { - const string msgName = "COMMAND:SIT"; + static const string msgName = "COMMAND:SIT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -2995,7 +2984,7 @@ bool CUserEntity::sit(bool s) // display stand msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserIsStanding"); + string msg = CI18N::get("msgUserIsStanding"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -3071,7 +3060,7 @@ void CUserEntity::setAFK(bool b, string afkTxt) } // send afk state - string msgName = "COMMAND:AFK"; + static const string msgName = "COMMAND:AFK"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -3082,18 +3071,18 @@ void CUserEntity::setAFK(bool b, string afkTxt) nlwarning("CUserEntity:setAFK: unknown message named '%s'.", msgName.c_str()); // custom afk txt - ucstring ucstr; + ucstring ucstr; // TODO: UTF-8 (serial) ucstr.fromUtf8( afkTxt ); CBitMemStream outTxt; - msgName = "STRING:AFK_TXT"; - if( GenericMsgHeaderMngr.pushNameToStream(msgName,outTxt) ) + static const string msgNameTxt = "STRING:AFK_TXT"; + if( GenericMsgHeaderMngr.pushNameToStream(msgNameTxt,outTxt) ) { outTxt.serial( ucstr ); NetMngr.push( outTxt ); } else { - nlwarning("CUserEntity:setAFK: unknown message named '%s'.", msgName.c_str()); + nlwarning("CUserEntity:setAFK: unknown message named '%s'.", msgNameTxt.c_str()); } @@ -3115,7 +3104,7 @@ void CUserEntity::rollDice(sint16 min, sint16 max, bool local) } sint16 roll = min + (sint16)dice->rand(max-min); - ucstring msg = CI18N::get("msgRollDiceLocal"); + string msg = CI18N::get("msgRollDiceLocal"); strFindReplace(msg, "%min", toString(min)); strFindReplace(msg, "%max", toString(max)); strFindReplace(msg, "%roll", toString(roll)); @@ -3147,7 +3136,7 @@ bool CUserEntity::canEngageCombat() { // display "you can't fight while sitting" message) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCantFightSit"); + string msg = CI18N::get("msgCantFightSit"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); @@ -3158,7 +3147,7 @@ bool CUserEntity::canEngageCombat() { // display "you can't fight while swiming" message) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCantFightSwim"); + string msg = CI18N::get("msgCantFightSwim"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); @@ -3169,7 +3158,7 @@ bool CUserEntity::canEngageCombat() { // display "you can't fight while swimming" message) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCantFightRide"); + string msg = CI18N::get("msgCantFightRide"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); @@ -3832,11 +3821,10 @@ void CUserEntity::CSkillPointsObserver::update(ICDBNode* node ) string deltaStr = toString("%+d", delta); // get the sp title - ucstring spTitle; - spTitle= CI18N::get(toString("uiSkillPointsBold%d",SpType)); + const string &spTitle = CI18N::get(toString("uiSkillPointsBold%d",SpType)); // run the popup - CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+deltaStr+"|text0="+spTitle.toUtf8()); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+deltaStr+"|text0="+spTitle); // Context help contextHelp ("skill_point"); @@ -4144,7 +4132,7 @@ void CUserEntity::switchVelocity(bool userRequest) // display message : your are running, you are walking CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg; + string msg; if( _Run ) msg = CI18N::get("msgUserIsRunning"); else diff --git a/ryzom/client/src/user_entity.h b/ryzom/client/src/user_entity.h index 7d6d78f97..7499c5888 100644 --- a/ryzom/client/src/user_entity.h +++ b/ryzom/client/src/user_entity.h @@ -1,8 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -486,7 +487,7 @@ public: /// true if current behaviour allows to change front bool canChangeFront(); - ucstring getLoginName() + string getLoginName() { if (_LoginName.empty()) _LoginName = getDisplayName(); @@ -785,7 +786,7 @@ private: CItemSnapshot _PreviousRightHandItem; CItemSnapshot _PreviousLeftHandItem; - ucstring _LoginName; + std::string _LoginName; }; /// Out game received position diff --git a/ryzom/client/src/weather_manager_client.cpp b/ryzom/client/src/weather_manager_client.cpp index caa3a6099..6f13c7ee5 100644 --- a/ryzom/client/src/weather_manager_client.cpp +++ b/ryzom/client/src/weather_manager_client.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2016 Jan BOON (Kaetemi) diff --git a/ryzom/client/src/weather_manager_client.h b/ryzom/client/src/weather_manager_client.h index 98cd8f3af..8cea856ee 100644 --- a/ryzom/client/src/weather_manager_client.h +++ b/ryzom/client/src/weather_manager_client.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2016 Jan BOON (Kaetemi) diff --git a/ryzom/client/src/zone_util.cpp b/ryzom/client/src/zone_util.cpp index 33b7fdf68..e81ee4606 100644 --- a/ryzom/client/src/zone_util.cpp +++ b/ryzom/client/src/zone_util.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -44,7 +47,7 @@ bool getPosFromZoneName(const std::string &name,NLMISC::CVector2f &dest) uint32 i = 0; while (zoneName[i] != '_') { - if (!::isdigit(zoneName[i])) return false; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isdigit(zoneName[i])) return false; yStr += zoneName[i]; ++i; if (i == zoneName.size()) return false; @@ -52,8 +55,8 @@ bool getPosFromZoneName(const std::string &name,NLMISC::CVector2f &dest) ++i; while (i < zoneName.size()) { - if (!::isalpha(zoneName[i])) return false; - xStr += (char) ::toupper(zoneName[i]); ++i; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isalpha(zoneName[i])) return false; + xStr += (char) NLMISC::toUpper(zoneName[i]); ++i; } if (xStr.size() != 2) return false; dest.x = 160.f * ((xStr[0] - 'A') * 26 + (xStr[1] - 'A')); @@ -80,7 +83,7 @@ bool getZonePosFromZoneName(const std::string &name, sint &x, sint &y) uint32 i = 0; while (zoneName[i] != '_') { - if (!::isdigit(zoneName[i])) return false; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isdigit(zoneName[i])) return false; yStr += zoneName[i]; ++i; if (i == zoneName.size()) return false; @@ -88,8 +91,8 @@ bool getZonePosFromZoneName(const std::string &name, sint &x, sint &y) ++i; while (i < zoneName.size()) { - if (!::isalpha(zoneName[i])) return false; - xStr += (char) ::toupper(zoneName[i]); ++i; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isalpha(zoneName[i])) return false; + xStr += (char) NLMISC::toUpper(zoneName[i]); ++i; } if (xStr.size() != 2) return false; x = (xStr[0] - 'A') * 26 + (xStr[1] - 'A'); diff --git a/ryzom/common/src/game_share/bg_downloader_msg.cpp b/ryzom/common/src/game_share/bg_downloader_msg.cpp index 297770ddb..68720bc91 100644 --- a/ryzom/common/src/game_share/bg_downloader_msg.cpp +++ b/ryzom/common/src/game_share/bg_downloader_msg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -26,10 +29,10 @@ namespace BGDownloader const wchar_t *DownloaderMutexName = L"RyzomBgDownloader"; -ucstring getWrittenSize(uint32 nSize) +std::string getWrittenSize(uint32 nSize) { float fSize = ((float)nSize)/(1024.0f*1024.0f); - ucstring ucs = NLMISC::toString("%.1f", fSize) + " " + NLMISC::CI18N::get("uiMb"); + std::string ucs = NLMISC::toString("%.1f", fSize) + " " + NLMISC::CI18N::get("uiMb"); return ucs; } diff --git a/ryzom/common/src/game_share/bg_downloader_msg.h b/ryzom/common/src/game_share/bg_downloader_msg.h index da903493f..34b89e6cb 100644 --- a/ryzom/common/src/game_share/bg_downloader_msg.h +++ b/ryzom/common/src/game_share/bg_downloader_msg.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -137,7 +140,7 @@ extern const wchar_t *DownloaderMutexName; // get patch written size in megabytes -ucstring getWrittenSize(uint32 nSize); +std::string getWrittenSize(uint32 nSize); std::string toString(TMsgType msgType); diff --git a/ryzom/common/src/game_share/brick_families.cpp b/ryzom/common/src/game_share/brick_families.cpp index 796a2f590..19deb6f7d 100644 --- a/ryzom/common/src/game_share/brick_families.cpp +++ b/ryzom/common/src/game_share/brick_families.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/brick_families.h b/ryzom/common/src/game_share/brick_families.h index be5f521d4..8a66c1c6d 100644 --- a/ryzom/common/src/game_share/brick_families.h +++ b/ryzom/common/src/game_share/brick_families.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/character_summary.h b/ryzom/common/src/game_share/character_summary.h index 34b0f2a86..ea589d848 100644 --- a/ryzom/common/src/game_share/character_summary.h +++ b/ryzom/common/src/game_share/character_summary.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -54,7 +57,7 @@ struct CCharacterSummary TSessionId Mainland; /// name - ucstring Name; + ucstring Name; // TODO: UTF-8 (serial) /// Localisation uint32 Location; diff --git a/ryzom/common/src/game_share/character_title.h b/ryzom/common/src/game_share/character_title.h index 5ad8c3c10..d3382ab46 100644 --- a/ryzom/common/src/game_share/character_title.h +++ b/ryzom/common/src/game_share/character_title.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -301,9 +304,9 @@ inline ECharacterTitle getGMTitleFromPriv (const std::string& priv) //---------------------------------------------------------------------- -inline bool isCsrTitle(const ucstring& title) +inline bool isCsrTitle(const std::string& title) { - ECharacterTitle titleEnum = toCharacterTitle( title.toUtf8() ); + ECharacterTitle titleEnum = toCharacterTitle( title ); bool bIsCsrTitle = (titleEnum >= SGM && titleEnum <= CM); return bIsCsrTitle; diff --git a/ryzom/common/src/game_share/crypt.cpp b/ryzom/common/src/game_share/crypt.cpp index 1416cac52..5a2e99b9c 100644 --- a/ryzom/common/src/game_share/crypt.cpp +++ b/ryzom/common/src/game_share/crypt.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/ecosystem.cpp b/ryzom/common/src/game_share/ecosystem.cpp index d41cb2bac..ce3973853 100644 --- a/ryzom/common/src/game_share/ecosystem.cpp +++ b/ryzom/common/src/game_share/ecosystem.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -39,14 +42,14 @@ namespace ECOSYSTEM //----------------------------------------------- EECosystem stringToEcosystem(const string &str) { - string strL = NLMISC::toLower( str ); - if( strL == NLMISC::toLower( CommonString) ) return common_ecosystem; - if( strL == NLMISC::toLower( DesertString ) ) return desert; - if( strL == NLMISC::toLower( ForestString ) ) return forest; - if( strL == NLMISC::toLower( LacustreString ) ) return lacustre; - if( strL == NLMISC::toLower( JungleString ) ) return jungle; - if( strL == NLMISC::toLower( GooString ) ) return goo; - if( strL == NLMISC::toLower( PrimaryRootString ) ) return primary_root; + string strL = NLMISC::toLowerAscii( str ); + if( strL == NLMISC::toLowerAscii( CommonString) ) return common_ecosystem; + if( strL == NLMISC::toLowerAscii( DesertString ) ) return desert; + if( strL == NLMISC::toLowerAscii( ForestString ) ) return forest; + if( strL == NLMISC::toLowerAscii( LacustreString ) ) return lacustre; + if( strL == NLMISC::toLowerAscii( JungleString ) ) return jungle; + if( strL == NLMISC::toLowerAscii( GooString ) ) return goo; + if( strL == NLMISC::toLowerAscii( PrimaryRootString ) ) return primary_root; return unknown; } // stringToEcosystem // diff --git a/ryzom/common/src/game_share/fame.cpp b/ryzom/common/src/game_share/fame.cpp index 03bf10e45..fe3bc8a21 100644 --- a/ryzom/common/src/game_share/fame.cpp +++ b/ryzom/common/src/game_share/fame.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -366,7 +366,7 @@ void CStaticFames::loadStaticFame( const string& filename ) // 1st, build the index table for (uint i=1; i +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -159,6 +160,16 @@ bool CGenericXmlMsgHeaderManager::pushNameToStream(const string &msgName, CBitMe return res; } +// +bool CGenericXmlMsgHeaderManager::pushNameToStream(const char *msgName, CBitMemStream &strm) +{ + bool res = (_Root->select(msgName, strm) != NULL); + + if (!res) nlwarning("pushNameToStream failed: Unknown message name '%s'", msgName); + + return res; +} + // void CGenericXmlMsgHeaderManager::popNameFromStream(string &resultName, CBitMemStream &strm) { diff --git a/ryzom/common/src/game_share/generic_xml_msg_mngr.h b/ryzom/common/src/game_share/generic_xml_msg_mngr.h index a6a6a7167..4bce11d92 100644 --- a/ryzom/common/src/game_share/generic_xml_msg_mngr.h +++ b/ryzom/common/src/game_share/generic_xml_msg_mngr.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -231,6 +234,14 @@ public: */ bool pushNameToStream(const std::string &msgName, NLMISC::CBitMemStream &strm); + /** + * Convert and write a Message Name into a stream. + * \param string msgName : Message Name to convert and write into the stream. + * \param CBitMemStream strm : the stream to receive the Message Name. + * \return bool : 'false' if the method cannot write the message Name into the stream (probably because de message name is wrong). + */ + bool pushNameToStream(const char *msgName, NLMISC::CBitMemStream &strm); + /** * Convert and return the Message Name from a stream. * \param string resultName: The result for the Message Name. diff --git a/ryzom/common/src/game_share/guild_grade.cpp b/ryzom/common/src/game_share/guild_grade.cpp index e6f055649..9f83f62f0 100644 --- a/ryzom/common/src/game_share/guild_grade.cpp +++ b/ryzom/common/src/game_share/guild_grade.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -40,7 +43,7 @@ void CGuildGrade::init() for (i=0; i<4; ++i) { _StrTable[TGuildGradeConvert[i].Value] = TGuildGradeConvert[i].Name; - _ValueMap[NLMISC::toLower(std::string(TGuildGradeConvert[i].Name))] = TGuildGradeConvert[i].Value; + _ValueMap[NLMISC::toLowerAscii(std::string(TGuildGradeConvert[i].Name))] = TGuildGradeConvert[i].Value; } _Initialised = true; } diff --git a/ryzom/common/src/game_share/guild_grade_inline.h b/ryzom/common/src/game_share/guild_grade_inline.h index dcb8cfa99..3c35e3cc2 100644 --- a/ryzom/common/src/game_share/guild_grade_inline.h +++ b/ryzom/common/src/game_share/guild_grade_inline.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,7 +46,7 @@ inline CGuildGrade::TGuildGrade CGuildGrade::fromString(const std::string& v) { return Unknown; } - const std::map::const_iterator it = _ValueMap.find(NLMISC::toLower(v)); + const std::map::const_iterator it = _ValueMap.find(NLMISC::toLowerAscii(v)); if (it == _ValueMap.end()) { nlwarning("TGuildGrade::toString(): string '%s' is not matched, 'Unknown' enum value returned", v.c_str()); diff --git a/ryzom/common/src/game_share/item_infos.h b/ryzom/common/src/game_share/item_infos.h index 1cb32ae41..4cdfe67ef 100644 --- a/ryzom/common/src/game_share/item_infos.h +++ b/ryzom/common/src/game_share/item_infos.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -136,9 +139,9 @@ public: CSPhraseCom Enchantment; float WearEquipmentMalus; // Malus for wearing this equipment (malus is used when execute an magic, forage action, craft action...), malus is only applicable for weapon and armor pieces - ucstring CustomText; - ucstring R2ItemDescription; - ucstring R2ItemComment; + ucstring CustomText; // TODO: UTF-8 (serial) + ucstring R2ItemDescription; // TODO: UTF-8 (serial) + ucstring R2ItemComment; // TODO: UTF-8 (serial) uint8 PetNumber; // 1 based pet index //@} }; diff --git a/ryzom/common/src/game_share/mainland_summary.h b/ryzom/common/src/game_share/mainland_summary.h index 81c001caa..68d321ba7 100644 --- a/ryzom/common/src/game_share/mainland_summary.h +++ b/ryzom/common/src/game_share/mainland_summary.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -41,10 +44,10 @@ struct CMainlandSummary TSessionId Id; /// description - ucstring Name; + ucstring Name; // TODO: UTF-8 (serial) /// description - ucstring Description; + ucstring Description; // TODO: UTF-8 (serial) /// language code std::string LanguageCode; diff --git a/ryzom/common/src/game_share/mirrored_data_set.cpp b/ryzom/common/src/game_share/mirrored_data_set.cpp index 8db024784..61c7dc08b 100644 --- a/ryzom/common/src/game_share/mirrored_data_set.cpp +++ b/ryzom/common/src/game_share/mirrored_data_set.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/msg_client_server.h b/ryzom/common/src/game_share/msg_client_server.h index 08dc0e171..64f803e0a 100644 --- a/ryzom/common/src/game_share/msg_client_server.h +++ b/ryzom/common/src/game_share/msg_client_server.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -88,7 +91,7 @@ public: class CCheckNameMsg { public: - ucstring Name; + ucstring Name; // TODO: UTF-8 (serial) TSessionId HomeSessionId; void serialBitMemStream(NLMISC::CBitMemStream &f) @@ -633,7 +636,7 @@ public: uint8 ChatMode; // uint32 DynChatChanID; NLMISC::CEntityId DynChatChanID; - ucstring Content; + ucstring Content; // FIXME: UTF-8 (serial) CChatMsg() { @@ -650,7 +653,7 @@ public: f.serial( ChatMode ); if(ChatMode==CChatGroup::dyn_chat) f.serial(DynChatChanID); - f.serial( Content ); + f.serial( Content ); // FIXME: UTF-8 (serial) } }; @@ -669,7 +672,7 @@ public: uint32 SenderNameId; uint8 ChatMode; uint32 PhraseId; - ucstring CustomTxt; + ucstring CustomTxt; // FIXME: UTF-8 (serial) CChatMsg2() { @@ -685,7 +688,7 @@ public: f.serial( SenderNameId ); f.serial( ChatMode ); f.serial( PhraseId ); - f.serial( CustomTxt ); + f.serial( CustomTxt ); // FIXME: UTF-8 (serial) } }; @@ -700,8 +703,8 @@ public: class CFarTellMsg { public: - ucstring SenderName; - ucstring Text; + ucstring SenderName; // FIXME: UTF-8 (serial) + ucstring Text; // FIXME: UTF-8 (serial) void serial(NLMISC::CBitMemStream &f) { diff --git a/ryzom/common/src/game_share/object.cpp b/ryzom/common/src/game_share/object.cpp index bb92c4936..51e5e3ef6 100644 --- a/ryzom/common/src/game_share/object.cpp +++ b/ryzom/common/src/game_share/object.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/object.h b/ryzom/common/src/game_share/object.h index 806d790aa..5b8c1c45d 100644 --- a/ryzom/common/src/game_share/object.h +++ b/ryzom/common/src/game_share/object.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/common/src/game_share/people_pd.cpp b/ryzom/common/src/game_share/people_pd.cpp index 90bd1bc8b..cf5d41690 100644 --- a/ryzom/common/src/game_share/people_pd.cpp +++ b/ryzom/common/src/game_share/people_pd.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -194,7 +197,7 @@ void CPeople::init() for (i=0; i<159; ++i) { _StrTable[TPeopleConvert[i].Value] = TPeopleConvert[i].Name; - _ValueMap[NLMISC::toLower(std::string(TPeopleConvert[i].Name))] = TPeopleConvert[i].Value; + _ValueMap[NLMISC::toLowerAscii(std::string(TPeopleConvert[i].Name))] = TPeopleConvert[i].Value; } _Initialised = true; } @@ -239,7 +242,7 @@ void CClassificationType::init() for (i=0; i<20; ++i) { _StrTable[TClassificationTypeConvert[i].Value] = TClassificationTypeConvert[i].Name; - _ValueMap[NLMISC::toLower(std::string(TClassificationTypeConvert[i].Name))] = TClassificationTypeConvert[i].Value; + _ValueMap[NLMISC::toLowerAscii(std::string(TClassificationTypeConvert[i].Name))] = TClassificationTypeConvert[i].Value; } _Initialised = true; } diff --git a/ryzom/common/src/game_share/people_pd_inline.h b/ryzom/common/src/game_share/people_pd_inline.h index b5bfc6097..5e749eda9 100644 --- a/ryzom/common/src/game_share/people_pd_inline.h +++ b/ryzom/common/src/game_share/people_pd_inline.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,7 +46,7 @@ inline CPeople::TPeople CPeople::fromString(const std::string& v) { return Unknown; } - const std::map::const_iterator it = _ValueMap.find(NLMISC::toLower(v)); + const std::map::const_iterator it = _ValueMap.find(NLMISC::toLowerAscii(v)); if (it == _ValueMap.end()) { nlwarning("TPeople::toString(): string '%s' is not matched, 'Unknown' enum value returned", v.c_str()); @@ -79,7 +82,7 @@ inline CClassificationType::TClassificationType CClassificationType::fromString( { return Unknown; } - const std::map::const_iterator it = _ValueMap.find(NLMISC::toLower(v)); + const std::map::const_iterator it = _ValueMap.find(NLMISC::toLowerAscii(v)); if (it == _ValueMap.end()) { nlwarning("TClassificationType::toString(): string '%s' is not matched, 'Unknown' enum value returned", v.c_str()); diff --git a/ryzom/common/src/game_share/player_visual_properties.cpp b/ryzom/common/src/game_share/player_visual_properties.cpp index 33f9da0a6..2dde246b2 100644 --- a/ryzom/common/src/game_share/player_visual_properties.cpp +++ b/ryzom/common/src/game_share/player_visual_properties.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/player_visual_properties.h b/ryzom/common/src/game_share/player_visual_properties.h index 14f245d97..30a223d6d 100644 --- a/ryzom/common/src/game_share/player_visual_properties.h +++ b/ryzom/common/src/game_share/player_visual_properties.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/pvp_clan.cpp b/ryzom/common/src/game_share/pvp_clan.cpp index 81a2ca1d3..b25ce9971 100644 --- a/ryzom/common/src/game_share/pvp_clan.cpp +++ b/ryzom/common/src/game_share/pvp_clan.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2018 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -52,9 +55,7 @@ namespace PVP_CLAN std::string toLowerString(TPVPClan clan) { - CSString s = PVPClanConversion.toString(clan); - CSString sl = s.toLower(); - return sl; + return toLowerAscii(PVPClanConversion.toString(clan)); } uint32 getFactionIndex(TPVPClan clan) diff --git a/ryzom/common/src/game_share/ring_access.cpp b/ryzom/common/src/game_share/ring_access.cpp index 1d178efad..5c2f4d6d5 100644 --- a/ryzom/common/src/game_share/ring_access.cpp +++ b/ryzom/common/src/game_share/ring_access.cpp @@ -156,7 +156,7 @@ void CRingAccess::init() CXMLAutoPtr sheetClientPtr( (const char*) xmlGetProp(entityAccess, (xmlChar*) "sheetClient") ); CXMLAutoPtr sheetPtr( (const char*) xmlGetProp(entityAccess, (xmlChar*) "sheetServer") ); - if (!namePtr.getDatas()|| !packagePtr.getDatas() || !sheetPtr.getDatas() || !sheetPtr.getDatas()) + if (!namePtr.getDatas()|| !packagePtr.getDatas() || !sheetClientPtr.getDatas() || !sheetPtr.getDatas()) { nlerror( "Syntax error in %s", pathFileName.c_str()); return; diff --git a/ryzom/common/src/game_share/rm_family.cpp b/ryzom/common/src/game_share/rm_family.cpp index a45793aad..cae184117 100644 --- a/ryzom/common/src/game_share/rm_family.cpp +++ b/ryzom/common/src/game_share/rm_family.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -118,7 +121,7 @@ namespace RM_FABER_TYPE } /// Client: use the CI18N - const ucstring& toLocalString( TRMFType e ) + const std::string& toLocalString( TRMFType e ) { return CI18N::get("mpft" + toString(e)); } @@ -134,7 +137,7 @@ namespace RM_FABER_TYPE namespace RM_FAMILY { /// Get the Localized UCString - const ucstring& toLocalString( TRMFamily e ) + const std::string& toLocalString( TRMFamily e ) { return CI18N::get("mpfam" + toString(e)); } @@ -144,7 +147,7 @@ namespace RM_FAMILY namespace RM_GROUP { /// Get the Localized UCString - const ucstring& toLocalString( TRMGroup e ) + const std::string& toLocalString( TRMGroup e ) { return CI18N::get("mpgroup" + toString(e)); } @@ -154,7 +157,7 @@ namespace RM_GROUP namespace RM_FABER_PROPERTY { /// Get the Localized UCString - const ucstring& toLocalString( TRMFProperty e ) + const std::string& toLocalString( TRMFProperty e ) { return CI18N::get("mpprop" + toString(e)); } @@ -188,7 +191,7 @@ namespace RM_FABER_QUALITY } /// Client: use the CI18N - const ucstring& toLocalString( TFaberQuality e ) + const std::string& toLocalString( TFaberQuality e ) { return CI18N::get("mpfq" + toString(e)); } @@ -224,7 +227,7 @@ namespace RM_COLOR } /// Get the Localized UCString - const ucstring& toLocalString( sint value ) + const std::string& toLocalString( sint value ) { return CI18N::get("mpcol" + toString(value)); } @@ -283,7 +286,7 @@ namespace RM_FABER_STAT_TYPE return conversion.toString(stats); } - const ucstring& toLocalString( TRMStatType stats ) + const std::string& toLocalString( TRMStatType stats ) { // must change en.uxt nlctassert(NumRMStatType == sizeof(stringTable)/sizeof(stringTable[0])); @@ -663,9 +666,9 @@ namespace RM_FABER_STAT_TYPE namespace RM_CLASS_TYPE { -const ucstring &toLocalString(TRMClassType classType) +const std::string &toLocalString(TRMClassType classType) { - return CI18N::get(toString("uiItemRMClass%d", classType).c_str()); + return CI18N::get(toString("uiItemRMClass%d", classType)); } diff --git a/ryzom/common/src/game_share/rm_family.h b/ryzom/common/src/game_share/rm_family.h index a69a51517..627969214 100644 --- a/ryzom/common/src/game_share/rm_family.h +++ b/ryzom/common/src/game_share/rm_family.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -85,7 +88,7 @@ namespace RM_FABER_TYPE const std::string &faberTypeToSheetEntry(TRMFType type); /// Get the Localized UCString - const ucstring& toLocalString( TRMFType e ); + const std::string& toLocalString( TRMFType e ); /// For Client Interface, return the define name of the type (eg: "item_part_icon_MpL") std::string toIconDefineString( TRMFType e ); @@ -101,7 +104,7 @@ namespace RM_FAMILY const TRMFamily Unknown = 0; /// Get the Localized UCString - const ucstring& toLocalString( TRMFamily e ); + const std::string& toLocalString( TRMFamily e ); /// Debug string inline std::string toString( TRMFamily e ) { return NLMISC::toString(e); } @@ -119,7 +122,7 @@ namespace RM_GROUP const TRMGroup Unknown = 0; /// Get the Localized UCString - const ucstring& toLocalString( TRMGroup e ); + const std::string& toLocalString( TRMGroup e ); // Note: the group names are accessible on server by CMP::rmGroupToString() @@ -138,7 +141,7 @@ namespace RM_FABER_PROPERTY const TRMFProperty Unknown = 0; /// Get the Localized UCString - const ucstring& toLocalString( TRMFProperty e ); + const std::string& toLocalString( TRMFProperty e ); /// Debug string inline std::string toString( TRMFProperty e ) { return NLMISC::toString(e); } @@ -178,7 +181,7 @@ namespace RM_FABER_QUALITY TFaberQuality toFaberQuality( const std::string& str ); /// Get the Localized UCString - const ucstring& toLocalString( TFaberQuality e ); + const std::string& toLocalString( TFaberQuality e ); } @@ -199,7 +202,7 @@ namespace RM_COLOR const std::string& toString( sint value ); /// Get the Localized UCString - const ucstring& toLocalString( sint value ); + const std::string& toLocalString( sint value ); }; @@ -251,7 +254,7 @@ namespace RM_FABER_STAT_TYPE const std::string& toString( TRMStatType stats ); /// Get the Localized UCString - const ucstring& toLocalString( TRMStatType stats ); + const std::string& toLocalString( TRMStatType stats ); /// For each Raw material faber type, does this Stat is relevant? bool isStatRelevant(RM_FABER_TYPE::TRMFType ft, TRMStatType fs); @@ -309,7 +312,7 @@ namespace RM_CLASS_TYPE }; /// Get the Localized UCString - const ucstring& toLocalString( TRMClassType classType ); + const std::string& toLocalString( TRMClassType classType ); /// return the item class for a given stat energy [0..100] inline TRMClassType getItemClass(uint32 energy) diff --git a/ryzom/common/src/game_share/roles.cpp b/ryzom/common/src/game_share/roles.cpp index 57ccfdcd4..f4471183a 100644 --- a/ryzom/common/src/game_share/roles.cpp +++ b/ryzom/common/src/game_share/roles.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -73,7 +76,7 @@ ERole toRoleId( const std::string& Role ) } // Return the Translated name of the Job -const ucstring &roleToUCString (ERole r) +const std::string &roleToUCString(ERole r) { return NLMISC::CI18N::get( toString( r ) ); } diff --git a/ryzom/common/src/game_share/roles.h b/ryzom/common/src/game_share/roles.h index 9164a3254..226a4d3c6 100644 --- a/ryzom/common/src/game_share/roles.h +++ b/ryzom/common/src/game_share/roles.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -60,7 +63,7 @@ const std::string& toString( ERole r ); ERole toRoleId( const std::string& Role ); // Return the Translated name of the Job -const ucstring &roleToUCString (ERole r); +const std::string &roleToUCString (ERole r); } // ROLES diff --git a/ryzom/common/src/game_share/sabrina_com.cpp b/ryzom/common/src/game_share/sabrina_com.cpp index e7d21cd60..570993f27 100644 --- a/ryzom/common/src/game_share/sabrina_com.cpp +++ b/ryzom/common/src/game_share/sabrina_com.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/sabrina_com.h b/ryzom/common/src/game_share/sabrina_com.h index d799a421e..9ae501c29 100644 --- a/ryzom/common/src/game_share/sabrina_com.h +++ b/ryzom/common/src/game_share/sabrina_com.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/season.cpp b/ryzom/common/src/game_share/season.cpp index a7065062c..bfe2b5c4f 100644 --- a/ryzom/common/src/game_share/season.cpp +++ b/ryzom/common/src/game_share/season.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -41,7 +44,7 @@ void CSeason::init() for (i=0; i<5; ++i) { _StrTable[TSeasonConvert[i].Value] = TSeasonConvert[i].Name; - _ValueMap[NLMISC::toLower(std::string(TSeasonConvert[i].Name))] = TSeasonConvert[i].Value; + _ValueMap[NLMISC::toLowerAscii(std::string(TSeasonConvert[i].Name))] = TSeasonConvert[i].Value; } _Initialised = true; } diff --git a/ryzom/common/src/game_share/season_inline.h b/ryzom/common/src/game_share/season_inline.h index 069d29cbc..69a308c95 100644 --- a/ryzom/common/src/game_share/season_inline.h +++ b/ryzom/common/src/game_share/season_inline.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,7 +46,7 @@ inline CSeason::TSeason CSeason::fromString(const std::string& v) { return Unknown; } - const std::map::const_iterator it = _ValueMap.find(NLMISC::toLower(v)); + const std::map::const_iterator it = _ValueMap.find(NLMISC::toLowerAscii(v)); if (it == _ValueMap.end()) { nlwarning("TSeason::toString(): string '%s' is not matched, 'Unknown' enum value returned", v.c_str()); diff --git a/ryzom/common/src/game_share/server_animation_module.cpp b/ryzom/common/src/game_share/server_animation_module.cpp index 3c3276130..634d518c3 100644 --- a/ryzom/common/src/game_share/server_animation_module.cpp +++ b/ryzom/common/src/game_share/server_animation_module.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/common/src/game_share/server_edition_module.cpp b/ryzom/common/src/game_share/server_edition_module.cpp index 79cf9a6f2..5936247a1 100644 --- a/ryzom/common/src/game_share/server_edition_module.cpp +++ b/ryzom/common/src/game_share/server_edition_module.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -1394,7 +1397,7 @@ void CServerEditionModule::connectChar(TSessionId sessionId, TCharId charId, TUs CMessage msg("HELLO"); clientEditionProxy->sendModuleMessage(this->getAnimationModule()->getModule(), msg); } - _PioneersInfo[charId].RingAccess = CSString(ringAccess).toLower(); + _PioneersInfo[charId].RingAccess = toLowerAscii(ringAccess); _PioneersInfo[charId].Newcomer = newcomer; if (_SessionManager) @@ -1434,7 +1437,7 @@ void CServerEditionModule::connectChar(TSessionId sessionId, TCharId charId, TUs if ( first->size() >= length && first->substr(0, length) == r2a) { - std::string ra = CSString(first->substr(length) ).replace("_", ":").toLower(); + std::string ra = toLowerAscii(CSString(first->substr(length) ).replace("_", ":")); _PioneersInfo[charId].RingAccess = ra; break; } @@ -2943,7 +2946,7 @@ void CServerEditionModule::addCharacterInSession(NLNET::IModuleProxy *sender, TS } - std::string upgradedRingAccess = CRingAccess::getInstance().upgradeRingAccess(CSString(DefaultCharRingAccess.get()).toLower(), CSString(ringAccess).toLower()) ; + std::string upgradedRingAccess = CRingAccess::getInstance().upgradeRingAccess(toLowerAscii(DefaultCharRingAccess.get()), toLowerAscii(ringAccess)) ; // TODO use security info for overdoing ring access diff --git a/ryzom/common/src/game_share/sp_type.cpp b/ryzom/common/src/game_share/sp_type.cpp index 15a6b2f93..7e506e344 100644 --- a/ryzom/common/src/game_share/sp_type.cpp +++ b/ryzom/common/src/game_share/sp_type.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -40,7 +43,7 @@ void CSPType::init() for (i=0; i<4; ++i) { _StrTable[TSPTypeConvert[i].Value] = TSPTypeConvert[i].Name; - _ValueMap[NLMISC::toLower(std::string(TSPTypeConvert[i].Name))] = TSPTypeConvert[i].Value; + _ValueMap[NLMISC::toLowerAscii(std::string(TSPTypeConvert[i].Name))] = TSPTypeConvert[i].Value; } _Initialised = true; } diff --git a/ryzom/common/src/game_share/sp_type_inline.h b/ryzom/common/src/game_share/sp_type_inline.h index 3f85729d2..71fa89f66 100644 --- a/ryzom/common/src/game_share/sp_type_inline.h +++ b/ryzom/common/src/game_share/sp_type_inline.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,7 +46,7 @@ inline CSPType::TSPType CSPType::fromString(const std::string& v) { return Unknown; } - const std::map::const_iterator it = _ValueMap.find(NLMISC::toLower(v)); + const std::map::const_iterator it = _ValueMap.find(NLMISC::toLowerAscii(v)); if (it == _ValueMap.end()) { nlwarning("TSPType::toString(): string '%s' is not matched, 'Unknown' enum value returned", v.c_str()); diff --git a/ryzom/common/src/game_share/sphrase_com.h b/ryzom/common/src/game_share/sphrase_com.h index 476034b2f..a71a0824b 100644 --- a/ryzom/common/src/game_share/sphrase_com.h +++ b/ryzom/common/src/game_share/sphrase_com.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -63,7 +66,7 @@ public: std::vector Bricks; // Name Of the Phrase. Saved on server, read on client. - ucstring Name; + ucstring Name; // FIXME: UTF-8 (serial) /// The comparison is made only on Bricks bool operator==(const CSPhraseCom &p) const; diff --git a/ryzom/common/src/game_share/time_weather_season/time_and_season.h b/ryzom/common/src/game_share/time_weather_season/time_and_season.h index 47734a2ba..d59258822 100644 --- a/ryzom/common/src/game_share/time_weather_season/time_and_season.h +++ b/ryzom/common/src/game_share/time_weather_season/time_and_season.h @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: // Copyright (C) 2016 Jan BOON (Kaetemi) diff --git a/ryzom/common/src/game_share/time_weather_season/weather_function.cpp b/ryzom/common/src/game_share/time_weather_season/weather_function.cpp index 02432142f..e43561da1 100644 --- a/ryzom/common/src/game_share/time_weather_season/weather_function.cpp +++ b/ryzom/common/src/game_share/time_weather_season/weather_function.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -37,7 +40,7 @@ CWeatherFunction::CWeatherFunction() void CWeatherFunction::buildFromSheet(const CWeatherFunctionSheet &sheet, const CWeatherManager &wm) { // copy common part of objects (parameters) - *static_cast(this) = *static_cast(&sheet); + static_cast(*this) = static_cast(sheet); // get pointer on the setup from their names _WeatherSetups.resize(sheet.SetupNames.size()); nlassert(sheet.SetupWeights.size() == sheet.SetupNames.size()); diff --git a/ryzom/common/src/game_share/time_weather_season/weather_manager.cpp b/ryzom/common/src/game_share/time_weather_season/weather_manager.cpp index 7d2f42aa7..06e3269b4 100644 --- a/ryzom/common/src/game_share/time_weather_season/weather_manager.cpp +++ b/ryzom/common/src/game_share/time_weather_season/weather_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -35,7 +38,7 @@ void CWeatherManager::init(const std::vector &sh { if (sheets[k]) { - std::string id = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(sheetNames[k])); + std::string id = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(sheetNames[k])); CWeatherSetup *ws = newWeatherSetup(); if (ws) { @@ -70,7 +73,7 @@ void CWeatherManager::release() //================================================================================================ const CWeatherSetup *CWeatherManager::getSetup(const char *name) const { - std::string id = NLMISC::toLower(CFile::getFilenameWithoutExtension(name)); + std::string id = NLMISC::toLowerAscii(CFile::getFilenameWithoutExtension(name)); TWeatherSetupMap::const_iterator it = _WeatherSetupMap.find(id); if (it == _WeatherSetupMap.end()) return NULL; return it->second; diff --git a/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp b/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp index a1a56f18e..cd9e9080c 100644 --- a/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp +++ b/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -85,7 +88,7 @@ void CWeatherStateSheet::build(const NLGEORGES::UFormElm &item) GetWeatherFormValue(item, fxName, "FXName"); if (!fxName.empty()) { - fxName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fxName)); + fxName = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(fxName)); if (!fxName.empty()) { FXInfos.resize(1); @@ -192,7 +195,7 @@ void CWeatherSetupSheetBase::build(const NLGEORGES::UFormElm &item) CloudState.build(item); std::string setupName; GetWeatherFormValue(item, setupName, "SetupName"); - SetupName = NLMISC::CStringMapper::map(NLMISC::toLower(setupName)); + SetupName = NLMISC::CStringMapper::map(NLMISC::toLowerAscii(setupName)); } //================================================================================== @@ -203,7 +206,7 @@ void CWeatherSetupSheetBase::serial(NLMISC::IStream &f) { std::string setupName; f.serial(setupName); - SetupName = NLMISC::CStringMapper::map(NLMISC::toLower(setupName)); + SetupName = NLMISC::CStringMapper::map(NLMISC::toLowerAscii(setupName)); } else { diff --git a/ryzom/common/src/game_share/timer.h b/ryzom/common/src/game_share/timer.h index 1659464fa..8f7ed63dd 100644 --- a/ryzom/common/src/game_share/timer.h +++ b/ryzom/common/src/game_share/timer.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/common/src/game_share/utils.h b/ryzom/common/src/game_share/utils.h index a534b156b..eb527162f 100644 --- a/ryzom/common/src/game_share/utils.h +++ b/ryzom/common/src/game_share/utils.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -43,7 +44,11 @@ inline std::string capitalize(const std::string & s) if ( s.empty() ) return s; - return NLMISC::toUpper( s.substr(0,1) ) + NLMISC::toLower( s.substr(1,std::string::npos) ); + std::string res; + res.reserve(4); + ptrdiff_t i = 0; + NLMISC::appendToUpper(res, s, i); + return res + NLMISC::toLower(s.substr(i)); } inline ucstring capitalize(const ucstring & s) @@ -51,7 +56,8 @@ inline ucstring capitalize(const ucstring & s) if ( s.empty() ) return s; - return NLMISC::toUpper( s.substr(0,1) ) + NLMISC::toLower( s.substr(1,std::string::npos) ); + // return NLMISC::toUpper( s.substr(0,1) ) + NLMISC::toLower( s.substr(1,std::string::npos) ); + return ucstring::makeFromUtf8(capitalize(s.toUtf8())); } diff --git a/ryzom/common/src/game_share/visual_slot_manager.h b/ryzom/common/src/game_share/visual_slot_manager.h index 4fd46cd81..de1a5634a 100644 --- a/ryzom/common/src/game_share/visual_slot_manager.h +++ b/ryzom/common/src/game_share/visual_slot_manager.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -53,7 +56,7 @@ public: static void releaseInstance(); public: - typedef struct + typedef struct TElement { uint32 Index; NLMISC::CSheetId SheetId; @@ -66,7 +69,7 @@ public: } } TElement; - typedef struct + typedef struct TElementList { // elements list for a visual slot. std::vector Element; diff --git a/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp b/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp index f38e5299b..3ba0d9bf3 100644 --- a/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp +++ b/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -42,13 +45,13 @@ void CGeneralSettingsWidget::load() CSystem &s = CSystem::GetInstance(); std::vector codes = NLMISC::CI18N::getLanguageCodes(); - std::vector names = NLMISC::CI18N::getLanguageNames(); + std::vector names = NLMISC::CI18N::getLanguageNames(); languageComboBox->clear(); for(uint i = 0; i < codes.size(); ++i) { - languageComboBox->addItem(QString::fromUtf16(names[i].c_str()), QString::fromUtf8(codes[i].c_str())); + languageComboBox->addItem(QString::fromUtf8(names[i].c_str()), QString::fromUtf8(codes[i].c_str())); } sint32 cbIndex = getIndexForLanguageCode( QString::fromUtf8( s.config.getString( "LanguageCode" ).c_str() ) ); diff --git a/ryzom/tools/client/client_patcher/main.cpp b/ryzom/tools/client/client_patcher/main.cpp index 21fc58959..fb1801fc5 100644 --- a/ryzom/tools/client/client_patcher/main.cpp +++ b/ryzom/tools/client/client_patcher/main.cpp @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) INelContext::getInstance().getWarningLog()->removeDisplayer("DEFAULT_SD"); // check if console supports colors - std::string term = toLower(std::string(getenv("TERM") ? getenv("TERM"):"")); + std::string term = toLowerAscii(std::string(getenv("TERM") ? getenv("TERM"):"")); useEsc = (term.find("xterm") != string::npos || term.find("linux") != string::npos); #ifdef NL_OS_WINDOWS @@ -293,15 +293,15 @@ int main(int argc, char *argv[]) printf("\n"); printf("Checking %s files to patch...\n", convert(CI18N::get("TheSagaOfRyzom")).c_str()); printf("Using '%s/%s.version'\n", ClientCfg.ConfigFile.getVar("PatchUrl").asString().c_str(), - ClientCfg.ConfigFile.getVar("Application").asString().c_str()); + ClientCfg.ConfigFile.getVar("Application").asString().c_str()); // use PatchUrl vector patchURLs; pPM->init(patchURLs, ClientCfg.ConfigFile.getVar("PatchUrl").asString(), ""); pPM->startCheckThread(true /* include background patchs */); - ucstring state; - vector log; + string state; + vector log; bool res = false; bool finished = false; @@ -377,6 +377,7 @@ int main(int argc, char *argv[]) try { // move downloaded files to final location + // batch file will not be created pPM->createBatchFile(pPM->getDescFile(), false, false); CFile::createEmptyFile("show_eula"); @@ -407,17 +408,20 @@ int main(int argc, char *argv[]) printError(convert(CI18N::get("uiErrPatchApply")) + " " + error); return 1; } - - pPM->executeBatchFile(); } -/* - // Start Scanning - pPM->startScanDataThread(); - - // request to stop the thread - pPM->askForStopScanDataThread(); -*/ + // upgd_nl.sh will normally take care of the permissions + // + // for linux/macOS (no-op on windows) + // Set for current executable (might be 'dev' version), + // and also 'ryzom_client_patcher' directly (from patched files) + CFile::setExecutable(Args.getProgramPath() + Args.getProgramName()); + CFile::setExecutable("ryzom_client_patcher"); + // other + CFile::setExecutable("crash_report"); + CFile::setExecutable("ryzom_client"); + CFile::setExecutable("ryzom_installer_qt"); + CFile::setExecutable("ryzom_configuration_qt"); return 0; } diff --git a/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp b/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp index f76b1baf3..ae8595bf8 100644 --- a/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp +++ b/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -1369,6 +1370,7 @@ void CScreenshotIslands::buildIslandsTextures() // Create and load landscape ULandscape * landscape = scene->createLandscape(); landscape->setThreshold(0.0005); + landscape->setTileNear(10000); if(_InverseZTest) { landscape->setZFunc(UMaterial::greaterequal); @@ -1464,7 +1466,7 @@ void CScreenshotIslands::buildIslandsTextures() vector zonesAdded; vector zonesRemoved; IProgressCallback progress; - landscape->refreshAllZonesAround(camera.getMatrix().getPos(), 1000, zonesAdded, zonesRemoved, progress); + landscape->refreshAllZonesAround(camera.getMatrix().getPos(), 2000, zonesAdded, zonesRemoved, progress); if(_Vegetation) { LandscapeIGManager.unloadArrayZoneIG(zonesRemoved); @@ -1644,8 +1646,8 @@ void CScreenshotIslands::buildIslandsTextures() // little tga - bitmapLittle.resample(bitmapLittle.getWidth()/10, bitmapLittle.getHeight()/10); - if(!isPowerOf2(bitmapLittle.getWidth()) || !isPowerOf2(bitmapLittle.getHeight()) ) + bitmapLittle.resample(bitmapLittle.getWidth() / 20, bitmapLittle.getHeight() / 20); + if (!isPowerOf2(bitmapLittle.getWidth()) || !isPowerOf2(bitmapLittle.getHeight())) { uint pow2w = NLMISC::raiseToNextPowerOf2(bitmapLittle.getWidth()); uint pow2h = NLMISC::raiseToNextPowerOf2(bitmapLittle.getHeight()); @@ -1871,15 +1873,19 @@ void CScreenshotIslands::buildBackTextureHLS(const std::string & islandName, con { _BackColor = maxColor; - CRandom randomGenerator; + std::string islandNameLwr = toLowerAscii(islandName); + uint32_t seed = 0; + for (ptrdiff_t i = 0; i < (ptrdiff_t)islandNameLwr.size(); ++i) + seed += wangHash(seed ^ islandNameLwr[i]); uint8 * backPixels = &(_BackBitmap.getPixels(0)[0]); + uint i = 0; for(uint x=0; x<_BackBitmap.getWidth(); x++) { - for(uint y=0; y<_BackBitmap.getHeight(); y++) + for(uint y=0; y<_BackBitmap.getHeight(); y++, i++) { - sint32 randomVal = randomGenerator.rand(colorsNb-1); + sint32 randomVal = wangHash(seed ^ i) % colorsNb; const CRGBA & color = sortedColors[randomVal]; *backPixels = (uint8) color.R; diff --git a/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index a1380407c..2a1eac76a 100644 --- a/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -1,5 +1,5 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010-2019 Winch Gate Property Limited +// Copyright (C) 2010-2020 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index 673c12d9a..24d2bec98 100644 --- a/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -187,7 +187,7 @@ BOOL CFileTreeCtrl::OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ) { LPNMHDR pnmh = (LPNMHDR) lParam; // Tree ? - if (wParam == 0) + // if (wParam == 0) { switch (pnmh->code) { diff --git a/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index a4d35fdcc..9d3b4df65 100644 --- a/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -720,6 +720,8 @@ void CFormDialog::onLastFocus () int CFormDialog::getWidget (uint dialogId) const { + if (dialogId == 0xFFFE) + dialogId = 0; for (uint i=0; iisDialog (dialogId)) @@ -1198,6 +1200,11 @@ void CFormDialog::onGetSubFocus (uint id) { // Get the widget int widget = getWidget (id); + if (widget < 0) + { + nldebug("Invalid widget id %d", (int)id); + return; + } WidgetFocused = widget; // Window view @@ -1584,7 +1591,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, { // Create the mem combobox parent->setComboSpinSize (currentPos); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE, reg, theApp.RememberListSize); parent->initWidget (Combo); // Create the spin @@ -1599,7 +1606,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, { // Create the mem combobox parent->setComboBrowseSize (currentPos); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE, reg, theApp.RememberListSize); parent->initWidget (Combo); // Create the spin @@ -1621,7 +1628,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, { // Create the mem combobox parent->setComboSize (currentPos, parent->SmallWidget); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE, reg, theApp.RememberListSize); parent->initWidget (Combo); parent->getNextPos (currentPos); } @@ -1914,7 +1921,7 @@ void CFormCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui parent->setComboSize (currentPos, parent->SmallWidget); RECT comboPos = currentPos; parent->adjusteComboSize (comboPos); - Combo.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_CHILD|WS_TABSTOP, comboPos, parent, dialog_index); + Combo.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_CHILD|WS_TABSTOP, comboPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Combo); parent->getNextPos (currentPos); @@ -2097,7 +2104,7 @@ void CFormBigEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, // Create the mem combobox parent->setBigEditSize (currentPos, parent->SmallWidget); - Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index); + Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Edit); parent->getNextPos (currentPos); @@ -2271,7 +2278,7 @@ void CColorEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui // Create the mem combobox parent->setColorSize (currentPos, parent->SmallWidget); - Color.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + Color.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Color); // Create the reset button @@ -2501,7 +2508,7 @@ void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the mem combobox parent->setListSize (currentPos, parent->SmallWidget); - ListCtrl.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + ListCtrl.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (ListCtrl); parent->getNextPos (currentPos); @@ -2759,7 +2766,7 @@ void CIconWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the mem combobox parent->setEditSize (currentPos, parent->IconHeight, parent->IconHeight); - Icon.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + Icon.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Icon); parent->getNextPos (currentPos); diff --git a/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp b/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp index d7dcd6b89..3505cc48c 100644 --- a/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp +++ b/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -184,7 +184,7 @@ bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement) } // Set file name and title - std::string name2 = toLower(NLMISC::CFile::getFilenameWithoutExtension(dfnName)); + std::string name2 = toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(dfnName)); SetPathName(nlUtf8ToTStr("*." + name2), FALSE); SetTitle(nlUtf8ToTStr("New " + name2 + " form")); @@ -547,7 +547,7 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) { // Check form std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(lpszPathName)); - string extLower = toLower(ext); + string extLower = toLowerAscii(ext); if (!extLower.empty ()) { diff --git a/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp b/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp index 824da9f2a..380aafcac 100644 --- a/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp +++ b/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -107,7 +107,7 @@ void CImageListEx::addResourceIcon (const char *filename) // Add in the map std::string name = NLMISC::CFile::getFilenameWithoutExtension(filename); - _IconMapString.insert (std::map::value_type (toLower(name), index)); + _IconMapString.insert (std::map::value_type (toLowerAscii(name), index)); // Release the icon DestroyIcon (handle); @@ -132,7 +132,7 @@ int CImageListEx::getImage (int resource) const int CImageListEx::getImage (const char *filename) const { - std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::string name = toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(filename)); std::map::const_iterator ite = _IconMapString.find (name); if (ite == _IconMapString.end()) return -1; diff --git a/ryzom/tools/leveldesign/install/georges.cfg b/ryzom/tools/leveldesign/install/georges.cfg index d108f3100..cc3723933 100644 --- a/ryzom/tools/leveldesign/install/georges.cfg +++ b/ryzom/tools/leveldesign/install/georges.cfg @@ -13,3 +13,4 @@ UserType = { StartExpanded = 1; SamplePath = "R:\sound\samplebanks"; PackedSheetPath = "R:\sound\"; +IconPath = "R:\graphics\interfaces"; diff --git a/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp b/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp index 1198d166d..1f2e63f3d 100644 --- a/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp +++ b/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -239,8 +239,8 @@ BOOL CMissionCompilerFeDlg::OnInitDialog() { // We found the same filename : check the path string srcPath = it->second; - srcPath = toUpper(CPath::standardizeDosPath(srcPath)); - files[i] = toUpper(CPath::standardizeDosPath(files[i])); + srcPath = toUpperAscii(CPath::standardizeDosPath(srcPath)); + files[i] = toUpperAscii(CPath::standardizeDosPath(files[i])); if (srcPath != files[i]) { ::MessageBox(NULL, _T("Primitive path and working directory are not the same !"), diff --git a/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp b/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp index 6c4285d46..6f32fbd8c 100644 --- a/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp +++ b/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp b/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp index b664bb0e2..d58ecbb43 100644 --- a/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp +++ b/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2011 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -189,7 +189,7 @@ GenderExtractor::GenderExtractor(const std::string & literal, const std::string& const char * f = fs[level]; const char * h = hs[level]; - _Identifier = toLower(identifier); + _Identifier = toLowerAscii(identifier); std::string newPhrase; @@ -657,7 +657,7 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c // use mission primitive instead fileName = primFileName; } - if (loadedPrimitives.find(toLower(fileName)) == loadedPrimitives.end()) + if (loadedPrimitives.find(toLowerAscii(fileName)) == loadedPrimitives.end()) { string fullFileName = CPath::lookup(fileName, false); if (fullFileName.empty()) @@ -670,7 +670,7 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c if (loadXmlPrimitiveFile(*primDoc, fullFileName, ligoConfig)) { // the primitive file is loaded correctly - loadedPrimitives.insert(make_pair(toLower(fileName), TLoadedPrimitive(primDoc, fullFileName))); + loadedPrimitives.insert(make_pair(toLowerAscii(fileName), TLoadedPrimitive(primDoc, fullFileName))); CPrimitiveContext::instance().CurrentPrimitive = NULL; } else @@ -679,7 +679,7 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c throw EParseException(NULL, toString("Can't read primitive file '%s'", fullFileName.c_str()).c_str()); } } - TLoadedPrimitive &loadedPrim = loadedPrimitives[toLower(fileName)]; + TLoadedPrimitive &loadedPrim = loadedPrimitives[toLowerAscii(fileName)]; CPrimitives *primDoc = loadedPrim.PrimDoc; TPrimitiveSet scripts; @@ -744,7 +744,7 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c fileName = primFileName; } - TLoadedPrimitive &loadedPrim = loadedPrimitives[toLower(fileName)]; + TLoadedPrimitive &loadedPrim = loadedPrimitives[toLowerAscii(fileName)]; CPrimitives *primDoc = loadedPrim.PrimDoc; CPrimitiveContext::instance().CurrentPrimitive = primDoc; @@ -1304,7 +1304,7 @@ retry: _Suffixe = tokens.back(); // generate identifier - _PhraseId = toUpper(md.getMissionName()+"_"+_Suffixe); + _PhraseId = toUpperAscii(md.getMissionName()+"_"+_Suffixe); set ps; // select only unique params @@ -1857,11 +1857,11 @@ void CMissionData::parseMissionHeader(NLLIGO::IPrimitive *prim) // _MissionTitle.init(*this, prim, vs); _MissionDescriptionRaw = getPropertyArray(prim, "mission_description", false, false); // _MissionDescription.init(*this, prim, vs); - _MonoInstance = toLower(getProperty(prim, "mono_instance", true, false)) == "true"; - _RunOnce = toLower(getProperty(prim, "run_only_once", true, false)) == "true"; - _Replayable = toLower(getProperty(prim, "replayable", true, false)) == "true"; + _MonoInstance = toBool(getProperty(prim, "mono_instance", true, false)); + _RunOnce = toBool(getProperty(prim, "run_only_once", true, false)); + _Replayable = toBool(getProperty(prim, "replayable", true, false)); - _NeedValidation = toLower(getProperty(prim, "need_validation", true, false)) == "true"; + _NeedValidation = toBool(getProperty(prim, "need_validation", true, false)); _MissionAutoMenuRaw = getPropertyArray(prim, "phrase_auto_menu", false, false); @@ -1872,15 +1872,15 @@ void CMissionData::parseMissionHeader(NLLIGO::IPrimitive *prim) else if (s == "guild") _Guild = true; - _NotInJournal = NLMISC::toLower(getProperty(prim, "not_in_journal", false, false)) == "true"; - _AutoRemoveFromJournal = NLMISC::toLower(getProperty(prim, "auto_remove_from_journal", false, false)) == "true"; + _NotInJournal = NLMISC::toBool(getProperty(prim, "not_in_journal", false, false)); + _AutoRemoveFromJournal = NLMISC::toBool(getProperty(prim, "auto_remove_from_journal", false, false)); _MissionCategory = getProperty(prim, "mission_category", false, false); NLMISC::fromString(getProperty(prim, "player_replay_timer", true, false), _PlayerReplayTimer); NLMISC::fromString(getProperty(prim, "global_replay_timer", true, false), _GlobalReplayTimer); - _NotProposed = NLMISC::toLower(getProperty(prim, "not_proposed", false, false)) == "true"; - _MissionAuto = NLMISC::toLower(getProperty(prim, "automatic", false, false)) == "true"; - _NonAbandonnable = NLMISC::toLower(getProperty(prim, "non_abandonnable", false, false)) == "true"; - _FailIfInventoryIsFull = NLMISC::toLower(getProperty(prim, "fail_if_inventory_is_full", false, false)) == "true"; + _NotProposed = NLMISC::toBool(getProperty(prim, "not_proposed", false, false)); + _MissionAuto = NLMISC::toBool(getProperty(prim, "automatic", false, false)); + _NonAbandonnable = NLMISC::toBool(getProperty(prim, "non_abandonnable", false, false)); + _FailIfInventoryIsFull = NLMISC::toBool(getProperty(prim, "fail_if_inventory_is_full", false, false)); _MissionIcon = getProperty(prim, "mission_icon", false, false); if (_MissionAuto) diff --git a/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp b/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp index 8a3daa1d5..073f6ddea 100644 --- a/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp +++ b/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2011 Fabien HENON +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -471,7 +472,7 @@ public: string s; s = md.getProperty(prim, "hide_others", true, false); - _HideOthers = (NLMISC::toLower(s) == "true"); + _HideOthers = NLMISC::toBool(s); } string genCode(CMissionData &md) @@ -788,7 +789,7 @@ public: string s; s = md.getProperty(prim, "group", true, false); - _Group = (NLMISC::toLower(s) == "true"); + _Group = NLMISC::toBool(s); _Guild = md.getProperty(prim, "guild", false, true) == "true"; // Check: if _Guild is true then check if we are in a guild mission @@ -866,7 +867,7 @@ public: string s; s = md.getProperty(prim, "group", true, false); - _Group = (NLMISC::toLower(s) == "true"); + _Group = NLMISC::toBool(s); _Guild = md.getProperty(prim, "guild", false, true) == "true"; // Check: if _Guild is true then check if we are in a guild mission @@ -1054,7 +1055,7 @@ public: string s; s = md.getProperty(prim, "group", true, false); - _Group = (NLMISC::toLower(s) == "true"); + _Group = NLMISC::toBool(s); IStepContent::init(md, prim); } @@ -1111,7 +1112,7 @@ public: string s; s = md.getProperty(prim, "group", true, false); - _Group = (NLMISC::toLower(s) == "true"); + _Group = NLMISC::toBool(s); IStepContent::init(md, prim); } @@ -1169,7 +1170,7 @@ public: string s; s = md.getProperty(prim, "group", true, false); - _Group = (NLMISC::toLower(s) == "true"); + _Group = NLMISC::toBool(s); IStepContent::init(md, prim); } @@ -1320,7 +1321,7 @@ public: _WorldPosition = md.getProperty(prim, "world_position", true, false); string s; prim->getPropertyByName("once", s); - _Once = (NLMISC::toLower(s) == "true"); + _Once = NLMISC::toBool(s); } string genCode(CMissionData &md) @@ -3212,7 +3213,7 @@ public: { _GroupName = md.getProperty(prim, "group_to_escort", true, false); string s = md.getProperty(prim, "save_all", true, false); - _SaveAll = (NLMISC::toLower(s) == "true"); + _SaveAll = NLMISC::toBool(s); CContentObjective::init(md, prim); } diff --git a/ryzom/tools/leveldesign/mp_generator/main.cpp b/ryzom/tools/leveldesign/mp_generator/main.cpp index 150807f5c..f265ccc05 100644 --- a/ryzom/tools/leveldesign/mp_generator/main.cpp +++ b/ryzom/tools/leveldesign/mp_generator/main.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/tools/leveldesign/prim_export/main.cpp b/ryzom/tools/leveldesign/prim_export/main.cpp index ad78325d5..4d219ba78 100644 --- a/ryzom/tools/leveldesign/prim_export/main.cpp +++ b/ryzom/tools/leveldesign/prim_export/main.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) -// Copyright (C) 2010-2014 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -527,7 +527,7 @@ public: formDate = 0; // In the map ? - string formShortName = NLMISC::toLower(CFile::getFilename (formName)); + string formShortName = NLMISC::toLowerAscii(CFile::getFilename (formName)); map::iterator ite = _FormMap.find (formShortName); if (ite == _FormMap.end ()) { @@ -614,7 +614,7 @@ void addPointPrimitive (CLandscape &landscape, const char *primFilename, uint32 if (point->getPropertyByName ("form", plantFilename)) { // Add an extension - if (NLMISC::toLower(CFile::getExtension (plantFilename)) != "plant") + if (NLMISC::toLowerAscii(CFile::getExtension (plantFilename)) != "plant") plantFilename += ".plant"; // Load this form @@ -669,7 +669,7 @@ void addPointPrimitive (CLandscape &landscape, const char *primFilename, uint32 instance.Scale = CVector (scale, scale, scale); instance.nParent = -1; instance.Name = shape; - instance.InstanceName = NLMISC::toLower(CFile::getFilename (plantFilename)); + instance.InstanceName = NLMISC::toLowerAscii(CFile::getFilename (plantFilename)); // Get the instance group ref CIgContainer::CIG &instances = igs.get (x, y); @@ -826,7 +826,7 @@ int main (int argc, char**argv) callback.progress ((float)i/(float)files.size ()); // Zonew ? - if (NLMISC::toLower(CFile::getExtension (files[i])) == "zonew") + if (NLMISC::toLowerAscii(CFile::getExtension (files[i])) == "zonew") { // Load it try @@ -890,7 +890,7 @@ int main (int argc, char**argv) for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -17,6 +20,7 @@ #include #include +#include #include #include #include @@ -76,21 +80,10 @@ int main(int argc, char *argv[]) ucstring str; CI18N::readTextFile(inputFile, str, false, false); - if (outMode == ASCII) - { - // remove any outof ascii char - ucstring temp; - for (uint i=0; i +// Copyright (C) 2014-2021 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -176,6 +176,7 @@ struct SOptions : public SExportOptions this->ZFactor = getFloat ("ZFactor1"); this->HeightMapFile2 = getStr ("HeightMapFile2"); this->ZFactor2 = getFloat ("ZFactor2"); + this->ExtendCoords = getFloat ("ExtendCoords"); this->Light = (uint8)getInt ("ZoneLight"); this->CellSize = getFloat ("CellSize"); this->Threshold = getFloat ("Threshold"); diff --git a/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp b/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp index 319925584..63d175470 100644 --- a/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp +++ b/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2021 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2171,13 +2171,19 @@ float CExport::getHeight (float x, float y) sint32 SizeX = _ZoneMaxX - _ZoneMinX + 1; sint32 SizeY = _ZoneMaxY - _ZoneMinY + 1; - clamp (x, _Options->CellSize*_ZoneMinX, _Options->CellSize*(_ZoneMaxX+1)); - clamp (y, _Options->CellSize*_ZoneMinY, _Options->CellSize*(_ZoneMaxY+1)); - if (_HeightMap != NULL) { - color = _HeightMap->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), - 1.0f - ((y-_Options->CellSize*_ZoneMinY)/(_Options->CellSize*SizeY))); + float xc = (x - _Options->CellSize * _ZoneMinX) / (_Options->CellSize * SizeX); + float yc = 1.0f - ((y - _Options->CellSize * _ZoneMinY) / (_Options->CellSize * SizeY)); + if (_Options->ExtendCoords) + { + uint32 w = _HeightMap->getWidth(), h = _HeightMap->getHeight(); + xc -= .5f / (float)w; + yc -= .5f / (float)h; + xc = xc * (float)(w + 1) / (float)w; + yc = yc * (float)(h + 1) / (float)h; + } + color = _HeightMap->getColor(xc, yc); color *= 255; deltaZ = color.A; deltaZ = deltaZ - 127.0f; // Median intensity is 127 @@ -2186,8 +2192,17 @@ float CExport::getHeight (float x, float y) if (_HeightMap2 != NULL) { - color = _HeightMap2->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), - 1.0f - ((y-_Options->CellSize*_ZoneMinY)/(_Options->CellSize*SizeY))); + float xc = (x - _Options->CellSize * _ZoneMinX) / (_Options->CellSize * SizeX); + float yc = 1.0f - ((y - _Options->CellSize * _ZoneMinY) / (_Options->CellSize * SizeY)); + if (_Options->ExtendCoords) + { + uint32 w = _HeightMap2->getWidth(), h = _HeightMap2->getHeight(); + xc -= .5f / (float)w; + yc -= .5f / (float)h; + xc = xc * (float)(w + 1) / (float)w; + yc = yc * (float)(h + 1) / (float)h; + } + color = _HeightMap2->getColor(xc, yc); color *= 255; deltaZ2 = color.A; deltaZ2 = deltaZ2 - 127.0f; // Median intensity is 127 diff --git a/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h b/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h index a8a6b93cb..e9bb28423 100644 --- a/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h +++ b/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2021 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -101,6 +101,7 @@ struct SExportOptions float ZFactor; std::string HeightMapFile2; float ZFactor2; + bool ExtendCoords; uint8 Light; // Roughly light the zone (0-none, 1-patch, 2-noise) diff --git a/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index e4cf1e670..8c869b220 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -3485,7 +3485,7 @@ BOOL CMyComboBox::PreTranslateMessage( MSG* pMsg ) _LastString.clear(); // Add this char - _LastString.push_back (tolower((TCHAR) pMsg->wParam)); + _LastString.push_back((wchar_t)NLMISC::toLower((ucchar)pMsg->wParam)); search = true; // New stroke time @@ -3518,7 +3518,7 @@ BOOL CMyComboBox::PreTranslateMessage( MSG* pMsg ) { // 0 final text[511] = 0; - _LastString = tStrToUtf8(text); + _LastString = CUtfStringView(tStrToUtf8(text)).toWide(); search = true; } } @@ -3538,11 +3538,11 @@ BOOL CMyComboBox::PreTranslateMessage( MSG* pMsg ) { CString rString; GetLBText (i, rString); - string tmp = toLower(tStrToUtf8(rString)); + wstring tmp = CUtfStringView(toLower(tStrToUtf8(rString))).toWide(); uint size = std::min (_LastString.size(), tmp.size()); if (size > matchSize) { - if (strncmp(tmp.c_str(), _LastString.c_str(), size) == 0) + if (wcsncmp(tmp.c_str(), _LastString.c_str(), size) == 0) { matchItem = i; matchSize = size; diff --git a/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.h b/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.h index 330138b27..5e1956381 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.h +++ b/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -60,7 +63,7 @@ public: bool loaded; private: - std::string _LastString; + std::wstring _LastString; sint64 _LastStrokeTime; std::vector _data; void reloadData(); diff --git a/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp b/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp index 5601d3ed4..63c658d07 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -110,7 +110,7 @@ void CImageListEx::addResourceIcon (const char *filename) index = ImageList.Replace( index, handle); // Add in the map - std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::string name = toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(filename)); _IconMapString.insert (std::map::value_type (name, index)); // Release the icon @@ -136,7 +136,7 @@ int CImageListEx::getImage (int resource) const int CImageListEx::getImage (const char *filename) const { - std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::string name = toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(filename)); std::map::const_iterator ite = _IconMapString.find (name); if (ite == _IconMapString.end()) return -1; diff --git a/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp b/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp index d05fb6fc9..25d1931f4 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -167,7 +167,7 @@ void CNameDlg::updateSearchList() m_nameFilter.UnlockBuffer(); // filter - if (NLMISC::toLower(ig).find(NLMISC::toLower(filter)) != std::string::npos) + if (NLMISC::toLowerAscii(ig).find(NLMISC::toLowerAscii(filter)) != std::string::npos) { m_listToName.insert(std::make_pair(j, i)); m_searchList.InsertString(j++, nlUtf8ToTStr(s)); diff --git a/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp b/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp index 0140452b5..ee47f6afb 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -555,7 +555,7 @@ bool CWorldEditorApp::initPath (const std::string &filename, CSplashScreen &spla string noRecurse; if (CIXml::getPropertyString (noRecurse, search_path, "NO_RECURSE")) { - if (toLower(noRecurse) == "true") + if (toBool(noRecurse)) recurse = false; } @@ -635,14 +635,14 @@ class CMainFrame *getMainFrame () std::string standardizePath (const std::string &str) { - return NLMISC::toLower(NLMISC::CPath::standardizePath (str, true)); + return NLMISC::toLowerAscii(NLMISC::CPath::standardizePath (str, true)); } // *************************************************************************** std::string formatString (const std::string &str) { - string copy = NLMISC::toLower(str); + string copy = NLMISC::toLowerAscii(str); return copy; } diff --git a/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp b/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp index 532d034d0..f5bc7c003 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/plugin.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -222,7 +225,7 @@ void CPlugin::drawFaunaGraph(CDisplay &display, const NLLIGO::IPrimitive &grp) if (!grp.getChild(child, k)) continue; std::string className; if (!child->getPropertyByName("class", className)) continue; - if (NLMISC::toLower(className) != FAUNA_PLACE) continue; + if (NLMISC::toLowerAscii(className) != FAUNA_PLACE) continue; if (_PluginAccess->isSelected(*child)) { found = true; @@ -239,7 +242,7 @@ void CPlugin::drawFaunaGraph(CDisplay &display, const NLLIGO::IPrimitive &grp) if (!grp.getChild(child, k)) continue; std::string className; if (!child->getPropertyByName("class", className)) continue; - if (NLMISC::toLower(className) != FAUNA_PLACE) continue; + if (NLMISC::toLowerAscii(className) != FAUNA_PLACE) continue; std::string indexStr; int index; if (!child->getPropertyByName("index", indexStr)) continue; diff --git a/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp b/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp index c92e90918..007bb1e45 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/sound_plugin.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -169,7 +172,7 @@ void CSoundPlugin::ReInit() bool fmodDriver = false; try { - fmodDriver = toLower(cf.getVar("DriverSound").asString())=="fmod"; + fmodDriver = toLowerAscii(cf.getVar("DriverSound").asString())=="fmod"; // FIXME: Support all drivers } catch(...) { diff --git a/ryzom/tools/make_anim_by_race/main.cpp b/ryzom/tools/make_anim_by_race/main.cpp index 6400cdcd6..ccc6fd997 100644 --- a/ryzom/tools/make_anim_by_race/main.cpp +++ b/ryzom/tools/make_anim_by_race/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -134,7 +137,7 @@ void makeAnimByRace(const std::string &animSetFile, const std::vector &a // get the possible anim file name (lowered) static vector raceAnimNames; raceAnimNames.clear(); - buildRaceAnimNames(raceAnimNames, toLower(CFile::getFilename(animList[i]))); + buildRaceAnimNames(raceAnimNames, toLowerAscii(CFile::getFilename(animList[i]))); // For each line of the animSet uint lastStructLine= 0; @@ -142,7 +145,7 @@ void makeAnimByRace(const std::string &animSetFile, const std::vector &a for(uint j=0;j TAg? => stop if(line.find("")!=string::npos) diff --git a/ryzom/tools/make_anim_melee_impact/main.cpp b/ryzom/tools/make_anim_melee_impact/main.cpp index 3f67edd5e..f5b0d0364 100644 --- a/ryzom/tools/make_anim_melee_impact/main.cpp +++ b/ryzom/tools/make_anim_melee_impact/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -87,7 +90,7 @@ void CAnimCombatState::build(const string &line) void makeAnimMeleeImpact(const std::string &animSetFile, const set &combatAnimSets) { // look if this animSetFile is in the combat list to patch - string shortName= NLMISC::toLower(CFile::getFilenameWithoutExtension(animSetFile)); + string shortName= NLMISC::toLowerAscii(CFile::getFilenameWithoutExtension(animSetFile)); CAnimCombatSet key; key.Name= shortName; set::const_iterator it= combatAnimSets.find(key); @@ -125,7 +128,7 @@ void makeAnimMeleeImpact(const std::string &animSetFile, const set TAg? => stop if(line.find("")!=string::npos) @@ -405,7 +408,7 @@ To generate the anim.txt file, this code has to be inserted in the client, in if(anim && anim3d) { // name - string name= NLMISC::toLower(_AnimationSet->getAnimationName(anim->id())); + string name= NLMISC::toLowerAscii(_AnimationSet->getAnimationName(anim->id())); if(animName.empty()) animName= name; else if(!extended) diff --git a/ryzom/tools/patch_gen/patch_gen_common.cpp b/ryzom/tools/patch_gen/patch_gen_common.cpp index a9502517d..799804c84 100644 --- a/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2011-2013 Matt RAYKOWSKI (sfb) // Copyright (C) 2014 Matthew LAGOE (Botanic) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -459,9 +459,9 @@ void CPackageDescription::buildDefaultFileList() std::vector fileList; NLMISC::CPath::getPathContent(_BnpDirectory,false,false,true,fileList); for (uint32 i=0;i +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -99,16 +99,16 @@ string xmlSpecialChars(string str) string getFullStdPathNoExt(const string &path) { - string dir = NLMISC::toLower(NLMISC::CFile::getPath(path)); - string file = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(path)); + string dir = NLMISC::toLowerAscii(NLMISC::CFile::getPath(path)); + string file = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(path)); return dir.empty() ? file : NLMISC::CPath::standardizePath(dir)+file; } string getFullStdPath(const string &path) { - string dir = NLMISC::toLower(NLMISC::CFile::getPath(path)); - string file = NLMISC::toLower(NLMISC::CFile::getFilename(path)); + string dir = NLMISC::toLowerAscii(NLMISC::CFile::getPath(path)); + string file = NLMISC::toLowerAscii(NLMISC::CFile::getFilename(path)); return dir.empty() ? file : NLMISC::CPath::standardizePath(dir)+file; } @@ -258,7 +258,7 @@ bool CDbNode::epilog() setEnv("db", Name); string fullfile = getFullStdPathNoExt(MainFile.empty() ? Name : MainFile); - string filename = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fullfile)); + string filename = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(fullfile)); setEnv("filename", filename); setEnv("fullfilename", fullfile); @@ -788,14 +788,14 @@ void CDbNode::generateLogContent() // get file path from this file string CDbNode::getFileNoExtPath(const std::string& file) { - string thisPath = NLMISC::CFile::getPath(NLMISC::toLower(getDbFile())); - string filePath = NLMISC::CFile::getPath(NLMISC::toLower(file)); - string fileName = NLMISC::CFile::getFilename(NLMISC::toLower(file)); + string thisPath = NLMISC::CFile::getPath(NLMISC::toLowerAscii(getDbFile())); + string filePath = NLMISC::CFile::getPath(NLMISC::toLowerAscii(file)); + string fileName = NLMISC::CFile::getFilename(NLMISC::toLowerAscii(file)); if (thisPath == filePath) return CFile::getFilenameWithoutExtension(fileName); else - return CPath::standardizePath(filePath)+CFile::getFilenameWithoutExtension(NLMISC::toLower(file)); + return CPath::standardizePath(filePath)+CFile::getFilenameWithoutExtension(NLMISC::toLowerAscii(file)); } @@ -825,7 +825,7 @@ bool CFileNode::generateProlog() if (!db->Description.empty()) Hpp << db->Description << "\n"; - string filename = NLMISC::toLower(CFile::getFilenameWithoutExtension(Name)); + string filename = NLMISC::toLowerAscii(CFile::getFilenameWithoutExtension(Name)); setEnv("fullfilename", getFullStdPathNoExt(Name)); setEnv("filename", filename); @@ -870,7 +870,7 @@ bool CFileNode::generateProlog() if (SeparatedFlag) { string fullfile = getFullStdPathNoExt(db->MainFile.empty() ? db->Name : db->MainFile); - string filename = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fullfile)); + string filename = NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(fullfile)); Hpp << "#include \"" << filename << ".h\"\n"; Hpp << "\n"; } @@ -920,7 +920,7 @@ bool CFileNode::generateEpilog() CDbNode* db = getDbNode(); string fullfile = getFullStdPathNoExt(Name); - string filename = NLMISC::toLower(CFile::getFilenameWithoutExtension(Name)); + string filename = NLMISC::toLowerAscii(CFile::getFilenameWithoutExtension(Name)); Hpp.indent(); Hpp << "\n} // End of " << db->Name <<"\n"; @@ -948,14 +948,14 @@ bool CFileNode::generateEpilog() string CFileNode::getFileNoExtPath(const string& file) { - string thisPath = NLMISC::CFile::getPath(NLMISC::toLower(Name)); - string filePath = NLMISC::CFile::getPath(NLMISC::toLower(file)); - string fileName = NLMISC::CFile::getFilename(NLMISC::toLower(file)); + string thisPath = NLMISC::CFile::getPath(NLMISC::toLowerAscii(Name)); + string filePath = NLMISC::CFile::getPath(NLMISC::toLowerAscii(file)); + string fileName = NLMISC::CFile::getFilename(NLMISC::toLowerAscii(file)); if (thisPath == filePath) return CFile::getFilenameWithoutExtension(fileName); else - return CFile::getFilenameWithoutExtension(NLMISC::toLower(file)); + return CFile::getFilenameWithoutExtension(NLMISC::toLowerAscii(file)); } void CFileNode::writeFile() @@ -1301,7 +1301,7 @@ bool CEnumNode::generateContent() gen.add("{"); gen.add("return Unknown;"); gen.add("}"); - gen.add("const std::map::const_iterator\tit = _ValueMap.find(NLMISC::toLower(v));"); + gen.add("const std::map::const_iterator\tit = _ValueMap.find(NLMISC::toLowerAscii(v));"); gen.add("if (it == _ValueMap.end())"); gen.add("{"); gen.add("nlwarning(\""+Name+"::toString(): string '%s' is not matched, 'Unknown' enum value returned\", v.c_str());"); @@ -1318,7 +1318,7 @@ bool CEnumNode::generateContent() gen.add("for (i=0; i<"+toString(Values.size())+"; ++i)"); gen.add("{"); gen.add("_StrTable["+Name+"Convert[i].Value] = "+Name+"Convert[i].Name;"); - gen.add("_ValueMap[NLMISC::toLower(std::string("+Name+"Convert[i].Name))] = "+Name+"Convert[i].Value;"); + gen.add("_ValueMap[NLMISC::toLowerAscii(std::string("+Name+"Convert[i].Name))] = "+Name+"Convert[i].Value;"); gen.add("}"); gen.add("_Initialised = true;"); diff --git a/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp b/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp index 4bbae8233..55aa255f0 100644 --- a/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp +++ b/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) -// Copyright (C) 2010-2014 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -180,7 +180,7 @@ int main(int argc, char* argv[]) if (!zonePath.empty()) { presentZonePathes.push_back(zonePath); - presentZoneNames.push_back(toLower(zoneNames[l])); + presentZoneNames.push_back(toLowerAscii(zoneNames[l])); } } // diff --git a/ryzom/tools/server/build_world_packed_col/village.cpp b/ryzom/tools/server/build_world_packed_col/village.cpp index f29486c61..42c537a1b 100644 --- a/ryzom/tools/server/build_world_packed_col/village.cpp +++ b/ryzom/tools/server/build_world_packed_col/village.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -266,7 +269,7 @@ void CIGInfo::load(TShapeCache &shapeCache) for(uint k = 0; k < IG->getNumInstance(); ++k) { std::string shapeName = standardizeShapeName(IG->getShapeName(k)); - if (NLMISC::toLower(CFile::getExtension(shapeName)) == "pacs_prim") + if (NLMISC::toLowerAscii(CFile::getExtension(shapeName)) == "pacs_prim") { continue; } diff --git a/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp b/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp index 3062878ed..f5c3971d9 100644 --- a/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp +++ b/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/tools/skill_extractor/skill_extractor.cpp b/ryzom/tools/skill_extractor/skill_extractor.cpp index 054d5788c..889108711 100644 --- a/ryzom/tools/skill_extractor/skill_extractor.cpp +++ b/ryzom/tools/skill_extractor/skill_extractor.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -311,10 +314,10 @@ sint main( sint argc, char ** argv ) } break; case 1: // code - skill.Code = toUpper(string( ptr )); + skill.Code = toUpperAscii(string( ptr )); break; case 2: // parent skill - skill.ParentSkill = toUpper(string( ptr )); + skill.ParentSkill = toUpperAscii(string( ptr )); break; case 3: // max skill value NLMISC::fromString(std::string(ptr), skill.MaxValue); diff --git a/ryzom/tools/translation_tools/extract_new_sheet_names.cpp b/ryzom/tools/translation_tools/extract_new_sheet_names.cpp index 4573c5eb5..15004cd59 100644 --- a/ryzom/tools/translation_tools/extract_new_sheet_names.cpp +++ b/ryzom/tools/translation_tools/extract_new_sheet_names.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -58,7 +61,7 @@ struct CSheetWordListBuilder : public IWordListBuilder virtual bool buildWordList(std::vector &allWords, string workSheetFileName) { - SheetExt= toLower(SheetExt); + SheetExt= toLowerAscii(SheetExt); // verify the directory is correct if(!CFile::isDirectory(SheetPath)) @@ -78,7 +81,7 @@ struct CSheetWordListBuilder : public IWordListBuilder for(uint i=0;igetPropertyByName(listProp[cid], primName) && !primName.empty()) { - primName= toLower(primName); + primName= toLowerAscii(primName); // avoid duplicate if(allWordSet.insert(primName).second) { diff --git a/ryzom/tools/translation_tools/main.cpp b/ryzom/tools/translation_tools/main.cpp index 4f65df260..dc91079f3 100644 --- a/ryzom/tools/translation_tools/main.cpp +++ b/ryzom/tools/translation_tools/main.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/studio/src/plugins/bnp_manager/bnp_manager_window.cpp b/studio/src/plugins/bnp_manager/bnp_manager_window.cpp index 9a4af0cd5..5dc19ff8f 100644 --- a/studio/src/plugins/bnp_manager/bnp_manager_window.cpp +++ b/studio/src/plugins/bnp_manager/bnp_manager_window.cpp @@ -1,6 +1,9 @@ // Object Viewer Qt - BNP Manager Plugin - MMORPG Framework // Copyright (C) 2011 Roland WINKLMEIER // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/studio/src/plugins/core/general_settings_page.cpp b/studio/src/plugins/core/general_settings_page.cpp index 6fb51b128..af2ede1b7 100644 --- a/studio/src/plugins/core/general_settings_page.cpp +++ b/studio/src/plugins/core/general_settings_page.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/studio/src/plugins/georges_editor/georges_editor_form.cpp b/studio/src/plugins/georges_editor/georges_editor_form.cpp index 009d2a6f0..89d8dfd19 100644 --- a/studio/src/plugins/georges_editor/georges_editor_form.cpp +++ b/studio/src/plugins/georges_editor/georges_editor_form.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp b/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp index 014b6c6ba..b6b6a8f92 100644 --- a/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -3,8 +3,8 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2014 Jan BOON (Kaetemi) // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/tool/attribution/annotate.py b/tool/attribution/annotate.py index 80d530650..4d5818857 100644 --- a/tool/attribution/annotate.py +++ b/tool/attribution/annotate.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019 Jan BOON +# Copyright (C) 2019-2020 Jan BOON # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ from datetime import datetime from pathlib import Path from git import Repo -repo = Repo("../../..") +repo = Repo("../..") # Mapping for author short name to full display name authors = { } @@ -83,6 +83,7 @@ authors["etrange"] = "StudioEtrange " authors["sircotare"] = "SirCotare" authors["rolandw"] = "Roland WINKLMEIER " authors["thibg"] = "Thibaut GIRKA (ThibG) " # LibVR support +authors["xtarsia"] = "Xtarsia" # Mapping from git author name to short name, dash to ignore author short_authors = { } @@ -164,6 +165,8 @@ short_authors["cemycc "] = "cemycc" short_authors["cemycc"] = "cemycc" short_authors["Thibaut Girka "] = "thibg" short_authors["Thibaut Girka (ThibG)"] = "thibg" +short_authors["Xtarsia <69606701+Xtarsia@users.noreply.github.com>"] = "xtarsia" +short_authors["Xtarsia"] = "xtarsia" # short_authors["\"picomancer ext:(%22) "] = "-" # short_authors["Quitta"] = "-" # short_authors["Krolock"] = "-" @@ -175,7 +178,7 @@ short_authors["Thibaut Girka (ThibG)"] = "thibg" # short_authors["Michael Witrant "] = "-" generic_authors = [ ] -generic_authors += [ "Ryzom Core " ] +generic_authors += [ "Ryzom Core " ] generic_authors += [ "by authors" ] # Reverse mapping for parsing original annotation @@ -203,15 +206,18 @@ override_author["43452ea27c6e92488d8bd1417b2aee60d75d8a68"] = "-" # Header override_author["8e21fed1e6b79bf92f6364c7cb4f0c56e1dda103"] = "-" # Header cleanup override_author["c8e562f37781d62ebc54b68ef74f7693de79a907"] = "-" # Header cleanup override_author["dc734ed66226b257becae9fcd140898e14510e6a"] = "-" # Header cleanup +override_author["a3a074f455a3f52e6fa4d44214f6c34289fa6f8c"] = "-" # Sync +override_author["141e7c645966ee3475097a75a65def8c9bd7086a"] = "-" # Sync +override_author["e6a617b8bcd1630dba5fc3b6ae9815775ba2c19d"] = "-" # Sync # Exclude some paths exclude_paths = { } -exclude_paths["code/nel/3rdparty"] = True -exclude_paths["code/nel/src/3d/driver/opengl/GL"] = True -exclude_paths["code/nel/src/3d/driver/opengl/EGL"] = True -exclude_paths["code/nel/src/3d/driver/opengl/GLES"] = True -exclude_paths["code/nel/src/3d/driver/opengl/KHR"] = True -exclude_paths["code/studio/src/3rdparty"] = True +exclude_paths["nel/3rdparty"] = True +exclude_paths["nel/src/3d/driver/opengl/GL"] = True +exclude_paths["nel/src/3d/driver/opengl/EGL"] = True +exclude_paths["nel/src/3d/driver/opengl/GLES"] = True +exclude_paths["nel/src/3d/driver/opengl/KHR"] = True +exclude_paths["studio/src/3rdparty"] = True # Programmatical remappings def remap_author(blob, commit, author): @@ -226,6 +232,9 @@ def remap_author(blob, commit, author): short_author = short_authors.get(author) if short_author == None: short_author = "?" + if "Update GPL headers" in commit.message: + # Ignore if commit message matches "Update GPL headers" + short_author = "-" # If you're paid by Winch Gate, or signed copyright transfer with # them, remap here, limit by authored_date if needed. if short_author == "ulukyn" or short_author == "ace": @@ -234,12 +243,14 @@ def remap_author(blob, commit, author): short_author = "winch_gate" if short_author == "sircotare" and authored_date.year >= 2012: short_author = "winch_gate" - if short_author == "inky": + if short_author == "inky" and authored_date.year < 2020: short_author = "winch_gate" if "feature-export-assimp" in commit.message and authored_date.year <= 2015: # Project paid for by Winch Gate short_author = "winch_gate" - if short_author == "kervala" or short_author == "nimetu": + if short_author == "nimetu" and authored_date.year >= 2009: + short_author = "winch_gate" + if short_author == "kervala": # Don't know if they signed the copyright assignment agreement with Winch Gate or Ryzom Forge short_author = "?" if short_author == "karu" or short_author == "kishan" or short_author == "glorf": @@ -334,7 +345,7 @@ def rewrite_cpp(path, copyright_oldest, copyright_newest, copyright_lines): # Everything before the first "// Copyright" remains intact # Parse existing notices, merge with lists, track which one is first # Write out new copyright and modification notices - contents = Path("../../../" + path).read_text() + contents = Path("../../" + path).read_text() content_start = contents.find("// This program is free software") if content_start < 0: header_not_found[path] = True @@ -431,7 +442,7 @@ def rewrite_cpp(path, copyright_oldest, copyright_newest, copyright_lines): new_contents = contents[0:copyright_start] + new_statement + contents[content_start:] if contents != new_contents: print(new_statement) - Path("../../../" + path).write_text(new_contents) + Path("../../" + path).write_text(new_contents) def process_cpp(cpp_entry): print(cpp_entry.path) diff --git a/web/public_php/setup/header.php b/web/public_php/setup/header.php index cefc30a01..11d64213a 100644 --- a/web/public_php/setup/header.php +++ b/web/public_php/setup/header.php @@ -33,7 +33,7 @@ function printalert($type, $message) { print '
'; } function is__writable($path) { - if ($path{strlen($path) - 1} == '/') { + if ($path[strlen($path) - 1] == '/' || $path[strlen($path) - 1] == '\\') { return is__writable($path.uniqid(mt_rand()).'.tmp'); }