From 7812ccafc18e30c4b26a98436bd5e6e9417ced2d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 30 Oct 2020 12:25:53 +0800 Subject: [PATCH 01/14] Fix infinite loop --- ryzom/client/src/interface_v3/chat_window.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index 237ffdd8b..3b3063879 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -208,7 +208,8 @@ void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGr { if (!_Chat) { - nlwarning(" There's no global chat"); + if (msg.toUtf8() != "WRN: There's no global chat") + nlwarning(" There's no global chat"); return; } CGroupList *gl; @@ -541,7 +542,8 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC { if (!_Chat) { - nlwarning(" There's no global chat"); + if (msg.toUtf8() != "WRN: There's no global chat") + nlwarning(" There's no global chat"); return; } From 39fc4895d2d003b9c63ff8e0181c864862d82795 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 30 Oct 2020 13:20:02 +0800 Subject: [PATCH 02/14] Fix to work with saner new behaviour --- ryzom/client/src/interface_v3/chat_window.cpp | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index 3b3063879..8d7551803 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -1093,10 +1093,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); @@ -1135,10 +1132,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); @@ -1185,7 +1179,7 @@ void CChatWindowManager::removeChatWindow(const ucstring &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.toUtf8().c_str()); return; } it->second->deleteContainer(); @@ -1225,18 +1219,9 @@ bool CChatWindowManager::rename(const ucstring &oldName, const ucstring &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(false); + it->second->getContainer()->setTitle(newName.toUtf8()); _ChatWindowMap.erase(it); return true; } From 2a7bf997b9c4fe3b68134ebcc1b31834965689aa Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 30 Oct 2020 15:06:12 +0800 Subject: [PATCH 03/14] Cleanup localization behaviour --- nel/include/nel/gui/view_text.h | 11 +- nel/src/gui/ctrl_text_button.cpp | 7 +- nel/src/gui/group_container.cpp | 32 ++--- nel/src/gui/group_editbox.cpp | 2 +- nel/src/gui/view_text.cpp | 211 ++++++++++++++++++++----------- nel/src/gui/widget_manager.cpp | 1 + 6 files changed, 166 insertions(+), 98 deletions(-) diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 7980e6427..69f9efca7 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -84,8 +84,10 @@ namespace NLGUI /// Set - void setText(const std::string &text); //< Not localized. Use setHardText to localize strings starting with "ui". TODO: Add a Localize flag, like title in group container. HardText then simply sets localize to true. + void setText(const std::string &text); + void setTextLocalized(const std::string &text, bool localized); void setTextAsUtf16 (const ucstring &text); + void setLocalized(bool localized); void setFontName (const std::string &name); void setFontSize (sint nFontSize, bool coef = true); void setEmbolden (bool nEmbolden); @@ -114,9 +116,10 @@ namespace NLGUI void disableStringSelection(); /// Get - std::string getText() const { return _Text; } + std::string getText() const { return _HardText.empty() ? _Text : _HardText; } ucstring getTextAsUtf16() const; ucstring getHardTextAsUtf16() const; + bool isLocalized() const { return _Localized; } sint getFontSize() const; std::string getFontName() const { return _FontName; } bool getEmbolden() { return _Embolden; } @@ -224,6 +227,7 @@ namespace NLGUI REFLECT_EXPORT_START(CViewText, CViewBase) REFLECT_STRING("text_raw", getText, setText); REFLECT_STRING("hardtext", getHardText, setHardText); + REFLECT_BOOL ("localize", isLocalized, setLocalized); // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense @@ -248,6 +252,7 @@ namespace NLGUI std::string _HardText; std::string _Text; mutable sint _TextLength; + bool _Localized; /// index of the computed String associated to this text control uint _Index; /// info on the computed String associated to this text control @@ -443,6 +448,8 @@ namespace NLGUI void setup (); void setupDefault (); + void setTextLocalized(const std::string &text); + void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd); // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp index c5571a4ca..3be6142e3 100644 --- a/nel/src/gui/ctrl_text_button.cpp +++ b/nel/src/gui/ctrl_text_button.cpp @@ -597,12 +597,7 @@ namespace NLGUI if (prop) { const char *propPtr = prop; - std::string text; - if (NLMISC::startsWith(propPtr, "ui")) - text = CI18N::get(propPtr); - else - text = propPtr; - _ViewText->setText(text); + _ViewText->setTextLocalized(propPtr, true); } } diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index 1416f5ee6..0740bd80f 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -2144,24 +2144,20 @@ namespace NLGUI ptr = xmlGetProp (cur, (xmlChar*)"title"); if (ptr) { - if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); - else _TitleTextOpened = string((const char*)ptr); - if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); - else _TitleTextClosed = string((const char*)ptr); + _TitleTextOpened = (const char *)ptr; + _TitleTextClosed = (const char *)ptr; } ptr = xmlGetProp (cur, (xmlChar*)"title_opened"); if (ptr) { - if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); - else _TitleTextOpened = string((const char*)ptr); + _TitleTextOpened = (const char*)ptr; } ptr = xmlGetProp (cur, (xmlChar*)"title_closed"); if (ptr) { - if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); - else _TitleTextClosed = string((const char*)ptr); + _TitleTextClosed = (const char *)ptr; } ptr = xmlGetProp (cur, (xmlChar*)"header_active"); @@ -3950,8 +3946,14 @@ namespace NLGUI void CGroupContainer::setLocalize(bool localize) { _Localize = localize; - setTitledOpenedViewText(); - setTitledClosedViewText(); + if (_TitleOpened) + { + _TitleOpened->setLocalized(localize); + } + if (_TitleClosed) + { + _TitleClosed->setLocalized(localize); + } invalidateCoords(); } @@ -4001,10 +4003,7 @@ namespace NLGUI { if (_TitleOpened != NULL) { - if (_Localize && NLMISC::startsWith(_TitleTextOpened, "ui")) - _TitleOpened->setHardText(_TitleTextOpened); - else - _TitleOpened->setText(_TitleTextOpened); + _TitleOpened->setTextLocalized(_TitleTextOpened, _Localize); } } @@ -4013,10 +4012,7 @@ namespace NLGUI { if (_TitleClosed != NULL) { - if (_Localize && NLMISC::startsWith(_TitleTextClosed, "ui")) - _TitleClosed->setHardText(_TitleTextClosed); - else - _TitleClosed->setText(_TitleTextClosed); + _TitleClosed->setTextLocalized(_TitleTextClosed, _Localize); } } diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index 799452b33..27084dd1b 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -1580,7 +1580,7 @@ namespace NLGUI _ViewText->setParent( this ); _ViewText->setIdRecurse( "edit_text" ); - _ViewText->setHardText( "" ); + _ViewText->setTextLocalized( "", false ); _ViewText->setPosRef( Hotspot_ML ); _ViewText->setParentPosRef( Hotspot_ML ); addView( _ViewText ); diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index 87ebab92d..f96ac535d 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -111,6 +111,8 @@ namespace NLGUI _ClampRight = true; // clamp on the right of the text _OverflowText = "..."; + _Localized = true; + _LetterColors = NULL; _Setuped= false; _AutoClampOffset = 0; @@ -211,7 +213,7 @@ namespace NLGUI _Index = 0xFFFFFFFF; _ModulateGlobalColor= vt._ModulateGlobalColor; - + _Localized = vt._Localized; // remove previous lines clearLines(); @@ -244,6 +246,11 @@ namespace NLGUI std::string CViewText::getTextProperty( const std::string &name ) const { + if( name == "localize" ) + { + return toString(_Localized); + } + else if( name == "color" ) { return toString( _Color ); @@ -418,6 +425,18 @@ namespace NLGUI bool CViewText::setTextProperty( const std::string &name, const std::string &value ) { + if( name == "localize" ) + { + bool b; + if (fromString(value, b)) + { + _Localized = b; + setTextLocalized(_HardText.empty() ? _Text : _HardText); // FIXME: setCase? + _TextLength = 0; + } + return true; + } + else if( name == "color" ) { CRGBA c; @@ -649,28 +668,19 @@ namespace NLGUI return true; } else + if( name == "text" ) + { + setTextLocalized(value); // FIXME: setCase? + _TextLength = 0; + invalidateContent(); + return true; + } + else if( name == "hardtext" ) { -#if 1 - if (NLMISC::startsWith(value, "ui")) - { - _Text = CI18N::get(value); - _TextLength = 0; - _HardText = value; - } - else - { - _Text = value; - _TextLength = 0; - _HardText.clear(); - } -#else - _Text = value; + _Localized = true; + setTextLocalized(value); // FIXME: setCase? _TextLength = 0; - _HardText.clear(); - if (NLMISC::startsWith(value, "ui")) - _HardText = _Text; -#endif invalidateContent(); return true; } @@ -705,6 +715,8 @@ namespace NLGUI bool CViewText::serializeTextOptions( xmlNodePtr node ) const { + xmlSetProp( node, BAD_CAST "localize", BAD_CAST toString( _Localized ).c_str() ); + xmlSetProp( node, BAD_CAST "color", BAD_CAST toString( _Color ).c_str() ); xmlSetProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); @@ -784,7 +796,7 @@ namespace NLGUI serializeTextOptions( node ); - xmlSetProp( node, BAD_CAST "hardtext", BAD_CAST _Text.c_str() ); + xmlSetProp( node, BAD_CAST "text", BAD_CAST (_HardText.empty() ? _Text.c_str() : _HardText.c_str()) ); xmlSetProp( node, BAD_CAST "hardtext_format", BAD_CAST _HardTextFormat.c_str() ); return node; @@ -795,6 +807,9 @@ namespace NLGUI { CXMLAutoPtr prop; + prop = xmlGetProp (cur, (xmlChar*)"localize"); + if (prop) _Localized = convertBool((const char*)prop); + prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); _Color = CRGBA(255,255,255,255); if (prop) @@ -1000,18 +1015,8 @@ namespace NLGUI if (prop) { const char *propPtr = prop; - if (NLMISC::startsWith(propPtr, "ui")) - { - _HardText = propPtr; - _Text = CI18N::get(propPtr); - _TextLength = 0; - } - else - { - _HardText.clear(); - _Text = propPtr; - _TextLength = 0; - } + _Localized = true; + setTextLocalized(propPtr); setCase(_Text, _CaseMode); _TextLength = 0; } @@ -1427,49 +1432,109 @@ namespace NLGUI } // *************************************************************************** - void CViewText::setText(const std::string &text) + void CViewText::setTextLocalized(const std::string &text, bool localized) { - _HardText.clear(); - // common case: no special format, no case mode => easy cache test - if (_FormatTags.empty() && _CaseMode==CaseNormal) + if (localized != _Localized) { - if (text != _Text) - { - _Text = text; - _TextLength = 0; - // no need to call "setCase (_Text, _CaseMode);" since CaseNormal: - invalidateContent (); - } + _Localized = localized; + + // Always recompute if localization and text changed + setTextLocalized(text); + setCase(_Text, _CaseMode); + _TextLength = 0; + invalidateContent(); } else { - // if the view text had some format before, no choice, must recompute all - if (!_FormatTags.empty()) + setText(text); + } + } + + // *************************************************************************** + void CViewText::setLocalized(bool localized) + { + if (localized != _Localized) + { + const std::string &text = _HardText.empty() ? _Text : _HardText; + _Localized = localized; + if (!text.empty() && NLMISC::startsWith(text, "ui")) { - _Text = text; - setCase (_Text, _CaseMode); + setTextLocalized(text); + setCase(_Text, _CaseMode); _TextLength = 0; - invalidateContent (); - } - // else test if after the case change the cache succeed - else - { - // compute the temp cased text - std::string tempText = text; - setCase (tempText, _CaseMode); - if (tempText != _Text) - { - _Text = tempText; - _TextLength = 0; - invalidateContent(); - } + invalidateContent(); } } - // clear format tags if any - _FormatTags.clear(); + nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(getText(), "ui"))) == (_HardText.empty() == _Text.empty()))); + } + + // *************************************************************************** + void CViewText::setTextLocalized(const std::string &text) + { + if (_Localized && NLMISC::startsWith(text, "ui")) + { + _HardText = text; + _Text = CI18N::get(text); + } + else + { + _Text = text; + _HardText.clear(); + } } + // *************************************************************************** + void CViewText::setText(const std::string &text) + { + // common case: no special format, no case mode => easy cache test + if (_FormatTags.empty() && _CaseMode == CaseNormal) + { + if (_HardText.empty() ? text != _Text : text != _HardText) + { + setTextLocalized(text); + _TextLength = 0; + // no need to call "setCase (_Text, _CaseMode);" since CaseNormal: + invalidateContent(); + } + } + else + { + // if the view text had some format before, no choice, must recompute all + if (!_FormatTags.empty()) + { + setTextLocalized(text); + setCase(_Text, _CaseMode); + _TextLength = 0; + invalidateContent(); + } + // else test if after the case change the cache succeed + else + { + // compute the temp cased text + std::string holdText, holdHardText; + holdText.swap(_Text); + holdHardText.swap(_HardText); + setTextLocalized(text); + setCase(_Text, _CaseMode); + if (holdText != _Text) + { + _TextLength = 0; + invalidateContent(); + } + else + { + holdText.swap(_Text); + } + } + } + + nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(text, "ui"))) == (_HardText.empty() == _Text.empty()))); + + // clear format tags if any + _FormatTags.clear(); + } + // *************************************************************************** void CViewText::setFontSizing(const std::string &chars, const std::string &fallback) { @@ -2396,15 +2461,12 @@ namespace NLGUI // *************************************************************************** void CViewText::setHardText (const std::string &ht) { - if (NLMISC::startsWith(ht, "ui")) - { - setText(CI18N::get(ht)); - _HardText = ht; - } - else + if (!_Localized) { - setText(ht); + setText(std::string()); + _Localized = true; } + setText(ht); } // *************************************************************************** @@ -3367,6 +3429,7 @@ namespace NLGUI // Copy to Text (preserve Memory) contReset(_Text); _Text = tempText; + _HardText.clear(); _TextLength = 0; CInterfaceGroup *parent = getParent(); @@ -3477,6 +3540,7 @@ namespace NLGUI // Copy to Text (preserve Memory) contReset(_Text); _Text = tempText; + _HardText.clear(); _TextLength = 0; invalidateContent (); } @@ -3560,6 +3624,11 @@ namespace NLGUI #define SERIAL_UINT(val) { uint32 tmp = (uint32) val; f.serial(tmp); val = (uint) tmp; } #define SERIAL_SINT(val) { sint32 tmp = (sint32) val; f.serial(tmp); val = (sint) tmp; } CViewBase::serial(f); + + int version = f.serialVersion(101); + nlassert(version >= 100); + + f.serial(_Localized); SERIAL_SINT(_FontSize); SERIAL_UINT(_FontWidth); SERIAL_UINT(_FontHeight); diff --git a/nel/src/gui/widget_manager.cpp b/nel/src/gui/widget_manager.cpp index 534a0cc1b..9ce889a95 100644 --- a/nel/src/gui/widget_manager.cpp +++ b/nel/src/gui/widget_manager.cpp @@ -1195,6 +1195,7 @@ namespace NLGUI sint32 backupX = groupOver->getX(); // Copy all aspects to the view + vtDst->setLocalized (vtSrc->isLocalized()); vtDst->setText (vtSrc->getText()); vtDst->setFontSize (vtSrc->getFontSize()); vtDst->setColor (vtSrc->getColor()); From d238d2122bafb2d7b7949af39adc636b974369ad Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 30 Oct 2020 15:07:36 +0800 Subject: [PATCH 04/14] Cleanup localization behaviour --- ryzom/client/src/connection.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 4fafe3ebc..a491d5e57 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -1021,7 +1021,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") + "..."); + 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 @@ -1237,8 +1237,8 @@ TInterfaceState globalMenu() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+".\n"+ - CI18N::get("uiFirewallAlert")+"."); + pVT->setTextLocalized(CI18N::get("uiFirewallFail")+".\n"+ + CI18N::get("uiFirewallAlert")+".", false); } } } @@ -1319,16 +1319,16 @@ public: if (pVT == NULL) return; if (rCS.Name.empty()) - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setTextLocalized("uiEmptySlot", true); else - pVT->setText(rCS.Name.toUtf8()); + 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); } } }; @@ -2171,7 +2171,7 @@ public: if (pVT != NULL) { std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8(); - pVT->setText(str); + pVT->setTextLocalized(str, false); } // Add to the list @@ -2311,7 +2311,7 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - pVT->setText(name.toUtf8()); + pVT->setTextLocalized(name.toUtf8(), false); } CCtrlBase *pBut = pNewLine->getCtrl("but"); @@ -2559,7 +2559,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName { CViewText* viewText = dynamic_cast(result); if(viewText) - viewText->setText(text.toUtf8()); + viewText->setTextLocalized(text.toUtf8(), false); CGroupEditBox* editBox = dynamic_cast(result); if(editBox) editBox->setInputStringAsUtf16(text); @@ -2682,7 +2682,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); } } @@ -2712,7 +2712,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText= dynamic_cast(result); if(viewText) - viewText->setText(""); + viewText->setText(std::string()); } } setScenarioInformation(scenarioWnd, ""); @@ -2748,7 +2748,7 @@ class CAHScenarioControl : public IActionHandler CViewText *shardName = dynamic_cast(toggleGr->getView("button_text")); if (shardName) { - shardName->setText(Mainlands[i].Name.toUtf8()); + shardName->setTextLocalized(Mainlands[i].Name.toUtf8(), false); } } } @@ -2888,7 +2888,7 @@ class CAHScenarioInformation : public IActionHandler scenarioName = scenarioName.substr(posScenarioName==0?posScenarioName:posScenarioName+1); posScenarioName = scenarioName.find('/'); } - viewText->setText(scenarioName); + viewText->setTextLocalized(scenarioName, false); } } @@ -3250,7 +3250,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; @@ -3331,7 +3331,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"); } @@ -3360,7 +3360,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"); } } From c061f3df3a707cbce417b140017c24998afb2ecd Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 03:32:50 +0800 Subject: [PATCH 05/14] Don't need this behaviour after all --- .../src/interface_v3/interface_manager.cpp | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index cbfb9ba57..24ab75058 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -425,37 +425,6 @@ public: formatedResult += botName; break; } - case '\'': // 's and 'S -> Potato’s Identity and TOMATOES’ IDENTITY - { - std::string::const_iterator it2 = it; - ++it2; - if (it2 == inputString.end()) - { - formatedResult += "$'"; - } - else - { - it = it2; - if (*it == 's' || *it == 'S') - { - if (formatedResult.size() && (formatedResult[formatedResult.size() - 1] == 's' || formatedResult[formatedResult.size() - 1] == 'S')) - { - formatedResult += "\xE2\x80\x99"; // RIGHT SINGLE QUOTATION MARK - } - else - { - formatedResult += "\xE2\x80\x99"; // RIGHT SINGLE QUOTATION MARK - formatedResult += *it; - } - } - else - { - --it; - formatedResult += "$'"; - } - } - break; - } default: { formatedResult += '$'; From 13f99b393f96f46e11bea14d6be2c23a17cb7a5b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 03:52:37 +0800 Subject: [PATCH 06/14] Reimplement setCase in purely UTF-8, kaetemi/ryzomclassic#172 --- nel/include/nel/misc/common.h | 10 ++++ nel/src/gui/string_case.cpp | 108 +++++++++++++++++----------------- nel/src/misc/unicode.cpp | 48 ++++++++++++--- 3 files changed, 103 insertions(+), 63 deletions(-) diff --git a/nel/include/nel/misc/common.h b/nel/include/nel/misc/common.h index 7c2cc2937..9ed33c8d8 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -240,6 +240,16 @@ std::string toUpper ( const char *str ); // UTF-8 std::string toUpper ( const std::string &str); // UTF-8 void toUpper ( char *str); // Ascii only +/** Convert a single character in UTF-8 to upper or lowercase. +* \param res Character is appended in UTF-8 into this string. +* \param src Character is sourced from this UTF-8 string. +* \param i Index in `str`, incremented by the number of bytes read. +*/ +void appendToLower(std::string &res, const char *str, ptrdiff_t &i); +void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i); +void appendToUpper(std::string &res, const char *str, ptrdiff_t &i); +void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i); + /** * Convert to an hexadecimal std::string diff --git a/nel/src/gui/string_case.cpp b/nel/src/gui/string_case.cpp index 801b2fc68..ced12e3ca 100644 --- a/nel/src/gui/string_case.cpp +++ b/nel/src/gui/string_case.cpp @@ -28,19 +28,19 @@ namespace NLGUI { - inline bool isSeparator (u32char c) + inline bool isSeparator (char c) { - return (c == (u32char)' ') || (c == (u32char)'\t') || (c == (u32char)'\n') || (c == (u32char)'\r'); + return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); } - inline bool isEndSentence (u32char c, u32char lastChar) + inline bool isEndSentence (char c, char lastChar) { // Ex: One sentence. Another sentence. // ^ // Counterexample: nevrax.com // ^ - return ((c == (u32char)' ') || (c == (u32char)'\n')) - && (lastChar == (u32char)'.') || (lastChar == (u32char)'!') || (lastChar == (u32char)'?'); + return ((c == ' ') || (c == '\n')) + && (lastChar == '.') || (lastChar == '!') || (lastChar == '?'); } void setCase(std::string &str, TCaseMode mode) @@ -60,85 +60,83 @@ namespace NLGUI break; case CaseFirstStringLetterUp: { - NLMISC::CUtfStringView sv(str); std::string res; - res.reserve(sv.largestSize()); - for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + res.reserve(str.size() + (str.size() >> 2)); + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) { - u32char c = *it; - if (c < 0x10000) + char c = str[i]; + if (!isSeparator(c)) { - if (!isSeparator(c)) - { - if (newString) - c = NLMISC::toUpper((ucchar)c); - else - c = NLMISC::toLower((ucchar)c); - newString = false; - } + if (newString) + NLMISC::appendToUpper(res, str, i); + else + NLMISC::appendToLower(res, str, i); + newString = false; + } + else + { + res += c; + ++i; } - NLMISC::CUtfStringView::append(res, c); } - str = nlmove(res); + str.swap(res); break; } case CaseFirstSentenceLetterUp: { - NLMISC::CUtfStringView sv(str); std::string res; - res.reserve(sv.largestSize()); - u32char lastChar = 0; - for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + res.reserve(str.size() + (str.size() >> 2)); + char lastChar = 0; + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) { - u32char c = *it; - if (c < 0x10000) + char c = str[i]; + if (isEndSentence(c, lastChar)) { - if (isEndSentence(c, lastChar)) - newSentence = true; + newSentence = true; + res += c; + ++i; + } + else + { + if (newSentence) + NLMISC::appendToUpper(res, str, i); else - { - if (newSentence) - c = NLMISC::toUpper((ucchar)c); - else - c = NLMISC::toLower((ucchar)c); + NLMISC::appendToLower(res, str, i); - if (!isSeparator(c)) - newSentence = false; - } + if (!isSeparator(c)) + newSentence = false; } - NLMISC::CUtfStringView::append(res, c); lastChar = c; } - str = nlmove(res); + str.swap(res); break; } case CaseFirstWordLetterUp: { - NLMISC::CUtfStringView sv(str); std::string res; - res.reserve(sv.largestSize()); - u32char lastChar = 0; - for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + res.reserve(str.size() + (str.size() >> 2)); + char lastChar = 0; + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) { - u32char c = *it; - if (c < 0x10000) + char c = str[i]; + if (isSeparator(c) || isEndSentence(c, lastChar)) + { + newWord = true; + res += c; + ++i; + } + else { - if (isSeparator(c) || isEndSentence(c, lastChar)) - newWord = true; + if (newWord) + NLMISC::appendToUpper(res, str, i); else - { - if (newWord) - c = NLMISC::toUpper((ucchar)c); - else - c = NLMISC::toLower((ucchar)c); + NLMISC::appendToLower(res, str, i); - newWord = false; - } + newWord = false; } - NLMISC::CUtfStringView::append(res, c); lastChar = c; } - str = nlmove(res); + str.swap(res); break; } default: diff --git a/nel/src/misc/unicode.cpp b/nel/src/misc/unicode.cpp index 10321a907..b38344d4a 100644 --- a/nel/src/misc/unicode.cpp +++ b/nel/src/misc/unicode.cpp @@ -4752,7 +4752,7 @@ NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrd if (table[idx]) { res += &table[idx]; - ++i; + i += 2; return; } } @@ -4770,20 +4770,23 @@ NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrd if (table[idx]) { res += &table[idx]; - i += 2; + i += 3; return; } } } } res += c; + ++i; } +// *************************************************************************** + std::string toLower(const char *str) { // UTF-8 toLower, tables generated from UTF-16 tables std::string res; - for (ptrdiff_t i = 0; str[i]; ++i) + for (ptrdiff_t i = 0; str[i];) appendToLowerAsUtf8(res, str, i); return res; } @@ -4796,11 +4799,25 @@ std::string toLower(const std::string &str) std::string res; res.reserve(str.size() + (str.size() >> 2)); const char *cstr = &str[0]; - for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size(); ++i) + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) appendToLowerAsUtf8(res, cstr, i); return res; } +// *************************************************************************** + +void appendToLower(std::string &res, const char *str, ptrdiff_t &i) +{ + appendToLowerAsUtf8(res, str, i); +} + +// *************************************************************************** + +void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i) +{ + appendToLowerAsUtf8(res, &str[0], i); +} + // *************************************************************************** // *************************************************************************** // *************************************************************************** @@ -4827,7 +4844,7 @@ NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrd if (table[idx]) { res += &table[idx]; - ++i; + i += 2; return; } } @@ -4845,13 +4862,14 @@ NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrd if (table[idx]) { res += &table[idx]; - i += 2; + i += 3; return; } } } } res += c; + ++i; } // *************************************************************************** @@ -4860,7 +4878,7 @@ std::string toUpper(const char *str) { // UTF-8 toLower, tables generated from UTF-16 tables std::string res; - for (ptrdiff_t i = 0; str[i]; ++i) + for (ptrdiff_t i = 0; str[i];) appendToUpperAsUtf8(res, str, i); return res; } @@ -4873,13 +4891,27 @@ std::string toUpper(const std::string &str) std::string res; res.reserve(str.size() + (str.size() >> 2)); const char *cstr = &str[0]; - for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size(); ++i) + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) appendToUpperAsUtf8(res, cstr, i); return res; } // *************************************************************************** +void appendToUpper(std::string &res, const char *str, ptrdiff_t &i) +{ + appendToUpperAsUtf8(res, str, i); +} + +// *************************************************************************** + +void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i) +{ + appendToUpperAsUtf8(res, &str[0], i); +} + +// *************************************************************************** + #else // *************************************************************************** From 1c09d2ea4bd0ceb2847d3bc8a169e54a9a2b6bed Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 04:19:02 +0800 Subject: [PATCH 07/14] Avoid useless string operations --- nel/include/nel/misc/string_common.h | 7 ++++--- nel/src/gui/interface_element.cpp | 9 ++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/nel/include/nel/misc/string_common.h b/nel/include/nel/misc/string_common.h index 96f7f7bd1..71ab05a30 100644 --- a/nel/include/nel/misc/string_common.h +++ b/nel/include/nel/misc/string_common.h @@ -254,9 +254,10 @@ inline bool fromString(const std::string &str, double &val) { bool ret = sscanf( inline bool fromString(const std::string &str, wchar_t &val) { return fromString(str, reinterpret_cast(val)); } #endif -// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined. -// (str[0] == '1' || (str[0] & 0xD2) == 0x50) -// - Kaetemi +/// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, and empty strings, anything else is undefined. +/// - Kaetemi +inline bool toBool(const char *str) { return str[0] == '1' || (str[0] & 0xD2) == 0x50; } +inline bool toBool(const std::string &str) { return toBool(str.c_str()); } // Safe because first byte may be null bool fromString(const std::string &str, bool &val); diff --git a/nel/src/gui/interface_element.cpp b/nel/src/gui/interface_element.cpp index cf5646077..bc5da4e03 100644 --- a/nel/src/gui/interface_element.cpp +++ b/nel/src/gui/interface_element.cpp @@ -1028,21 +1028,16 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - bool CInterfaceElement::convertBool (const char *ptr) + bool CInterfaceElement::convertBool (const char *ptr) { - std::string str = toLower(ptr); - bool b = false; - fromString( str, b ); - return b; + return NLMISC::toBool(ptr); } // ------------------------------------------------------------------------------------------------ NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) { float x = 0.0f, y = 0.0f, z = 0.0f; - sscanf (ptr, "%f %f %f", &x, &y, &z); - return CVector(x,y,z); } From 0629951ba6903f3eb506dbca31cd0a1cecb57d49 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 04:25:07 +0800 Subject: [PATCH 08/14] Fix useless cursor reloads --- nel/include/nel/gui/view_pointer.h | 7 +++++-- nel/src/gui/view_pointer.cpp | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/nel/include/nel/gui/view_pointer.h b/nel/include/nel/gui/view_pointer.h index b947cc604..db7355465 100644 --- a/nel/include/nel/gui/view_pointer.h +++ b/nel/include/nel/gui/view_pointer.h @@ -61,8 +61,11 @@ namespace NLGUI // TEMP PATCH void setCursor (const std::string &name) { - _TxDefault = name; - _TxIdDefault = -2; + if (_TxDefault != name) + { + _TxDefault = name; + _TxIdDefault = -2; + } } // TEMP PATCH diff --git a/nel/src/gui/view_pointer.cpp b/nel/src/gui/view_pointer.cpp index 74644fa9f..228868731 100644 --- a/nel/src/gui/view_pointer.cpp +++ b/nel/src/gui/view_pointer.cpp @@ -207,7 +207,10 @@ namespace NLGUI if (_TxIdDefault == -2) { - _TxIdDefault = rVR.getTextureIdFromName (_TxDefault); + _TxIdDefault = rVR.getTextureIdFromName(_TxDefault); + } + if (_TxIdMoveWindow == -2) + { _TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow); _TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL); _TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR); From 22fd1132edd0cf95fa14c440deb28d7faaf201e7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 04:26:21 +0800 Subject: [PATCH 09/14] Improve setCase behaviour --- nel/src/gui/string_case.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nel/src/gui/string_case.cpp b/nel/src/gui/string_case.cpp index ced12e3ca..946b8d58a 100644 --- a/nel/src/gui/string_case.cpp +++ b/nel/src/gui/string_case.cpp @@ -40,7 +40,7 @@ namespace NLGUI // Counterexample: nevrax.com // ^ return ((c == ' ') || (c == '\n')) - && (lastChar == '.') || (lastChar == '!') || (lastChar == '?'); + && ((lastChar == '.') || (lastChar == '!') || (lastChar == '?') || (lastChar == '\n')); } void setCase(std::string &str, TCaseMode mode) From 7e8f84462f5097c923faa8e8e796ff23f9252db2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 04:36:46 +0800 Subject: [PATCH 10/14] Add manifest to enable segment heap --- ryzom/client/src/CMakeLists.txt | 2 +- ryzom/client/src/segement_heap.manifest | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 ryzom/client/src/segement_heap.manifest diff --git a/ryzom/client/src/CMakeLists.txt b/ryzom/client/src/CMakeLists.txt index 99b9a6773..f5d19f1d5 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/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 + + + From 246ea2f603c7a3a3084bc175e2faecb1638ffcfd Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 06:38:33 +0800 Subject: [PATCH 11/14] UTF-8 entity name, ryzom/ryzomcore#335 --- nel/include/nel/misc/common.h | 4 + nel/src/misc/unicode.cpp | 232 +++++++++++++++++- ryzom/client/src/character_cl.cpp | 2 +- ryzom/client/src/client_chat_manager.cpp | 18 +- ryzom/client/src/connection.cpp | 8 +- ryzom/client/src/connection.h | 4 +- ryzom/client/src/debug_client.cpp | 2 +- ryzom/client/src/entity_cl.cpp | 34 +-- ryzom/client/src/entity_cl.h | 16 +- ryzom/client/src/forage_source_cl.cpp | 14 +- ryzom/client/src/init_main_loop.cpp | 8 +- .../src/interface_v3/action_handler_game.cpp | 4 +- .../src/interface_v3/action_handler_help.cpp | 14 +- .../src/interface_v3/action_handler_item.cpp | 4 +- .../src/interface_v3/action_handler_misc.cpp | 12 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../client/src/interface_v3/group_compas.cpp | 2 +- .../src/interface_v3/group_html_webig.cpp | 4 +- ryzom/client/src/interface_v3/group_map.cpp | 6 +- .../client/src/interface_v3/guild_manager.cpp | 4 +- .../src/interface_v3/interface_manager.cpp | 8 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 8 +- .../src/interface_v3/people_interraction.cpp | 6 +- ryzom/client/src/net_manager.cpp | 8 +- .../client/src/r2/displayer_visual_entity.cpp | 2 +- ryzom/client/src/string_manager_client.cpp | 4 +- 26 files changed, 329 insertions(+), 101 deletions(-) diff --git a/nel/include/nel/misc/common.h b/nel/include/nel/misc/common.h index 9ed33c8d8..6a4480e5a 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -250,6 +250,10 @@ void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i); void appendToUpper(std::string &res, const char *str, ptrdiff_t &i); void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i); +/** UTF-8 case insensitive compare */ +int compareCaseInsensitive(const char *a, const char *b); +int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB); + /** * Convert to an hexadecimal std::string diff --git a/nel/src/misc/unicode.cpp b/nel/src/misc/unicode.cpp index b38344d4a..6e00afe88 100644 --- a/nel/src/misc/unicode.cpp +++ b/nel/src/misc/unicode.cpp @@ -4732,8 +4732,8 @@ static const char **s_UtfLowerToUpperMap[16] = { NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrdiff_t &i) { - char c = str[i]; - char d, e; + unsigned char c = str[i]; + unsigned char d, e; if (c < 0x80) { if (c >= 'A' && c <= 'Z') @@ -4824,8 +4824,8 @@ void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i) NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrdiff_t &i) { - char c = str[i]; - char d, e; + unsigned char c = str[i]; + unsigned char d, e; if (c < 0x80) { if (c >= 'a' && c <= 'z') @@ -4910,6 +4910,230 @@ void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i) appendToUpperAsUtf8(res, &str[0], i); } +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +static const char s_UpperAscii[] = { + 'A', 0, 'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F', 0, 'G', 0, + 'H', 0, 'I', 0, 'J', 0, 'K', 0, 'L', 0, 'M', 0, 'N', 0, + 'O', 0, 'P', 0, 'Q', 0, 'R', 0, 'S', 0, 'T', 0, 'U', 0, + 'V', 0, 'W', 0, 'X', 0, 'Y', 0, 'Z', 0, 0, 0, 0, 0 +}; + +const char *fetchToUpperAsUtf8(const char **str) +{ + unsigned char c = *(*str); + unsigned char d, e; + if (c < 0x80) + { + if (c >= 'a' && c <= 'z') + { + // 1-byte UTF-8 + ++(*str); + return &s_UpperAscii[(c - 'a') << 1]; + } + } + else if ((c & 0xE0) == 0xC0 && ((d = (*str)[1]) & 0xC0) == 0x80) + { + // 2-byte UTF-8 + const char *table = s_Utf8LowerToUpperTables[c & 0x1F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + (*str) += 2; + return &table[idx]; + } + } + } + else if ((c & 0xF0) == 0xE0 && ((d = (*str)[1]) & 0xC0) == 0x80 && ((e = (*str)[2]) & 0xC0) == 0x80) + { + // 3-byte UTF-8 + const char **map = s_UtfLowerToUpperMap[c & 0x0F]; + if (map) + { + const char *table = map[d & 0x3F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + (*str) += 3; + return &table[idx]; + } + } + } + } + return NULL; +} + +int compareCaseInsensitive(const char *a, const char *b) +{ + // while (*a != 0 && *b != 0) + for (; ;) + { + const char *ca = fetchToUpperAsUtf8(&a); + const char *cb = fetchToUpperAsUtf8(&b); + if (!ca && !cb) + { + // Easy case, ASCII compare or junk + if (*a != *b) + { + if (*a > * b) return 1; + else return -1; + } + else if (!*a) // Equal and NUL, ends both + { + return 0; + } + ++a; + ++b; + } + else if (!cb) + { + // String a changed lowercase, iterate ca until NUL alongside b + nlassert(*ca); + do + { + if (*ca != *b) + { + if (*ca > *b) return 1; + else return -1; + } + ++ca; + ++b; + } while (*ca); + } + else if (!ca) + { + // String b changed lowercase, iterate a alongside cb until NUL + nlassert(*cb); + do + { + if (*a != *cb) + { + if (*a > *cb) return 1; + else return -1; + } + ++a; + ++cb; + } while (*cb); + } + else + { + // Both strings changed lowercase + if (ca != cb) // Only check if it's a different result + { + do + { + if (*ca != *cb) + { + if (*ca > *cb) return 1; + else return -1; + } + ++ca; + ++cb; + } while (*ca && *cb); + } + } + } + // if (*a == *b) return 0; + // if (*a > *b) return 1; + // return -1; +} + +int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB) +{ + const char *ma = a + lenA; + const char *mb = b + lenB; + for (; ;) + { + if (a >= ma) + { + if (b >= mb) + { + return 0; // Both strings ended + } + else + { + return 1; // A is longer + } + } + if (b >= mb) + { + return -1; // B is longer + } + const char *ca = fetchToUpperAsUtf8(&a); + const char *cb = fetchToUpperAsUtf8(&b); + if (!ca && !cb) + { + // Easy case, ASCII compare or junk + if (*a != *b) + { + if (*a > * b) return 1; + else return -1; + } + /* + else if (!*a) // Equal and NUL, ends both + { + return 0; + } + */ + ++a; + ++b; + } + else if (!cb) + { + // String a changed lowercase, iterate ca until NUL alongside b + nlassert(*ca); + do + { + if (*ca != *b) + { + if (*ca > *b) return 1; + else return -1; + } + ++ca; + ++b; + } while (*ca); + } + else if (!ca) + { + // String b changed lowercase, iterate a alongside cb until NUL + nlassert(*cb); + do + { + if (*a != *cb) + { + if (*a > *cb) return 1; + else return -1; + } + ++a; + ++cb; + } while (*cb); + } + else + { + // Both strings changed lowercase + if (ca != cb) // Only check if it's a different result + { + do + { + if (*ca != *cb) + { + if (*ca > *cb) return 1; + else return -1; + } + ++ca; + ++cb; + } while (*ca && *cb); + } + } + } +} + // *************************************************************************** #else diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index 84b058902..d68a836de 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -811,7 +811,7 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual // Get the fauna name in the sheet const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); if (creatureName.find(ucstring("(EntitiesMngr.getEntityByName(sender, true, true)); bool bWoman = entity && entity->getGender() == GSGENDER::female; - name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); + name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman); { // Sometimes translation contains another title ucstring::size_type pos = name.find('$'); if (pos != ucstring::npos) { - name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman); + name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name.toUtf8()), bWoman); } } } 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.toUtf8())) ? ucstring("(CSR) ") : ucstring(""); } result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; @@ -1018,13 +1018,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde } // Format the sentence with the provided sender name - ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender); + ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender.toUtf8()); ucstring 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.toUtf8())) ? ucstring("(CSR) ") : ucstring(""); - if (UserEntity && senderName == UserEntity->getDisplayName()) + if (UserEntity && senderName.toUtf8() == UserEntity->getDisplayName()) { // The player talks switch(type) @@ -1046,13 +1046,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde // We need the gender to display the correct title bool bWoman = entity && entity->getGender() == GSGENDER::female; - senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); + senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman); { // Sometimes translation contains another title ucstring::size_type pos = senderName.find('$'); if (pos != ucstring::npos) { - senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman); + senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName.toUtf8()), bWoman); } } } diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index a491d5e57..1fa7efb9f 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -145,8 +145,8 @@ 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 @@ -1441,7 +1441,7 @@ Deprecated { ucstring::size_type pos = sValue.find('$'); if (pos != ucstring::npos) { - sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle); + sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue.toUtf8()), womanTitle); } } setTarget (pCaller, sTarget, sValue); @@ -3348,7 +3348,7 @@ class CAHLoadScenario : public IActionHandler ucstring res; if (pSMC->getString(val,res)) { - string charName = CEntityCL::removeTitleAndShardFromName(res).toString(); + string charName = CEntityCL::removeTitleAndShardFromName(res.toUtf8()); sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName); if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult"))) diff --git a/ryzom/client/src/connection.h b/ryzom/client/src/connection.h index 67bda815c..bb6f4cd24 100644 --- a/ryzom/client/src/connection.h +++ b/ryzom/client/src/connection.h @@ -30,8 +30,8 @@ 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; diff --git a/ryzom/client/src/debug_client.cpp b/ryzom/client/src/debug_client.cpp index 88df4be99..cbceca4ef 100644 --- a/ryzom/client/src/debug_client.cpp +++ b/ryzom/client/src/debug_client.cpp @@ -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 diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 9d3f446eb..9e57b3acb 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -2097,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; } @@ -2264,7 +2264,7 @@ void CEntityCL::load() // virtual //----------------------------------------------- void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) { - _EntityName = value; + _EntityName = value.toUtf8(); // remove the shard name if possible _EntityName= removeShardFromName(_EntityName); @@ -2303,7 +2303,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) if (pos != ucstring::npos) { ucstring sn = replacement; - _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos)); + _EntityName = sn.substr(0, pos).toUtf8(); ucstring::size_type pos2 = sn.find('$', pos + 1); _TitleRaw = sn.substr(pos+1, pos2 - pos - 1); replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); @@ -2370,32 +2370,32 @@ 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('$'); + std::string::size_type p1 = name.find('$'); if (p1 != ucstring::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('$'); + std::string::size_type p1 = name.find('$'); if (p1 == ucstring::npos) { return name; } else { - ucstring::size_type p2 = name.find('$', p1 + 1); + std::string::size_type p2 = name.find('$', p1 + 1); if (p2 != ucstring::npos) { return name.substr(0, p1) + name.substr(p2 + 1); @@ -2410,16 +2410,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 @@ -2429,7 +2429,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..5b53c3027 100644 --- a/ryzom/client/src/entity_cl.h +++ b/ryzom/client/src/entity_cl.h @@ -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); } @@ -931,7 +931,7 @@ 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; // Current entity tags diff --git a/ryzom/client/src/forage_source_cl.cpp b/ryzom/client/src/forage_source_cl.cpp index 46249ed9e..7f538a2f0 100644 --- a/ryzom/client/src/forage_source_cl.cpp +++ b/ryzom/client/src/forage_source_cl.cpp @@ -508,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 + "]"; } } @@ -539,15 +539,15 @@ void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* game const ucchar *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); if ( name ) { - _EntityName = name; + _EntityName = ucstring(name).toUtf8(); if ( _ProspectorSlot != 255 ) { 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 @@ -568,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 diff --git a/ryzom/client/src/init_main_loop.cpp b/ryzom/client/src/init_main_loop.cpp index a5bfa67df..e2566e48f 100644 --- a/ryzom/client/src/init_main_loop.cpp +++ b/ryzom/client/src/init_main_loop.cpp @@ -225,8 +225,8 @@ 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()); @@ -236,7 +236,7 @@ struct CStatThread : public NLMISC::IRunnable bool connect() { //nlinfo("connect"); - if(!UserEntity || UserEntity->getEntityName().toString().empty()) + if(!UserEntity || UserEntity->getEntityName().empty()) return false; referer = ContinentMngr.getCurrentContinentSelectName(); @@ -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())); diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index cf25d00c5..4da75a8da 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -1959,13 +1959,13 @@ public: if (pChar != NULL) womanTitle = pChar->getGender() == GSGENDER::female; - STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); + STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout.toUtf8()), womanTitle); // Sometimes translation contains another title ucstring::size_type pos = copyInout.find('$'); if (pos != ucstring::npos) { - copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); + copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout.toUtf8()), womanTitle); } CStringPostProcessRemoveTitle::cbIDStringReceived(copyInout); diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index dc64feae1..2ccbf963a 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -670,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler if (selection == NULL) return; //if(selection->isNPC()) { - ucstring name = selection->getEntityName(); + std::string name = selection->getEntityName(); if(name.empty()) { // try to get the name from the string manager (for npc) @@ -679,7 +679,7 @@ class CHandlerOpenTitleHelp : public IActionHandler { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); pSMC->getString (nDBid, name); - ucstring copyName = name; + std::string copyName = name; name = CEntityCL::removeTitleAndShardFromName(name); if (name.empty()) { @@ -689,18 +689,18 @@ class CHandlerOpenTitleHelp : public IActionHandler woman = pChar->getGender() == GSGENDER::female; // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(copyName); + std::string strNewTitle = CEntityCL::getTitleFromName(copyName); // retrieve the translated string if (!strNewTitle.empty()) - name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(strNewTitle, woman); + name = ucstring(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(ucstring::makeFromUtf8(strNewTitle), woman)).toUtf8(); else name.clear(); } } } 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; } } @@ -2762,7 +2762,7 @@ class CPlayerShardNameRemover : public IOnReceiveTextId { virtual void onReceiveTextId(ucstring &str) { - str= CEntityCL::removeShardFromName(str); + str= CEntityCL::removeShardFromName(str.toUtf8()); } }; static CPlayerShardNameRemover PlayerShardNameRemover; @@ -3629,7 +3629,7 @@ public: CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) { - CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt).toUtf8()); + CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt.toUtf8())); } } }; diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index e3ee653aa..0edd74491 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1737,7 +1737,7 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet) ucstring creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( itemInfo.CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + if ( toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString.toUtf8())) isCraftedByUserEntity = true; } @@ -1845,7 +1845,7 @@ class CHandlerItemMenuCheck : public IActionHandler ucstring creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( getInventory().getItemInfo(getInventory().getItemSlotId(pCS)).CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString.toUtf8())) isTextEditionActive = true; } } diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 8b379f6d1..63d491deb 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -836,7 +836,7 @@ class CAHReplyTeller : public IActionHandler { w->setKeyboardFocus(); w->enableBlink(1); - PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName)); + PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8())); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -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(ucstring("tell ") + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8()) + ucstring(" "), false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -916,7 +916,7 @@ NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "") bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) { // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(inOut); + ucstring strNewTitle = CEntityCL::getTitleFromName(inOut.toUtf8()); // retrieve the translated string if (!strNewTitle.empty()) @@ -927,7 +927,7 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) ucstring::size_type pos = inOut.find('$'); if (pos != ucstring::npos) { - inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut), Woman); + inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut.toUtf8()), Woman); } } } @@ -940,14 +940,14 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) // *************************************************************************** bool CStringPostProcessRemoveTitle::cbIDStringReceived(ucstring &inOut) { - inOut = CEntityCL::removeTitleAndShardFromName(inOut); + inOut = CEntityCL::removeTitleAndShardFromName(inOut.toUtf8()); return true; } // *************************************************************************** bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut) { - ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut); + ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut.toUtf8()); if (sOut.empty()) { CStringPostProcessRemoveName SPPRM; 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 a461d0194..3d59ea644 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -692,7 +692,7 @@ void CDBGroupListSheetTrade::checkCoords () ucstring result; if( pSMC->getString ( cst->LastVendorNameId, result) ) { - cst->VendorNameString = CEntityCL::removeShardFromName(result); + cst->VendorNameString = CEntityCL::removeShardFromName(result.toUtf8()); set< CSheetChildTrade *>::iterator itTmp = it; ++it; VendorNameIdToUpdate.erase(itTmp); diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index a5e443da6..d5b8d7e9c 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -560,7 +560,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) CStringManagerClient *pSMC = CStringManagerClient::instance(); ucstring name; if (pSMC->getString(nameNode->getValue32(), name)) - ct.Name = CEntityCL::removeTitleAndShardFromName(name); // TODO : dynamic support for name + ct.Name = CEntityCL::removeTitleAndShardFromName(name.toUtf8()); // TODO : dynamic support for name else ct.Name = CI18N::get("uiNotReceived"); return true; diff --git a/ryzom/client/src/interface_v3/group_html_webig.cpp b/ryzom/client/src/interface_v3/group_html_webig.cpp index 985ae3f20..d190b83b6 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -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)); diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index ce6d21021..7725d45f9 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -1201,7 +1201,7 @@ void CGroupMap::checkCoords() CEntityCL *sel = EntitiesMngr.entity(UserEntity->selection()); if (sel) { - _TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName()).toUtf8()); + _TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName())); } } } @@ -1405,8 +1405,8 @@ void CGroupMap::checkCoords() if (pSMC->getString(val,res)) { - res = CEntityCL::removeTitleAndShardFromName(res); - _TeammateLM[i]->setDefaultContextHelp(res.toUtf8()); + std::string res2 = CEntityCL::removeTitleAndShardFromName(res.toUtf8()); + _TeammateLM[i]->setDefaultContextHelp(res2); } } updateLMPosFromDBPos(_TeammateLM[i], px, py); diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp index e3a1b6b41..328579d06 100644 --- a/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/ryzom/client/src/interface_v3/guild_manager.cpp @@ -359,7 +359,7 @@ void CGuildManager::update() for (uint i = 0; i < _GuildMembers.size(); ++i) { if (!pSMC->getString (_GuildMembers[i].NameID, _GuildMembers[i].Name)) bAllValid = false; - else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name); + else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name.toUtf8()); } // If all is valid no more need update and if guild is opened update the interface @@ -875,7 +875,7 @@ class CAHGuildSheetOpen : public IActionHandler CCtrlBase *inviteButton = pLine->getCtrl("invite_button"); if (inviteButton != NULL) - inviteButton->setActive(rGuildMembers[i].Online != ccs_offline && rGuildMembers[i].Name != UserEntity->getEntityName()); + inviteButton->setActive(rGuildMembers[i].Online != ccs_offline && rGuildMembers[i].Name.toUtf8() != UserEntity->getEntityName()); // Enter Date CViewText *pViewEnterDate = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_ENTER_DATE)); diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 24ab75058..40413914e 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -358,7 +358,7 @@ public: } else { - std::string name = UserEntity->getEntityName().toUtf8(); + std::string name = UserEntity->getEntityName(); if (*it == 'P') name = toUpper(name); formatedResult += name; } @@ -391,7 +391,7 @@ public: } else { - botName = entity->getDisplayName().toUtf8(); + botName = entity->getDisplayName(); } CCharacterCL *pChar = dynamic_cast(entity); if (pChar != NULL) @@ -405,7 +405,7 @@ public: spprn.Woman = womanTitle; spprn.cbIDStringReceived(sTitleTranslated); - botName = CEntityCL::removeTitleAndShardFromName(botName).toUtf8(); + botName = CEntityCL::removeTitleAndShardFromName(botName); // short name (with no title such as 'guard', 'merchant' ...) if (*it == 's') @@ -4214,7 +4214,7 @@ bool CInterfaceManager::parseTokens(string& ucstr) // Parse the parameter if (token_param == "name") { - string name = pTokenSubjectEntity->getDisplayName().toUtf8(); + string name = pTokenSubjectEntity->getDisplayName(); // special case where there is only a title, very rare case for some NPC if (name.empty()) { diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index e448b1f4a..c9dc2767e 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1363,7 +1363,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; } @@ -1441,7 +1441,7 @@ int CLuaIHMRyzom::getTargetName(CLuaState &ls) if (!target) return 0; - ls.push(target->getEntityName().toUtf8()); + ls.push(target->getEntityName()); return 1; } @@ -3274,7 +3274,7 @@ 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); @@ -3648,7 +3648,7 @@ 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); + w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player.toUtf8()) + ucstring(" "), false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index 948b45e51..de7c9023a 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -1276,7 +1276,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8()); // add the contact to this list sint index = pl.getIndexFromName(name); @@ -1327,7 +1327,7 @@ bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) c // select correct people list const CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8()); return pl.getIndexFromName(name) != -1; } @@ -2250,7 +2250,7 @@ public: if (peopleList) { // don't add if it is the player name - if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputStringAsUtf16())) + if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputString())) { displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList")); } diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index f1f622836..e2d55e250 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -832,7 +832,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c } if (!senderName.empty()) { - CEntityCL *senderEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(senderName), true, true); + CEntityCL *senderEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()), true, true); if (senderEntity) { if (senderEntity->Type != CEntityCL::Player) @@ -845,7 +845,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c } else { - CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName), false, true); + CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName.toUtf8()), false, true); if (destEntity) { destEntity->removeStateFx(); @@ -866,7 +866,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // if tell, bkup sendername if (mode == CChatGroup::tell && windowVisible && !senderName.empty()) { - PeopleInterraction.LastSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + PeopleInterraction.LastSenderName = CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()); } } @@ -928,7 +928,7 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); bool windowVisible; - ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()); // The sender part is up to and including the first ":" after the goodSenderName ucstring::size_type pos = finalString.find(goodSenderName); diff --git a/ryzom/client/src/r2/displayer_visual_entity.cpp b/ryzom/client/src/r2/displayer_visual_entity.cpp index 72b4c3ddb..01eaf0bc0 100644 --- a/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -1017,7 +1017,7 @@ void CDisplayerVisualEntity::updateName() { //BENCH(setEntityName) - _Entity->setEntityName(ucName); + _Entity->setEntityName(ucName.toUtf8()); } { //BENCH(buildInSceneInterface) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 06c3523b4..ec493e3d3 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -734,7 +734,7 @@ 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); } } @@ -744,7 +744,7 @@ restartLoop: ucstring::size_type pos = str.find('$'); if ( ! str.empty() && pos != ucstring::npos) { - str = CEntityCL::removeTitleFromName(str); + str = CEntityCL::removeTitleFromName(str.toUtf8()); } // append this string From 9d534882e862bc89f127b1d3c6a9ced098b88214 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 08:11:32 +0800 Subject: [PATCH 12/14] UTF-8 string manager, ryzom/ryzomcore#335 --- ryzom/client/src/commands.cpp | 22 +- ryzom/client/src/entity_cl.cpp | 37 ++- ryzom/client/src/entity_cl.h | 4 +- ryzom/client/src/forage_source_cl.cpp | 4 +- .../src/interface_v3/action_handler_help.cpp | 4 +- .../src/interface_v3/action_handler_misc.cpp | 2 +- .../client/src/interface_v3/group_compas.cpp | 4 +- .../src/interface_v3/sbrick_manager.cpp | 6 +- ryzom/client/src/net_manager.cpp | 8 +- ryzom/client/src/player_cl.cpp | 2 +- ryzom/client/src/player_r2_cl.cpp | 2 +- ryzom/client/src/string_manager_client.cpp | 241 +++++++++--------- ryzom/client/src/string_manager_client.h | 138 +++++----- 13 files changed, 247 insertions(+), 227 deletions(-) diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index 986da78e6..d3a6a2df6 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -1385,14 +1385,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 +1406,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) @@ -1459,7 +1459,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); diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 9e57b3acb..b28d3fda6 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -2262,32 +2262,32 @@ 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.toUtf8(); + _EntityName = value; // remove the shard name if possible _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('$'); + string::size_type p1 = _EntityName.find('$'); if (p1 != ucstring::npos) { // we found a replacement point begin tag - ucstring::size_type p2 = _EntityName.find('$', p1+1); + string::size_type p2 = _EntityName.find('$', p1+1); if (p2 != ucstring::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) @@ -2295,22 +2295,21 @@ 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.toUtf8(), womanTitle); // Sometimes translation contains another title { - ucstring::size_type pos = replacement.find('$'); + string::size_type pos = replacement.find('$'); if (pos != ucstring::npos) { - ucstring sn = replacement; - _EntityName = sn.substr(0, pos).toUtf8(); - ucstring::size_type pos2 = sn.find('$', pos + 1); - _TitleRaw = sn.substr(pos+1, pos2 - pos - 1); - replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); + _EntityName = _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.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.toUtf8(), womanTitle); } } - _Tags = STRING_MANAGER::CStringManagerClient::getTitleInfos(_TitleRaw, womanTitle); + _Tags = STRING_MANAGER::CStringManagerClient::getTitleInfos(_TitleRaw.toUtf8(), womanTitle); if (!replacement.empty() || !ClientCfg.DebugStringManager) { @@ -2319,9 +2318,9 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(_EntityName.substr(0, p1)); // + _Name.substr(p2+1) // Get extended name _NameEx = replacement; - newtitle = _NameEx; + newtitle = _NameEx.toUtf8(); } - CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw.toString() ); + CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw.toUtf8() ); if ( titleEnum >= CHARACTER_TITLE::BeginGmTitle && titleEnum <= CHARACTER_TITLE::EndGmTitle ) { _GMTitle = titleEnum - CHARACTER_TITLE::BeginGmTitle; @@ -2359,7 +2358,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) if (pGC != NULL) pGC->setUCTitle(_EntityName); CSkillManager *pSM = CSkillManager::getInstance(); - pSM->setPlayerTitle(_TitleRaw.toString()); + pSM->setPlayerTitle(_TitleRaw.toUtf8()); } // Must rebuild the in scene interface 'cause name has changed diff --git a/ryzom/client/src/entity_cl.h b/ryzom/client/src/entity_cl.h index 5b53c3027..3ac01ed25 100644 --- a/ryzom/client/src/entity_cl.h +++ b/ryzom/client/src/entity_cl.h @@ -935,7 +935,7 @@ protected: // Current entity title ucstring _Title; // Current entity tags - std::vector _Tags; + std::vector _Tags; // Current entity title string id ucstring _TitleRaw; // Current permanent content symbol for the entity @@ -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/forage_source_cl.cpp b/ryzom/client/src/forage_source_cl.cpp index 7f538a2f0..e813912df 100644 --- a/ryzom/client/src/forage_source_cl.cpp +++ b/ryzom/client/src/forage_source_cl.cpp @@ -536,10 +536,10 @@ 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 = ucstring(name).toUtf8(); + _EntityName = name; if ( _ProspectorSlot != 255 ) { CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index 2ccbf963a..c00328ef0 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -693,7 +693,7 @@ class CHandlerOpenTitleHelp : public IActionHandler // retrieve the translated string if (!strNewTitle.empty()) - name = ucstring(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(ucstring::makeFromUtf8(strNewTitle), woman)).toUtf8(); + name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(strNewTitle, woman); else name.clear(); } @@ -752,7 +752,7 @@ class CHandlerOpenTitleHelp : public IActionHandler for (titleIDnb = 0; titleIDnb < CHARACTER_TITLE::NB_CHARACTER_TITLE; ++titleIDnb) { bool women = UserEntity && UserEntity->getGender()==GSGENDER::female; - if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title) + if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title.toUtf8()) break; } diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 63d491deb..8190ab799 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -916,7 +916,7 @@ NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "") bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) { // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(inOut.toUtf8()); + string strNewTitle = CEntityCL::getTitleFromName(inOut.toUtf8()); // retrieve the translated string if (!strNewTitle.empty()) diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index d5b8d7e9c..fc0f2a5a5 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -1047,12 +1047,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/sbrick_manager.cpp b/ryzom/client/src/interface_v3/sbrick_manager.cpp index d12ed783c..a2cecf2d4 100644 --- a/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -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 diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index e2d55e250..9f05fe860 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -2299,11 +2299,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; @@ -3390,7 +3388,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) diff --git a/ryzom/client/src/player_cl.cpp b/ryzom/client/src/player_cl.cpp index 9aef1032b..437149f16 100644 --- a/ryzom/client/src/player_cl.cpp +++ b/ryzom/client/src/player_cl.cpp @@ -743,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.toUtf8(), _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..8f7621755 100644 --- a/ryzom/client/src/player_r2_cl.cpp +++ b/ryzom/client/src/player_r2_cl.cpp @@ -446,7 +446,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.toUtf8(),_Gender == GSGENDER::female)); if (!replacement.empty()) { // Get extended name diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index ec493e3d3..7381f5cb9 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -39,17 +39,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 +57,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,6 +122,7 @@ 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()); @@ -131,6 +132,8 @@ namespace STRING_MANAGER // there is a cache file, check date reset it if needed { NLMISC::CIFile file(_CacheFilename); + file.setVersionException(false, false); + file.serialVersion(currentVersion); file.serial(_Timestamp); } @@ -139,6 +142,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 +155,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 +165,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 +201,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 +224,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 +237,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 +260,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 +337,7 @@ restartLoop4: - bool CStringManagerClient::getString(uint32 stringId, ucstring &result) + bool CStringManagerClient::getString(uint32 stringId, string &result) { H_AUTO( CStringManagerClient_getString ) @@ -357,7 +364,7 @@ restartLoop4: _WaitingStrings.insert(stringId); // need to ask for this string. NLMISC::CBitMemStream bms; - const std::string msgType = "STRING_MANAGER:STRING_RQ"; + const string msgType = "STRING_MANAGER:STRING_RQ"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( stringId ); @@ -374,7 +381,7 @@ restartLoop4: { char tmp[1024]; sprintf(tmp, "", stringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); // = _WaitString; @@ -385,14 +392,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 +409,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 +426,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 +491,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 +623,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 +706,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 +719,7 @@ restartLoop: { case string_id: { - ucstring str; + string str; if (!getString(param.StringId, str)) return false; @@ -741,10 +748,10 @@ restartLoop: } // If the string contains a title, then remove it - ucstring::size_type pos = str.find('$'); + string::size_type pos = str.find('$'); if ( ! str.empty() && pos != ucstring::npos) { - str = CEntityCL::removeTitleFromName(str.toUtf8()); + str = CEntityCL::removeTitleFromName(str); } // append this string @@ -759,13 +766,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) ) { @@ -796,7 +803,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 @@ -805,7 +812,7 @@ restartLoop: break; case dyn_string_id: { - ucstring dynStr; + string dynStr; if (!getDynString(param.DynStringId, dynStr)) return false; temp.append(move, src+param.ReplacementPoint); @@ -823,8 +830,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) { @@ -853,7 +860,7 @@ restartLoop: } - bool CStringManagerClient::getDynString(uint32 dynStringId, ucstring &result) + bool CStringManagerClient::getDynString(uint32 dynStringId, std::string &result) { H_AUTO( CStringManagerClient_getDynString ) @@ -882,7 +889,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp) + it->second.String; + result = tmp + it->second.String; } else result = it->second.String; @@ -908,7 +915,7 @@ restartLoop: nlwarning("DynStringID %u is unknown !", dynStringId); char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); //_WaitString; @@ -920,7 +927,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp) + it->second.String; + result = tmp + it->second.String; } else result = it->second.String; @@ -933,7 +940,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); // = _WaitString; @@ -943,7 +950,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 @@ -964,14 +971,14 @@ restartLoop: return referenceFile; } - void CLoadProxy::loadStringFile(const std::string &filename, ucstring &text) + void CLoadProxy::loadStringFile(const string &filename, ucstring &text) { 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()) @@ -1041,7 +1048,7 @@ public: 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()) @@ -1134,7 +1141,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()); @@ -1142,7 +1149,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"); @@ -1213,8 +1220,8 @@ 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]; + string fileName = fileNames[i]; + string keyExtenstion = specialWords[i*3+2]; // read the ucstring and make diffs with data in ./translation/work. CReadWorkSheetFile rwsf; @@ -1250,17 +1257,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() ) { @@ -1276,7 +1283,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) if(womenNameColIndex!=std::numeric_limits::max()) { const ucstring &womenName= ws.getData(j, womenNameColIndex); - _SpecItem_TempMap[keyStr].WomenName= womenName; + _SpecItem_TempMap[keyStr].WomenName= womenName.toUtf8(); // replace all \n in the women name with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n")); } @@ -1285,7 +1292,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) if(descColIndex!=std::numeric_limits::max()) { const ucstring &desc= ws.getData(j, descColIndex); - _SpecItem_TempMap[keyStr].Desc= desc; + _SpecItem_TempMap[keyStr].Desc= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n")); } @@ -1294,7 +1301,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) if(descColIndex2!=std::numeric_limits::max()) { const ucstring &desc= ws.getData(j, descColIndex2); - _SpecItem_TempMap[keyStr].Desc2= desc; + _SpecItem_TempMap[keyStr].Desc2= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n")); } @@ -1358,7 +1365,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; @@ -1366,35 +1373,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++; @@ -1406,22 +1408,21 @@ 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; + static string lwrLabel; lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) @@ -1456,28 +1457,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; + static string lwrLabel; lwrLabel = toLower(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()) @@ -1497,20 +1496,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; + static string lwrLabel; lwrLabel = toLower(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()) @@ -1539,87 +1538,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]); @@ -1661,18 +1661,18 @@ 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); } } @@ -1680,74 +1680,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; + static string lwrLabel; lwrLabel = toLower(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()) @@ -1773,6 +1775,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 971d808b3..5179318f4 100644 --- a/ryzom/client/src/string_manager_client.h +++ b/ryzom/client/src/string_manager_client.h @@ -63,15 +63,16 @@ public: // Force the cache to be saved void flushStringCache(); - bool getString(uint32 stringId, std::string &result) { ucstring temp; bool res = getString(stringId, temp); result = temp.toUtf8(); return res; } // FIXME: UTF-8 - bool getString(uint32 stringId, ucstring &result); - void waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); + bool getString(uint32 stringId, std::string &result); + bool getString(uint32 stringId, ucstring &result) { std::string temp; bool res = getString(stringId, temp); result.fromUtf8(temp); return res; } // FIXME: UTF-8 + 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); + bool getDynString(uint32 dynStringId, ucstring &result) { std::string temp; bool res = getString(dynStringId, temp); result.fromUtf8(temp); return res; } // FIXME: UTF-8 + 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); @@ -80,55 +81,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. @@ -153,8 +154,8 @@ private: struct TParamValue { - TParamType Type; - ucstring::size_type ReplacementPoint; + TParamType Type; + std::string::size_type ReplacementPoint; union { uint32 StringId; @@ -177,7 +178,7 @@ private: NLMISC::CBitMemStream Message; uint32 StringId; std::vector Params; - ucstring String; + std::string String; }; enum @@ -189,7 +190,7 @@ private: struct TStringWaiter { /// Pointer to the ucstring to fill - ucstring *Result; + std::string *Result; /// Pointer to the remover that contains this string reference const IStringWaiterRemover *Remover; }; @@ -198,7 +199,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. @@ -224,7 +225,7 @@ private: TStringCallbacksContainer _DynStringsCallbacks; // Return value for waiting string.. - static ucstring _WaitString; + static std::string _WaitString; // Singleton pattern implementation static CStringManagerClient *_Instance; @@ -247,7 +248,7 @@ private: struct CCacheString { uint32 StringId; - ucstring String; + std::string String; }; std::vector _CacheStringToSave; //@} @@ -257,41 +258,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; + ucstring womenName; + ucstring desc; + ucstring desc2; + 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 { @@ -303,9 +323,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 @@ -381,9 +401,9 @@ 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() { From 5a470a7b16a77c1be7b56d8a1d1a40ba7b26788e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 08:21:31 +0800 Subject: [PATCH 13/14] UTF-8 string manager, ryzom/ryzomcore#335 --- nel/include/nel/gui/interface_expr.h | 1 + ryzom/client/src/game_context_menu.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 6 ++---- ryzom/client/src/interface_v3/dbctrl_sheet.cpp | 8 ++++---- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../src/interface_v3/encyclopedia_manager.cpp | 9 +++------ .../src/interface_v3/group_in_scene_bubble.cpp | 3 +-- .../interface_v3/group_phrase_skill_filter.cpp | 2 +- ryzom/client/src/interface_v3/group_skills.cpp | 4 ++-- .../interface_expr_user_fct_game.cpp | 16 ++++++++-------- .../interface_expr_user_fct_items.cpp | 8 ++++---- 11 files changed, 28 insertions(+), 33 deletions(-) diff --git a/nel/include/nel/gui/interface_expr.h b/nel/include/nel/gui/interface_expr.h index 27ed24fe0..b4474ac22 100644 --- a/nel/include/nel/gui/interface_expr.h +++ b/nel/include/nel/gui/interface_expr.h @@ -68,6 +68,7 @@ namespace NLGUI void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } + void setString(const char *value) { clean(); _Type = String; _StringValue = value; } void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); } void setUserType(CInterfaceExprUserType *value); // reset this object to initial state (no type) diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp index 441976be8..47ca97a80 100644 --- a/ryzom/client/src/game_context_menu.cpp +++ b/ryzom/client/src/game_context_menu.cpp @@ -798,7 +798,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options) { CViewTextMenu *pVTM = _TextOutpostState; if (pVTM) - pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8()); + pVTM->setText(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)); } // apply the active diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 0edd74491..2df888285 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -161,9 +161,8 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(localDesc.toUtf8()); + display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); else { ucstring text = itemInfo.CustomText; @@ -305,9 +304,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // Finish the display or add the waiter if (getInventory().isItemInfoUpToDate(ItemSlotId)) { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(localDesc.toUtf8()); + display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); else { ucstring text = itemInfo.CustomText; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index a07d4c2fb..e9575f776 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -3385,7 +3385,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { // just show the name of the skill // the sheet id is interpreted as a skill enum - help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() )).toUtf8(); + help= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() ); } else if(getType() == CCtrlSheetInfo::SheetType_Macro) { @@ -3485,7 +3485,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId())); if(brick) - help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id)).toUtf8(); + help= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id); else help= _ContextHelp; } @@ -3549,7 +3549,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { CSPhraseSheet *phrase= dynamic_cast(SheetMngr.get(CSheetId(getSheetId()))); if(phrase) - help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id)).toUtf8(); + help= STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id); else help= _ContextHelp; } @@ -3557,7 +3557,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { const COutpostBuildingSheet *outpost = asOutpostBuildingSheet(); if (outpost) - help = CUtfStringView(CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()))).toUtf8(); + help = CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32())); else help = _ContextHelp; } 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 3d59ea644..2b52de9b0 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -269,7 +269,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT if (pOBS != NULL) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - text += string("\n") + CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()))).toUtf8(); + text += string("\n") + pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId())); text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper)); text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); if ((pOBS->CostTime % 60) != 0) diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 63c5f07c9..25f5bc2e8 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -360,18 +360,15 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) { if (pES->type() == CEntitySheet::ITEM) { - CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc.toUtf8()); + pRBVT->setText(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SBRICK) { - CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc.toUtf8()); + pRBVT->setText(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SPHRASE) { - CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc.toUtf8()); + pRBVT->setText(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); } } 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 258700dd2..c3edc87f9 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -531,10 +531,9 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t if (group) { // Skill name - CUtfStringView sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); CViewText *pViewSkillName = dynamic_cast(group->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName.toUtf8()); + 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); 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 d246918bd..7d2054fc4 100644 --- a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -225,7 +225,7 @@ void CGroupPhraseSkillFilter::rebuild() // just text pNode->DisplayText = true; pNode->Template = NULL; - pNode->Text = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); + pNode->Text = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); // Action handler? if(!_AHCtrlNode.empty()) diff --git a/ryzom/client/src/interface_v3/group_skills.cpp b/ryzom/client/src/interface_v3/group_skills.cpp index d0efce626..146117d17 100644 --- a/ryzom/client/src/interface_v3/group_skills.cpp +++ b/ryzom/client/src/interface_v3/group_skills.cpp @@ -336,7 +336,7 @@ void CGroupSkills::createAllTreeNodes() // local variable (avoid realloc in loop) vector< pair > tempVec(2); - string sSkillName; + const char *sSkillName; while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop { @@ -366,7 +366,7 @@ void CGroupSkills::createAllTreeNodes() pNode->Id = NLMISC::toString(i); // get Skill Name - sSkillName = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); + sSkillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); // just text or template? if(_TemplateSkill.empty()) 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 a4dfb9d79..9494deacf 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 @@ -1083,7 +1083,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const std::string name = CUtfStringView(pSMC->getOutpostLocalizedName(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getOutpostLocalizedName(CSheetId(nSheet)); result.setString(name); @@ -1110,7 +1110,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getOutpostLocalizedDescription(CSheetId(nSheet)); result.setString(name); @@ -1137,7 +1137,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet)); result.setString(name); @@ -1163,18 +1163,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) } // get sheet name - string 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 { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - name = CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet))).toUtf8(); + name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet)); } @@ -1203,7 +1203,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getSquadLocalizedName(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getSquadLocalizedName(CSheetId(nSheet)); result.setString(name); @@ -1230,7 +1230,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getSquadLocalizedDescription(CSheetId(nSheet)); result.setString(name); 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 eafdcccaf..cae4b9d77 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 @@ -320,8 +320,8 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName) else { const CItemSheet *itemSheet = getItemSheet(args); - string tmp; - if (itemSheet != NULL) tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id)).toUtf8(); + const char *tmp = ""; + if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id); result.setString(tmp); return true; } @@ -346,8 +346,8 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName) return false; } - string tmp; - tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet)).toUtf8(); + const char *tmp = ""; + tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet); result.setString(tmp); return true; } From ecabc00ec5338da1569f552a089dab194b610243 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 08:40:06 +0800 Subject: [PATCH 14/14] UTF-8 various, ryzom/ryzomcore#335 --- ryzom/client/src/init.cpp | 16 ++++++------- .../interface_v3/group_in_scene_user_info.cpp | 12 +++++----- ryzom/client/src/interface_v3/group_map.cpp | 10 ++++---- ryzom/client/src/progress.cpp | 24 +++++++++---------- ryzom/client/src/r2/auto_group.cpp | 6 ++--- ryzom/client/src/r2/editor.cpp | 6 ++--- ryzom/client/src/r2/tool_draw_prim.cpp | 6 ++--- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/ryzom/client/src/init.cpp b/ryzom/client/src/init.cpp index ebb713a73..41c924baf 100644 --- a/ryzom/client/src/init.cpp +++ b/ryzom/client/src/init.cpp @@ -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 @@ -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; @@ -343,7 +343,7 @@ void ExitClientError (const char *format, ...) /* ucstring ucstr; ucstr.fromUtf8 (str); - MessageBoxW (NULL, (WCHAR*)ucstr.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONERROR); + MessageBoxW (NULL, (WCHAR *)ucstr.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR); */ #else fprintf (stderr, "%s\n", str); @@ -360,7 +360,7 @@ void ExitClientError (const char *format, ...) void ClientInfo (const ucstring &message) { #ifdef NL_OS_WINDOWS - MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONINFORMATION); + MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION); #endif } @@ -368,7 +368,7 @@ void ClientInfo (const ucstring &message) bool ClientQuestion (const ucstring &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, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO; #else return false; #endif 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 fa88db43e..c5dc116e3 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 @@ -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().toUtf8(); // For some NPC's the name is empty and only a title is given, // in that case, treat the title as the name. @@ -780,19 +780,19 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Set player name if (info->_Name) { - info->_Name->setText(entityName.toUtf8()); + info->_Name->setText(entityName); info->_Name->setModulateGlobalColor(false); } // Set player title if (info->_Title) - info->_Title->setText(entityTitle.toUtf8()); + info->_Title->setText(entityTitle); // Set tribe name if (info->_TribeName) { nlassert(info->_GuildName == NULL); - info->_TribeName->setText(theTribeName.toUtf8()); + info->_TribeName->setText(theTribeName); } // Init user leaf nodes diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index 7725d45f9..b5302885e 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -2530,19 +2530,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; @@ -2551,7 +2551,7 @@ void CGroupMap::createLMWidgets(const std::vector &lms) else // just add a text { CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam()); - pNewText->setText(ucsTmp.toUtf8()); + pNewText->setText(ucsTmp); pNewText->Pos = mapPos; pNewText->setParent(this); pNewText->setParentPosRef(Hotspot_BL); diff --git a/ryzom/client/src/progress.cpp b/ryzom/client/src/progress.cpp index e75b4a984..c27e285e1 100644 --- a/ryzom/client/src/progress.cpp +++ b/ryzom/client/src/progress.cpp @@ -50,7 +50,7 @@ extern NL3D::UMaterial LoadingMaterialFull; extern std::vector LogoBitmaps; extern uint TipsOfTheDayIndex; -extern ucstring TipsOfTheDay; +extern string TipsOfTheDay; extern bool UseEscapeDuringLoading; CProgress::CProgress () @@ -287,8 +287,8 @@ void CProgress::internalProgress (float value) // Display the tips of the day. TextContext->setFontSize((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; @@ -297,15 +297,15 @@ 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(); } @@ -338,7 +338,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.toUtf8() + ") - " + 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); @@ -386,13 +386,13 @@ void CProgress::internalProgress (float value) TextContext->setFontSize( (uint)(16.f * fontFactor)); // build the ucstr(s) - ucstring ucstr = CI18N::get((*itpc).Text); - vector vucstr; - ucstring sep("\n"); - splitUCString(ucstr,sep,vucstr); + string ucstr = CI18N::get((*itpc).Text); + 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; diff --git a/ryzom/client/src/r2/auto_group.cpp b/ryzom/client/src/r2/auto_group.cpp index ee269376c..7da977b3d 100644 --- a/ryzom/client/src/r2/auto_group.cpp +++ b/ryzom/client/src/r2/auto_group.cpp @@ -279,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")); + 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/editor.cpp b/ryzom/client/src/r2/editor.cpp index 3628dfe93..c9b47e6a3 100644 --- a/ryzom/client/src/r2/editor.cpp +++ b/ryzom/client/src/r2/editor.cpp @@ -1571,12 +1571,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; diff --git a/ryzom/client/src/r2/tool_draw_prim.cpp b/ryzom/client/src/r2/tool_draw_prim.cpp index c32682626..7ec119e29 100644 --- a/ryzom/client/src/r2/tool_draw_prim.cpp +++ b/ryzom/client/src/r2/tool_draw_prim.cpp @@ -551,9 +551,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