From cd8ed8ab576747bce8f2273f87068e50c90bc4b7 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sat, 31 Oct 2020 16:23:41 +0800 Subject: [PATCH 01/16] Update entity_cl.cpp --- ryzom/client/src/entity_cl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 77d1e3c65..4c1b4a842 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -2302,7 +2302,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value) string::size_type pos = replacement.find('$'); if (pos != string::npos) { - _EntityName = _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos)); + _EntityName = _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(replacement.substr(0, pos)); string::size_type pos2 = replacement.find('$', pos + 1); _TitleRaw = replacement.substr(pos+1, pos2 - pos - 1); replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); From 04805ec38c6807be2aa308d88565e6fa3ee767b0 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 16:46:00 +0800 Subject: [PATCH 02/16] Fix build --- ryzom/client/src/connection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index cf0abdbfd..2885ee1ac 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -3478,7 +3478,7 @@ class CAHInitImportCharacter : public IActionHandler { CViewText *text = dynamic_cast(newLine->getView("name")); if (text) - text->setText(ucstring(savedCharacters[i])); + text->setText(string(savedCharacters[i])); // first button is pushed CCtrlButton *button = dynamic_cast(newLine->getCtrl("but")); From a1337dbda9ae73222cc7e68dc168362f7ddad10b Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 02:45:39 +0800 Subject: [PATCH 03/16] Update string_manager_client.cpp --- ryzom/client/src/string_manager_client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 0ef667dc9..734b3bea6 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -1178,9 +1178,9 @@ bool CStringManagerClient::checkWordFileDates(vector &fileChecks, co // *************************************************************************** void CStringManagerClient::initI18NSpecialWords(const string &languageCode) { - ucstring womenNameColIdent = "women_name"; - ucstring descColIdent = "description"; - ucstring descColIdent2 = "description2"; + ucstring womenNameColIdent = ucstring("women_name"); + ucstring descColIdent = ucstring("description"); + ucstring descColIdent2 = ucstring("description2"); // List of words to append to the local CI18N system. static const char *specialWords[]= From da9254e7480dcf6551fb0977f3238539e2643c14 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 04:53:32 +0800 Subject: [PATCH 04/16] Update release.cpp --- ryzom/client/src/release.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ryzom/client/src/release.cpp b/ryzom/client/src/release.cpp index 889bcee11..7a7cc91eb 100644 --- a/ryzom/client/src/release.cpp +++ b/ryzom/client/src/release.cpp @@ -30,6 +30,7 @@ #include "nel/misc/async_file_manager.h" #include "nel/misc/system_utils.h" #include "nel/misc/streamed_package_manager.h" +#include "nel/web/http_package_provider.h" // 3D Interface. #include "nel/3d/bloom_effect.h" #include "nel/3d/fxaa.h" From 6c247256d29f030093748adf3fb665f1ccc74e5d Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 04:55:29 +0800 Subject: [PATCH 05/16] Update string_manager_client.cpp --- ryzom/client/src/string_manager_client.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 734b3bea6..98483bd6b 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -1629,13 +1629,13 @@ const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, b } -const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext) +const ucchar *CStringManagerClient::getLocalizedName(const string &uctext) { - string text = uctext.toUtf8(); + string text = uctext; if (text[0] == '[') { vector textLocalizations; - static ucstring defaultText; + static string defaultText; splitString(text.substr(1), "[", textLocalizations); if (!textLocalizations.empty()) { @@ -1643,12 +1643,12 @@ const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext) { if (textLocalizations[i].substr(0, 3) == CI18N::getCurrentLanguageCode()+"]") { - defaultText.fromUtf8(textLocalizations[i].substr(3)); + defaultText = textLocalizations[i].substr(3); return defaultText.c_str(); } else if (textLocalizations[i].substr(0, 3) == "wk]") { - defaultText.fromUtf8(textLocalizations[i].substr(3)); + defaultText = extLocalizations[i].substr(3); } } } From afa22ee22bec1ee1722e38cc9ae48c1d0d6dd29b Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 06:15:03 +0800 Subject: [PATCH 06/16] Update string_manager_client.cpp --- ryzom/client/src/string_manager_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 98483bd6b..623a66152 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -1629,7 +1629,7 @@ const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, b } -const ucchar *CStringManagerClient::getLocalizedName(const string &uctext) +const char *CStringManagerClient::getLocalizedName(const string &uctext) { string text = uctext; if (text[0] == '[') From 2bb13937e85ef6418d7ce609e124ce3065bad11c Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 06:57:53 +0800 Subject: [PATCH 07/16] Update string_manager_client.cpp --- ryzom/client/src/string_manager_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 623a66152..79a0ee36d 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -1648,7 +1648,7 @@ const char *CStringManagerClient::getLocalizedName(const string &uctext) } else if (textLocalizations[i].substr(0, 3) == "wk]") { - defaultText = extLocalizations[i].substr(3); + defaultText = textLocalizations[i].substr(3); } } } From 9d3891f1aa1ae5c7de2687b49bfd2814df7d7230 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 10:33:53 +0800 Subject: [PATCH 08/16] Update action_handler_item.cpp --- ryzom/client/src/interface_v3/action_handler_item.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 7a87719ab..8cbeaf678 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -161,28 +161,29 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { + const char *localDesc = STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); + display->setTextFormatTaged(localDesc); else { - ucstring text = itemInfo.CustomText; + string text = itemInfo.CustomText.toUtf8(); if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(text.substr(4, text.size()-4).toString().c_str()); + pGH->browse(text.substr(4, text.size()-4).c_str()); text = localDesc; } else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') { - string code = text.substr(4, text.size()-4).toString(); + string code = text.substr(4, text.size()-4); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); text = localDesc; } if (!text.empty()) { - display->setTextFormatTaged(text.toUtf8()); + display->setTextFormatTaged(text); group->setActive(true); } } From f859a39da483f602db24f5d7ffd751eab6b7be4d Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sun, 1 Nov 2020 10:34:51 +0800 Subject: [PATCH 09/16] Update action_handler_item.cpp --- ryzom/client/src/interface_v3/action_handler_item.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 8cbeaf678..1f8cd61b0 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -305,27 +305,28 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // Finish the display or add the waiter if (getInventory().isItemInfoUpToDate(ItemSlotId)) { + const char *localDesc = STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); + display->setTextFormatTaged(localDesc); else { - ucstring text = itemInfo.CustomText; + string text = itemInfo.CustomText.toUtf8(); if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(text.substr(4, text.size()-4).toUtf8().c_str()); + pGH->browse(text.substr(4, text.size()-4).c_str()); text = localDesc; } else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') { - string code = text.substr(4, text.size()-4).toUtf8(); + string code = text.substr(4, text.size()-4); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); text = localDesc; } if (!text.empty()) - display->setTextFormatTaged(text.toUtf8()); + display->setTextFormatTaged(text); } } else From c069b70ce8ec156b9a3c1638fee2d6dbc1d321a6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 05:13:39 +0800 Subject: [PATCH 10/16] UTF-8 various, ryzom/ryzomcore#335 --- nel/include/nel/misc/utf_string_view.h | 6 + nel/src/misc/utf_string_view.cpp | 39 +++ ryzom/client/src/actions.cpp | 41 ++- ryzom/client/src/actions.h | 4 +- ryzom/client/src/bg_downloader_access.cpp | 25 +- ryzom/client/src/bg_downloader_access.h | 16 +- ryzom/client/src/candidate.h | 3 +- ryzom/client/src/client_cfg.cpp | 2 +- ryzom/client/src/client_chat_manager.cpp | 10 +- ryzom/client/src/client_chat_manager.h | 14 +- ryzom/client/src/commands.cpp | 60 ++--- ryzom/client/src/commands.h | 2 +- ryzom/client/src/connection.cpp | 123 +++++---- ryzom/client/src/connection.h | 8 +- ryzom/client/src/continent.cpp | 2 + ryzom/client/src/continent_manager_build.h | 2 +- ryzom/client/src/entities.cpp | 2 +- ryzom/client/src/far_tp.cpp | 6 + ryzom/client/src/init.cpp | 20 +- .../src/interface_v3/action_handler_game.cpp | 5 +- .../src/interface_v3/action_handler_help.cpp | 249 +++++++++--------- ryzom/client/src/interface_v3/chat_window.cpp | 35 +-- .../client/src/interface_v3/dbctrl_sheet.cpp | 20 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 4 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 6 +- .../interface_v3/group_in_scene_bubble.cpp | 2 + .../src/interface_v3/group_modal_get_key.cpp | 4 +- .../src/interface_v3/interface_manager.cpp | 2 + .../interface_v3/item_consumable_effect.cpp | 20 +- .../src/interface_v3/item_consumable_effect.h | 2 +- .../src/interface_v3/item_special_effect.cpp | 8 +- .../src/interface_v3/item_special_effect.h | 4 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 6 + ryzom/client/src/interface_v3/lua_ihm_ryzom.h | 4 +- .../client/src/interface_v3/macrocmd_key.cpp | 16 +- .../src/interface_v3/macrocmd_manager.cpp | 15 +- .../client/src/interface_v3/music_player.cpp | 4 +- .../src/interface_v3/people_interraction.cpp | 28 +- .../src/interface_v3/people_interraction.h | 2 +- ryzom/client/src/interface_v3/people_list.cpp | 14 +- ryzom/client/src/interface_v3/people_list.h | 4 +- .../src/interface_v3/req_skill_formula.cpp | 4 +- .../src/interface_v3/req_skill_formula.h | 2 +- .../src/interface_v3/sphrase_manager.cpp | 50 ++-- .../client/src/interface_v3/sphrase_manager.h | 12 +- ryzom/client/src/login.cpp | 22 +- ryzom/client/src/main_loop.cpp | 4 + ryzom/client/src/net_manager.cpp | 20 +- ryzom/client/src/progress.cpp | 13 +- ryzom/client/src/progress.h | 10 +- ryzom/client/src/release.cpp | 4 + .../common/src/game_share/character_summary.h | 2 +- ryzom/common/src/game_share/item_infos.h | 6 +- .../common/src/game_share/mainland_summary.h | 4 +- .../common/src/game_share/msg_client_server.h | 2 +- ryzom/common/src/game_share/sphrase_com.h | 2 +- 56 files changed, 550 insertions(+), 446 deletions(-) diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h index 0aac8d2c3..572d39ac4 100644 --- a/nel/include/nel/misc/utf_string_view.h +++ b/nel/include/nel/misc/utf_string_view.h @@ -23,6 +23,8 @@ namespace NLMISC { +class IStream; + /// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints. /// This string view keeps the string as a reference, it does not make a copy. /// Only use this for iterating a string's codepoints. @@ -141,6 +143,10 @@ public: static void append(std::string &str, u32char c); + /// Encode or decode a single UTF-8 character in a stream (also useful for packing unsigned 20-bit integers) + static void append(IStream &s, u32char c); + static u32char get(IStream &s); + private: typedef u32char (*TIterator)(const void **addr); static u32char utf8Iterator(const void **addr); diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp index 17dbaea58..64f2f8e55 100644 --- a/nel/src/misc/utf_string_view.cpp +++ b/nel/src/misc/utf_string_view.cpp @@ -18,6 +18,7 @@ // Project includes #include +#include // References: // - https://twiserandom.com/unicode/unicode-encoding-utf-8-utf-16-utf-32/ @@ -69,6 +70,44 @@ void CUtfStringView::append(std::string &str, u32char c) appendUtf8(str, c); } +void CUtfStringView::append(IStream &s, u32char c) +{ + nlassert(!s.isReading()); + std::string tmp; + tmp.reserve(4); + append(tmp, c); + s.serialBuffer((uint8_t *)&tmp[0], tmp.size()); +} + +u32char CUtfStringView::get(IStream &s) +{ + nlassert(s.isReading()); + + std::string tmp; + tmp.reserve(4); + uint8_t c; + s.serial(c); + + // Single byte + if (c < 0x80) + return c; + + // Do a fast check of length + tmp += (char)c; + size_t len; + if ((c & 0xF0) == 0xF0) len = 4; + if ((c & 0xE0) == 0xE0) len = 3; + else len = 2; + + // Read from stream + tmp.resize(len); + s.serialBuffer((uint8_t *)&tmp[1], len - 1); + + // Decode + const void *str = tmp.c_str(); + return utf8Iterator(&str); +} + std::string CUtfStringView::toUtf8(bool reEncode) const { // Decode UTF and encode UTF-8 diff --git a/ryzom/client/src/actions.cpp b/ryzom/client/src/actions.cpp index 67695a9d6..604343afd 100644 --- a/ryzom/client/src/actions.cpp +++ b/ryzom/client/src/actions.cpp @@ -42,7 +42,7 @@ extern CEventsListener EventsListener; // Hierarchical timer H_AUTO_DECL ( RZ_Client_Actions_Context_Mngr_Update ) -static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, ucstring ¶mValue, const std::string &argu, uint paramId); +static bool getParam (CBaseAction::CParameter::TType type, string ¶mName, string ¶mValue, const std::string &argu, uint paramId); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// @@ -243,8 +243,8 @@ bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const const CBaseAction::CParameter ¶meter = baseAction->Parameters[i]; if (parameter.Type == CBaseAction::CParameter::Constant) { - ucstring paramName; - ucstring paramValue = parameter.DefaultValue; + string paramName; + string paramValue = parameter.DefaultValue; // Get the param from the argu getParam (parameter.Type, paramName, paramValue, name.Argu, i); @@ -252,7 +252,7 @@ bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const bool found = true; for (uint k = 0; k < parameter.Values.size(); ++k) { - if (parameter.Values[k].Value == paramValue.toUtf8()) + if (parameter.Values[k].Value == paramValue) { if (!ActionsContext.matchContext(parameter.Values[k].Contexts)) return false; found = true; @@ -631,7 +631,7 @@ CBaseAction::CParameter::CParameter () // *************************************************************************** -static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, ucstring ¶mValue, const std::string &argu, uint paramId) +static bool getParam (CBaseAction::CParameter::TType type, string ¶mName, string ¶mValue, const std::string &argu, uint paramId) { const string separator = "|"; const string equal_separator = "="; @@ -672,10 +672,7 @@ static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, } // Value ? - if(type==CBaseAction::CParameter::User || type==CBaseAction::CParameter::UserName) - paramValue.fromUtf8(argu.substr(pos, end-pos)); - else - paramValue = argu.substr(pos, end-pos); + paramValue = argu.substr(pos, end-pos); // Ok return true; @@ -683,10 +680,10 @@ static bool getParam (CBaseAction::CParameter::TType type, ucstring ¶mName, return false; } -ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const +string CBaseAction::getActionLocalizedText(const CAction::CName &name) const { // Action base name - ucstring temp = CI18N::get(LocalizedName); + string temp = CI18N::get(LocalizedName); // Get the parameter uint i; @@ -694,8 +691,8 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const { bool parameterOk = false; const CParameter ¶meter = Parameters[i]; - ucstring paramName; - ucstring paramValue; + string paramName; + string paramValue; // Get the param from the argu if (getParam (parameter.Type, paramName, paramValue, name.Argu, i)) @@ -703,7 +700,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const switch (parameter.Type) { case CParameter::Hidden: - if ((ucstring (parameter.DefaultValue) == paramValue) && (ucstring (parameter.Name) == paramName)) + if ((parameter.DefaultValue == paramValue) && (parameter.Name == paramName)) parameterOk = true; break; case CParameter::Constant: @@ -713,7 +710,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const { // This value ? const CParameter::CValue &value = parameter.Values[j]; - if (ucstring(value.Value) == paramValue) + if (value.Value == paramValue) { temp += " "; @@ -746,7 +743,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const if (i==Parameters.size ()) return temp; - return ucstring(""); + return string(); } // *************************************************************************** @@ -791,8 +788,8 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons { bool parameterOk = false; const CBaseAction::CParameter ¶meter = baseAction.Parameters[i]; - ucstring paramName; - ucstring paramValue; + string paramName; + string paramValue; // Get the param from the argu if (getParam (parameter.Type, paramName, paramValue, name.Argu, i)) @@ -800,7 +797,7 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons switch (parameter.Type) { case CBaseAction::CParameter::Hidden: - if ((ucstring (parameter.DefaultValue) == paramValue) && (ucstring (parameter.Name) == paramName)) + if ((parameter.DefaultValue == paramValue) && (parameter.Name == paramName)) parameterOk = true; break; case CBaseAction::CParameter::Constant: @@ -810,7 +807,7 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons for (j=0; jgetActionLocalizedText(name); } diff --git a/ryzom/client/src/actions.h b/ryzom/client/src/actions.h index f333782f5..df3d794c9 100644 --- a/ryzom/client/src/actions.h +++ b/ryzom/client/src/actions.h @@ -248,7 +248,7 @@ public: std::string Contexts; /// Get an action localized text - ucstring getActionLocalizedText (const CAction::CName &name) const; + std::string getActionLocalizedText (const CAction::CName &name) const; // see if there's at least one set of parameters for which this action is usable in current context bool isUsableInCurrentContext() const; @@ -415,7 +415,7 @@ public: const TActionsForceDisplaySet &getActionsForceDisplaySet() const {return _ActionForceDisplay;} /// Get an action localized text - ucstring getActionLocalizedText (const CAction::CName &name) const; + std::string getActionLocalizedText (const CAction::CName &name) const; //@} diff --git a/ryzom/client/src/bg_downloader_access.cpp b/ryzom/client/src/bg_downloader_access.cpp index e2500eaa6..338b86f9a 100644 --- a/ryzom/client/src/bg_downloader_access.cpp +++ b/ryzom/client/src/bg_downloader_access.cpp @@ -19,6 +19,9 @@ #include "stdpch.h" #include "bg_downloader_access.h" + +#ifdef RYZOM_BG_DOWNLOADER + #include "global.h" #include "login_patch.h" // @@ -84,7 +87,7 @@ CBGDownloaderAccess::CBGDownloaderAccess() //===================================================== void CBGDownloaderAccess::clearCurrentMessage() { - _CurrentMessage = ucstring(); + _CurrentMessage = ucstring(); // OLD _CurrentFilesToGet = 0; _TotalFilesToGet = 0; _PatchingSize = 0; @@ -194,7 +197,7 @@ void CBGDownloaderAccess::startTask(const BGDownloader::CTaskDesc &taskDesc, con } //===================================================== -bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const +bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const // OLD { if (_State == State_Finished) { @@ -354,7 +357,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() { shutdownDownloader(); Parent->_TaskResult = TaskResult_Error; - Parent->_ErrorMsg = ucstring(e.what()); + Parent->_ErrorMsg = ucstring(e.what()); // OLD Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError; } catch(const NLMISC::EStream &e) @@ -362,7 +365,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() shutdownDownloader(); Parent->_TaskResult = TaskResult_Error; nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Stream error"); - Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); + Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); // OLD Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError; } catch (const EWaitMessageTimeoutException &e) @@ -370,7 +373,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() shutdownDownloader(); Parent->_TaskResult = TaskResult_Error; nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Message timeout"); - Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); + Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); // OLD Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError; } Parent->_State = State_Finished; @@ -614,7 +617,7 @@ TDownloaderMode CBGDownloaderAccess::CDownloadCoTask::getDownloaderMode() void CBGDownloaderAccess::CDownloadCoTask::getTaskResult(TTaskResult &result, uint32 &availablePatchs, bool &mustLaunchBatFile, - ucstring &errorMsg + ucstring &errorMsg // OLD ) { sendSimpleMsg(CL_GetTaskResult); @@ -623,7 +626,7 @@ void CBGDownloaderAccess::CDownloadCoTask::getTaskResult(TTaskResult &result, inMsg.serialEnum(result); inMsg.serial(availablePatchs); inMsg.serial(mustLaunchBatFile); - inMsg.serial(errorMsg); + inMsg.serial(errorMsg); // OLD } //===================================================== @@ -687,7 +690,7 @@ void CBGDownloaderAccess::CDownloadCoTask::shutdownDownloader() } } CWinProcess::terminateProcessFromModuleName(BGDownloaderName); // for safety - Parent->_CurrentMessage = ucstring(); + Parent->_CurrentMessage = ucstring(); // OLD } //===================================================== @@ -795,7 +798,7 @@ bool CBGDownloaderAccess::CDownloadCoTask::defaultMessageHandling(BGDownloader:: case BGD_Error: { Parent->_TaskResult = TaskResult_Error; - ucstring errorMsg; + ucstring errorMsg; // OLD msg.serial(errorMsg); throw EDownloadException(errorMsg.toUtf8()); } @@ -885,7 +888,7 @@ void CBGDownloaderAccess::startTask(const BGDownloader::CTaskDesc &taskDesc, con } //===================================================== -bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const +bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const // OLD { // TODO for Linux return false; @@ -956,3 +959,5 @@ void unpauseBGDownloader() DownloaderPaused = false; } } + +#endif diff --git a/ryzom/client/src/bg_downloader_access.h b/ryzom/client/src/bg_downloader_access.h index e27cadb3e..5b4e7094b 100644 --- a/ryzom/client/src/bg_downloader_access.h +++ b/ryzom/client/src/bg_downloader_access.h @@ -14,11 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifdef RYZOM_BG_DOWNLOADER #ifndef CL_BG_DOWNLOADER_ACCESS #define CL_BG_DOWNLOADER_ACCESS #include "nel/misc/singleton.h" -#include "nel/misc/ucstring.h" +#include "nel/misc/ucstring.h" // OLD #include "nel/misc/inter_window_msg_queue.h" #include "nel/misc/co_task.h" // @@ -36,7 +37,7 @@ public: void release(); // jobs void startTask(const BGDownloader::CTaskDesc &taskDesc, const std::string &commandLine, bool showDownloader); - bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const; + bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const; // OLD // The following flag will be true after a 'patch' task has been completed successfully bool getPatchCompletionFlag(bool clearFlag); // @@ -50,7 +51,7 @@ public: // void update(); // call this at each frame to update the download process // Get last displayed message by the background downloader - const ucstring &getCurrentMessage() const { return _CurrentMessage; } + const ucstring &getCurrentMessage() const { return _CurrentMessage; } // OLD uint32 getCurrentFilesToGet() const { return _CurrentFilesToGet; } uint32 getTotalFilesToGet() const { return _TotalFilesToGet; } // @@ -66,17 +67,17 @@ public: bool isDownloaderUIFrozen() const { return _FrozenUI; } void requestDownloadThreadPriority(BGDownloader::TThreadPriority newPriority, bool freezeUI); - const ucstring &getLastErrorMessage() const { return _ErrorMsg; } + const ucstring &getLastErrorMessage() const { return _ErrorMsg; } // OLD private: enum TState { State_Idle, State_Patching, State_Finished }; TState _State; - ucstring _CurrentMessage; + ucstring _CurrentMessage; // OLD #ifdef NL_OS_WINDOWS NLMISC::CInterWindowMsgQueue _DownloaderMsgQueue; #endif - ucstring _ErrorMsg; + ucstring _ErrorMsg; // OLD std::string _CommandLine; BGDownloader::TTaskResult _TaskResult; uint32 _AvailablePatchs; @@ -122,7 +123,7 @@ private: void getTaskResult(BGDownloader::TTaskResult &result, uint32 &availablePatchs, bool &mustLaunchBatFile, - ucstring &errorMsg + ucstring &errorMsg // OLD ); void getDescFile(); BGDownloader::TDownloaderMode getDownloaderMode(); @@ -146,3 +147,4 @@ void unpauseBGDownloader(); #endif +#endif diff --git a/ryzom/client/src/candidate.h b/ryzom/client/src/candidate.h index 41d04e681..ee169f77d 100644 --- a/ryzom/client/src/candidate.h +++ b/ryzom/client/src/candidate.h @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// FIXME: Lost code #if 0 #ifndef CL_CANDIDATE_H @@ -33,7 +34,7 @@ struct Candidate NLMISC::CEntityId id; std::string name; std::string surname; - std::list program; + std::list program; uint32 nbVotes; }; diff --git a/ryzom/client/src/client_cfg.cpp b/ryzom/client/src/client_cfg.cpp index 41df9430f..95bc6306b 100644 --- a/ryzom/client/src/client_cfg.cpp +++ b/ryzom/client/src/client_cfg.cpp @@ -2026,7 +2026,7 @@ void CClientConfig::init(const string &configFileName) } // read the exising config file (don't parse it yet!) - ucstring content; + ucstring content; // UTF-16 and UTF-8 textfile support NLMISC::CI18N::readTextFile(configFileName, content); std::string contentUtf8 = content.toUtf8(); diff --git a/ryzom/client/src/client_chat_manager.cpp b/ryzom/client/src/client_chat_manager.cpp index ec8da3eb1..5515e8580 100644 --- a/ryzom/client/src/client_chat_manager.cpp +++ b/ryzom/client/src/client_chat_manager.cpp @@ -65,7 +65,7 @@ extern CEntityManager EntitiesMngr; //#ifdef OLD_STRING_SYSTEM // -//bool CNetworkString::getString (ucstring &result, CClientChatManager *mng) +//bool CNetworkString::getString (ucstring &result, CClientChatManager *mng) // OLD //{ // result = StaticString + " / "; // for (uint i = 0; i < Args.size(); i++) @@ -86,7 +86,7 @@ extern CEntityManager EntitiesMngr; // return mng->getString (result, Args, StaticString); //} // -//void CNetworkString::setString (const ucstring &staticStringId, CClientChatManager *mng) +//void CNetworkString::setString (const ucstring &staticStringId, CClientChatManager *mng) // OLD //{ // CBitMemStream bms; // mng->getStaticDB().getInfos(staticStringId, StaticString, bms); @@ -96,11 +96,11 @@ extern CEntityManager EntitiesMngr; //// add //// ////----------------------------------------------- -//uint32 CChatDynamicDatabase::add( uint32 index, ucstring& ucstr, vector& code ) +//uint32 CChatDynamicDatabase::add( uint32 index, ucstring& ucstr, vector& code ) // OLD //{ // nlinfo ("receive dynamic string association '%d' '%s'", index, ucstr.toString().c_str()); // -// map::iterator itIdx = _StringToIndex.find( ucstr ); +// map::iterator itIdx = _StringToIndex.find( ucstr ); // OLD // if( itIdx == _StringToIndex.end() ) // { // map::iterator itStr = _Data.find( index ); @@ -162,7 +162,7 @@ extern CEntityManager EntitiesMngr; //// decodeString //// ////----------------------------------------------- -//void CChatDynamicDatabase::decodeString( ucstring& str, CBitMemStream& bms ) +//void CChatDynamicDatabase::decodeString( ucstring& str, CBitMemStream& bms ) // OLD //{ // _Huffman.getId( str, bms ); // diff --git a/ryzom/client/src/client_chat_manager.h b/ryzom/client/src/client_chat_manager.h index 19afcab15..014481c0f 100644 --- a/ryzom/client/src/client_chat_manager.h +++ b/ryzom/client/src/client_chat_manager.h @@ -54,7 +54,7 @@ class CCDBNodeLeaf; struct CDynamicStringInfos { /// string - ucstring Str; + ucstring Str; // OLD /// index in the infos buffer, same as the index in the client dynamic string known buffer uint32 Index; @@ -89,12 +89,12 @@ public : /// \param str the string /// \param huffCode the Huffman code(may be empty) /// \return the index of the string - uint32 add( uint32 index, ucstring& str, std::vector& huffCode ); + uint32 add( uint32 index, ucstring& str, std::vector& huffCode ); // OLD /// Get the string from its Huffman code /// \param str will be filled with the string /// \param bms contains the Huffman code - void decodeString( ucstring& str, NLMISC::CBitMemStream& bms ); + void decodeString( ucstring& str, NLMISC::CBitMemStream& bms ); // OLD /// Get infos on the dynamic string CDynamicStringInfos * getDynamicStringInfos( uint32 index ); @@ -111,7 +111,7 @@ private : std::map< uint32, CDynamicStringInfos *> _Data; /// Map to find index from the string (only for uncoded strings) - std::map< ucstring, uint32> _StringToIndex; + std::map< ucstring, uint32> _StringToIndex; // OLD }; #endif @@ -372,13 +372,13 @@ private : #ifdef OLD_STRING_SYSTEM class CNetworkString { - ucstring StaticString; + ucstring StaticString; // OLD public: std::vector Args; - bool getString (ucstring &result, CClientChatManager *mng); + bool getString (ucstring &result, CClientChatManager *mng); // OLD - void setString (const ucstring &staticStringId, CClientChatManager *mng); + void setString (const ucstring &staticStringId, CClientChatManager *mng); // OLD }; #endif diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index d756c938c..ea14537be 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -241,7 +241,7 @@ NLMISC_COMMAND(equipGroup, "equip group ", "name") if(CItemGroupManager::getInstance()->equipGroup(args[0])) { string msg = CI18N::get("cmdEquipGroupSuccess"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); @@ -250,7 +250,7 @@ NLMISC_COMMAND(equipGroup, "equip group ", "name") else { string msg = CI18N::get("cmdEquipGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); @@ -273,7 +273,7 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1]))) { string msg = CI18N::get("cmdMoveGroupSuccess"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); @@ -283,7 +283,7 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") else { string msg = CI18N::get("cmdMoveGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); @@ -313,7 +313,7 @@ NLMISC_COMMAND(createGroup, "create group [true](create a for ev msg = CI18N::get("cmdCreateGroupSuccess2"); else msg = CI18N::get("cmdCreateGroupSuccess1"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); @@ -322,7 +322,7 @@ NLMISC_COMMAND(createGroup, "create group [true](create a for ev else { string msg = CI18N::get("cmdCreateGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); @@ -345,7 +345,7 @@ NLMISC_COMMAND(deleteGroup, "delete group ", "name") if(CItemGroupManager::getInstance()->deleteGroup(args[0])) { string msg = CI18N::get("cmdDeleteGroupSuccess"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); @@ -354,7 +354,7 @@ NLMISC_COMMAND(deleteGroup, "delete group ", "name") else { string msg = CI18N::get("cmdDeleteGroupError"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); @@ -1672,10 +1672,10 @@ NLMISC_COMMAND(missionProgress, "debug"," ") NLMISC_COMMAND( displayDBModifs, "display server database modification in the chat window"," ") { if ( VerboseDatabase ) - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already in verbose mode"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("the database is already in verbose mode",CRGBA(255,255,255,255)); else { - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is now in verbose mode"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("database is now in verbose mode",CRGBA(255,255,255,255)); VerboseDatabase = true; } return true; @@ -1684,10 +1684,10 @@ NLMISC_COMMAND( displayDBModifs, "display server database modification in the ch NLMISC_COMMAND( hideDBModifs, "stop displaying server database modification in the chat window"," ") { if ( !VerboseDatabase ) - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already not in verbose mode"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("the database is already not in verbose mode",CRGBA(255,255,255,255)); else { - CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is not in verbose mode anymore"),CRGBA(255,255,255,255)); + CInterfaceManager::getInstance()->getChatOutput()->addTextChild("database is not in verbose mode anymore",CRGBA(255,255,255,255)); VerboseDatabase = false; } return true; @@ -2297,7 +2297,7 @@ NLMISC_COMMAND(record, "Start Recording", "") // Warning when already recording. if(NetMngr.isRecording()) { - IM->displaySystemInfo(ucstring("Already Recording. Stop the current Record first")); + IM->displaySystemInfo("Already Recording. Stop the current Record first"); return true; } @@ -2641,12 +2641,12 @@ NLMISC_COMMAND(magic, "Cast a spell", "\n" if(args.size() != 6) { // Help -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); +// CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 or 3 paramters :"); +// CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); +// CInterfaceManager::getInstance()->displaySystemInfo(" : the behaviour to play for the entity, one of the following number :"); // for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); -// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); +// CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i))); +// CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END)); } else { @@ -2695,7 +2695,7 @@ NLMISC_COMMAND(magic, "Cast a spell", "\n" entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); } else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -2714,12 +2714,12 @@ NLMISC_COMMAND(spell, "Cast a spell", "\n" if(args.size() != 6) { // Help - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); + // CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 or 3 paramters :"); + // CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); + // CInterfaceManager::getInstance()->displaySystemInfo(" : the behaviour to play for the entity, one of the following number :"); // for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); - // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); + // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i))); + // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END)); } else { @@ -5314,8 +5314,8 @@ void CUserCommand::release() // *************************************************************************** -CUserCommand::CUserCommand(const string &commandName, const ucstring &help, const ucstring &argsHelp) - : ICommand("user", commandName.c_str(), toString(help).c_str(), toString(argsHelp).c_str()) +CUserCommand::CUserCommand(const string &commandName, const string &help, const string &argsHelp) + : ICommand("user", commandName.c_str(), help.c_str(), argsHelp.c_str()) { CommandName = commandName; } @@ -5369,7 +5369,7 @@ bool CUserCommand::execute(const std::string &/* rawCommandString */, const std: else { if (keywords[i] == "$") - finalArgs += /*ucstring(*/args[index++]/*).toUtf8()*/; + finalArgs += args[index++]; else { while (indexLocalizedName); // Build a argument help - ucstring argsHelp; + string argsHelp; if (ab) { @@ -5477,7 +5477,7 @@ void CUserCommand::createCommand (const char *name, const char *action, const ch // Add the string if (!argsHelp.empty()) argsHelp += " "; - argsHelp += ucstring("<") + CI18N::get(ab->Parameters[j].LocalizedName) + ucstring(">"); + argsHelp += "<" + CI18N::get(ab->Parameters[j].LocalizedName) + ">"; bFound = true; } } diff --git a/ryzom/client/src/commands.h b/ryzom/client/src/commands.h index 8a0b8764a..2d724f289 100644 --- a/ryzom/client/src/commands.h +++ b/ryzom/client/src/commands.h @@ -43,7 +43,7 @@ public: std::vector Keywords; }; - CUserCommand (const std::string &commandName, const ucstring &help, const ucstring &argsHelp); + CUserCommand (const std::string &commandName, const std::string &help, const std::string &argsHelp); void addMode (const std::string &action, uint numArg, bool infiniteAgr, const std::vector &keywords); diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 2885ee1ac..63b8a6dd8 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -149,8 +149,8 @@ std::string PlayerSelectedHomeShardName; std::string PlayerSelectedHomeShardNameWithParenthesis; extern std::string CurrentCookie; -ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created -ucstring NewKeysCharNameValidated; +std::string NewKeysCharNameWanted; // name of the character for which a new keyset must be created +std::string NewKeysCharNameValidated; std::string GameKeySet = "keys.xml"; std::string RingEditorKeySet = "keys_r2ed.xml"; @@ -520,7 +520,9 @@ bool connection (const string &cookie, const string &fsaddr) if (InterfaceState == GOGOGO_IN_THE_GAME) { // set background downloader to 'paused' to ease loading of client +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif return true; } @@ -659,7 +661,9 @@ bool reconnection() if (InterfaceState == GOGOGO_IN_THE_GAME) { +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif return true; } if (InterfaceState == QUIT_THE_GAME) @@ -779,12 +783,12 @@ void globalMenuMovieShooter() // ------------------------------------------------------------------------------------------------ // Build a valid PlayerName for file Save selection. -std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn) +std::string buildPlayerNameForSaveFile(const std::string &playerNameIn) { // remove any shard name appended - ucstring playerName = playerNameIn; - ucstring::size_type pos = playerNameIn.find('('); - if(pos!=ucstring::npos && pos>0) + string playerName = playerNameIn; + string::size_type pos = playerNameIn.find('('); + if(pos!=string::npos && pos>0) { playerName.resize(pos); } @@ -809,9 +813,9 @@ std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn) } +#ifdef RYZOM_BG_DOWNLOADER static bool LuaBGDSuccessFlag = true; // tmp, for debug - void updateBGDownloaderUI() { CInterfaceManager *im = CInterfaceManager::getInstance(); @@ -909,11 +913,12 @@ void updateBGDownloaderUI() nlwarning("Some scipt error occurred"); } } - +#endif // compute patcher priority, depending on the presence of one or more mainland characters : in this case, give the patch a boost void updatePatcherPriorityBasedOnCharacters() { +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { if (CBGDownloaderAccess::getInstance().getDownloadThreadPriority() != BGDownloader::ThreadPriority_Paused) @@ -932,6 +937,7 @@ void updatePatcherPriorityBasedOnCharacters() CBGDownloaderAccess::getInstance().requestDownloadThreadPriority(hasMainlandChar ? BGDownloader::ThreadPriority_Normal : BGDownloader::ThreadPriority_Low, false); } } +#endif } // Launch the interface to choose a character @@ -940,6 +946,7 @@ TInterfaceState globalMenu() { CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_CharacterSelection, "login_step_character_selection")); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); if (isBGDownloadEnabled()) @@ -950,14 +957,14 @@ TInterfaceState globalMenu() // if a task is already started, then this was a situation where player went back from game to the character selection, // so just unpause BGDownloader::TTaskResult dummyResult; - ucstring dummyMessage; + ucstring dummyMessage; // OLD if (!bgDownloader.isTaskEnded(dummyResult, dummyMessage)) { unpauseBGDownloader(); } } } - +#endif CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -1003,8 +1010,9 @@ TInterfaceState globalMenu() } #endif +#ifdef RYZOM_BG_DOWNLOADER updateBGDownloaderUI(); - +#endif // Update network. try @@ -1087,7 +1095,7 @@ TInterfaceState globalMenu() { if (noUserChar || userChar) { - +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { // If there's a need for mainland download, then proceed @@ -1096,7 +1104,7 @@ TInterfaceState globalMenu() // if a task is already started, then this was a situation where player went back from game to the character selection, // so just unpause BGDownloader::TTaskResult dummyResult; - ucstring dummyMessage; + ucstring dummyMessage; // OLD if (bgDownloader.isTaskEnded(dummyResult, dummyMessage)) { // launch mainland patch as a background task @@ -1111,6 +1119,7 @@ TInterfaceState globalMenu() } } } +#endif //nlinfo("impulseCallBack : received userChars list"); noUserChar = userChar = false; @@ -1260,8 +1269,8 @@ TInterfaceState globalMenu() LoginSM.pushEvent(CLoginStateMachine::ev_global_menu_exited); // Init the current Player Name (for interface.cfg and sentence.name save). Make a good File Name. - ucstring &playerName= CharacterSummaries[PlayerSelectedSlot].Name; - PlayerSelectedFileName= buildPlayerNameForSaveFile(playerName); + string playerName = CharacterSummaries[PlayerSelectedSlot].Name.toUtf8(); + PlayerSelectedFileName = buildPlayerNameForSaveFile(playerName); // Init the current Player Home shard Id and name CharacterHomeSessionId = CharacterSummaries[PlayerSelectedSlot].Mainland; @@ -1337,7 +1346,7 @@ public: REGISTER_ACTION_HANDLER (CAHNetInitCharSel, "net_init_char_sel"); // ------------------------------------------------------------------------------------------------ -void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) +void setTarget(CCtrlBase *ctrl, const string &targetName, std::string &value) { std::vector targets; // find first enclosing group @@ -1352,7 +1361,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) if (ig) { CInterfaceExprValue exprValue; - exprValue.setString(value.toUtf8()); + exprValue.setString(value); CInterfaceLink::splitLinkTargets(targetName, ig, targets); for(uint k = 0; k < targets.size(); ++k) @@ -1410,12 +1419,12 @@ public: if (CharacterSummaries[PlayerSelectedSlot].Name.empty()) return; - ucstring sValue(""); + string sValue; uint32 nValue = 0; if (sProp == "name") { - sValue = CharacterSummaries[PlayerSelectedSlot].Name; + sValue = CharacterSummaries[PlayerSelectedSlot].Name.toUtf8(); setTarget (pCaller, sTarget, sValue); } /* else if (sProp == "surname") @@ -1440,10 +1449,10 @@ Deprecated { sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(titleStr, womanTitle); { // Sometimes translation contains another title - ucstring::size_type pos = sValue.find('$'); - if (pos != ucstring::npos) + string::size_type pos = sValue.find('$'); + if (pos != string::npos) { - sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue.toUtf8()), womanTitle); + sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle); } } setTarget (pCaller, sTarget, sValue); @@ -1684,11 +1693,11 @@ public: // Setup the name string sEditBoxPath = getParam (Params, "name"); - ucstring sFirstName = ucstring("NotSet"); - ucstring sSurName = ucstring("NotSet"); + string sFirstName = "NotSet"; + string sSurName = "NotSet"; CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath)); if (pGEB != NULL) - sFirstName = pGEB->getInputStringAsUtf16(); + sFirstName = pGEB->getInputString(); else nlwarning ("can't get edit box name : %s",sEditBoxPath.c_str()); @@ -1803,8 +1812,8 @@ public: out.serial (nSelectedSlot); // Yoyo: delete the Local files. To avoid problem if recreate a character with same name. - ucstring &playerName= CharacterSummaries[nSelectedSlot].Name; - string playerDeletedFileName= buildPlayerNameForSaveFile(playerName); + string playerName = CharacterSummaries[nSelectedSlot].Name.toUtf8(); + string playerDeletedFileName = buildPlayerNameForSaveFile(playerName); // Delete the 2 Local files pIM->deletePlayerConfig(playerDeletedFileName); pIM->deletePlayerKeys(playerDeletedFileName); @@ -1855,7 +1864,7 @@ string getTarget(CCtrlBase * /* ctrl */, const string &targetName) } // ------------------------------------------------------------------------------------------------ -ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName) +ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName) // TODO: UTF-8 Lua { string sTmp = targetName; std::vector targetsVector; @@ -1867,13 +1876,13 @@ ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName) if (!elem) { nlwarning(" : Element is NULL"); - return ucstring(""); + return ucstring(""); // TODO: UTF-8 Lua } const CReflectedProperty *pRP = elem->getReflectedProperty(rTI.PropertyName); if (pRP->Type == CReflectedProperty::UCString) return ((elem->*(pRP->GetMethod.GetUCString))()); - return ucstring(""); + return ucstring(""); // TODO: UTF-8 Lua } /*// Ask the server to rename a character @@ -1946,7 +1955,7 @@ public: string sDBLink = getParam(Params, "dblink"); CharNameValidDBLink = sDBLink; - ucstring sName = getUCTarget(NULL,sTarget); + string sName = getUCTarget(NULL,sTarget).toUtf8(); // TODO: UTF-8 Lua CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (sName.empty()) @@ -1988,13 +1997,13 @@ public: if (Mainlands[k].Id == MainlandSelected) { // extract name from mainland - /*ucstring::size_type first = Mainlands[k].Name.find('('); - ucstring::size_type last = Mainlands[k].Name.find(')'); - if (first != ucstring::npos && last != ucstring::npos && first < last) + /*ucstring::size_type first = Mainlands[k].Name.find('('); // OLD + ucstring::size_type last = Mainlands[k].Name.find(')');// OLD + if (first != ucstring::npos && last != ucstring::npos && first < last)// OLD { NewKeysCharNameWanted += Mainlands[k].Name.substr(first, last - first + 1); }*/ - NewKeysCharNameWanted += ('(' + Mainlands[k].Name + ')'); + NewKeysCharNameWanted += ('(' + Mainlands[k].Name.toUtf8() + ')'); break; } } @@ -2017,7 +2026,7 @@ public: for (uint i = 0; i < CharacterSummaries.size(); ++i) { - ucstring ls = CharacterSummaries[i].Name.toString(); + string ls = CharacterSummaries[i].Name.toString(); if (ls == sName) CharNameValid = false; } @@ -2304,7 +2313,7 @@ public: } // add a new keyset in the list - void addKeySet(const std::string &filename, const ucstring &name, const ucstring tooltip) + void addKeySet(const std::string &filename, const std::string &name, const std::string tooltip) { nlassert(List); CInterfaceGroup *pNewLine = buildTemplate("t_keyset", toString(filename)); @@ -2313,13 +2322,13 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - pVT->setTextLocalized(name.toUtf8(), false); + pVT->setTextLocalized(name, false); } CCtrlBase *pBut = pNewLine->getCtrl("but"); if (pBut != NULL) { - pBut->setDefaultContextHelp(tooltip.toUtf8()); + pBut->setDefaultContextHelp(tooltip); } addGroupInList(pNewLine); } @@ -2355,12 +2364,12 @@ public: std::string strId = "uiCP_KeysetName_" + keySetVar->asString(k); strFindReplace(strId, ".", "_"); - ucstring keySetName = CI18N::get(strId); + const string &keySetName = CI18N::get(strId); strId = "uiCP_KeysetTooltip_" + keySetVar->asString(k); strFindReplace(strId, ".", "_"); if (CI18N::hasTranslation(strId)) { - ucstring keySetTooltip = CI18N::get(strId); + const string &keySetTooltip = CI18N::get(strId); addKeySet(keySetVar->asString(k), keySetName, keySetTooltip); } } @@ -2369,8 +2378,8 @@ public: { nlwarning("'%s' var not found in config file, or list is empty, proposing default keyset only", KeySetVarName); std::string defaultKeySet = "keys"; - ucstring keySetName = CI18N::get("uiCP_KeysetName_" + defaultKeySet); - ucstring keySetTooltip = CI18N::get("uiCP_KeysetTooltip_" + defaultKeySet); + const string &keySetName = CI18N::get("uiCP_KeysetName_" + defaultKeySet); + const string &keySetTooltip = CI18N::get("uiCP_KeysetTooltip_" + defaultKeySet); addKeySet(defaultKeySet, keySetName, keySetTooltip); } @@ -2396,19 +2405,19 @@ public: { for(TKeySetFileMap::iterator it = keySetFiles.begin(); it != keySetFiles.end(); ++it) { - ucstring name; + string name; if (ClientCfg.Local) { - name = ucstring(it->first); + name = it->first; } else { - // search matching ucstring name from character summaries + // search matching utf-8 string name from character summaries for (uint k = 0; k < CharacterSummaries.size(); ++k) { - if (it->first == buildPlayerNameForSaveFile(CharacterSummaries[k].Name)) + if (it->first == buildPlayerNameForSaveFile(CharacterSummaries[k].Name.toUtf8())) { - name = CharacterSummaries[k].Name; + name = CharacterSummaries[k].Name.toUtf8(); } } } @@ -2419,7 +2428,7 @@ public: addSeparator(); separatorAdded = true; } - addKeySet(it->first, ucstring(it->first), CI18N::get(std::string("uiCP_KeysetImport") + (it->second & GameKeys ? "_Game" : "") + addKeySet(it->first, it->first, CI18N::get(std::string("uiCP_KeysetImport") + (it->second & GameKeys ? "_Game" : "") + (it->second & EditorKeys ? "_Editor" : ""))); } } @@ -2554,26 +2563,24 @@ REGISTER_ACTION_HANDLER (CAHResetKeysetSelect, "keyset_select"); // *************************** SCENARIO CONTROL WINDOW *********************** // *************************************************************************** // helper function for "setScenarioInformation" -static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const ucstring &text) +static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const std::string &text) { CInterfaceElement *result = scenarioWnd->findFromShortId(uiName); if(result) { CViewText* viewText = dynamic_cast(result); if(viewText) - viewText->setTextLocalized(text.toUtf8(), false); + viewText->setTextLocalized(text, false); CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - editBox->setInputStringAsUtf16(text); + editBox->setInputString(text); } } // helper function for "setScenarioInformation" -static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const std::string &utf8Text) +static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const ucstring &text) // TODO: UTF-8 Lua { - ucstring ucText; - ucText.fromUtf8(utf8Text); - setTextField(scenarioWnd, uiName, ucText); + setTextField(scenarioWnd, uiName, text.toUtf8()); } // helper function for "setScenarioInformation" static std::string fieldLookup(const vector< pair< string, string > > &values, const std::string &id) @@ -3455,7 +3462,7 @@ class CAHInitImportCharacter : public IActionHandler CPath::getPathContent("save/", false, false, true, savedCharacters); CInterfaceGroup *newLine; - CInterfaceGroup *prevLine; + CInterfaceGroup *prevLine = NULL; for (uint i = 0; i < savedCharacters.size(); ++i) { @@ -3644,7 +3651,7 @@ class CAHExportCharacter : public IActionHandler return; // extract name - const std::string name = buildPlayerNameForSaveFile(CS.Name.toString()); + const std::string name = buildPlayerNameForSaveFile(CS.Name.toUtf8()); COFile fd; bool success = false; diff --git a/ryzom/client/src/connection.h b/ryzom/client/src/connection.h index bb6f4cd24..7c81b0c80 100644 --- a/ryzom/client/src/connection.h +++ b/ryzom/client/src/connection.h @@ -36,8 +36,8 @@ extern std::vector CharacterSummaries; extern std::string UserPrivileges; extern sint LoginCharsel; -extern ucstring NewKeysCharNameWanted; -extern ucstring NewKeysCharNameValidated; +extern std::string NewKeysCharNameWanted; +extern std::string NewKeysCharNameValidated; extern std::string GameKeySet; extern std::string RingEditorKeySet; @@ -71,12 +71,14 @@ enum TInterfaceState TInterfaceState autoLogin (const std::string &cookie, const std::string &fsaddr, bool firstConnection); -std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn); +std::string buildPlayerNameForSaveFile(const std::string &playerNameIn); void globalMenuMovieShooter(); +#ifdef RYZOM_BG_DOWNLOADER void updateBGDownloaderUI(); +#endif // compute patcher priority, depending on the presence of one or more mainland characters : in this case, give the patch a boost void updatePatcherPriorityBasedOnCharacters(); diff --git a/ryzom/client/src/continent.cpp b/ryzom/client/src/continent.cpp index 3a7dff52d..07fd6155a 100644 --- a/ryzom/client/src/continent.cpp +++ b/ryzom/client/src/continent.cpp @@ -413,7 +413,9 @@ static uint16 getZoneIdFromName(const string &zoneName) //----------------------------------------------- void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress, bool complete, bool unhibernate, EGSPD::CSeason::TSeason season) { +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif CNiceInputAuto niceInputs; // Season has changed ? Season = season; diff --git a/ryzom/client/src/continent_manager_build.h b/ryzom/client/src/continent_manager_build.h index 52719f9ad..b8d7a7e82 100644 --- a/ryzom/client/src/continent_manager_build.h +++ b/ryzom/client/src/continent_manager_build.h @@ -43,7 +43,7 @@ public: TContLMType Type; NLMISC::CVector2f Pos; // Center of the zone NLLIGO::CPrimZone Zone; // Region & Place - std::string TitleTextID; // should be converted with CStringManagerClient::getPlaceLocalizedName() to get the actual title in ucstring + std::string TitleTextID; // should be converted with CStringManagerClient::getPlaceLocalizedName() to get the actual title in utf-8 string CContLandMark() { diff --git a/ryzom/client/src/entities.cpp b/ryzom/client/src/entities.cpp index 80d64c35a..11c403403 100644 --- a/ryzom/client/src/entities.cpp +++ b/ryzom/client/src/entities.cpp @@ -246,7 +246,7 @@ public : } private: std::list _PendingMissionTitle; -// std::set _AlreadyReceived; +// std::set _AlreadyReceived; }; //----------------------------------------------- diff --git a/ryzom/client/src/far_tp.cpp b/ryzom/client/src/far_tp.cpp index fa3d9720d..7f98d8b82 100644 --- a/ryzom/client/src/far_tp.cpp +++ b/ryzom/client/src/far_tp.cpp @@ -422,11 +422,13 @@ void CLoginStateMachine::run() bool mustReboot = false; +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { mustReboot = CBGDownloaderAccess::getInstance().mustLaunchBatFile(); } else +#endif { mustReboot = CPatchManager::getInstance()->mustLaunchBatFile(); } @@ -470,11 +472,13 @@ void CLoginStateMachine::run() } initPatchCheck(); SM_BEGIN_EVENT_TABLE +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { SM_EVENT(ev_patch_needed, st_patch); // no choice for patch content when background downloader is used } else +#endif { SM_EVENT(ev_patch_needed, st_display_cat); } @@ -600,7 +604,9 @@ void CLoginStateMachine::run() break; case st_enter_far_tp_main_loop: // if bgdownloader is used, then pause it +#ifdef RYZOM_BG_DOWNLOADER pauseBGDownloader(); +#endif // Far TP part 1.2: let the main loop finish the current frame. diff --git a/ryzom/client/src/init.cpp b/ryzom/client/src/init.cpp index b9e701e92..dbaa9a5c8 100644 --- a/ryzom/client/src/init.cpp +++ b/ryzom/client/src/init.cpp @@ -341,9 +341,7 @@ void ExitClientError (const char *format, ...) CurrentErrorMessage = NLMISC::utf8ToWide(str); DialogBox(HInstance, MAKEINTRESOURCE(IDD_ERROR_HELP_MESSAGE_BOX), NULL, ExitClientErrorDialogProc); /* - ucstring ucstr; - ucstr.fromUtf8 (str); - MessageBoxW (NULL, (WCHAR *)ucstr.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR); + MessageBoxW (NULL, nlUtf8ToWide(str.c_str()), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR); */ #else fprintf (stderr, "%s\n", str); @@ -357,18 +355,18 @@ void ExitClientError (const char *format, ...) } // Use this function to return an information to the final user -void ClientInfo (const ucstring &message) +void ClientInfo (const std::string &message) { #ifdef NL_OS_WINDOWS - MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION); + MessageBoxW(NULL, nlUtf8ToWide(message.c_str()), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION); #endif } // Use this function to ask a question to the final user -bool ClientQuestion (const ucstring &message) +bool ClientQuestion (const std::string &message) { #ifdef NL_OS_WINDOWS - return MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO; + return MessageBoxW(NULL, nlUtf8ToWide(message.c_str()), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO; #else return false; #endif @@ -379,7 +377,7 @@ void selectTipsOfTheDay (uint /* tips */) /* todo tips of the day uncomment tips %= RZ_NUM_TIPS; TipsOfTheDayIndex = tips; - ucstring title = CI18N::get ("uiTipsTitle"); + string title = CI18N::get ("uiTipsTitle"); title += toString (tips+1); title += " : "; TipsOfTheDay = title+CI18N::get ("uiTips"+toString (tips));*/ @@ -541,7 +539,7 @@ void checkDriverVersion() { if (driverVersion < driversVersion[i]) { - ucstring message = CI18N::get ("uiUpdateDisplayDriversNotUpToDate") + "\n\n"; + string message = CI18N::get ("uiUpdateDisplayDriversNotUpToDate") + "\n\n"; // message += CI18N::get ("uiUpdateDisplayDriversVendor") + driversVendor[i] + "\n"; message += CI18N::get ("uiUpdateDisplayDriversCard") + deviceName + "\n"; message += CI18N::get ("uiUpdateDisplayDriversCurrent") + getVersionString (driverVersion) + "\n"; @@ -999,7 +997,7 @@ void prelogInit() FPU_CHECKER_ONCE // Set the data path for the localisation. - const ucstring nmsg("Loading I18N..."); + const string nmsg("Loading I18N..."); ProgressBar.newMessage ( nmsg ); FPU_CHECKER_ONCE @@ -1177,7 +1175,9 @@ void prelogInit() #ifdef NL_OS_WINDOWS +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().init(); +#endif if (SlashScreen) DestroyWindow (SlashScreen); diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index ee243a5a2..b43e8e19a 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -732,7 +732,7 @@ public: CEntityCL *entity = EntitiesMngr.entity(trader); if (entity) { - ucstring playerName = entity->getEntityName(); + string playerName = entity->getEntityName(); if (!playerName.empty()) { PeopleInterraction.askAddContact(playerName, &PeopleInterraction.FriendList); @@ -4023,7 +4023,6 @@ REGISTER_ACTION_HANDLER(CHandlerSelectProtectedSlot, "select_protected_slot"); // *************************************************************************** // Common code -//static void fillPlayerBarText(ucstring &str, const string &dbScore, const string &dbScoreMax, const string &ttFormat) static void fillPlayerBarText(std::string &str, const string &dbScore, SCORES::TScores score, const string &ttFormat) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -4567,7 +4566,7 @@ public: } else { - ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; + ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; // FIXME: UTF-8 (serial) } out.serialEnum(behavToSend); diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index e8c36809f..3ba05a570 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -89,14 +89,14 @@ using namespace STRING_MANAGER; // STATIC FUNCTIONS DECLARATIONS // /////////////////////////////////// static void setupCreatorName(CSheetHelpSetup &setup); -static void setHelpText(CSheetHelpSetup &setup, const ucstring &text); +static void setHelpText(CSheetHelpSetup &setup, const string &text); static void setHelpTextID(CSheetHelpSetup &setup, sint32 id); static void fillSabrinaPhraseListBrick(const CSPhraseCom &phrase, IListSheetBase *listBrick); static void setupListBrickHeader(CSheetHelpSetup &setup); static void hideListBrickHeader(CSheetHelpSetup &setup); static void setupHelpPage(CInterfaceGroup *window, const string &url); -static void setupHelpTitle(CInterfaceGroup *group, const ucstring &title); +static void setupHelpTitle(CInterfaceGroup *group, const string &title); static void setHelpCtrlSheet(CSheetHelpSetup &setup, uint32 sheetId); // Setup help for an item in a window (type is known) @@ -187,7 +187,7 @@ void CInterfaceHelp::initWindows() // add observers for the update of phrase help texts (depends of weight of equipped weapons) for (uint i = 0; i < MAX_HANDINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -210,7 +210,7 @@ void CInterfaceHelp::release() // add observers for the update of phrase help texts (depends of weight of equipped weapons) for (uint i = 0; i < MAX_HANDINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -565,7 +565,7 @@ void CInterfaceHelp::updateWindowSPhraseTexts() */ class CHandlerCloseHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceHelp::closeAll(); } @@ -578,7 +578,7 @@ REGISTER_ACTION_HANDLER( CHandlerCloseHelp, "close_help"); */ class CHandlerOpenItemHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (cs != NULL && cs->getSheetId()!=0 ) @@ -609,7 +609,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenItemHelp, "open_item_help"); */ class CHandlerOpenPactHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (cs != NULL && cs->getSheetId()!=0 ) @@ -633,7 +633,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenPactHelp, "open_pact_help"); */ class CHandlerOpenTitleHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { // display web profile if necessary if (getParam(sParams, "from") == "contact") @@ -656,10 +656,10 @@ class CHandlerOpenTitleHelp : public IActionHandler sint index = peopleList->getIndexFromContainerID(fatherGC->getId()); if (index == -1) return; - ucstring name = peopleList->getName(index); + string name = peopleList->getName(index); if ( ! name.empty()) { - CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)CEntityCL::Player)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name+"|ptype="+toString((int)CEntityCL::Player)); } return; } @@ -670,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler if (selection == NULL) return; //if(selection->isNPC()) { - std::string name = selection->getEntityName(); + 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); - std::string copyName = name; + string copyName = name; name = CEntityCL::removeTitleAndShardFromName(name); if (name.empty()) { @@ -689,7 +689,7 @@ class CHandlerOpenTitleHelp : public IActionHandler woman = pChar->getGender() == GSGENDER::female; // extract the replacement id - std::string strNewTitle = CEntityCL::getTitleFromName(copyName); + string strNewTitle = CEntityCL::getTitleFromName(copyName); // retrieve the translated string if (!strNewTitle.empty()) @@ -716,8 +716,8 @@ class CHandlerOpenTitleHelp : public IActionHandler // Get name and title // ------------------ - ucstring name; - ucstring title; + string name; + string title; bool reservedTitle = false; string sFrom = getParam(sParams, "from"); if (sFrom == "target") @@ -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.toUtf8()) + if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title) break; } @@ -764,21 +764,21 @@ class CHandlerOpenTitleHelp : public IActionHandler // Display all infos found // ----------------------- - ucstring titleText = CI18N::get("uihelpTitleFormat"); - strFindReplace(titleText, "%name", name.toString()); + string titleText = CI18N::get("uihelpTitleFormat"); + strFindReplace(titleText, "%name", name); // Display title - ucstring::size_type p1 = title.find('('); - if (p1 != ucstring::npos) + string::size_type p1 = title.find('('); + if (p1 != string::npos) { - ucstring::size_type p2 = title.find(')', p1+1); - if (p2 != ucstring::npos) + string::size_type p2 = title.find(')', p1+1); + if (p2 != string::npos) title = title.substr(p1+1, p2-p1-1); } strFindReplace(titleText, "%title", title); // Display all skills needed to obtain this title - ucstring sSkillsNeeded; + string sSkillsNeeded; if (!title.empty() && pTU == NULL) sSkillsNeeded = CI18N::get("uiTitleCantObtain"); @@ -822,7 +822,7 @@ class CHandlerOpenTitleHelp : public IActionHandler strFindReplace(titleText, "%skills", sSkillsNeeded); // Display all bricks needed to obtain this title - ucstring sBricksNeeded; + string sBricksNeeded; if (pTU != NULL) { sBricksNeeded = CI18N::get("uiTitleBrickHeader"); @@ -861,7 +861,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenTitleHelp, "open_title_help"); */ class CHandlerOpenSkillToTradeHelp : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (cs != NULL) @@ -884,7 +884,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenSkillToTradeHelp, "open_skill_to_trade_help */ class CHandlerOpenHelpAuto : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CDBCtrlSheet *cs = dynamic_cast(pCaller); if (!cs) @@ -914,7 +914,7 @@ REGISTER_ACTION_HANDLER( CHandlerOpenHelpAuto, "open_help_auto"); */ class CHandlerBrowse : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { string container = getParam (sParams, "name"); CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container); @@ -1052,7 +1052,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowse, "browse"); class CHandlerBrowseUndo : public IActionHandler { public: - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); @@ -1071,7 +1071,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseUndo, "browse_undo"); class CHandlerBrowseRedo : public IActionHandler { public: - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); @@ -1090,7 +1090,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseRedo, "browse_redo"); class CHandlerBrowseRefresh : public IActionHandler { public: - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); @@ -1108,7 +1108,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseRefresh, "browse_refresh"); // *************************************************************************** class CHandlerHTMLSubmitForm : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { string container = getParam (sParams, "name"); @@ -1153,9 +1153,9 @@ static void setupHelpPage(CInterfaceGroup *window, const string &url) } // *************************************************************************** -void setHelpText(CSheetHelpSetup &setup, const ucstring &text) +void setHelpText(CSheetHelpSetup &setup, const string &text) { - ucstring copyStr= text; + string copyStr= text; // remove trailing \n while(!copyStr.empty() && copyStr[copyStr.size()-1]=='\n') { @@ -1166,7 +1166,7 @@ void setHelpText(CSheetHelpSetup &setup, const ucstring &text) CViewText *viewText= dynamic_cast(setup.HelpWindow->getView(setup.ViewText)); if(viewText) { - viewText->setTextFormatTaged(copyStr.toUtf8()); + viewText->setTextFormatTaged(copyStr); } CInterfaceGroup *viewTextGroup = setup.HelpWindow->getGroup(setup.ScrollTextGroup); if (viewTextGroup) viewTextGroup->setActive(true); @@ -1203,12 +1203,12 @@ void setHelpTextID(CSheetHelpSetup &setup, sint32 id) } // *************************************************************************** -static void setupHelpTitle(CInterfaceGroup *group, const ucstring &title) +static void setupHelpTitle(CInterfaceGroup *group, const string &title) { CGroupContainer *pGC= dynamic_cast(group); if(!group) return; - pGC->setUCTitle(title); + pGC->setTitle(title); } // *************************************************************************** @@ -1237,10 +1237,10 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) setup.DestSheet->setActive(true); } - ucstring skillText; + string skillText; // Name in title - const ucstring title(CStringManagerClient::getSkillLocalizedName(skill)); + const char *title = CStringManagerClient::getSkillLocalizedName(skill); setupHelpTitle(setup.HelpWindow, title); // search all job that have minimum required level for that skill @@ -1249,7 +1249,7 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) // { // for (uint job = 0; job < 8; ++job) // { -// std::string dbPath = toString("CHARACTER_INFO:CAREER%d:JOB%d:JOB_CAP", (int) career, (int) job); +// string dbPath = toString("CHARACTER_INFO:CAREER%d:JOB%d:JOB_CAP", (int) career, (int) job); // uint level = (uint) NLGUI::CDBManager::getInstance()->getDbProp(dbPath)->getValue32(); // if (level != 0) // has the player this job ? // { @@ -1265,10 +1265,11 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) // } // setup skill desc if available. - const ucstring desc(CStringManagerClient::getSkillLocalizedDescription(skill)); - if( !desc.empty() ) + const char *desc = CStringManagerClient::getSkillLocalizedDescription(skill); + if (*desc) { - skillText+= "\n" + desc; + skillText += "\n"; + skillText += desc; } setHelpText(setup, skillText); @@ -1305,7 +1306,7 @@ static string toPercentageText(float val) } // *************************************************************************** -void getItemDefenseText(CDBCtrlSheet *item, ucstring &itemText) +void getItemDefenseText(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1322,7 +1323,7 @@ void getItemDefenseText(CDBCtrlSheet *item, ucstring &itemText) } -void getDamageText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText, bool displayAsMod) +void getDamageText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText, bool displayAsMod) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1347,7 +1348,7 @@ void getDamageText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText, } } -void getSpeedText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) +void getSpeedText(CDBCtrlSheet *item, string &itemText, bool displayAsMod) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1358,7 +1359,7 @@ void getSpeedText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) strFindReplace(itemText, "%speed", strMod + toReadableFloat(itemInfo.HitRate)); } -void getRangeText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) +void getRangeText(CDBCtrlSheet *item, string &itemText, bool displayAsMod) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1369,7 +1370,7 @@ void getRangeText(CDBCtrlSheet *item, ucstring &itemText, bool displayAsMod) strFindReplace(itemText, "%range", strMod + toReadableFloat(itemInfo.Range/1000.f)); } -void getHPAndSapLoadText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getHPAndSapLoadText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1386,7 +1387,7 @@ void getHPAndSapLoadText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &ite } -void getBuffText(CDBCtrlSheet *item, ucstring &itemText) +void getBuffText(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1394,7 +1395,7 @@ void getBuffText(CDBCtrlSheet *item, ucstring &itemText) const string valIds[]={"Hp", "Sap", "Sta", "Focus"}; sint32 vals[]= {itemInfo.HpBuff, itemInfo.SapBuff, itemInfo.StaBuff, itemInfo.FocusBuff}; uint numVals= sizeof(vals) / sizeof(vals[0]); - ucstring bufInfo; + string bufInfo; // For each buf, append a line if !=0 for(uint i=0;i0?"Bonus":"Malus") ); + string line= CI18N::get( "uihelpItem" + valIds[i] + (modifier>0?"Bonus":"Malus") ); strFindReplace(line, "%val", toString(modifier) ); bufInfo+= line; } @@ -1416,13 +1417,13 @@ void getBuffText(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%buffs", bufInfo); } -void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) +void getMagicProtection(CDBCtrlSheet *item, string &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); - ucstring mProtInfo; + string mProtInfo; // Header (always here, because at least max absorb) mProtInfo= CI18N::get("uihelpMagicProtectFormatHeader"); @@ -1433,7 +1434,7 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) if(itemInfo.MagicProtection[i] != PROTECTION_TYPE::None) { // Protection info - ucstring str= CI18N::get("uihelpMagicProtectFormat"); + string str= CI18N::get("uihelpMagicProtectFormat"); strFindReplace(str, "%t", CI18N::get("pt"+PROTECTION_TYPE::toString(itemInfo.MagicProtection[i])) ); strFindReplace(str, "%v", toString(itemInfo.MagicProtectionFactor[i]) ); mProtInfo+= str; @@ -1449,7 +1450,7 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) maxAbsorb= maxAbsorb*nodeFactor->getValue32()/100; // Add to text - ucstring str= CI18N::get("uihelpMagicProtectMaxAbsorbFormat"); + string str= CI18N::get("uihelpMagicProtectMaxAbsorbFormat"); strFindReplace(str, "%v", toString(maxAbsorb) ); mProtInfo+= str; } @@ -1458,12 +1459,12 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%magic_protection", mProtInfo); } -void getMagicResistance(CDBCtrlSheet *item, ucstring &itemText) +void getMagicResistance(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); - ucstring mResistInfo; + string mResistInfo; // Header (always here, because at least max absorb) mResistInfo= CI18N::get("uihelpMagicResistFormatHeader"); @@ -1481,7 +1482,7 @@ void getMagicResistance(CDBCtrlSheet *item, ucstring &itemText) if(resist[i] != 0) { // Resist info - ucstring str= CI18N::get("uihelpMagicResistFormat"); + string str= CI18N::get("uihelpMagicResistFormat"); strFindReplace(str, "%t", CI18N::get("rs"+RESISTANCE_TYPE::toString((RESISTANCE_TYPE::TResistanceType)i) )); strFindReplace(str, "%v", toReadableFloat(float(resist[i])/100) ); mResistInfo+= str; @@ -1492,7 +1493,7 @@ void getMagicResistance(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%magic_resistance", mResistInfo); } -void getActionMalus(CDBCtrlSheet *item, ucstring &itemText) +void getActionMalus(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1500,7 +1501,7 @@ void getActionMalus(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%actmalus", toPercentageText(itemInfo.WearEquipmentMalus) ); } -void getBulkText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getBulkText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { // Display direct value: because cannot know where this item will be drop!! (bag, mektoub etc...) float slotBulkTotal= max((sint32)1, item->getQuantity()) * pIS->Bulk; @@ -1513,7 +1514,7 @@ void getBulkText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) strFindReplace(itemText, "%bulk", toString("%.2f", slotBulkTotal) ); } -void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -1550,14 +1551,14 @@ void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) strFindReplace(itemText, "%weight", "???" ); } -void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) +void getMagicBonus(CDBCtrlSheet *item, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); nlctassert(CClientItemInfo::NumMagicFactorType==4); const string valIds[CClientItemInfo::NumMagicFactorType]={"OffElemental", "OffAffliction", "DefHeal", "DefAffliction"}; - ucstring mbInfo; + string mbInfo; // For each magic bonus, test first if equal sint32 allCastSpeedFactor= sint(itemInfo.CastingSpeedFactor[0]*100); @@ -1582,7 +1583,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) if(allCastSpeedFactor!=0 || allMagicPowerFactor!=0) { // else display "all" - ucstring line= CI18N::get( "uihelpItemMagicBonusAll"); + string line= CI18N::get( "uihelpItemMagicBonusAll"); strFindReplace(line, "%cs", toString("%+d", allCastSpeedFactor) ); strFindReplace(line, "%mp", toString("%+d", allMagicPowerFactor) ); mbInfo+= line; @@ -1597,7 +1598,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) sint32 mp= sint(itemInfo.MagicPowerFactor[i]*100); if(cs!=0 || mp!=0) { - ucstring line= CI18N::get( string("uihelpItemMagicBonus") + valIds[i] ); + string line= CI18N::get( string("uihelpItemMagicBonus") + valIds[i] ); strFindReplace(line, "%cs", toString("%+d", cs) ); strFindReplace(line, "%mp", toString("%+d", mp) ); mbInfo+= line; @@ -1609,7 +1610,7 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) if(!mbInfo.empty()) { // add spell level header - ucstring spellRuleFmt= CI18N::get("uihelpItemMagicBonusHeader"); + string spellRuleFmt= CI18N::get("uihelpItemMagicBonusHeader"); strFindReplace(spellRuleFmt, "%mglvl", toString(item->getQuality())); mbInfo= spellRuleFmt + mbInfo; } @@ -1618,11 +1619,11 @@ void getMagicBonus(CDBCtrlSheet *item, ucstring &itemText) strFindReplace(itemText, "%magic_bonus", mbInfo); } -void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); bool requiredNeeded= false; - ucstring fmt, fmtc; + string fmt, fmtc; // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); @@ -1655,7 +1656,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & fmt = CI18N::get("uihelpItemSkillReqNotMetFmt"); strFindReplace(fmt, "%d", toString((uint)itemInfo.RequiredSkillLevel)); - const ucstring skillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill)); + const char *skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill); strFindReplace(fmt, "%s", skillName); } else @@ -1686,7 +1687,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & fmt = CI18N::get("uihelpItemSkillReqNotMetFmt"); strFindReplace(fmt, "%d", toString((uint)itemInfo.RequiredSkillLevel2)); - const ucstring skillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill2)); + const char *skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill2); strFindReplace(fmt, "%s", skillName); } else @@ -1749,7 +1750,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & if(req) { // Build the req string - ucstring fmt; + string fmt; if(pIM->isItemCaracRequirementMet(caracType, (sint32)caracValue)) fmt= CI18N::get("uihelpItemCaracReqMetFmt"); else @@ -1784,7 +1785,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & if (skillReq) { // Build the req string - ucstring fmt; + string fmt; if (req) fmt = CI18N::get("uihelpItemCaracReqAnd"); @@ -1793,7 +1794,7 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & else fmt += CI18N::get("uihelpItemSkillReqNotMetFmt"); strFindReplace(fmt, "%d", toString((uint)itemInfo.MinRequiredSkillLevel)); - const ucstring skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill); + const char *skillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName(itemInfo.RequiredSkill); strFindReplace(fmt, "%s", skillName); strFindReplace(itemText, "%skillreq", fmt ); @@ -1805,12 +1806,12 @@ void getItemRequirementText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring & #endif } -void getSkillModVsType(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) +void getSkillModVsType(CDBCtrlSheet *item, const CItemSheet*pIS, string &itemText) { // retrieve the current itemInfo const CClientItemInfo &itemInfo= getInventory().getItemInfo(getInventory().getItemSlotId(item) ); - ucstring sMod; + string sMod; // check skill mod if(!itemInfo.TypeSkillMods.empty()) { @@ -1831,9 +1832,9 @@ void getSkillModVsType(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemT strFindReplace(itemText, "%skill_mod_vs_type", sMod); } -void getArmorBonus(CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) +void getArmorBonus(CDBCtrlSheet *item, string &itemText, const CItemSheet*pIS) { - ucstring armor_bonus(""); + string armor_bonus; sint32 level = 0; if (pIS->Armor.ArmorType == ARMORTYPE::HEAVY) @@ -1848,7 +1849,7 @@ void getArmorBonus(CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) } // *************************************************************************** -void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) +void getItemText (CDBCtrlSheet *item, string &itemText, const CItemSheet*pIS) { if ((item == NULL) || (pIS == NULL)) return; @@ -1894,24 +1895,24 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) CItemSpecialEffectHelper::getInstance()->getItemSpecialEffectText(pIS, itemText); // Description - const ucstring desc(CStringManagerClient::getItemLocalizedDescription(pIS->Id)); - if(!desc.empty()) + const char *desc = CStringManagerClient::getItemLocalizedDescription(pIS->Id); + if (*desc) { strFindReplace(itemText, "%desc", "@{FFF9}" + CI18N::get("uiMissionDesc") + "\n@{FFFF}" + desc + "\n" ); } else - strFindReplace(itemText, "%desc", ucstring() ); + strFindReplace(itemText, "%desc", string() ); // Custom text const CClientItemInfo &itemInfo = getInventory().getItemInfo(getInventory().getItemSlotId(item) ); if (!itemInfo.CustomText.empty()) { - strFindReplace(itemText, "%custom_text", "\n@{FFFF}" + itemInfo.CustomText + "\n"); - ucstring itemMFC = CI18N::get("uiItemTextMessageFromCrafter"); + strFindReplace(itemText, "%custom_text", "\n@{FFFF}" + itemInfo.CustomText.toUtf8() + "\n"); + string itemMFC = CI18N::get("uiItemTextMessageFromCrafter"); strFindReplace(itemText, "%mfc", itemMFC); } else - strFindReplace(itemText, "%custom_text", ucstring() ); + strFindReplace(itemText, "%custom_text", string() ); if ( pIS->Family == ITEMFAMILY::COSMETIC ) { @@ -1919,10 +1920,10 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) if ( UserEntity->getGender() != pIS->Cosmetic.Gender || UserEntity->people() != people ) strFindReplace(itemText, "%cansell", CI18N::get("uihelpItemCosmeticDontFit") ); else - strFindReplace(itemText, "%cansell", ucstring() ); + strFindReplace(itemText, "%cansell", string() ); } else if(pIS->DropOrSell ) - strFindReplace(itemText, "%cansell", ucstring() ); + strFindReplace(itemText, "%cansell", string() ); else strFindReplace(itemText, "%cansell", CI18N::get("uihelpItemCantSell") ); @@ -2012,8 +2013,8 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) // Craft some part? if(pIS->canBuildSomeItemPart()) { - ucstring fmt= CI18N::get("uihelpItemMPCraft"); - std::string ipList; + string fmt= CI18N::get("uihelpItemMPCraft"); + string ipList; pIS->getItemPartListAsText(ipList); strFindReplace(fmt, "%ip", ipList); strFindReplace(itemText, "%craft", fmt); @@ -2111,11 +2112,11 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) // *************************************************************************** -static void setupEnchantedItem(CSheetHelpSetup &setup, ucstring &itemText) +static void setupEnchantedItem(CSheetHelpSetup &setup, string &itemText) { // if don't find the tag in the text (eg: if not useful), no-op - static const ucstring enchantTag("%enchantment"); - if( itemText.find(enchantTag) == ucstring::npos ) + static const string enchantTag("%enchantment"); + if( itemText.find(enchantTag) == string::npos ) return; // retrieve the current itemInfo @@ -2132,7 +2133,7 @@ static void setupEnchantedItem(CSheetHelpSetup &setup, ucstring &itemText) CSPhraseManager *pPM= CSPhraseManager::getInstance(); // fill the enchantement info - ucstring enchantInfo; + string enchantInfo; const CItemSheet *pIS= ctrl->asItemSheet(); if(pIS && pIS->Family == ITEMFAMILY::CRYSTALLIZED_SPELL) pPM->buildPhraseDesc(enchantInfo, itemInfo.Enchantment, 0, false, "uihelpPhraseCrystalSpellFormat"); @@ -2159,7 +2160,7 @@ static void setupEnchantedItem(CSheetHelpSetup &setup, ucstring &itemText) hideListBrickHeader(setup); // hide the text - strFindReplace(itemText, enchantTag, ucstring()); + strFindReplace(itemText, enchantTag, string()); } } @@ -2500,14 +2501,14 @@ void refreshItemHelp(CSheetHelpSetup &setup) setupCreatorName(setup); // **** setup the item Text info - ucstring itemText; + string itemText; CEntitySheet *pES = SheetMngr.get ( CSheetId(setup.SrcSheet->getSheetId()) ); if ((pES != NULL) && (pES->type() == CEntitySheet::ITEM)) { CItemSheet *pIS = (CItemSheet*)pES; // ---- Common - ucstring title = setup.SrcSheet->getItemActualName(); + string title = setup.SrcSheet->getItemActualName().toUtf8(); setupHelpTitle(setup.HelpWindow, title ); getItemText (setup.SrcSheet, itemText, pIS); @@ -2591,7 +2592,7 @@ static void setupPactHelp(CSheetHelpSetup &setup) const CPactSheet::SPact &pactLose = pact->PactLose[pactLevel]; // **** setup the brick Text info - ucstring pactText; + string pactText; // TODO Localisation setupHelpTitle(setup.HelpWindow, pactLose.Name); @@ -2698,7 +2699,7 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) // fill text, choose color according to conditions and block for (uint j = i ; j < orIndexMax ; ++j ) { - const std::string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",j+1); + const string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",j+1); CViewText *viewText = dynamic_cast(setup.HelpWindow->getElement(text)); if (viewText) { @@ -2709,7 +2710,7 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) viewText->setHardText("uiMissionOr"); } - const std::string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",j+1); + const string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",j+1); CViewTextID *viewTextID = dynamic_cast(setup.HelpWindow->getElement(textId)); if(viewTextID) @@ -2737,12 +2738,12 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) // inactivate other lines for (uint i = (uint)infos.Prerequisits.size(); i < 15 ; ++i) { - const std::string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",i+1); + const string text = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_%u",i+1); CViewText *viewText = dynamic_cast(setup.HelpWindow->getElement(text)); if (viewText) viewText->setActive(false); - const std::string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",i+1); + const string textId = setup.HelpWindow->getId() + ":content:scroll_text_id:text_list:" + NLMISC::toString("text_id_prereq_%u",i+1); CViewTextID *viewTextID = dynamic_cast(setup.HelpWindow->getElement(textId)); if(viewTextID) viewTextID->setActive(false); @@ -2873,12 +2874,12 @@ void setupOutpostBuildingHelp(CSheetHelpSetup &setup) setupHelpTitle(setup.HelpWindow, CI18N::get("uihelpOutpostBuilding")); - ucstring sOBText; + string sOBText; sOBText = CI18N::get("uihelpOBFormat_"+COutpostBuildingSheet::toString(pOBS->OBType)); { - ucstring timeText; + string timeText; timeText = toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); if ((pOBS->CostTime % 60) != 0) timeText += toString(pOBS->CostTime%60) + CI18N::get("uiBotChatTimeSecond"); @@ -2944,7 +2945,7 @@ static sint getBonusMalusSpecialTT(CDBCtrlSheet *cs) // *************************************************************************** -void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) +void getSabrinaBrickText(CSBrickSheet *pBR, string &brickText) { if(!pBR) return; @@ -2963,15 +2964,15 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) // Level strFindReplace(brickText, "%lvl", toString(pBR->Level)); // Kill the whole text between %ks, if the skill is unknown - const ucstring killSkill("%ks"); + const string killSkill("%ks"); if( pBR->getSkill()==SKILLS::unknown ) { - ucstring::size_type pos0= brickText.find(killSkill); + string::size_type pos0= brickText.find(killSkill); if(pos0 != ucstring::npos) { - ucstring::size_type pos1= brickText.find(killSkill, pos0 + killSkill.size() ); - if(pos1 != ucstring::npos) - brickText.replace(pos0, pos1+killSkill.size()-pos0, ucstring() ); + string::size_type pos1= brickText.find(killSkill, pos0 + killSkill.size() ); + if(pos1 != string::npos) + brickText.replace(pos0, pos1+killSkill.size()-pos0, string() ); } } else @@ -2984,7 +2985,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) strFindReplace(brickText, "%skill", CStringManagerClient::getSkillLocalizedName(pBR->getSkill())); else { - ucstring fullSkillText; + string fullSkillText; bool first= true; for(uint i=0;iUsedSkills.size();i++) { @@ -3014,13 +3015,13 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) // Kill the whole text between %krc, if the relative cost is 0 if(pBR->SabrinaRelativeCost==0.f) { - const ucstring killRC("%krc"); - ucstring::size_type pos0= brickText.find(killRC); - if(pos0 != ucstring::npos) + const string killRC("%krc"); + string::size_type pos0= brickText.find(killRC); + if(pos0 != string::npos) { - ucstring::size_type pos1= brickText.find(killRC, pos0 + killRC.size() ); - if(pos1 != ucstring::npos) - brickText.replace(pos0, pos1+killRC.size()-pos0, ucstring() ); + string::size_type pos1= brickText.find(killRC, pos0 + killRC.size() ); + if(pos1 != string::npos) + brickText.replace(pos0, pos1+killRC.size()-pos0, string() ); } } else @@ -3053,7 +3054,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) } else { - ucstring mpInfo; + string mpInfo; for(uint i=0;iFaberPlan.ItemPartMps.size();i++) { CSBrickSheet::CFaberPlan::CItemPartMP &mpSlot= pBR->FaberPlan.ItemPartMps[i]; @@ -3074,7 +3075,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) } else { - ucstring mpInfo; + string mpInfo; for(uint i=0;iFaberPlan.FormulaMps.size();i++) { CSBrickSheet::CFaberPlan::CFormulaMP &mpSlot= pBR->FaberPlan.FormulaMps[i]; @@ -3090,7 +3091,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, ucstring &brickText) } // *** Magic - ucstring magicResistStr; + string magicResistStr; // Has Some Magic Resistance setuped? if( pBR->isMagic() && pBR->MagicResistType!=RESISTANCE_TYPE::None) { @@ -3190,10 +3191,10 @@ void setupSabrinaPhraseHelp(CSheetHelpSetup &setup, const CSPhraseCom &phrase, u } // **** setup the phrase Text info - setupHelpTitle(setup.HelpWindow, phrase.Name); + setupHelpTitle(setup.HelpWindow, phrase.Name.toUtf8()); // get the phraseText - ucstring phraseText; + string phraseText; // if required, add the .sphrase requirements. // NB: don't add if from bot chat validation (useless cause already filtered by server) pPM->buildPhraseDesc(phraseText, phrase, phraseSheetId, !setup.FromBotChat); @@ -3261,12 +3262,12 @@ static void setupSabrinaBrickHelp(CSheetHelpSetup &setup, bool auraDisabled) // **** setup the brick Text info - ucstring brickText; + string brickText; CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickSheet *pBR= pBM->getBrick(CSheetId(setup.SrcSheet->getSheetId())); if(pBR) { - const ucstring title(CStringManagerClient::getSBrickLocalizedName(pBR->Id)); + const char *title = CStringManagerClient::getSBrickLocalizedName(pBR->Id); setupHelpTitle(setup.HelpWindow, title); // add brick info @@ -3596,7 +3597,7 @@ public: else if( getAuraDisabledState(cs) ) { // get the normal string, and append a short info. - std::string str; + string str; cs->getContextHelp(str); str+= CI18N::get("uittAuraDisabled"); @@ -3735,7 +3736,7 @@ REGISTER_ACTION_HANDLER( CAHMilkoKick, "milko_kick"); // *************************************************************************** -static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const std::string &statPrefixId) +static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const string &statPrefixId) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -3939,7 +3940,7 @@ public: s += getSystemInformation(); string progname; - std::string moduleName; + string moduleName; #ifdef NL_OS_WINDOWS wchar_t name[1024]; GetModuleFileNameW(NULL, name, 1023); diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index eef48509e..58dc5d52a 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -932,7 +932,7 @@ void CChatGroupWindow::removeAllFreeTellers() //================================================================================= void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) { - f.serialVersion(2); + f.serialVersion(3); // Save the free teller only if it is present in the friend list to avoid the only-growing situation // because free tellers are never deleted in game if we save/load all the free tellers, we just create more @@ -940,7 +940,7 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) uint32 i, nNbFreeTellerSaved = 0; for (i = 0; i < _FreeTellers.size(); ++i) - if (PeopleInterraction.FriendList.getIndexFromName(_FreeTellers[i]->getUCTitle()) != -1) + if (PeopleInterraction.FriendList.getIndexFromName(_FreeTellers[i]->getTitle()) != -1) nNbFreeTellerSaved++; f.serial(nNbFreeTellerSaved); @@ -949,9 +949,9 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) { CGroupContainer *pGC = _FreeTellers[i]; - if (PeopleInterraction.FriendList.getIndexFromName(pGC->getUCTitle()) != -1) + if (PeopleInterraction.FriendList.getIndexFromName(pGC->getTitle()) != -1) { - ucstring sTitle = pGC->getUCTitle(); + string sTitle = pGC->getTitle(); f.serial(sTitle); } } @@ -960,7 +960,7 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) //================================================================================= void CChatGroupWindow::loadFreeTeller(NLMISC::IStream &f) { - sint ver = f.serialVersion(2); + sint ver = f.serialVersion(3); if (ver == 1) { @@ -980,10 +980,15 @@ void CChatGroupWindow::loadFreeTeller(NLMISC::IStream &f) string sID; f.serial(sID); } - ucstring sTitle; - f.serial(sTitle); + string title; + if (ver < 3) + { + ucstring sTitle; // Old UTF-16 serial + f.serial(sTitle); + title = sTitle.toUtf8(); + } - CGroupContainer *pGC = createFreeTeller(sTitle, ""); + CGroupContainer *pGC = createFreeTeller(title, ""); // With version 1 all tells are active because windows information have "title based" ids and no "sID based". if ((ver == 1) && (pGC != NULL)) @@ -1334,13 +1339,13 @@ REGISTER_ACTION_HANDLER(CHandlerChatBoxEntry, "chat_box_entry"); -static ucstring getFreeTellerName(CInterfaceElement *pCaller) +static string getFreeTellerName(CInterfaceElement *pCaller) { - if (!pCaller) return ucstring(); + if (!pCaller) return string(); CChatGroupWindow *cgw = PeopleInterraction.getChatGroupWindow(); - if (!cgw) return ucstring(); + if (!cgw) return string(); CInterfaceGroup *freeTeller = pCaller->getParentContainer(); - if (!freeTeller) return ucstring(); + if (!freeTeller) return string(); return cgw->getFreeTellerName( freeTeller->getId() ); } @@ -1350,7 +1355,7 @@ class CHandlerAddTellerToFriendList : public IActionHandler public: void execute (CCtrlBase *pCaller, const std::string &/* sParams */) { - ucstring playerName = ::getFreeTellerName(pCaller); + string playerName = ::getFreeTellerName(pCaller); if (!playerName.empty()) { sint playerIndex = PeopleInterraction.IgnoreList.getIndexFromName(playerName); @@ -1378,7 +1383,7 @@ public: CInterfaceManager *im = CInterfaceManager::getInstance(); std::string callerId = getParam(sParams, "id"); CInterfaceElement *prevCaller = CWidgetManager::getInstance()->getElementFromId(callerId); - ucstring playerName = ::getFreeTellerName(prevCaller); + string playerName = ::getFreeTellerName(prevCaller); if (!playerName.empty()) { // if already in friend list, ask to move rather than add @@ -1410,7 +1415,7 @@ class CHandlerInviteToRingSession : public IActionHandler public: void execute (CCtrlBase *pCaller, const std::string &/* sParams */) { - string playerName = ::getFreeTellerName(pCaller).toUtf8(); + string playerName = ::getFreeTellerName(pCaller); if (!playerName.empty()) { // ask the SBS to invite the character in the session diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 7196bdac9..63392c583 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -3394,22 +3394,22 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const if (!macro) return; - ucstring macroName = macro->Name; + string macroName = macro->Name; if (macroName.empty()) macroName = CI18N::get("uiNotAssigned"); - ucstring assignedTo = macro->Combo.toString(); + string assignedTo = macro->Combo.toString(); if (assignedTo.empty()) assignedTo = CI18N::get("uiNotAssigned"); - ucstring dispText; - ucstring dispCommands; + string dispText; + string dispCommands; const CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); uint nb = 0; for (uint i = 0; i < macro->Commands.size(); ++i) { - ucstring commandName; + string commandName; for (uint j = 0; j < pMCM->ActionManagers.size(); ++j) { CAction::CName c(macro->Commands[i].Name.c_str(), macro->Commands[i].Params.c_str()); @@ -3425,14 +3425,14 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const } } // formats - dispText = ucstring("%n (@{6F6F}%k@{FFFF})\n%c"); + dispText = "%n (@{6F6F}%k@{FFFF})\n%c"; if (nb > 5) // more? dispCommands += toString(" ... @{6F6F}%i@{FFFF}+", nb-5); - strFindReplace(dispText, ucstring("%n"), macroName); - strFindReplace(dispText, ucstring("%k"), assignedTo); - strFindReplace(dispText, ucstring("%c"), dispCommands); - help = dispText.toUtf8(); + strFindReplace(dispText, "%n", macroName); + strFindReplace(dispText, "%k", assignedTo); + strFindReplace(dispText, "%c", dispCommands); + help = dispText; } else if(getType() == CCtrlSheetInfo::SheetType_Item) { diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index be0df19ad..4f173088d 100644 --- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -1242,9 +1242,9 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) // **** Setup the phrase Desc if(_TextPhraseDesc) { - ucstring text; + string text; pPM->buildPhraseDesc(text, phrase, 0, false, "composition"); - _TextPhraseDesc->setTextFormatTaged(text.toUtf8()); + _TextPhraseDesc->setTextFormatTaged(text); } 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 21a56ec4f..f8b5d4b56 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -281,15 +281,15 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT if(Ctrl->getSheetCategory() == CDBCtrlSheet::Phrase) { // For combat action, Append weapon restriction - ucstring weaponRestriction; + string weaponRestriction; CSPhraseManager *pPM= CSPhraseManager::getInstance(); bool melee,range; pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range); // don't add also if no combat restriction - if(!weaponRestriction.empty() && weaponRestriction!=CI18N::getAsUtf16("uiawrSF")) + if(!weaponRestriction.empty() && weaponRestriction!=CI18N::get("uiawrSF")) { weaponRestriction= CI18N::get("uiPhraseWRHeader") + weaponRestriction; - text+= "\n" + weaponRestriction.toUtf8(); + text+= "\n" + weaponRestriction; } } 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 35cc56ebe..9f03834c8 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -1311,6 +1311,7 @@ class CAHDynChatClickOption : public IActionHandler uint32 optStrId = InSceneBubbleManager.dynChatGetOptionStringId(nBubbleNb, nOpt); if (!optStrId) return; +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); @@ -1330,6 +1331,7 @@ class CAHDynChatClickOption : public IActionHandler } } } +#endif static const string sMsg = "BOTCHAT:DYNCHAT_SEND"; CBitMemStream out; diff --git a/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/ryzom/client/src/interface_v3/group_modal_get_key.cpp index b79f6c38a..1bd1f0936 100644 --- a/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -111,8 +111,8 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) const CBaseAction *baseAction = pCurAM->getBaseAction(it->second); if (baseAction && pCurAM->isActionPresentInContext(it->second)) { - ucstring shortcutName = baseAction->getActionLocalizedText(it->second); - if (pVT != NULL) pVT->setText(shortcutName.toUtf8()); + string shortcutName = baseAction->getActionLocalizedText(it->second); + if (pVT != NULL) pVT->setText(shortcutName); } } else diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 0fa12432b..963093235 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1605,7 +1605,9 @@ void CInterfaceManager::updateFrameEvents() // handle gc for lua CLuaManager::getInstance().getLuaState()->handleGC(); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().update(); +#endif CItemGroupManager::getInstance()->update(); diff --git a/ryzom/client/src/interface_v3/item_consumable_effect.cpp b/ryzom/client/src/interface_v3/item_consumable_effect.cpp index a91394390..38b22a3e4 100644 --- a/ryzom/client/src/interface_v3/item_consumable_effect.cpp +++ b/ryzom/client/src/interface_v3/item_consumable_effect.cpp @@ -33,10 +33,10 @@ CItemConsumableEffectHelper* CItemConsumableEffectHelper::getInstance() return instance; } -void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet *pIS, ucstring &itemText, sint32 itemQuality) +void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet *pIS, string &itemText, sint32 itemQuality) { // check if some effects are present on this item - ucstring effects(""); + string effects(""); uint i; for( i=0; iConsumable.Properties.size(); ++i ) @@ -71,7 +71,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 timeInSec; fromString(params[3].c_str(), timeInSec); - ucstring result; + string result; if (bonus >= 0) result = CI18N::get("uiItemConsumableEffectUpCharac"); @@ -101,7 +101,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectLifeAura"); + string result = CI18N::get("uiItemConsumableEffectLifeAura"); strFindReplace(result, "%modifier", toString(regenMod)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -128,7 +128,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectLifeAura"); + string result = CI18N::get("uiItemConsumableEffectLifeAura"); strFindReplace(result, "%modifier", toString(bonus)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -154,7 +154,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectStaminaAura"); + string result = CI18N::get("uiItemConsumableEffectStaminaAura"); strFindReplace(result, "%modifier", toString(regenMod)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -182,7 +182,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectStaminaAura"); + string result = CI18N::get("uiItemConsumableEffectStaminaAura"); strFindReplace(result, "%modifier", toString(bonus)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -208,7 +208,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectSapAura"); + string result = CI18N::get("uiItemConsumableEffectSapAura"); strFindReplace(result, "%modifier", toString(regenMod)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -235,7 +235,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * uint32 userDisableTime; fromString(params[4].c_str(), userDisableTime); - ucstring result = CI18N::get("uiItemConsumableEffectSapAura"); + string result = CI18N::get("uiItemConsumableEffectSapAura"); strFindReplace(result, "%modifier", toString(bonus)); strFindReplace(result, "%minutes", toString(duration/60)); strFindReplace(result, "%secondes", toString(duration%60)); @@ -249,7 +249,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet * // skill modifier consumables //--------------------------- - ucstring result(""); + string result(""); uint8 paramIdx = 0; if( name == "SP_MOD_DEFENSE" ) { diff --git a/ryzom/client/src/interface_v3/item_consumable_effect.h b/ryzom/client/src/interface_v3/item_consumable_effect.h index 69a0472ad..a6150204a 100644 --- a/ryzom/client/src/interface_v3/item_consumable_effect.h +++ b/ryzom/client/src/interface_v3/item_consumable_effect.h @@ -32,7 +32,7 @@ public: static CItemConsumableEffectHelper* getInstance(); // Fill itemText with consumable effects from item sheet - void getItemConsumableEffectText(const CItemSheet *pIS, ucstring &itemText, sint32 itemQuality); + void getItemConsumableEffectText(const CItemSheet *pIS, std::string &itemText, sint32 itemQuality); private: CItemConsumableEffectHelper() {} diff --git a/ryzom/client/src/interface_v3/item_special_effect.cpp b/ryzom/client/src/interface_v3/item_special_effect.cpp index 5d696738a..7b659fe6d 100644 --- a/ryzom/client/src/interface_v3/item_special_effect.cpp +++ b/ryzom/client/src/interface_v3/item_special_effect.cpp @@ -76,11 +76,11 @@ void CItemSpecialEffectHelper::registerItemSpecialEffect(const string &name) effectMap.insert(make_pair(name, params)); } -void CItemSpecialEffectHelper::getItemSpecialEffectText(const CItemSheet *pIS, ucstring &itemText) +void CItemSpecialEffectHelper::getItemSpecialEffectText(const CItemSheet *pIS, string &itemText) { // check if some effects are present on this item bool firstEffect = false; - ucstring effects; + string effects; effects += getEffect(pIS->getEffect1(), firstEffect); effects += getEffect(pIS->getEffect2(), firstEffect); effects += getEffect(pIS->getEffect3(), firstEffect); @@ -92,9 +92,9 @@ void CItemSpecialEffectHelper::getItemSpecialEffectText(const CItemSheet *pIS, u strFindReplace(itemText, "%special_effects", effects); } -ucstring CItemSpecialEffectHelper::getEffect(const std::string &effect, bool &first) +string CItemSpecialEffectHelper::getEffect(const std::string &effect, bool &first) { - ucstring result; + string result; CSString eff = effect; if (eff.empty()) diff --git a/ryzom/client/src/interface_v3/item_special_effect.h b/ryzom/client/src/interface_v3/item_special_effect.h index a97437958..201c83927 100644 --- a/ryzom/client/src/interface_v3/item_special_effect.h +++ b/ryzom/client/src/interface_v3/item_special_effect.h @@ -32,7 +32,7 @@ public: static CItemSpecialEffectHelper* getInstance(); // Fill itemText with special effects from item sheet - void getItemSpecialEffectText(const CItemSheet *pIS, ucstring &itemText); + void getItemSpecialEffectText(const CItemSheet *pIS, std::string &itemText); // Register a new item special effect void registerItemSpecialEffect(const std::string &name); @@ -42,7 +42,7 @@ private: CItemSpecialEffectHelper(const CItemSpecialEffectHelper&); // Get UI text with values filled from 'effect' string - ucstring getEffect(const std::string &effect, bool &first); + std::string getEffect(const std::string &effect, bool &first); // Map effects name with parameters typedef std::vector stringVector; diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 55d31bf54..4e6599fa1 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -533,10 +533,12 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), LUABIND_FUNC(replacePvpEffectParam), LUABIND_FUNC(secondsSince1970ToHour), +#ifdef RYZOM_BG_DOWNLOADER LUABIND_FUNC(pauseBGDownloader), LUABIND_FUNC(unpauseBGDownloader), LUABIND_FUNC(requestBGDownloaderPriority), LUABIND_FUNC(getBGDownloaderPriority), +#endif LUABIND_FUNC(loadBackground), LUABIND_FUNC(getPatchLastErrorMessage), LUABIND_FUNC(getPlayerSelectedSlot), @@ -3080,6 +3082,7 @@ sint32 CLuaIHMRyzom::secondsSince1970ToHour(sint32 seconds) return tstruct->tm_hour; // 0-23 } +#ifdef RYZOM_BG_DOWNLOADER // *************************************************************************** void CLuaIHMRyzom::pauseBGDownloader() { @@ -3108,6 +3111,7 @@ sint CLuaIHMRyzom::getBGDownloaderPriority() { return CBGDownloaderAccess::getInstance().getDownloadThreadPriority(); } +#endif // *************************************************************************** void CLuaIHMRyzom::loadBackground(const std::string &bg) @@ -3120,11 +3124,13 @@ void CLuaIHMRyzom::loadBackground(const std::string &bg) // *************************************************************************** ucstring CLuaIHMRyzom::getPatchLastErrorMessage() { +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { return CBGDownloaderAccess::getInstance().getLastErrorMessage(); } else +#endif { CPatchManager *pPM = CPatchManager::getInstance(); return pPM->getLastErrorMessage(); diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index abf09594e..44e841636 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -174,12 +174,14 @@ private: static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode); static void messageBoxWithHelp(const std::string &text); - static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); + static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); // TODO: UTF-8 Lua static sint32 secondsSince1970ToHour(sint32 seconds); +#ifdef RYZOM_BG_DOWNLOADER static void pauseBGDownloader(); static void unpauseBGDownloader(); static void requestBGDownloaderPriority(uint priority); static sint getBGDownloaderPriority(); +#endif static void loadBackground(const std::string &bg); static ucstring getPatchLastErrorMessage(); static bool isInGame(); diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp index 81033f5aa..aa6ffe213 100644 --- a/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -125,7 +125,7 @@ struct CComboActionName CCombo Combo; // KeyCount <=> action name unbound CAction::CName ActionName; }; -void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, map &remaped) +void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, map &remaped) { CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); CActionsManager *pAM = pMCM->ActionManagers[nAM]; @@ -148,7 +148,7 @@ void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, // see if action active in current context if (pAM->isActionPresentInContext(it->second)) { - pair value; + pair value; // Don't take any risk: avoid any bug if the localisation is buggy and give same text for 2 differents CAction::CName // Use the localized text first, to have correct sort according to language value.first= pAM->getActionLocalizedText(rName) + rName.Name + rName.Argu; @@ -177,7 +177,7 @@ void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, // see if action active in current context if (pAM->isActionPresentInContext(rName)) { - pair value; + pair value; // Don't take any risk: avoid any bug if the localisation is buggy and give same text for 2 differents CAction::CName // Use the localized text first, to have correct sort according to language value.first= pAM->getActionLocalizedText(rName) + rName.Name + rName.Argu; @@ -197,15 +197,15 @@ void buildActionToComboMap(uint8 nAM, CGroupList * /* pList */, string catName, // Get all the couple (combo,action) from the action manager nAM and insert them into pList (with the template) -void getAllComboAction(uint8 nAM, CGroupList *pList, const map &remaped) +void getAllComboAction(uint8 nAM, CGroupList *pList, const map &remaped) { CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); CActionsManager *pAM = pMCM->ActionManagers[nAM]; // *** Fill Actions - map::const_iterator remapIT = remaped.begin(); + map::const_iterator remapIT = remaped.begin(); while (remapIT != remaped.end()) { - ucstring keyName; + string keyName; if(remapIT->second.Combo.Key==KeyCount) keyName= CI18N::get("uiNotAssigned"); else @@ -213,7 +213,7 @@ void getAllComboAction(uint8 nAM, CGroupList *pList, const mapgetBaseAction(remapIT->second.ActionName); if (baseAction) { - ucstring shortcutName = baseAction->getActionLocalizedText(remapIT->second.ActionName); + string shortcutName = baseAction->getActionLocalizedText(remapIT->second.ActionName); addKeyLine(pList, keyName, shortcutName, remapIT->second.Combo.Key==KeyCount); CModalContainerEditCmd::CLine line; @@ -274,7 +274,7 @@ public: pList->clearGroups(); pList->setDynamicDisplaySize(true); - map remaped; + map remaped; buildActionToComboMap(nAM, pList, rCats[i].Name, remaped); if (!remaped.empty()) { diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 03e53c06b..54bc39d29 100644 --- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -65,7 +65,7 @@ void CMacroCmd::writeTo (xmlNodePtr node) const xmlNodePtr macroNode = xmlNewChild ( node, NULL, (const xmlChar*)"macro", NULL ); // Props - xmlSetProp (macroNode, (const xmlChar*)"name", (const xmlChar*)ucstring(Name).toUtf8().c_str()); + xmlSetProp (macroNode, (const xmlChar*)"name", (const xmlChar*)Name.c_str()); xmlSetProp (macroNode, (const xmlChar*)"id", (const xmlChar*)toString(ID).c_str()); xmlSetProp (macroNode, (const xmlChar*)"back", (const xmlChar*)toString(BitmapBack).c_str()); xmlSetProp (macroNode, (const xmlChar*)"icon", (const xmlChar*)toString(BitmapIcon).c_str()); @@ -86,12 +86,7 @@ bool CMacroCmd::readFrom (xmlNodePtr node) CXMLAutoPtr ptrName; ptrName = (char*) xmlGetProp( node, (xmlChar*)"name" ); - if (ptrName) - { - ucstring ucName; - ucName.fromUtf8((const char*)ptrName); - Name = ucName.toString(); - } + if (ptrName) Name = (const char *)ptrName; ptrName = (char*) xmlGetProp( node, (xmlChar*)"id" ); if (ptrName) fromString((const char*)ptrName, ID); @@ -818,7 +813,7 @@ public: REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdDelete, "new_macro_cmd_delete"); // *************************************************************************** -void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName) +void addCommandLine (CGroupList *pParent, uint cmdNb, const string &cmdName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -828,7 +823,7 @@ void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName) if (pNewCmd == NULL) return; CViewText *pVT = dynamic_cast(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT)); - if (pVT != NULL) pVT->setText(cmdName.toUtf8()); + if (pVT != NULL) pVT->setText(cmdName); pNewCmd->setParent (pParent); pParent->addChild (pNewCmd); @@ -906,7 +901,7 @@ public: for (uint i = 0; i < pMCM->CurrentEditMacro.Commands.size(); ++i) { - ucstring commandName; + string commandName; for (uint j = 0; j < pMCM->ActionManagers.size(); ++j) { CAction::CName c(pMCM->CurrentEditMacro.Commands[i].Name.c_str(), pMCM->CurrentEditMacro.Commands[i].Params.c_str()); diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp index b45af6c7b..790949352 100644 --- a/ryzom/client/src/interface_v3/music_player.cpp +++ b/ryzom/client/src/interface_v3/music_player.cpp @@ -327,9 +327,7 @@ void CMusicPlayer::rebuildPlaylist() CViewText *pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_TITLE)); if (pVT) { - ucstring title; - title.fromUtf8(_Songs[i].Title); - pVT->setText(title.toUtf8()); + pVT->setText(_Songs[i].Title); } pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION)); diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index e1a01400d..e2f880744 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -1089,7 +1089,7 @@ CFilteredChat *CPeopleInterraction::getFilteredChatFromChatWindow(CChatWindow *c } //=========================================================================================================== -void CPeopleInterraction::askAddContact(const ucstring &contactName, CPeopleList *pl) +void CPeopleInterraction::askAddContact(const string &contactName, CPeopleList *pl) { if (pl == NULL) return; @@ -1109,7 +1109,7 @@ void CPeopleInterraction::askAddContact(const ucstring &contactName, CPeopleList } // add into server (NB: will be added by the server response later) - const std::string sMsg = "TEAM:CONTACT_ADD"; + const char *sMsg = "TEAM:CONTACT_ADD"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -1121,14 +1121,14 @@ void CPeopleInterraction::askAddContact(const ucstring &contactName, CPeopleList if (pl == &FriendList) list = 0; - ucstring temp = contactName; + ucstring temp = contactName; // TODO: UTF-8 serial out.serial(temp); out.serial(list); NetMngr.push(out); //nlinfo("impulseCallBack : %s %s %d sent", sMsg.c_str(), contactName.toString().c_str(), list); } else - nlwarning("impulseCallBack : unknown message name : '%s'.", sMsg.c_str()); + nlwarning("impulseCallBack : unknown message name : '%s'.", sMsg); // NB: no client prediction, will be added by server later @@ -1275,7 +1275,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.toUtf8()); + string name= CEntityCL::removeShardFromName(nameIn.toUtf8()); // add the contact to this list sint index = pl.getIndexFromName(name); @@ -1326,7 +1326,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.toUtf8()); + string name= CEntityCL::removeShardFromName(nameIn.toUtf8()); return pl.getIndexFromName(name) != -1; } @@ -1393,7 +1393,7 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS // Only show the message if this player is not in my guild (because then the guild manager will show a message) std::vector GuildMembers = CGuildManager::getInstance()->getGuildMembers(); bool bOnlyFriend = true; - string name = toLower(FriendList.getName(index).toUtf8()); + string name = toLower(FriendList.getName(index)); for (uint i = 0; i < GuildMembers.size(); ++i) { if (toLower(GuildMembers[i].Name) == name) @@ -1410,7 +1410,7 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS if (showMsg) { string msg = (online != ccs_offline) ? CI18N::get("uiPlayerOnline") : CI18N::get("uiPlayerOffline"); - strFindReplace(msg, "%s", FriendList.getName(index).toUtf8()); + strFindReplace(msg, "%s", FriendList.getName(index)); string cat = getStringCategory(msg, msg); map::const_iterator it; NLMISC::CRGBA col = CRGBA::Yellow; @@ -1471,9 +1471,9 @@ bool CPeopleInterraction::testValidPartyChatName(const ucstring &title) if (GuildChat && title == GuildChat->getTitle()) return false; if (TeamChat && title == TeamChat->getTitle()) return false; sint index; - index = FriendList.getIndexFromName(title); + index = FriendList.getIndexFromName(title.toUtf8()); if (index != -1) return false; - index = IgnoreList.getIndexFromName(title); + index = IgnoreList.getIndexFromName(title.toUtf8()); if (index != -1) return false; // TODO_GAMEDEV server test for the name (not only local), & modify callers of this function // The party chat should NOT have the name of a player @@ -2137,7 +2137,7 @@ public: uint peopleIndex; if (PeopleInterraction.getPeopleFromCurrentMenu(list, peopleIndex)) { - CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex).toUtf8()); + CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex)); } } }; @@ -2159,7 +2159,7 @@ class CHandlerTellContact : public IActionHandler uint peopleIndex; if (PeopleInterraction.getPeopleFromContainerID(gc->getId(), list, peopleIndex)) { - CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex).toUtf8()); + CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex)); } } @@ -2255,7 +2255,7 @@ public: } else { - PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList); + PeopleInterraction.askAddContact(geb->getInputString(), peopleList); geb->setInputString(std::string()); } } @@ -3176,7 +3176,7 @@ NLMISC_COMMAND(ignore, "add or remove a player from the ignore list", " people %s inserted twice.", name.toString().c_str()); } @@ -687,14 +687,14 @@ void CPeopleList::updatePeopleMenu(uint index) } //================================================================== -ucstring CPeopleList::getName(uint index) const +std::string CPeopleList::getName(uint index) const { if (index >= _Peoples.size()) { nlwarning("bad index"); - return ucstring("BAD INDEX!"); + return "BAD INDEX!"; } - return _Peoples[index].getName(); + return _Peoples[index].getName().toUtf8(); } //================================================================== diff --git a/ryzom/client/src/interface_v3/people_list.h b/ryzom/client/src/interface_v3/people_list.h index da7556aa5..91dbf50d3 100644 --- a/ryzom/client/src/interface_v3/people_list.h +++ b/ryzom/client/src/interface_v3/people_list.h @@ -75,13 +75,13 @@ public: */ bool create(const CPeopleListDesc &desc, const CChatWindowDesc *chat = NULL); // Get index from the name of a people, or -1 if not found - sint getIndexFromName(const ucstring &name) const; + sint getIndexFromName(const std::string &name) const; // Get index from the id of the container that represent the people sint getIndexFromContainerID(const std::string &id) const; // Get the number of people in this list uint getNumPeople() const { return (uint)_Peoples.size(); } // Get name of a people - ucstring getName(uint index) const; + std::string getName(uint index) const; // Sort people alphabetically void sort(); diff --git a/ryzom/client/src/interface_v3/req_skill_formula.cpp b/ryzom/client/src/interface_v3/req_skill_formula.cpp index 1165dccc5..5099d325f 100644 --- a/ryzom/client/src/interface_v3/req_skill_formula.cpp +++ b/ryzom/client/src/interface_v3/req_skill_formula.cpp @@ -343,7 +343,7 @@ void CReqSkillFormula::log(const char *prefix) const } // *************************************************************************** -void CReqSkillFormula::getInfoText(ucstring &info) const +void CReqSkillFormula::getInfoText(string &info) const { info.clear(); @@ -363,7 +363,7 @@ void CReqSkillFormula::getInfoText(ucstring &info) const { const CSkillValue &sv= *itSv; // get the colored line if the skill don't reach the req level - ucstring line; + string line; if(!isSkillValueTrained(sv)) line= CI18N::get("uihelpPhraseRequirementNotMetLine"); else diff --git a/ryzom/client/src/interface_v3/req_skill_formula.h b/ryzom/client/src/interface_v3/req_skill_formula.h index 7286172ce..bf0ef5dc0 100644 --- a/ryzom/client/src/interface_v3/req_skill_formula.h +++ b/ryzom/client/src/interface_v3/req_skill_formula.h @@ -101,7 +101,7 @@ public: void log(const char *prefix) const; // For SPhrase Info - void getInfoText(ucstring &info) const; + void getInfoText(std::string &info) const; // return true if the requirement formula completes regarding the actual player state (through CSkillMananger). return true if empty() bool evaluate() const; diff --git a/ryzom/client/src/interface_v3/sphrase_manager.cpp b/ryzom/client/src/interface_v3/sphrase_manager.cpp index f6a89df7a..c42d544d1 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -960,7 +960,7 @@ bool CSPhraseManager::isPhraseKnown(const CSPhraseCom &phrase) const } // *************************************************************************** -ucstring CSPhraseManager::formatMalus(sint base, sint malus) +string CSPhraseManager::formatMalus(sint base, sint malus) { if(malus) return toString("@{F80F}%d@{FFFF} (%d)", base+malus, base); @@ -969,7 +969,7 @@ ucstring CSPhraseManager::formatMalus(sint base, sint malus) } // *************************************************************************** -ucstring CSPhraseManager::formatMalus(float base, float malus) +string CSPhraseManager::formatMalus(float base, float malus) { if(malus) return toString("@{F80F}%.1f@{FFFF} (%.1f)", base+malus, base); @@ -1008,7 +1008,7 @@ string CSPhraseManager::formatBonusMalus(sint32 base, sint32 mod) } // *************************************************************************** -void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat) +void CSPhraseManager::buildPhraseDesc(string &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat) { CSBrickManager *pBM= CSBrickManager::getInstance(); CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -1029,7 +1029,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, if(rootBrick) { static const string compoId= "composition"; - static const ucstring compoTag("%compostart"); + static const string compoTag("%compostart"); bool isComposition= specialPhraseFormat==compoId; // if format not given by user, auto select it. @@ -1053,14 +1053,14 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // if composition, cut the text before the tag (including) if(isComposition) { - ucstring::size_type pos= text.find(compoTag); - if(pos!=ucstring::npos) + string::size_type pos= text.find(compoTag); + if(pos!=string::npos) text.erase(0, pos+compoTag.size()); } // else just clear the tag else { - strFindReplace(text, compoTag, ucstring() ); + strFindReplace(text, compoTag, string() ); } } else @@ -1071,7 +1071,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // **** Phrase info basics // replace name - strFindReplace(text, "%name", phrase.Name); + strFindReplace(text, "%name", phrase.Name.toUtf8()); // replace Sabrina Cost and credit. uint32 cost, credit; pBM->getSabrinaCom().getPhraseCost(phrase.Bricks, cost, credit); @@ -1079,7 +1079,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, strFindReplace(text, "%credit", toString(credit)); // for combat, fill weapon compatibility - ucstring weaponRestriction; + string weaponRestriction; bool usableWithMelee; bool usableWithRange; if(rootBrick && rootBrick->isCombat()) @@ -1099,7 +1099,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, bool resistMagic[RESISTANCE_TYPE::NB_RESISTANCE_TYPE]; getResistMagic(resistMagic, phrase.Bricks); bool first= true; - ucstring resList; + string resList; for(uint i=0;iisForageExtraction()) { // Choose the fmt text - ucstring fmt= getForageExtractionPhraseEcotypeFmt(phrase); + string fmt= getForageExtractionPhraseEcotypeFmt(phrase); // Replace forage success rate in any ecotype successModifier = 0; @@ -1292,16 +1292,16 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, } // **** Special .sphrase description - if(phraseSheetId) + if (phraseSheetId) { // get the text - ucstring desc(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(CSheetId(phraseSheetId))); - if(desc.empty()) - strFindReplace(text, "%desc", ucstring()); + string desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(CSheetId(phraseSheetId)); + if (desc.empty()) + strFindReplace(text, "%desc", string()); else { // append an \n before, for clearness - desc= ucstring("\n") + desc; + desc= string("\n") + desc; // append \n at end if not done if(desc[desc.size()-1]!='\n') desc+= '\n'; @@ -1311,13 +1311,13 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, } else { - strFindReplace(text, "%desc", ucstring()); + strFindReplace(text, "%desc", string()); } // **** Special .sphrase requirement if(phraseSheetId && wantRequirement) { - ucstring reqText; + string reqText; reqText= CI18N::get("uihelpPhraseRequirementHeader"); // replace the skill point cost @@ -1331,7 +1331,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, const CReqSkillFormula &formula= it->second; // from this formula, build the requirement tex - ucstring textForm; + string textForm; formula.getInfoText(textForm); reqText+= textForm; } @@ -4089,7 +4089,7 @@ bool CSPhraseManager::allowListBrickInHelp(const CSPhraseCom &phrase) const } // *************************************************************************** -void CSPhraseManager::getCombatWeaponRestriction(ucstring &text, const CSPhraseCom &phrase, bool& usableWithMelee, bool& usableWithRange) +void CSPhraseManager::getCombatWeaponRestriction(string &text, const CSPhraseCom &phrase, bool& usableWithMelee, bool& usableWithRange) { text.clear(); @@ -4165,7 +4165,7 @@ void CSPhraseManager::getCombatWeaponRestriction(ucstring &text, const CSPhra } // *************************************************************************** -void CSPhraseManager::getCombatWeaponRestriction(ucstring &text, sint32 phraseSheetId, bool& usableWithMelee, bool& usableWithRange) +void CSPhraseManager::getCombatWeaponRestriction(string &text, sint32 phraseSheetId, bool& usableWithMelee, bool& usableWithRange) { CSPhraseCom phrase; buildPhraseFromSheet(phrase, phraseSheetId); @@ -4279,7 +4279,7 @@ void CSPhraseManager::fullDeletePhraseIfLast(uint32 memoryLine, uint32 memorySl // *************************************************************************** -ucstring CSPhraseManager::getForageExtractionPhraseEcotypeFmt(const CSPhraseCom &phrase) +string CSPhraseManager::getForageExtractionPhraseEcotypeFmt(const CSPhraseCom &phrase) { CSBrickManager *pBM= CSBrickManager::getInstance(); diff --git a/ryzom/client/src/interface_v3/sphrase_manager.h b/ryzom/client/src/interface_v3/sphrase_manager.h index 03c0f1718..59150927e 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.h +++ b/ryzom/client/src/interface_v3/sphrase_manager.h @@ -338,7 +338,7 @@ public: * \specialPhraseFormat if empty, format is auto selected. if "composition", same but the text is cut under the %compostart tag. * else take directly this format. */ - void buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat= std::string()); + void buildPhraseDesc(std::string &text, const CSPhraseCom &phrase, uint32 phraseSheetId, bool wantRequirement, const std::string &specialPhraseFormat= std::string()); // Get the Phrase Success Rate % sint getPhraseSuccessRate(const CSPhraseCom &phrase); // Get the Phrase Success Rate %. Manually gives the Skill to do the comparison (for craft) @@ -346,7 +346,7 @@ public: // Get the Phrase Success Rate %. Manually gives the Skill to do the comparison (for Forage Extraction) sint getForageExtractionPhraseSuccessRate(const CSPhraseCom &phrase, SKILLS::ESkills skill); // return the fmt according to forage terrain specializing - ucstring getForageExtractionPhraseEcotypeFmt(const CSPhraseCom &phrase); + std::string getForageExtractionPhraseEcotypeFmt(const CSPhraseCom &phrase); // Get the Phrase Sap Cost void getPhraseSapCost(const CSPhraseCom &phrase, uint32 totalActionMalus, sint &cost, sint &costMalus); // Get the Phrase Sta Cost @@ -370,8 +370,8 @@ public: /// true if interesting to list the bricks of this phrase in help bool allowListBrickInHelp(const CSPhraseCom &phrase) const; /// return the combat restriction text (empty if not combat) - void getCombatWeaponRestriction(ucstring &text, const CSPhraseCom &phrase, bool& usableWithMelee, bool& usableWithRange); - void getCombatWeaponRestriction(ucstring &text, sint32 phraseSheetId, bool& usableWithMelee, bool& usableWithRange); + void getCombatWeaponRestriction(std::string &text, const CSPhraseCom &phrase, bool& usableWithMelee, bool& usableWithRange); + void getCombatWeaponRestriction(std::string &text, sint32 phraseSheetId, bool& usableWithMelee, bool& usableWithRange); // return true if any of the Bricks contains AvoidCyclic==true (the phrase cannot be cyclic) bool avoidCyclicForPhrase(const CSPhraseCom &phrase) const; bool avoidCyclicForPhrase(sint32 phraseSheetId) const; @@ -693,8 +693,8 @@ private: // @} - ucstring formatMalus(sint base, sint malus); - ucstring formatMalus(float base, float malus); + std::string formatMalus(sint base, sint malus); + std::string formatMalus(float base, float malus); std::string formatBonusMalus(sint32 base, sint32 mod); // Special for combat: Build the "phrase skill compatible" formula diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index a5b94c879..e39d406ff 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -357,6 +357,7 @@ static void setPatcherProgressText(const std::string &baseUIPath, const ucstring static void updatePatchingInfoText(const std::string &baseUIPath) { CPatchManager *pPM = CPatchManager::getInstance(); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); if (isBGDownloadEnabled()) { @@ -380,6 +381,7 @@ static void updatePatchingInfoText(const std::string &baseUIPath) } } else +#endif { ucstring state; vector log; @@ -406,7 +408,9 @@ void loginMainLoop() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance(); +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); +#endif bool windowBlinkDone = false; bool fatalMessageBoxShown = false; @@ -464,11 +468,13 @@ void loginMainLoop() BGDownloader::TTaskResult taskResult = BGDownloader::TaskResult_Unknown; bool finished = false; ucstring bgDownloaderError; +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); } else +#endif { finished = pPM->isCheckThreadEnded(res); } @@ -478,6 +484,7 @@ void loginMainLoop() setPatcherStateText("ui:login:checking", ucstring()); setPatcherProgressText("ui:login:checking", ucstring()); +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { AvailablePatchs = bgDownloader.getAvailablePatchs(); @@ -529,6 +536,7 @@ void loginMainLoop() } else +#endif { if(res) { @@ -642,7 +650,7 @@ void loginMainLoop() int currentPatchingSize; int totalPatchSize; - +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { currentPatchingSize = bgDownloader.getPatchingSize(); @@ -683,6 +691,7 @@ void loginMainLoop() } } else +#endif { totalPatchSize = TotalPatchSize; currentPatchingSize = pPM->getPatchingSize(); @@ -1130,18 +1139,22 @@ void initPatchCheck() LoginShardId = Shards[ShardSelected].ShardId; } +#ifdef RYZOM_BG_DOWNLOADER if (!isBGDownloadEnabled()) +#endif { getPatchParameters(url, ver, patchURIs); pPM->init(patchURIs, url, ver); pPM->startCheckThread(true /* include background patchs */); } +#ifdef RYZOM_BG_DOWNLOADER else { BGDownloader::CTaskDesc taskDesc(BGDownloader::DLState_CheckPatch); CBGDownloaderAccess::getInstance().requestDownloadThreadPriority(BGDownloader::ThreadPriority_Normal, false); CBGDownloaderAccess::getInstance().startTask(taskDesc, getBGDownloaderCommandLine(), true /* showDownloader */); } +#endif NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); setPatcherStateText("ui:login:checking", ucstring()); @@ -1650,8 +1663,9 @@ void initPatch() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance(); - +#ifdef RYZOM_BG_DOWNLOADER if (!isBGDownloadEnabled()) +#endif { // Get the list of optional categories to patch vector vCategories; @@ -1686,6 +1700,7 @@ void initPatch() } pPM->startPatchThread(vCategories, true); } +#ifdef RYZOM_BG_DOWNLOADER else { // NB : here we only do a part of the download each time @@ -1695,6 +1710,7 @@ void initPatch() NLMISC::CBigFile::getInstance().removeAll(); NLMISC::CStreamedPackageManager::getInstance().unloadAll(); } +#endif NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); CInterfaceElement *closeBtn = CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CLOSE_PATCH); @@ -1840,11 +1856,13 @@ class CAHReboot : public IActionHandler CInterfaceManager *im = CInterfaceManager::getInstance(); try { +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { CBGDownloaderAccess::getInstance().reboot(); } else +#endif { CPatchManager::getInstance()->reboot(); } diff --git a/ryzom/client/src/main_loop.cpp b/ryzom/client/src/main_loop.cpp index 299972b15..bab17a7b6 100644 --- a/ryzom/client/src/main_loop.cpp +++ b/ryzom/client/src/main_loop.cpp @@ -1100,6 +1100,7 @@ bool mainLoop() // Start Bench H_AUTO_USE ( RZ_Client_Main_Loop ) +#ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) { CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance(); @@ -1110,6 +1111,7 @@ bool mainLoop() unpauseBGDownloader(); } } +#endif FPU_CHECKER_ONCE @@ -1281,7 +1283,9 @@ bool mainLoop() // Get Mouse Position. OldMouseX = MouseX; OldMouseY = MouseY; +#ifdef RYZOM_BG_DOWNLOADER updateBGDownloaderUI(); +#endif } // Get the pointer pos diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index d412fa7c8..c06389f0c 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -404,7 +404,7 @@ void impulseUserChars(NLMISC::CBitMemStream &impulse) // if there's a new char for which a key set was wanted, create it now for (uint k = 0; k < CharacterSummaries.size(); ++k) { - if (toLower(CharacterSummaries[k].Name) == toLower(NewKeysCharNameValidated)) + if (toLower(CharacterSummaries[k].Name.toUtf8()) == toLower(NewKeysCharNameValidated)) { // first, stripes server name copyKeySet(lookupSrcKeyFile(GameKeySet), "save/keys_" + buildPlayerNameForSaveFile(NewKeysCharNameValidated) + ".xml"); @@ -1582,8 +1582,8 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) R2::TTeleportContext tpContext = R2::TPContext_Unknown; - ucstring tpReason; - ucstring tpCancelText; + string tpReason; + string tpCancelText; try { @@ -1597,14 +1597,14 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) uint32 size = (uint32)tpInfos.TpReasonParams.size(); uint32 first = 0; - CSString str(tpReason.toString()); + CSString str(tpReason); for (;first != size ; ++first) { std::string value = tpInfos.TpReasonParams[first]; std::string key = NLMISC::toString("%%%u", first +1); str = str.replace( key.c_str(), value.c_str()); } - tpReason = ucstring(str); + tpReason = string(str); tpCancelText = CI18N::get(tpInfos.TpCancelTextId); tpContext = tpInfos.TpContext; } @@ -1612,16 +1612,16 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) } catch (const EStream &) { - tpReason = ucstring("TP Reason"); - tpCancelText = ucstring("Cancel TP"); // for test + tpReason = "TP Reason"; + tpCancelText = "Cancel TP"; // for test // try to deduce tp context from current editor mode switch (R2::getEditor().getMode()) { case R2::CEditor::EditionMode: case R2::CEditor::NotInitialized: tpContext = R2::TPContext_Unknown; - tpReason = ucstring(); - tpCancelText = ucstring(); + tpReason = string(); + tpCancelText = string(); break; case R2::CEditor::GoingToDMMode: case R2::CEditor::TestMode: @@ -1667,7 +1667,7 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) //InitMouseWithCursor(oldHardwareCursor); // reset 'cancel' button - ProgressBar.setTPMessages(ucstring(), ucstring(), ""); + ProgressBar.setTPMessages(string(), string(), ""); // ProgressBar.enableQuitButton(false); // TMP TMP diff --git a/ryzom/client/src/progress.cpp b/ryzom/client/src/progress.cpp index c27e285e1..534ae46e9 100644 --- a/ryzom/client/src/progress.cpp +++ b/ryzom/client/src/progress.cpp @@ -71,7 +71,7 @@ void CProgress::setFontFactor(float temp) _FontFactor = temp; } -void CProgress::newMessage (const ucstring& message) +void CProgress::newMessage (const string& message) { popCropedValues (); _CurrentRootStep++; @@ -249,7 +249,7 @@ void CProgress::internalProgress (float value) for(uint i = 0; i < ClientCfg.Logos.size(); i++) { std::vector res; - explode(ClientCfg.Logos[i], std::string(":"), res); + explode(ClientCfg.Logos[i], string(":"), res); if(res.size()==9 && isetFontSize((uint)(15.f * fontFactor)); TextContext->setHotSpot(UTextContext::BottomLeft); - string uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText.toUtf8() + ") - " + CI18N::get("uiDelayedTPCancel"); + string uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText + ") - " + CI18N::get("uiDelayedTPCancel"); UTextContext::CStringInfo info = TextContext->getStringInfo(uc); float stringX = 0.5f - info.StringWidth/(ClientCfg.Width*2); TextContext->printAt(stringX, 7.f / ClientCfg.Height, uc); @@ -452,8 +452,9 @@ void CProgress::internalProgress (float value) _TPCancelFlag = true; } - +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().update(); +#endif // Display to screen. Driver->swapBuffers(); @@ -474,7 +475,7 @@ void CProgress::internalProgress (float value) } -void CProgress::setTPMessages(const ucstring &tpReason,const ucstring &tpCancelText, const std::string &/* iconName */) +void CProgress::setTPMessages(const string &tpReason,const string &tpCancelText, const string &/* iconName */) { _TPReason = tpReason; _TPCancelText = tpCancelText; @@ -497,7 +498,7 @@ bool CProgress::getTPCancelFlag(bool clearFlag /*=true*/) void CProgress::release() { - setTPMessages(ucstring(), ucstring(), ""); + setTPMessages(string(), string(), string()); _TPCancelFlag = false; } diff --git a/ryzom/client/src/progress.h b/ryzom/client/src/progress.h index 2d50b573f..ee9495028 100644 --- a/ryzom/client/src/progress.h +++ b/ryzom/client/src/progress.h @@ -64,7 +64,7 @@ public: void finish (); // New message - void newMessage (const ucstring& message); + void newMessage (const std::string& message); void setFontFactor(float f); @@ -72,7 +72,7 @@ public: bool ApplyTextCommands; // Set teleport specific message - void setTPMessages(const ucstring &tpReason, const ucstring &tpCancelText, const std::string &iconName); + void setTPMessages(const std::string &tpReason, const std::string &tpCancelText, const std::string &iconName); bool getTPCancelFlag(bool clearFlag = true); @@ -83,7 +83,7 @@ private: // Display a text to describe what is the application going to do. // this function can be call even if texture is NULL, driver or textcontext not initialised - ucstring _ProgressMessage; + std::string _ProgressMessage; // Time since last update sint64 _LastUpdate; @@ -92,8 +92,8 @@ private: uint _CurrentRootStep; uint _RootStepCount; - ucstring _TPReason; - ucstring _TPCancelText; + std::string _TPReason; + std::string _TPCancelText; bool _TPCancelFlag; diff --git a/ryzom/client/src/release.cpp b/ryzom/client/src/release.cpp index 7a7cc91eb..bcbf7259f 100644 --- a/ryzom/client/src/release.cpp +++ b/ryzom/client/src/release.cpp @@ -489,7 +489,9 @@ void releaseMainLoop(bool closeConnection) // Called when Quit from OutGame void releaseOutGame() { +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().release(); +#endif ProgressBar.release(); @@ -571,7 +573,9 @@ void release() CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_GameExit, "login_step_game_exit&play_time=" + toString((NLMISC::CTime::getLocalTime() - StartPlayTime) / 1000))); } +#ifdef RYZOM_BG_DOWNLOADER CBGDownloaderAccess::getInstance().release(); +#endif ProgressBar.release(); diff --git a/ryzom/common/src/game_share/character_summary.h b/ryzom/common/src/game_share/character_summary.h index 34b0f2a86..4397d1146 100644 --- a/ryzom/common/src/game_share/character_summary.h +++ b/ryzom/common/src/game_share/character_summary.h @@ -54,7 +54,7 @@ struct CCharacterSummary TSessionId Mainland; /// name - ucstring Name; + ucstring Name; // TODO: UTF-8 (serial) /// Localisation uint32 Location; diff --git a/ryzom/common/src/game_share/item_infos.h b/ryzom/common/src/game_share/item_infos.h index 1cb32ae41..1a0746f3b 100644 --- a/ryzom/common/src/game_share/item_infos.h +++ b/ryzom/common/src/game_share/item_infos.h @@ -136,9 +136,9 @@ public: CSPhraseCom Enchantment; float WearEquipmentMalus; // Malus for wearing this equipment (malus is used when execute an magic, forage action, craft action...), malus is only applicable for weapon and armor pieces - ucstring CustomText; - ucstring R2ItemDescription; - ucstring R2ItemComment; + ucstring CustomText; // TODO: UTF-8 (serial) + ucstring R2ItemDescription; // TODO: UTF-8 (serial) + ucstring R2ItemComment; // TODO: UTF-8 (serial) uint8 PetNumber; // 1 based pet index //@} }; diff --git a/ryzom/common/src/game_share/mainland_summary.h b/ryzom/common/src/game_share/mainland_summary.h index 81c001caa..98f73439a 100644 --- a/ryzom/common/src/game_share/mainland_summary.h +++ b/ryzom/common/src/game_share/mainland_summary.h @@ -41,10 +41,10 @@ struct CMainlandSummary TSessionId Id; /// description - ucstring Name; + ucstring Name; // TODO: UTF-8 (serial) /// description - ucstring Description; + ucstring Description; // TODO: UTF-8 (serial) /// language code std::string LanguageCode; diff --git a/ryzom/common/src/game_share/msg_client_server.h b/ryzom/common/src/game_share/msg_client_server.h index c66e7856a..ce942291e 100644 --- a/ryzom/common/src/game_share/msg_client_server.h +++ b/ryzom/common/src/game_share/msg_client_server.h @@ -88,7 +88,7 @@ public: class CCheckNameMsg { public: - ucstring Name; + ucstring Name; // TODO: UTF-8 (serial) TSessionId HomeSessionId; void serialBitMemStream(NLMISC::CBitMemStream &f) diff --git a/ryzom/common/src/game_share/sphrase_com.h b/ryzom/common/src/game_share/sphrase_com.h index 476034b2f..dd2c053ae 100644 --- a/ryzom/common/src/game_share/sphrase_com.h +++ b/ryzom/common/src/game_share/sphrase_com.h @@ -63,7 +63,7 @@ public: std::vector Bricks; // Name Of the Phrase. Saved on server, read on client. - ucstring Name; + ucstring Name; // FIXME: UTF-8 (serial) /// The comparison is made only on Bricks bool operator==(const CSPhraseCom &p) const; From 298e9129491c39b9da159733872f1f34eda0f1b0 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 05:22:31 +0800 Subject: [PATCH 11/16] UTF-8 login patcher, ryzom/ryzomcore#335 --- ryzom/client/src/item_group_manager.cpp | 2 +- ryzom/client/src/login.cpp | 90 +++++++++++----------- ryzom/client/src/login_patch.cpp | 86 ++++++++++----------- ryzom/client/src/login_patch.h | 20 ++--- ryzom/tools/client/client_patcher/main.cpp | 4 +- 5 files changed, 101 insertions(+), 101 deletions(-) diff --git a/ryzom/client/src/item_group_manager.cpp b/ryzom/client/src/item_group_manager.cpp index ad35a2a97..2cbb86dac 100644 --- a/ryzom/client/src/item_group_manager.cpp +++ b/ryzom/client/src/item_group_manager.cpp @@ -698,7 +698,7 @@ void CItemGroupManager::listGroup() { CItemGroup group = _Groups[i]; string msg = NLMISC::CI18N::get("cmdListGroupLine"); - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) string nameUC = group.name; NLMISC::strFindReplace(msg, "%name", nameUC); NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size())); diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index e39d406ff..d0f6243b8 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -199,7 +199,7 @@ void setLoginFinished( bool f ) // *************************************************************************** // Pop a fatal error message box, giving the option to 'quit' the client, plus a help button -static void fatalMessageBox(const ucstring &msg) +static void fatalMessageBox(const std::string &msg) { CInterfaceManager *im = CInterfaceManager::getInstance(); im->messageBoxWithHelp(msg, "ui:login", "login_quit"); @@ -207,7 +207,7 @@ static void fatalMessageBox(const ucstring &msg) // *************************************************************************** // Pop an error message box, giving the option to go back to main menu, plus a help button -static void errorMessageBox(const ucstring &msg) +static void errorMessageBox(const std::string &msg) { CInterfaceManager *im = CInterfaceManager::getInstance(); im->messageBoxWithHelp(msg, "ui:login", "on_back_to_login"); @@ -281,25 +281,25 @@ void initEula() } // *************************************************************************** -static void setDataScanLog(const ucstring &text) +static void setDataScanLog(const std::string &text) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log")); if (pVT != NULL) { - pVT->setText(text.toUtf8()); + pVT->setText(text); } } // *************************************************************************** -static void setDataScanState(const ucstring &text, ucstring progress= ucstring()) +static void setDataScanState(const std::string &text, const std::string &progress = string()) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state")); - if (pVT != NULL) pVT->setText(text.toUtf8()); + if (pVT != NULL) pVT->setText(text); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress")); - if (pVT != NULL) pVT->setText(progress.toUtf8()); + if (pVT != NULL) pVT->setText(progress); } void initCatDisplay() @@ -332,24 +332,24 @@ void initReboot() // *************************************************************************** -static void setPatcherStateText(const std::string &baseUIPath, const ucstring &str) +static void setPatcherStateText(const std::string &baseUIPath, const std::string &str) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state")); if (pVT != NULL) { - pVT->setText(str.toUtf8()); + pVT->setText(str); } } // *************************************************************************** -static void setPatcherProgressText(const std::string &baseUIPath, const ucstring &str) +static void setPatcherProgressText(const std::string &baseUIPath, const std::string &str) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress")); if (pVT != NULL) { - pVT->setText(str.toUtf8()); + pVT->setText(str); } } @@ -365,7 +365,7 @@ static void updatePatchingInfoText(const std::string &baseUIPath) if (bgDownloader.getDownloadThreadPriority() == BGDownloader::ThreadPriority_Paused) { setPatcherStateText(baseUIPath, CI18N::get("uiBGD_Paused")); - setPatcherProgressText(baseUIPath, ucstring()); + setPatcherProgressText(baseUIPath, string()); } else { @@ -376,15 +376,15 @@ static void updatePatchingInfoText(const std::string &baseUIPath) } else { - setPatcherProgressText(baseUIPath, ucstring()); + setPatcherProgressText(baseUIPath, string()); } } } else #endif { - ucstring state; - vector log; + string state; + vector log; if(pPM->getThreadState(state, log)) { setPatcherStateText(baseUIPath, state); @@ -394,7 +394,7 @@ static void updatePatchingInfoText(const std::string &baseUIPath) } else { - setPatcherProgressText(baseUIPath, ucstring()); + setPatcherProgressText(baseUIPath, string()); } } } @@ -481,8 +481,8 @@ void loginMainLoop() if (finished) { - setPatcherStateText("ui:login:checking", ucstring()); - setPatcherProgressText("ui:login:checking", ucstring()); + setPatcherStateText("ui:login:checking", string()); + setPatcherProgressText("ui:login:checking", string()); #ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) @@ -561,7 +561,7 @@ void loginMainLoop() } else { - ucstring errMsg = CI18N::get("uiErrChecking"); + string errMsg = CI18N::get("uiErrChecking"); if (!pPM->getLastErrorMessage().empty()) { errMsg = pPM->getLastErrorMessage(); @@ -604,14 +604,14 @@ void loginMainLoop() setDataScanState(CI18N::get("uiScanDataSucess")); else { - ucstring fmt= CI18N::get("uiScanDataErrors"); + string fmt= CI18N::get("uiScanDataErrors"); strFindReplace(fmt, "%d", toString(numFiles)); setDataScanState(fmt); } } else { - ucstring errMsg = CI18N::get("uiErrDataScanning"); + string errMsg = CI18N::get("uiErrDataScanning"); if (!pPM->getLastErrorMessage().empty()) { errMsg = pPM->getLastErrorMessage(); @@ -620,7 +620,7 @@ void loginMainLoop() } // the log may have changed - ucstring dsLog; + string dsLog; if(pPM->getDataScanLog(dsLog)) setDataScanLog(dsLog); } @@ -628,8 +628,8 @@ void loginMainLoop() else { // update inteface content - ucstring state; - vector log; + string state; + vector log; // get state if(pPM->getThreadState(state, log)) { @@ -637,7 +637,7 @@ void loginMainLoop() setDataScanState(state, toString("%d/%d", pPM->getCurrentFilesToGet(), pPM->getTotalFilesToGet())); } // set special data scan log - ucstring dsLog; + string dsLog; if(pPM->getDataScanLog(dsLog)) setDataScanLog(dsLog); } @@ -704,7 +704,7 @@ void loginMainLoop() } else { - ucstring errMsg = CI18N::get("uiErrPatchApply"); + string errMsg = CI18N::get("uiErrPatchApply"); if (!pPM->getLastErrorMessage().empty()) { errMsg = pPM->getLastErrorMessage(); @@ -1157,8 +1157,8 @@ void initPatchCheck() #endif NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); - setPatcherStateText("ui:login:checking", ucstring()); - setPatcherProgressText("ui:login:checking", ucstring()); + setPatcherStateText("ui:login:checking", string()); + setPatcherProgressText("ui:login:checking", string()); } void initShardDisplay() @@ -1717,8 +1717,8 @@ void initPatch() if (closeBtn) closeBtn->setActive(false); - setPatcherStateText("ui:login:patching", ucstring()); - setPatcherProgressText("ui:login:patching", ucstring()); + setPatcherStateText("ui:login:patching", string()); + setPatcherProgressText("ui:login:patching", string()); } // *************************************************************************** @@ -2274,7 +2274,7 @@ void initDataScan() CPatchManager *pPM = CPatchManager::getInstance(); // reset the log - setDataScanLog(ucstring()); + setDataScanLog(string()); // Start Scanning pPM->startScanDataThread(); @@ -2442,26 +2442,26 @@ bool initCreateAccount() if(!CurlHttpClient.sendGet(url, params, pPM->isVerboseLog())) { - ucstring errorMessage("Can't send (error code 60)"); + string errorMessage("Can't send (error code 60)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return false; } string res; if(!CurlHttpClient.receive(res, pPM->isVerboseLog())) { - ucstring errorMessage("Can't receive (error code 61)"); + string errorMessage("Can't receive (error code 61)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return false; } if(res.empty()) { - ucstring errorMessage("Empty result (error code 13)"); + string errorMessage("Empty result (error code 13)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return false; } @@ -2618,9 +2618,9 @@ class CAHOnCreateAccountSubmit : public IActionHandler if (!CurlHttpClient.connect(url)) { - ucstring errorMessage("Can't connect"); + string errorMessage("Can't connect"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } @@ -2645,26 +2645,26 @@ class CAHOnCreateAccountSubmit : public IActionHandler if(!CurlHttpClient.sendPost(url, params, pPM->isVerboseLog())) { - ucstring errorMessage("Can't send (error code 60)"); + string errorMessage("Can't send (error code 60)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } string res; if(!CurlHttpClient.receive(res, pPM->isVerboseLog())) { - ucstring errorMessage("Can't receive (error code 61)"); + string errorMessage("Can't receive (error code 61)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } if(res.empty()) { - ucstring errorMessage("Empty result (error code 13)"); + string errorMessage("Empty result (error code 13)"); errorMessageBox(errorMessage); - nlwarning(errorMessage.toString().c_str()); + nlwarning(errorMessage.c_str()); return; } diff --git a/ryzom/client/src/login_patch.cpp b/ryzom/client/src/login_patch.cpp index 650531773..2b7d0c1ba 100644 --- a/ryzom/client/src/login_patch.cpp +++ b/ryzom/client/src/login_patch.cpp @@ -189,7 +189,7 @@ void CPatchManager::setClientRootPath(const std::string& clientRootPath) } // **************************************************************************** -void CPatchManager::setErrorMessage(const ucstring &message) +void CPatchManager::setErrorMessage(const std::string &message) { _ErrorMessage = message; } @@ -656,7 +656,7 @@ bool CPatchManager::isPatchThreadEnded (bool &ok) // **************************************************************************** // Called in main thread -bool CPatchManager::getThreadState (ucstring &stateOut, vector &stateLogOut) +bool CPatchManager::getThreadState (std::string &stateOut, vector &stateLogOut) { if ((PatchThread == NULL) && (CheckThread == NULL) && (ScanDataThread==NULL)) return false; @@ -685,7 +685,7 @@ bool CPatchManager::getThreadState (ucstring &stateOut, vector &stateL // verbose log if (isVerboseLog() && !stateLogOut.empty()) for (uint32 i = 0; i < stateLogOut.size(); ++i) - nlinfo("%s", stateLogOut[i].toUtf8().c_str()); + nlinfo("%s", stateLogOut[i].c_str()); return changed; } @@ -1120,28 +1120,28 @@ float CPatchManager::getCurrentFileProgress() const // **************************************************************************** void CPatchManager::setRWAccess (const string &filename, bool bThrowException) { - ucstring s = CI18N::get("uiSetAttrib") + " " + CFile::getFilename(filename); + string s = CI18N::get("uiSetAttrib") + " " + CFile::getFilename(filename); setState(true, s); if (!NLMISC::CFile::setRWAccess(filename) && bThrowException) { s = CI18N::get("uiAttribErr") + " " + CFile::getFilename(filename) + " (" + toString(errno) + "," + strerror(errno) + ")"; setState(true, s); - throw Exception (s.toUtf8()); + throw Exception (s); } } // **************************************************************************** string CPatchManager::deleteFile (const string &filename, bool bThrowException, bool bWarning) { - ucstring s = CI18N::get("uiDelFile") + " " + CFile::getFilename(filename); + string s = CI18N::get("uiDelFile") + " " + CFile::getFilename(filename); setState(true, s); if (!NLMISC::CFile::fileExists(filename)) { s = CI18N::get("uiDelNoFile"); setState(true, s); - return s.toUtf8(); + return s; } if (!NLMISC::CFile::deleteFile(filename)) @@ -1150,8 +1150,8 @@ string CPatchManager::deleteFile (const string &filename, bool bThrowException, if(bWarning) setState(true, s); if(bThrowException) - throw Exception (s.toUtf8()); - return s.toUtf8(); + throw Exception (s); + return s; } return ""; } @@ -1159,20 +1159,20 @@ string CPatchManager::deleteFile (const string &filename, bool bThrowException, // **************************************************************************** void CPatchManager::renameFile (const string &src, const string &dst) { - ucstring s = CI18N::get("uiRenameFile") + " " + NLMISC::CFile::getFilename(src); + string s = CI18N::get("uiRenameFile") + " " + NLMISC::CFile::getFilename(src); setState(true, s); if (!NLMISC::CFile::moveFile(dst, src)) { s = CI18N::get("uiRenameErr") + " " + src + " -> " + dst + " (" + toString(errno) + "," + strerror(errno) + ")"; setState(true, s); - throw Exception (s.toUtf8()); + throw Exception (s); } } // **************************************************************************** // Take care this function is called by the thread -void CPatchManager::setState (bool bOutputToLog, const ucstring &ucsNewState) +void CPatchManager::setState (bool bOutputToLog, const string &ucsNewState) { { CSynchronized::CAccessor as(&State); @@ -1342,7 +1342,7 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const try { - ucstring s = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename(srcName); + string s = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename(srcName); setState(true, s); // get the new file @@ -1364,13 +1364,13 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const // if emergency patch server, this is a real issue, rethrow exception if (UsedServer < 0) { - ucstring s = CI18N::get("uiDLFailed"); + string s = CI18N::get("uiDLFailed"); setState(true, s); throw Exception(e.what()); } - ucstring s = CI18N::get("uiDLURIFailed") + " " + serverDisplayPath; + string s = CI18N::get("uiDLURIFailed") + " " + serverDisplayPath; setState(true, s); // this server is unavailable @@ -1384,7 +1384,7 @@ void CPatchManager::getServerFile (const std::string &name, bool bZipped, const // scanned all servers? use alternative if (nextServer == UsedServer) { - ucstring s = CI18N::get("uiNoMoreURI"); + string s = CI18N::get("uiNoMoreURI"); setState(true, s); UsedServer = -1; nlwarning("EXCEPTION CATCH: getServerFile() failed - no alternative found"); @@ -1409,7 +1409,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de try { #ifdef USE_CURL - ucstring s = CI18N::get("uiDLWithCurl") + " " + CFile::getFilename(dest); + string s = CI18N::get("uiDLWithCurl") + " " + CFile::getFilename(dest); setState(true, s); // user agent = nel_launcher @@ -1417,7 +1417,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de CURL *curl; CURLcode res; - ucstring sTranslate = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename (source); + string sTranslate = CI18N::get("uiLoginGetFile") + " " + NLMISC::CFile::getFilename (source); setState(true, sTranslate); CurrentFile = NLMISC::CFile::getFilename (source); @@ -1566,7 +1566,7 @@ void CPatchManager::downloadFile (const string &source, const string &dest, NLMI void CPatchManager::decompressFile (const string &filename) { - ucstring sTranslate = CI18N::get("uiDecompressing") + " " + NLMISC::CFile::getFilename(filename); + string sTranslate = CI18N::get("uiDecompressing") + " " + NLMISC::CFile::getFilename(filename); setState(true, sTranslate); //if(isVerboseLog()) nlinfo("Calling gzopen('%s','rb')", filename.c_str()); @@ -1664,7 +1664,7 @@ void CPatchManager::applyDate (const string &sFilename, uint32 nDate) if(nDate != 0) { setRWAccess(sFilename, false); - ucstring s = CI18N::get("uiChangeDate") + " " + NLMISC::CFile::getFilename(sFilename) + " " + timestampToHumanReadable(NLMISC::CFile::getFileModificationDate (sFilename)) + + string s = CI18N::get("uiChangeDate") + " " + NLMISC::CFile::getFilename(sFilename) + " " + timestampToHumanReadable(NLMISC::CFile::getFileModificationDate (sFilename)) + " -> " + timestampToHumanReadable(nDate); setState(true,s); @@ -1786,7 +1786,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, // If the version cannot be found with size and time try with sha1 if (nVersionFound == 0xFFFFFFFF) { - ucstring sTranslate = CI18N::get("uiCheckInt") + " " + rFilename; + string sTranslate = CI18N::get("uiCheckInt") + " " + rFilename; setState(true, sTranslate); CHashKey hkLocalSHA1 = getSHA1(sFilePath); for (j = 0; j < rFile.versionCount(); ++j) @@ -1806,7 +1806,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, // No version available found if (nVersionFound == 0xFFFFFFFF) { - ucstring sTranslate = CI18N::get("uiNoVersionFound"); + string sTranslate = CI18N::get("uiNoVersionFound"); setState(true, sTranslate); // Get all patches from beginning (first patch is reference file) ftpOut.FileName = rFilename; @@ -1827,7 +1827,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, } else // A version of the file has been found { - ucstring sTranslate = CI18N::get("uiVersionFound") + " " + toString(nVersionFound); + string sTranslate = CI18N::get("uiVersionFound") + " " + toString(nVersionFound); setState(true, sTranslate); // Get All patches from this version ! ftpOut.FileName = rFilename; @@ -1883,7 +1883,7 @@ bool CPatchManager::bnpUnpack(const string &srcBigfile, const string &dstPath, v else DestPath = CPath::standardizePath (dstPath); - ucstring s = CI18N::get("uiUnpack") + " " + NLMISC::CFile::getFilename(SourceName); + string s = CI18N::get("uiUnpack") + " " + NLMISC::CFile::getFilename(SourceName); setState(true,s); // Read Header of the BNP File @@ -1892,7 +1892,7 @@ bool CPatchManager::bnpUnpack(const string &srcBigfile, const string &dstPath, v if (!bnpFile.readHeader()) { - ucstring s = CI18N::get("uiUnpackErrHead") + " " + CFile::getFilename(SourceName); + string s = CI18N::get("uiUnpackErrHead") + " " + CFile::getFilename(SourceName); setState(true,s); return false; } @@ -1938,8 +1938,8 @@ int CPatchManager::validateProgress(void *foo, double t, double d, double /* ult CPatchManager *pPM = CPatchManager::getInstance(); double pour1 = t!=0.0?d*100.0/t:0.0; - ucstring sTranslate = CI18N::get("uiLoginGetFile") + ucstring::makeFromUtf8(toString(" %s : %s / %s (%.02f %%)", NLMISC::CFile::getFilename(pPM->CurrentFile).c_str(), - NLMISC::bytesToHumanReadableUnits((uint64)d, units).c_str(), NLMISC::bytesToHumanReadableUnits((uint64)t, units).c_str(), pour1)); + string sTranslate = CI18N::get("uiLoginGetFile") + toString(" %s : %s / %s (%.02f %%)", NLMISC::CFile::getFilename(pPM->CurrentFile).c_str(), + NLMISC::bytesToHumanReadableUnits((uint64)d, units).c_str(), NLMISC::bytesToHumanReadableUnits((uint64)t, units).c_str(), pour1); pPM->setState(false, sTranslate); if (foo) { @@ -1953,7 +1953,7 @@ void CPatchManager::MyPatchingCB::progress(float f) { CPatchManager *pPM = CPatchManager::getInstance(); double p = 100.0*f; - ucstring sTranslate = CI18N::get("uiApplyingDelta") + ucstring::makeFromUtf8(toString(" %s (%.02f %%)", CFile::getFilename(patchFilename).c_str(), p)); + string sTranslate = CI18N::get("uiApplyingDelta") + toString(" %s (%.02f %%)", CFile::getFilename(patchFilename).c_str(), p); pPM->setState(false, sTranslate); } @@ -2079,7 +2079,7 @@ uint CPatchManager::applyScanDataResult() } // *************************************************************************** -bool CPatchManager::getDataScanLog(ucstring &text) +bool CPatchManager::getDataScanLog(string &text) { text.clear(); bool changed= false; @@ -2092,7 +2092,7 @@ bool CPatchManager::getDataScanLog(ucstring &text) { for(uint i=0;igetClientVersion(); string sServerVersion = pPM->getServerVersion(); - ucstring sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; + string sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; sTranslate += CI18N::get("uiServerVersion") + " (" + sServerVersion + ")"; pPM->setState(true, sTranslate); @@ -2216,7 +2216,7 @@ void CCheckThread::run () for (i = 0; i < rDescFiles.fileCount(); ++i) { CPatchManager::SFileToPatch ftp; - sTranslate = CI18N::get("uiCheckingFile") + " " + ucstring::makeFromUtf8(rDescFiles.getFile(i).getFileName()); + sTranslate = CI18N::get("uiCheckingFile") + " " + rDescFiles.getFile(i).getFileName(); pPM->setState(true, sTranslate); // get list of patch to apply to this file. don't to a full checksum test if possible nlwarning(rDescFiles.getFile(i).getFileName().c_str()); @@ -2408,7 +2408,7 @@ void CCheckThread::run () catch (const Exception &e) { nlwarning("EXCEPTION CATCH: CCheckThread::run() failed"); - ucstring sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); + string sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); pPM->setState(true, CI18N::get("uiCheckEndWithErr")); pPM->setErrorMessage(sTranslate); CheckOk = false; @@ -2478,7 +2478,7 @@ void CPatchThread::run() CurrentFilePatched = 0.f; - ucstring sTranslate; + string sTranslate; try { // First do all ref files @@ -2536,7 +2536,7 @@ void CPatchThread::run() catch(const Exception &e) { nlwarning("EXCEPTION CATCH: CPatchThread::run() failed"); - pPM->setState(true, ucstring(e.what())); + pPM->setState(true, string(e.what())); sTranslate = CI18N::get("uiPatchEndWithErr"); bErr = true; } @@ -2649,7 +2649,7 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP) rFTP.LocalFileExists = false; } - ucstring sTranslate; + string sTranslate; sTranslate = CI18N::get("uiProcessing") + " " + rFTP.FileName; pPM->setState(true, sTranslate); @@ -2984,7 +2984,7 @@ void CScanDataThread::run () uint32 i; // Check if the client version is the same as the server version string sClientVersion = pPM->getClientVersion(); - ucstring sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; + string sTranslate = CI18N::get("uiClientVersion") + " (" + sClientVersion + ") "; pPM->setState(true, sTranslate); // For all bnp in the description file get all patches to apply @@ -3023,7 +3023,7 @@ void CScanDataThread::run () catch (const Exception &e) { nlwarning("EXCEPTION CATCH: CScanDataThread::run() failed"); - ucstring sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); + string sTranslate = CI18N::get("uiCheckEndWithErr") + " " + e.what(); pPM->setState(true, sTranslate); CheckOk = false; Ended = true; @@ -3157,7 +3157,7 @@ bool CPatchManager::download(const std::string& patchFullname, const std::string catch ( const std::exception& e) { nlwarning("%s", e.what()); - pPM->setState(true, ucstring(e.what()) ); + pPM->setState(true, string(e.what()) ); return false; } @@ -3408,7 +3408,7 @@ void CDownloadThread::run() catch ( const std::exception& e) { nlwarning("%s", e.what()); - pPM->setState(true, ucstring(e.what()) ); + pPM->setState(true, string(e.what()) ); pPM->fatalError("uiCanNotDownload", patchName.c_str(), ""); } catch (...) @@ -3525,7 +3525,7 @@ void CInstallThread::run() catch ( const std::exception& e) { nlwarning("%s", e.what()); - pPM->setState(true, ucstring(e.what()) ); + pPM->setState(true, string(e.what()) ); pPM->fatalError("uiCanNotInstall", patchName.c_str(), ""); return; diff --git a/ryzom/client/src/login_patch.h b/ryzom/client/src/login_patch.h index 2b108994d..dfd46b49c 100644 --- a/ryzom/client/src/login_patch.h +++ b/ryzom/client/src/login_patch.h @@ -56,7 +56,7 @@ public: class IPatchManagerStateListener { public: - virtual void setState (bool /* bOutputToLog */, const ucstring &/* ucsNewState */){} + virtual void setState (bool /* bOutputToLog */, const std::string &/* ucsNewState */){} }; // Get Info of file to install @@ -154,12 +154,12 @@ public: // Get the string information about what the threads are doing // Return true if the state has changed - bool getThreadState (ucstring &state, std::vector &stateLog); + bool getThreadState (std::string &state, std::vector &stateLog); /** Get the error message (filled after a patch of check) * May be empty if the cause of error is unknown or unhandled */ - const ucstring &getLastErrorMessage() { return _ErrorMessage; } + const std::string &getLastErrorMessage() { return _ErrorMessage; } // --------------------- // First Part : Checking @@ -235,7 +235,7 @@ public: uint applyScanDataResult(); // get the current info Log for data Scan (true if some change from last get, else text is not filled) - bool getDataScanLog(ucstring &text); + bool getDataScanLog(std::string &text); CProductDescriptionForClient &getDescFile() { return DescFile; } @@ -284,7 +284,7 @@ private: friend class CPatchThreadDownloadProgress; // Set the thread state (called by threads to let us know what they are doing) - void setState (bool bOutputToLog, const ucstring &ucsState); + void setState (bool bOutputToLog, const std::string &ucsState); void touchState(); /// Get the version of the server given during init() @@ -330,7 +330,7 @@ private: // add a file to the scan data log void addDataScanLogCorruptedFile(const SFileToPatch &ftp); void clearDataScanLog(); - static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate); + static void getCorruptedFileInfo(const SFileToPatch &ftp, std::string &sTranslate); static bool downloadAndUnpack(const std::string& patchPath, const std::string& sourceFilename, const std::string& extractPath, const std::string& tmpDirectory, uint32 timestamp); // Forward message to Installation Software @@ -404,7 +404,7 @@ private: std::vector FilesToPatch; std::vector OptionalCat; - ucstring _ErrorMessage; + std::string _ErrorMessage; // Threads CPatchThread *PatchThread; @@ -417,8 +417,8 @@ private: // State struct CState { - ucstring State; - std::vector StateLog; + std::string State; + std::vector StateLog; bool StateChanged; CState() { @@ -470,7 +470,7 @@ private: bool _StartRyzomAtEnd; public: // used by threads to signal error at the end of execution - void setErrorMessage(const ucstring &message); + void setErrorMessage(const std::string &message); }; /** diff --git a/ryzom/tools/client/client_patcher/main.cpp b/ryzom/tools/client/client_patcher/main.cpp index e7d57a335..3f5cb04ee 100644 --- a/ryzom/tools/client/client_patcher/main.cpp +++ b/ryzom/tools/client/client_patcher/main.cpp @@ -252,8 +252,8 @@ int main(int argc, char *argv[]) pPM->init(patchURLs, PatchUrl, ""); pPM->startCheckThread(true /* include background patchs */); - ucstring state; - vector log; + string state; + vector log; bool res = false; bool finished = false; From 52e3ca024fed660ecc925466c7bc960668d7a12a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 05:40:32 +0800 Subject: [PATCH 12/16] UTF-8 various, ryzom/ryzomcore#335 --- .../src/interface_v3/group_html_forum.cpp | 8 +-- .../src/interface_v3/group_html_mail.cpp | 8 +-- .../src/interface_v3/group_html_webig.cpp | 6 +-- ryzom/client/src/net_manager.cpp | 54 +++++++++---------- ryzom/client/src/progress.cpp | 6 +-- .../client/src/r2/displayer_visual_entity.cpp | 10 ++-- ryzom/client/src/string_manager_client.cpp | 28 +++++----- ryzom/client/src/string_manager_client.h | 12 ++--- ryzom/client/src/text_manager.cpp | 13 ++--- ryzom/client/src/text_manager.h | 12 +++-- ryzom/client/src/user_entity.cpp | 7 ++- ryzom/client/src/user_entity.h | 4 +- 12 files changed, 82 insertions(+), 86 deletions(-) diff --git a/ryzom/client/src/interface_v3/group_html_forum.cpp b/ryzom/client/src/interface_v3/group_html_forum.cpp index 4b74732f3..e6e6ff34f 100644 --- a/ryzom/client/src/interface_v3/group_html_forum.cpp +++ b/ryzom/client/src/interface_v3/group_html_forum.cpp @@ -58,7 +58,7 @@ CGroupHTMLForum::~CGroupHTMLForum() void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); const SGuild &guild = CGuildManager::getInstance()->getGuild(); string gname = guild.Name; @@ -76,7 +76,7 @@ void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) url += ((url.find('?') != string::npos) ? "&" : "?") + string("shard=") + toString(CharacterHomeSessionId) + - string("&user_login=") + user_name.toString() + + string("&user_login=") + user_name + string("&forum=") + gname + string("&session_cookie=") + NetMngr.getLoginCookie().toString(); } @@ -90,14 +90,14 @@ void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) void CGroupHTMLForum::addHTTPPostParams (SFormFields &formfields, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); const SGuild &guild = CGuildManager::getInstance()->getGuild(); string gname = guild.Name; if (!gname.empty()) { formfields.add("shard", toString(CharacterHomeSessionId)); - formfields.add("user_login", user_name.toString()); + formfields.add("user_login", user_name); formfields.add("forum", gname); formfields.add("session_cookie", NetMngr.getLoginCookie().toString()); } diff --git a/ryzom/client/src/interface_v3/group_html_mail.cpp b/ryzom/client/src/interface_v3/group_html_mail.cpp index ac2241523..eb49e5d78 100644 --- a/ryzom/client/src/interface_v3/group_html_mail.cpp +++ b/ryzom/client/src/interface_v3/group_html_mail.cpp @@ -57,10 +57,10 @@ CGroupHTMLMail::~CGroupHTMLMail() void CGroupHTMLMail::addHTTPGetParams (string &url, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); url += ((url.find('?') != string::npos) ? "&" : "?") + string("shard=") + toString(CharacterHomeSessionId) + - string("&user_login=") + user_name.toString() + + string("&user_login=") + user_name + // FIXME: UrlEncode string("&session_cookie=") + NetMngr.getLoginCookie().toString() + string("&lang=") + CI18N::getCurrentLanguageCode(); } @@ -69,9 +69,9 @@ void CGroupHTMLMail::addHTTPGetParams (string &url, bool /*trustedDomain*/) void CGroupHTMLMail::addHTTPPostParams (SFormFields &formfields, bool /*trustedDomain*/) { - ucstring user_name = UserEntity->getLoginName (); + string user_name = UserEntity->getLoginName (); formfields.add("shard", toString(CharacterHomeSessionId)); - formfields.add("user_login", user_name.toString()); + formfields.add("user_login", user_name); // FIXME: UrlEncode formfields.add("session_cookie", NetMngr.getLoginCookie().toString()); formfields.add("lang", CI18N::getCurrentLanguageCode()); } diff --git a/ryzom/client/src/interface_v3/group_html_webig.cpp b/ryzom/client/src/interface_v3/group_html_webig.cpp index d190b83b6..7dda8b004 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -66,7 +66,7 @@ static string getWebAuthKey() // authkey = uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; string rawKey = toString(CharacterHomeSessionId) + - UserEntity->getLoginName().toString() + + UserEntity->getLoginName() + toString(cid) + NetMngr.getLoginCookie().toString(); string key = getMD5((const uint8*)rawKey.c_str(), (uint32)rawKey.size()).toString(); @@ -85,7 +85,7 @@ void addWebIGParams (string &url, bool trustedDomain) uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; url += ((url.find('?') != string::npos) ? "&" : "?") + string("shardid=") + toString(CharacterHomeSessionId) + - string("&name=") + UserEntity->getLoginName().toUtf8() + + string("&name=") + UserEntity->getLoginName() + // FIXME: UrlEncode string("&lang=") + CI18N::getCurrentLanguageCode() + string("&datasetid=") + toString(UserEntity->dataSetId()) + string("&ig=1"); @@ -384,7 +384,7 @@ void CGroupHTMLAuth::addHTTPPostParams (SFormFields &formfields, bool trustedDom uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; formfields.add("shardid", toString(CharacterHomeSessionId)); - formfields.add("name", UserEntity->getLoginName().toUtf8()); + formfields.add("name", UserEntity->getLoginName()); formfields.add("lang", CI18N::getCurrentLanguageCode()); formfields.add("ig", "1"); if (trustedDomain) diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index c06389f0c..2c94b956d 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -614,8 +614,8 @@ static CInterfaceChatDisplayer InterfaceChatDisplayer; void CInterfaceChatDisplayer::colorizeSender(string &text, const string &senderName, CRGBA baseColor) { // find the sender/text separator to put color tags - ucstring::size_type pos = senderName.length() - 1; - if (pos != ucstring::npos) + string::size_type pos = senderName.length() - 1; + if (pos != string::npos) { string str; @@ -666,7 +666,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c for(;;) { string::size_type index = finalString.find("{break}"); - if (index == ucstring::npos) break; + if (index == string::npos) break; finalString = finalString.substr(0, index) + finalString.substr(index+7,finalString.size()); } @@ -819,7 +819,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c else { string::size_type index = finalString.find(""); - if (index != ucstring::npos) + if (index != string::npos) { bubbleWanted = false; finalString = finalString.substr(index+6,finalString.size()); @@ -1015,7 +1015,7 @@ void inpulseDynStringInChatGroup(NLMISC::CBitMemStream &impulse) // impulse.serialBit(huff); // // uint32 index; -// ucstring ucstr; +// ucstring ucstr; // OLD // // impulse.serial( index ); // impulse.serial( ucstr ); @@ -1109,15 +1109,15 @@ void setFakeNews () CViewText *inter2 = (CViewText *)inter->getView("title0"); nlassert (inter2 != NULL); - inter2->setText(ucstring(shortNews[rnd*3])); + inter2->setText(ucstring(shortNews[rnd*3])); // OLD CViewText *inter3 = (CViewText *)inter->getView("title1"); nlassert (inter3 != NULL); - inter3->setText(ucstring(shortNews[rnd*3+1])); + inter3->setText(ucstring(shortNews[rnd*3+1])); // OLD CViewText *inter4 = (CViewText *)inter->getView("title2"); nlassert (inter4 != NULL); - inter4->setText(ucstring(shortNews[rnd*3+2])); + inter4->setText(ucstring(shortNews[rnd*3+2])); // OLD } { // set test for the neutral main string iname; @@ -1134,11 +1134,11 @@ void setFakeNews () CViewText *inter2 = (CViewText *)inter->getView("title0"); nlassert (inter2 != NULL); - inter2->setText(ucstring(shortNews[rnd*3])); + inter2->setText(ucstring(shortNews[rnd*3])); // OLD CViewText *inter3 = (CViewText *)inter->getView("title1"); nlassert (inter3 != NULL); - inter3->setText(ucstring(shortNews[rnd*3+1])); + inter3->setText(ucstring(shortNews[rnd*3+1])); // OLD } { // set test for the more news string iname; @@ -1155,15 +1155,15 @@ void setFakeNews () CViewText *inter2 = (CViewText *)inter->getView("title0"); nlassert (inter2 != NULL); - inter2->setText(ucstring(longNews[rnd*3])); + inter2->setText(ucstring(longNews[rnd*3])); // OLD CViewText *inter3 = (CViewText *)inter->getView("title1"); nlassert (inter3 != NULL); - inter3->setText(ucstring(longNews[rnd*3+1])); + inter3->setText(ucstring(longNews[rnd*3+1])); // OLD CViewText *inter4 = (CViewText *)inter->getView("title2"); nlassert (inter4 != NULL); - inter4->setText(ucstring(longNews[rnd*3+2])); + inter4->setText(ucstring(longNews[rnd*3+2])); // OLD } } } @@ -1180,7 +1180,7 @@ void setFakeNews () static void setupBotChatChoiceList(CInterfaceGroup *botChatGroup) { // Temp for test. Should then be read from server msg - std::vector choices; + std::vector choices; for(uint k = 0; k < 90; ++k) { choices.push_back("Choice " + toString(k)); @@ -1195,7 +1195,7 @@ static void setupBotChatChoiceList(CInterfaceGroup *botChatGroup) /* static void setupBotChatDescription(CInterfaceGroup *botChatGroup) { - ucstring desc; + string desc; for(uint k = 0; k < 90; ++k) { desc += "This is a multi line description. "; @@ -1216,7 +1216,7 @@ static void setupBotChatBotGift(CInterfaceGroup *botChatGroup) NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:0:QUALITY")->setValue32(0); NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:1:SHEET")->setValue32(CSheetId("fyros_sword_lvl_01_05.item").asInt()); NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:1:QUALITY")->setValue32(2); - CBotChat::setBotGift(botChatGroup, ucstring("Thanks to have succeeded the mission"), ucstring("Here's your reward"), ucstring("The bot has taken the object quest from your inventory")); + CBotChat::setBotGift(botChatGroup, "Thanks to have succeeded the mission", "Here's your reward", "The bot has taken the object quest from your inventory"); } */ @@ -1798,7 +1798,7 @@ void impulseTeamContactInit(NLMISC::CBitMemStream &impulse) { vector vFriendListName; vector vFriendListOnline; - vector vIgnoreListName; + vector vIgnoreListName; // TODO: UTF-8 (serial) impulse.serialCont(vFriendListName); uint32 nbState; @@ -2136,9 +2136,9 @@ void impulseWhere(NLMISC::CBitMemStream &impulse) void impulseWho(NLMISC::CBitMemStream &impulse) { nlinfo("impulseWho Received"); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Players currently in the game :")); + CInterfaceManager::getInstance()->displaySystemInfo("Players currently in the game :"); - ucstring name; + ucstring name; // OLD uint32 loginId; uint16 dist; uint8 dirshort; @@ -2176,7 +2176,7 @@ void impulseWho(NLMISC::CBitMemStream &impulse) }; str = toString (" - uid %d - distance %hu meters - direction ", loginId, dist); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name + ucstring(str) + CI18N::get(txts[direction]))); + CInterfaceManager::getInstance()->displaySystemInfo(name + str + CI18N::get(txts[direction])); } }// impulseWho // */ @@ -2185,9 +2185,9 @@ void impulseWho(NLMISC::CBitMemStream &impulse) void impulseWhoGM(NLMISC::CBitMemStream &impulse) { nlinfo("impulseWhoGM Received"); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Players currently in the game :")); + CInterfaceManager::getInstance()->displaySystemInfo("Players currently in the game :"); - ucstring name; + ucstring name; // OLD uint32 loginId; uint16 dist; uint8 dirshort; @@ -2225,7 +2225,7 @@ void impulseWhoGM(NLMISC::CBitMemStream &impulse) }; str = toString (" - uid %d - distance %hu meters - direction ", loginId, dist); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name + ucstring(str) + CI18N::get(txts[direction]))); + CInterfaceManager::getInstance()->displaySystemInfo(name + str + CI18N::get(txts[direction])); } }// impulseWho // */ @@ -3115,12 +3115,12 @@ void impulsePVPChooseClan(NLMISC::CBitMemStream &impulse) CCtrlTextButton * butClan1 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan1")); if( butClan1 == NULL ) return; - butClan1->setText( ucstring(EGSPD::CPeople::toString( clan1 )) ); + butClan1->setText( EGSPD::CPeople::toString( clan1 ) ); CCtrlTextButton * butClan2 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan2")); if( butClan2 == NULL ) return; - butClan2->setText( ucstring(EGSPD::CPeople::toString( clan2 )) ); + butClan2->setText( EGSPD::CPeople::toString( clan2 ) ); } */ @@ -3316,8 +3316,8 @@ private: if(i!=digitMaxEnd) { // get the width - ucstring digitStr= contentStr.substr(digitStart, i-digitStart); - fromString(digitStr.toString(), w); + string digitStr= contentStr.substr(digitStart, i-digitStart); + fromString(digitStr, w); // remove the first tag contentStr= contentStr.substr(i+1); } diff --git a/ryzom/client/src/progress.cpp b/ryzom/client/src/progress.cpp index 534ae46e9..620b5486d 100644 --- a/ryzom/client/src/progress.cpp +++ b/ryzom/client/src/progress.cpp @@ -312,7 +312,7 @@ void CProgress::internalProgress (float value) // More help TextContext->setFontSize((uint)(12.f * fontFactor)); /* todo tips of the day uncomment - ucstring ucstr = CI18N::get ("uiTipsEnd"); + string ucstr = CI18N::get ("uiTipsEnd"); TextContext->printAt(0.5f, fY, ucstr); */ fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); @@ -360,11 +360,9 @@ void CProgress::internalProgress (float value) (uint)RT.getRyzomTime(), CI18N::get ("uiSeason"+toStringEnum(CRyzomTime::getSeasonByDay(day))).c_str(), CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName).c_str()); - ucstring ucstr; - ucstr.fromUtf8 (str); TextContext->setHotSpot(UTextContext::MiddleBottom); TextContext->setColor(CRGBA(186, 179, 163, 255)); - TextContext->printAt(0.5f, 25/768.f, ucstr); + TextContext->printAt(0.5f, 25/768.f, str); } // apply text commands diff --git a/ryzom/client/src/r2/displayer_visual_entity.cpp b/ryzom/client/src/r2/displayer_visual_entity.cpp index 01eaf0bc0..81c24342a 100644 --- a/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -968,9 +968,7 @@ void CDisplayerVisualEntity::updateName() //H_AUTO(R2_CDisplayerVisualEntity_updateName) if (!_Entity) return; - std::string name = getString(&getProps(), "Name"); - ucstring ucName; - ucName.fromUtf8(name); + std::string ucName = getString(&getProps(), "Name"); if (ucName.empty()) { ucName = CI18N::get("uiR2EDNoName"); @@ -1011,13 +1009,11 @@ void CDisplayerVisualEntity::updateName() actName = NLMISC::toString(" [%s]", actName.c_str()); - ucstring ucActName; - ucActName.fromUtf8(actName); - ucName += ucActName; + ucName += actName; { //BENCH(setEntityName) - _Entity->setEntityName(ucName.toUtf8()); + _Entity->setEntityName(ucName); } { //BENCH(buildInSceneInterface) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 79a0ee36d..71b8ddc81 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -971,7 +971,7 @@ restartLoop: return referenceFile; } - void CLoadProxy::loadStringFile(const string &filename, ucstring &text) + void CLoadProxy::loadStringFile(const string &filename, ucstring &text) // TODO: UTF-8 (serial) { vector reference; vector addition; @@ -1015,7 +1015,7 @@ restartLoop: context.Diff.push_back(context.Addition[addIndex]); //nldebug("Adding new string '%s' in CI18N", context.Addition[addIndex].Identifier.c_str()); if (ClientCfg.DebugStringManager) - context.Diff.back().Text = ucstring("")+context.Diff.back().Text; + context.Diff.back().Text = ucstring("")+context.Diff.back().Text; // TODO: UTF-8 (serial) } void CLoadProxy::onRemove(uint /* addIndex */, uint /* refIndex */, TStringDiffContext &/* context */) { @@ -1027,7 +1027,7 @@ restartLoop: context.Diff.push_back(context.Addition[addIndex]); //nldebug("Using changed string '%s' in CI18N", context.Addition[addIndex].Identifier.c_str()); if (ClientCfg.DebugStringManager) - context.Diff.back().Text = ucstring("")+context.Diff.back().Text; + context.Diff.back().Text = ucstring("")+context.Diff.back().Text; // TODO: UTF-8 (serial) } void CLoadProxy::onSwap(uint /* newIndex */, uint /* refIndex */, TStringDiffContext &/* context */) { @@ -1041,7 +1041,7 @@ restartLoop: class CReadWorkSheetFile : public TWorkSheetDiff::IDiffCallback { public: - void readWorkSheetFile(const string &filename, ucstring &text) + void readWorkSheetFile(const string &filename, ucstring &text) // TODO: UTF-8 (serial) { TWorksheet addition; TWorksheet reference; @@ -1178,9 +1178,9 @@ bool CStringManagerClient::checkWordFileDates(vector &fileChecks, co // *************************************************************************** void CStringManagerClient::initI18NSpecialWords(const string &languageCode) { - ucstring womenNameColIdent = ucstring("women_name"); - ucstring descColIdent = ucstring("description"); - ucstring descColIdent2 = ucstring("description2"); + ucstring womenNameColIdent = ucstring("women_name"); // TODO: UTF-8 (serial) + ucstring descColIdent = ucstring("description"); // TODO: UTF-8 (serial) + ucstring descColIdent2 = ucstring("description2"); // TODO: UTF-8 (serial) // List of words to append to the local CI18N system. static const char *specialWords[]= @@ -1219,11 +1219,11 @@ void CStringManagerClient::initI18NSpecialWords(const string &languageCode) { uint32 profile0= (uint32)ryzomGetLocalTime(); - ucstring ucs; + ucstring ucs; // TODO: UTF-8 (serial) string fileName = fileNames[i]; string keyExtenstion = specialWords[i*3+2]; - // read the ucstring and make diffs with data in ./translation/work. + // read the ucstring and make diffs with data in ./translation/work. // TODO: UTF-8 (serial) CReadWorkSheetFile rwsf; rwsf.readWorkSheetFile(fileName, ucs); if(ucs.empty()) @@ -1235,9 +1235,9 @@ void CStringManagerClient::initI18NSpecialWords(const string &languageCode) // Get the Key and Data ColIndex. uint nameColIndex = 0, keyColIndex = 0; - if( !ws.findCol(ucstring("name"), nameColIndex) ) + if( !ws.findCol(ucstring("name"), nameColIndex) ) // TODO: UTF-8 (serial) continue; - if( !ws.findCol(ucstring(specialWords[i*3+1]), keyColIndex) ) + if( !ws.findCol(ucstring(specialWords[i*3+1]), keyColIndex) ) // TODO: UTF-8 (serial) continue; // Get the women name index if possible. @@ -1282,7 +1282,7 @@ void CStringManagerClient::initI18NSpecialWords(const string &languageCode) // insert in map of Women Name if OK. if(womenNameColIndex!=std::numeric_limits::max()) { - const ucstring &womenName= ws.getData(j, womenNameColIndex); + const ucstring &womenName= ws.getData(j, womenNameColIndex); // TODO: UTF-8 (serial) _SpecItem_TempMap[keyStr].WomenName= womenName.toUtf8(); // replace all \n in the women name with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n")); @@ -1291,7 +1291,7 @@ void CStringManagerClient::initI18NSpecialWords(const string &languageCode) // insert in map of Description if OK. if(descColIndex!=std::numeric_limits::max()) { - const ucstring &desc= ws.getData(j, descColIndex); + const ucstring &desc= ws.getData(j, descColIndex); // TODO: UTF-8 (serial) _SpecItem_TempMap[keyStr].Desc= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n")); @@ -1300,7 +1300,7 @@ void CStringManagerClient::initI18NSpecialWords(const string &languageCode) // insert in map of Description2 if OK. if(descColIndex2!=std::numeric_limits::max()) { - const ucstring &desc= ws.getData(j, descColIndex2); + const ucstring &desc= ws.getData(j, descColIndex2); // TODO: UTF-8 (serial) _SpecItem_TempMap[keyStr].Desc2= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n")); diff --git a/ryzom/client/src/string_manager_client.h b/ryzom/client/src/string_manager_client.h index 864c80c1f..e3cd736fd 100644 --- a/ryzom/client/src/string_manager_client.h +++ b/ryzom/client/src/string_manager_client.h @@ -187,7 +187,7 @@ private: struct TStringWaiter { - /// Pointer to the ucstring to fill + /// Pointer to the utf-8 string to fill std::string *Result; /// Pointer to the remover that contains this string reference const IStringWaiterRemover *Remover; @@ -277,10 +277,10 @@ private: else { nlassert(f.isReading()); - ucstring name; - ucstring womenName; - ucstring desc; - ucstring desc2; + ucstring name; // Old UTF-16 serial + ucstring womenName; // Old UTF-16 serial + ucstring desc; // Old UTF-16 serial + ucstring desc2; // Old UTF-16 serial f.serial(name); if (ver >= 1) f.serial(womenName); @@ -419,7 +419,7 @@ public: */ class CLoadProxy : public NLMISC::CI18N::ILoadProxy, public TStringDiff::IDiffCallback { - void loadStringFile(const std::string &filename, ucstring &text); + void loadStringFile(const std::string &filename, ucstring &text); // TODO: UTF-8 (serial) void onEquivalent(uint addIndex, uint refIndex, TStringDiffContext &context); void onAdd(uint addIndex, uint refIndex, TStringDiffContext &context); diff --git a/ryzom/client/src/text_manager.cpp b/ryzom/client/src/text_manager.cpp index bb78bffff..9873b4986 100644 --- a/ryzom/client/src/text_manager.cpp +++ b/ryzom/client/src/text_manager.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . - +#if 0 #include "stdpch.h" @@ -55,14 +55,14 @@ CTextManager::CTextManager() //----------------------------------------------- /// Return the text according to the Id. //----------------------------------------------- -ucstring CTextManager::text(uint textId) +ucstring CTextManager::text(uint textId) // OLD { - map::iterator it = _Texts.find(textId); + map::iterator it = _Texts.find(textId); // OLD if(it != _Texts.end()) return (*it).second; // Return an empty string. - return ucstring(); + return ucstring(); // OLD } //----------------------------------------------- @@ -70,13 +70,14 @@ ucstring CTextManager::text(uint textId) //----------------------------------------------- void CTextManager::text(uint textId, const std::string &str) { - _Texts.insert(make_pair(textId, ucstring(str))); + _Texts.insert(make_pair(textId, ucstring(str))); // OLD } //----------------------------------------------- /// Set the text for 'textId'. //----------------------------------------------- -void CTextManager::text(uint textId, const ucstring &str) +void CTextManager::text(uint textId, const ucstring &str) // OLD { _Texts.insert(make_pair(textId, str)); } +#endif diff --git a/ryzom/client/src/text_manager.h b/ryzom/client/src/text_manager.h index 371d6bac9..d154541e3 100644 --- a/ryzom/client/src/text_manager.h +++ b/ryzom/client/src/text_manager.h @@ -14,8 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// Lost code - +#if 0 #ifndef NL_TEXT_MANAGER_H #define NL_TEXT_MANAGER_H @@ -25,7 +26,7 @@ ///////////// // Misc #include "nel/misc/types_nl.h" -#include "nel/misc/ucstring.h" +#include "nel/misc/ucstring.h" // OLD // Std #include @@ -42,18 +43,18 @@ class CTextManager { protected: - std::map _Texts; + std::map _Texts; // OLD public: /// Constructor CTextManager(); /// Return the text according to the Id. - ucstring text(uint textId); + ucstring text(uint textId); // OLD /// Set the text for 'textId'. void text(uint textId, const std::string &str); /// Set the text for 'textId'. - void text(uint textId, const ucstring &str); + void text(uint textId, const ucstring &str); // OLD }; @@ -65,5 +66,6 @@ extern CTextManager TextMngr; #endif // NL_TEXT_MANAGER_H +#endif /* End of text_manager.h */ diff --git a/ryzom/client/src/user_entity.cpp b/ryzom/client/src/user_entity.cpp index b2dcb0cab..dce3191dd 100644 --- a/ryzom/client/src/user_entity.cpp +++ b/ryzom/client/src/user_entity.cpp @@ -3078,7 +3078,7 @@ void CUserEntity::setAFK(bool b, string afkTxt) nlwarning("CUserEntity:setAFK: unknown message named '%s'.", msgName.c_str()); // custom afk txt - ucstring ucstr; + ucstring ucstr; // TODO: UTF-8 (serial) ucstr.fromUtf8( afkTxt ); CBitMemStream outTxt; static const string msgNameTxt = "STRING:AFK_TXT"; @@ -3828,11 +3828,10 @@ void CUserEntity::CSkillPointsObserver::update(ICDBNode* node ) string deltaStr = toString("%+d", delta); // get the sp title - ucstring spTitle; - spTitle= CI18N::get(toString("uiSkillPointsBold%d",SpType)); + const string &spTitle = CI18N::get(toString("uiSkillPointsBold%d",SpType)); // run the popup - CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+deltaStr+"|text0="+spTitle.toUtf8()); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+deltaStr+"|text0="+spTitle); // Context help contextHelp ("skill_point"); diff --git a/ryzom/client/src/user_entity.h b/ryzom/client/src/user_entity.h index 382a7d810..3dccc362a 100644 --- a/ryzom/client/src/user_entity.h +++ b/ryzom/client/src/user_entity.h @@ -485,7 +485,7 @@ public: /// true if current behaviour allows to change front bool canChangeFront(); - ucstring getLoginName() + string getLoginName() { if (_LoginName.empty()) _LoginName = getDisplayName(); @@ -772,7 +772,7 @@ private: CItemSnapshot _PreviousRightHandItem; CItemSnapshot _PreviousLeftHandItem; - ucstring _LoginName; + std::string _LoginName; }; /// Out game received position From c27547c3a3bfc2f53130a186a862212f76e2f707 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 06:23:58 +0800 Subject: [PATCH 13/16] UTF-8 various, ryzom/ryzomcore#335 --- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 18 +++++----- ryzom/client/src/login.cpp | 34 +++++++------------ ryzom/client/src/misc.cpp | 4 +-- ryzom/client/src/misc.h | 4 +-- ryzom/client/src/net_manager.cpp | 2 +- .../src/game_share/bg_downloader_msg.cpp | 4 +-- .../common/src/game_share/bg_downloader_msg.h | 2 +- 9 files changed, 32 insertions(+), 40 deletions(-) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 963093235..1b36c91d5 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2413,7 +2413,7 @@ void CInterfaceManager::messageBox(const ucstring &text, const string &masterGro // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, +void CInterfaceManager::messageBoxWithHelp(const std::string &text, const std::string &masterGroup, const std::string &ahOnOk, const std::string ¶msOnOk, TCaseMode caseMode) { diff --git a/ryzom/client/src/interface_v3/interface_manager.h b/ryzom/client/src/interface_v3/interface_manager.h index 2aed09dc5..91178677d 100644 --- a/ryzom/client/src/interface_v3/interface_manager.h +++ b/ryzom/client/src/interface_v3/interface_manager.h @@ -310,7 +310,7 @@ public: * The help button with open a browser on ryzom.com faq * ui:interface:message_box_with_help must be defined in xml, with a "text" ViewText son */ - void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup="ui:interface", + void messageBoxWithHelp(const std::string &text, const std::string &masterGroup="ui:interface", const std::string &ahOnOk = std::string(), const std::string ¶msOnOk= std::string(), TCaseMode caseMode = CaseFirstSentenceLetterUp); diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 4e6599fa1..0e97c73f7 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -527,9 +527,9 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), // TODO: Lua UTF-8 + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), // TODO: Lua UTF-8 + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), // TODO: Lua UTF-8 luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), LUABIND_FUNC(replacePvpEffectParam), LUABIND_FUNC(secondsSince1970ToHour), @@ -2929,23 +2929,23 @@ void CLuaIHMRyzom::messageBox(const std::string &text) } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) // TODO: Lua UTF-8 { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text); + pIM->messageBoxWithHelp(text.toUtf8()); } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) // TODO: Lua UTF-8 { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup); + pIM->messageBoxWithHelp(text.toUtf8(), masterGroup); } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) // TODO: Lua UTF-8 { if (caseMode < 0 || caseMode >= CaseCount) { @@ -2954,7 +2954,7 @@ void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string & //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup, "" , "", (TCaseMode) caseMode); + pIM->messageBoxWithHelp(text.toUtf8(), masterGroup, "" , "", (TCaseMode) caseMode); } // *************************************************************************** diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index d0f6243b8..bedd66f7c 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -243,7 +243,7 @@ void createOptionalCatUI() pVT = dynamic_cast(pNewLine->getView("size")); if (pVT != NULL) { - pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size).toUtf8()); + pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size)); } // Add to the list @@ -467,8 +467,8 @@ void loginMainLoop() bool res = false; BGDownloader::TTaskResult taskResult = BGDownloader::TaskResult_Unknown; bool finished = false; - ucstring bgDownloaderError; #ifdef RYZOM_BG_DOWNLOADER + string bgDownloaderError; if (isBGDownloadEnabled()) { finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); @@ -657,7 +657,7 @@ void loginMainLoop() totalPatchSize = bgDownloader.getTotalSize(); BGDownloader::TTaskResult taskResult; bool finished = false; - ucstring bgDownloaderError; + string bgDownloaderError; finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); if (finished) { @@ -670,8 +670,8 @@ void loginMainLoop() if (taskResult == BGDownloader::TaskResult_Error) { - setPatcherStateText("ui:login:patching", ucstring()); - setPatcherProgressText("ui:login:patching", ucstring()); + setPatcherStateText("ui:login:patching", string()); + setPatcherProgressText("ui:login:patching", string()); if (!fatalMessageBoxShown) { @@ -723,10 +723,10 @@ void loginMainLoop() } CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE_PATCH)); - ucstring sTmp; + string sTmp; sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); - if (pVT != NULL) pVT->setText(sTmp.toUtf8()); + if (pVT != NULL) pVT->setText(sTmp); } // else if (screen == UI_VARIABLES_SCREEN_CATDISP) // If we are displaying patch info else if (LoginSM.getCurrentState() == CLoginStateMachine::st_display_cat) @@ -775,10 +775,10 @@ void loginMainLoop() // Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize).toUtf8()); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize)); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize).toUtf8()); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize)); } } } @@ -802,7 +802,7 @@ void initLoginScreen() // version std::string ext; - if (ClientApp.find("ryzom_") != ucstring::npos) + if (ClientApp.find("ryzom_") != string::npos) ext = " (" + ClientApp.substr(6) + ")"; CViewText *pV = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:ver_value")); @@ -1878,7 +1878,7 @@ class CAHReboot : public IActionHandler } catch (const std::exception &e) { - im->messageBoxWithHelp(ucstring::makeFromUtf8(e.what()), "ui:login", "login_quit"); + im->messageBoxWithHelp(e.what(), "ui:login", "login_quit"); } } }; @@ -2354,10 +2354,6 @@ inline string parseTooltip(const string & initString, const string & tagName) tooltip = tooltip.substr(0, tooltip.find("<")); } - ucstring uc; - uc.fromUtf8(tooltip);; - tooltip = uc.toString(); - return tooltip; } @@ -2377,10 +2373,6 @@ inline string parseCommentError(const string & initString, const string & tagNam error = error.substr(0, error.find("<")); } - ucstring uc; - uc.fromUtf8(error);; - error = uc.toString(); - return error; } @@ -3304,7 +3296,7 @@ void loginIntro() if (i != 0) { beginLoading(IntroNVidia); - ucstring nmsg(""); + string nmsg(""); ProgressBar.newMessage (nmsg); } @@ -3330,7 +3322,7 @@ void loginIntro() Driver->AsyncListener.isKeyPushed (KeySPACE)) break; - const ucstring nmsg(""); + const string nmsg(""); ProgressBar.newMessage (nmsg); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); diff --git a/ryzom/client/src/misc.cpp b/ryzom/client/src/misc.cpp index 9816202d4..4e35cfc2a 100644 --- a/ryzom/client/src/misc.cpp +++ b/ryzom/client/src/misc.cpp @@ -879,7 +879,7 @@ NLMISC::CRGBA interpClientCfgColor(const string &src, string &dest) if (src[0] == '&') { string::size_type nextPos = src.find('&', 1); - if (nextPos != ucstring::npos) + if (nextPos != string::npos) { std::string colorCode; colorCode.resize(nextPos - 1); @@ -980,7 +980,7 @@ std::string getStringCategoryIfAny(const string &src, string &dest) // *************************************************************************** -sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1) +sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1) // OLD { // start const ucchar *start1= s1.c_str(); diff --git a/ryzom/client/src/misc.h b/ryzom/client/src/misc.h index 96568c22e..c48b18137 100644 --- a/ryzom/client/src/misc.h +++ b/ryzom/client/src/misc.h @@ -193,8 +193,8 @@ enum TFilter3d RYZOM_MAX_FILTER_3D, }; -// compare 2 ucstring s0 and s1, without regard to case. give start and size for sequence p0 -sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1); +// compare 2 ucstring s0 and s1, without regard to case. give start and size for sequence p0 // OLD +sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1); // OLD /** Compute a non-continuous noise with uniform repartition in [0, 1], with the given noise object * By default repartition is not uniform for noise diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 2c94b956d..6b73acba2 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -4340,7 +4340,7 @@ NLMISC_COMMAND(testDuelInvite, "","") //{ // uint32 index; // fromString(args[0], index); -// ucstring ucstr = args[1]; +// ucstring ucstr = args[1]; // OLD // // vector code; // diff --git a/ryzom/common/src/game_share/bg_downloader_msg.cpp b/ryzom/common/src/game_share/bg_downloader_msg.cpp index 297770ddb..e26aad9be 100644 --- a/ryzom/common/src/game_share/bg_downloader_msg.cpp +++ b/ryzom/common/src/game_share/bg_downloader_msg.cpp @@ -26,10 +26,10 @@ namespace BGDownloader const wchar_t *DownloaderMutexName = L"RyzomBgDownloader"; -ucstring getWrittenSize(uint32 nSize) +std::string getWrittenSize(uint32 nSize) { float fSize = ((float)nSize)/(1024.0f*1024.0f); - ucstring ucs = NLMISC::toString("%.1f", fSize) + " " + NLMISC::CI18N::get("uiMb"); + std::string ucs = NLMISC::toString("%.1f", fSize) + " " + NLMISC::CI18N::get("uiMb"); return ucs; } diff --git a/ryzom/common/src/game_share/bg_downloader_msg.h b/ryzom/common/src/game_share/bg_downloader_msg.h index da903493f..4ed562168 100644 --- a/ryzom/common/src/game_share/bg_downloader_msg.h +++ b/ryzom/common/src/game_share/bg_downloader_msg.h @@ -137,7 +137,7 @@ extern const wchar_t *DownloaderMutexName; // get patch written size in megabytes -ucstring getWrittenSize(uint32 nSize); +std::string getWrittenSize(uint32 nSize); std::string toString(TMsgType msgType); From 0dfff69c6f9d17c71c71b8f8bea1b47a71b5268e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 09:57:33 +0800 Subject: [PATCH 14/16] UTF-8 various, ryzom/ryzomcore#335 --- nel/include/nel/misc/utf_string_view.h | 3 + nel/src/misc/utf_string_view.cpp | 15 +++++ ryzom/client/src/connection.cpp | 2 +- ryzom/client/src/entities.cpp | 26 ++------ ryzom/client/src/entity_cl.cpp | 2 +- .../src/interface_v3/action_handler_help.cpp | 8 +-- .../src/interface_v3/action_handler_misc.cpp | 6 +- .../interface_v3/action_handler_phrase.cpp | 4 +- .../src/interface_v3/action_phrase_faber.cpp | 8 +-- .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.h | 4 +- ryzom/client/src/interface_v3/chat_filter.cpp | 3 +- ryzom/client/src/interface_v3/chat_window.cpp | 59 +++++++++---------- ryzom/client/src/interface_v3/chat_window.h | 30 +++++----- .../client/src/interface_v3/dbctrl_sheet.cpp | 20 +++---- ryzom/client/src/interface_v3/dbctrl_sheet.h | 4 +- .../client/src/interface_v3/group_career.cpp | 6 +- .../interface_expr_user_fct_game.cpp | 4 +- .../interface_expr_user_fct_items.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/inventory_manager.cpp | 26 ++++---- .../src/interface_v3/inventory_manager.h | 10 ++-- .../src/interface_v3/item_special_effect.cpp | 4 +- .../client/src/interface_v3/macrocmd_key.cpp | 6 +- .../client/src/interface_v3/music_player.cpp | 10 +++- .../src/interface_v3/people_interraction.cpp | 40 +++++++------ .../src/interface_v3/people_interraction.h | 14 ++--- ryzom/client/src/interface_v3/people_list.cpp | 27 ++++----- ryzom/client/src/interface_v3/people_list.h | 7 +-- .../client/src/interface_v3/skill_manager.cpp | 8 +-- .../src/interface_v3/sphrase_manager.cpp | 13 ++-- .../src/interface_v3/view_bitmap_faber_mp.cpp | 6 +- ryzom/client/src/misc.cpp | 4 +- ryzom/client/src/net_manager.cpp | 2 +- ryzom/client/src/zone_util.cpp | 4 +- 35 files changed, 198 insertions(+), 193 deletions(-) diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h index 572d39ac4..309377578 100644 --- a/nel/include/nel/misc/utf_string_view.h +++ b/nel/include/nel/misc/utf_string_view.h @@ -147,6 +147,9 @@ public: static void append(IStream &s, u32char c); static u32char get(IStream &s); + /// Get an UTF-8 string from an undefined ASCII-based codepage + static std::string fromAscii(std::string &str); + private: typedef u32char (*TIterator)(const void **addr); static u32char utf8Iterator(const void **addr); diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp index 64f2f8e55..dd7a88868 100644 --- a/nel/src/misc/utf_string_view.cpp +++ b/nel/src/misc/utf_string_view.cpp @@ -174,6 +174,21 @@ std::string CUtfStringView::toAscii() const return res; } +std::string CUtfStringView::fromAscii(std::string &str) +{ + std::string res; + res.reserve(str.size()); + for (std::string::iterator it(str.begin()), end(str.end()); it != end; ++it) + { + unsigned char c = *it; + if (c < 0x80) + res += (char)c; + else + res += '?'; + } + return res; +} + std::wstring CUtfStringView::toWide() const { #ifdef NL_OS_WINDOWS diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 63b8a6dd8..e31bd37fd 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -804,7 +804,7 @@ std::string buildPlayerNameForSaveFile(const std::string &playerNameIn) (c>='0' && c<='9') || (c=='_') ) { - ret[i]= tolower(c); + ret[i]= tolower(c); // TODO: toLowerAscii } else ret[i]= '_'; diff --git a/ryzom/client/src/entities.cpp b/ryzom/client/src/entities.cpp index 11c403403..7743cb02e 100644 --- a/ryzom/client/src/entities.cpp +++ b/ryzom/client/src/entities.cpp @@ -2419,14 +2419,8 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &keywo //----------------------------------------------- CEntityCL *CEntityManager::getEntityByName (const string &name, bool caseSensitive, bool complete) const { - string source = name; - const uint size = (uint)source.size(); - if (!caseSensitive) - { - uint j; - for (j=0; jgetDisplayName(); + string value = caseSensitive ? _Entities[i]->getDisplayName() : toLower(_Entities[i]->getDisplayName()); // TODO: toLowerInsensitive bool foundEntity = false; - uint j; - if (!caseSensitive) - { - for (j=0; j= size) - { - if (std::operator==(source, value.substr (0, size))) - foundEntity = true; - } + if (NLMISC::startsWith(value, source)) + foundEntity = true; } if (foundEntity) diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 4c1b4a842..8f96cb96b 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -2355,7 +2355,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value) if (pVT != NULL) pVT->setText(_Title); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player")); - if (pGC != NULL) pGC->setUCTitle(_EntityName); + if (pGC != NULL) pGC->setTitle(_EntityName); CSkillManager *pSM = CSkillManager::getInstance(); pSM->setPlayerTitle(_TitleRaw); diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index 3ba05a570..9cad50e25 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -973,12 +973,12 @@ class CHandlerBrowse : public IActionHandler { if(params[i]=='%' && igetItemActualName().toUtf8(); + string title = setup.SrcSheet->getItemActualName(); setupHelpTitle(setup.HelpWindow, title ); getItemText (setup.SrcSheet, itemText, pIS); diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 8b144f844..73c967bcb 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.toUtf8())); + PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName)); 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.toUtf8()) + ucstring(" "), false); + w->setCommand("tell " + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName) + " ", false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -908,7 +908,7 @@ REGISTER_ACTION_HANDLER (CAHCycleTell, "cycle_tell") NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "") { if (args.size() != 1) return false; - PeopleInterraction.LastSenderName = ucstring(args[0]); + PeopleInterraction.LastSenderName = args[0]; return true; } diff --git a/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 56382bf54..16a65e336 100644 --- a/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -279,9 +279,9 @@ void launchPhraseComposition(bool creation) // Set the Text of the Window if(creation) - window->setUCTitle(CI18N::get("uiPhraseCreate")); + window->setTitle(CI18N::get("uiPhraseCreate")); else - window->setUCTitle(CI18N::get("uiPhraseEdit")); + window->setTitle(CI18N::get("uiPhraseEdit")); // clear the sentence for a New Phrase creation. buildSentenceTarget->clearBuildingPhrase(); diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 3eacf8a60..47fda6d00 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -188,8 +188,8 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn window->setActive(true); // Setup the Title with a default text - ucstring title= CI18N::get("uiPhraseFaberExecuteNoPlan"); - window->setUCTitle (title); + string title= CI18N::get("uiPhraseFaberExecuteNoPlan"); + window->setTitle (title); } // **** setup DB observer! @@ -570,9 +570,9 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick if(window) { // Setup the Title with the item built - ucstring title= CI18N::get("uiPhraseFaberExecute"); + string title= CI18N::get("uiPhraseFaberExecute"); strFindReplace(title, "%item", STRING_MANAGER::CStringManagerClient::getItemLocalizedName(_ExecuteFromItemPlanBrick->FaberPlan.ItemBuilt) ); - window->setUCTitle (title); + window->setTitle (title); } diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index ce4ec3173..13e60fff8 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -250,7 +250,7 @@ void CBotChatPageTrade::begin() if (gc) { // set the title - gc->setUCTitle(_Title); + gc->setTitle(_Title); // show the buy mean CInterfaceGroup *money = dynamic_cast(gc->getGroup("money")); if (money) money->setActive((_BuyMean == Money) || (_BuyMean == MoneyFactionPoints)); diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.h b/ryzom/client/src/interface_v3/bot_chat_page_trade.h index ae11a2008..58a4e572d 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.h +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.h @@ -72,7 +72,7 @@ public: // set the buy mean (must be called before 'begin' is called) void setBuyMean(TBuyMean buyMean) { _BuyMean = buyMean; } // set the title of the window (actually applied when 'begin' is called) - void setTitle(const ucstring &title) { _Title = title; } + void setTitle(const std::string &title) { _Title = title; } // update the 'buy' dialog window for the given sphrase sheet (the player has changed an equipped weapon => action stats change) void updateSPhraseBuyDialog(); // invalidate window coords @@ -134,7 +134,7 @@ private: uint32 _CurrItemInventory; bool _BuyOnly; TBuyMean _BuyMean; - ucstring _Title; + std::string _Title; bool _ResaleEdit; bool _QuantityEdit; sint32 _QuantityCheck; diff --git a/ryzom/client/src/interface_v3/chat_filter.cpp b/ryzom/client/src/interface_v3/chat_filter.cpp index 237106170..c77a93fa5 100644 --- a/ryzom/client/src/interface_v3/chat_filter.cpp +++ b/ryzom/client/src/interface_v3/chat_filter.cpp @@ -363,8 +363,7 @@ void CChatTargetFilter::setTargetGroup(CChatGroup::TGroupType groupType, uint32 if (_Chat) { // set the prompt - const ucstring prompt(""); - _Chat->setPrompt(prompt + (ucchar) '>'); + _Chat->setPrompt(">"); // set the color string entry="UI:SAVE:CHAT:COLORS:"; diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index 58dc5d52a..816a2016a 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -135,10 +135,7 @@ bool CChatWindow::create(const CChatWindowDesc &desc, const std::string &chatId) return false; } _Chat->setLocalize (desc.Localize); - if (desc.Localize) - _Chat->setTitle(desc.Title.toString()); - else - _Chat->setUCTitle(desc.Title); + _Chat->setTitle(desc.Title); _Chat->setSavable(desc.Savable); // groups like system info don't have edit box. @@ -259,12 +256,12 @@ void CChatWindow::setMenu(const std::string &menuName) } //================================================================================= -void CChatWindow::setPrompt(const ucstring &prompt) +void CChatWindow::setPrompt(const string &prompt) { if (!_Chat) return; CGroupEditBox *eb = dynamic_cast(_Chat->getGroup("eb")); if (!eb) return; - eb->setPrompt(prompt.toUtf8()); + eb->setPrompt(prompt); } void CChatWindow::setPromptColor(NLMISC::CRGBA col) @@ -312,7 +309,7 @@ void CChatWindow::deleteContainer() } //================================================================================= -bool CChatWindow::rename(const ucstring &newName, bool newNameLocalize) +bool CChatWindow::rename(const string &newName, bool newNameLocalize) { return getChatWndMgr().rename(getTitle(), newName, newNameLocalize); } @@ -362,22 +359,22 @@ void CChatWindow::setCommand(const ucstring &command,bool execute) //================================================================================= -void CChatWindow::setEntry(const ucstring &entry) +void CChatWindow::setEntry(const string &entry) { if (!_EB) return; - _EB->setInputStringAsUtf16(entry); + _EB->setInputString(entry); } //================================================================================= -ucstring CChatWindow::getTitle() const +string CChatWindow::getTitle() const { if (!_Chat) { - return ucstring(""); + return string(); } else { - return _Chat->getUCTitle(); + return _Chat->getTitle(); } } @@ -472,7 +469,7 @@ void CChatWindow::setHeaderColor(const std::string &n) } //================================================================================= -void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks /*= 0*/) +void CChatWindow::displayLocalPlayerTell(const string &receiver, const string &msg, uint numBlinks /*= 0*/) { string finalMsg; CInterfaceProperty prop; @@ -483,10 +480,10 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstrin finalMsg += csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); encodeColorTag(prop.getRGBA(), finalMsg, true); - finalMsg += msg.toUtf8(); + finalMsg += msg; string s = CI18N::get("youTellPlayer"); - strFindReplace(s, "%name", receiver.toUtf8()); + strFindReplace(s, "%name", receiver); strFindReplace(finalMsg, CI18N::get("youTell"), s); displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks); CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell)); @@ -730,13 +727,13 @@ const string CChatGroupWindow::getValidUiStringId(const string &stringId) } //================================================================================= -CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, const string &winColor) +CGroupContainer *CChatGroupWindow::createFreeTeller(const string &winNameIn, const string &winColor) { // must parse the entity name, and eventually make it Full with shard name (eg: 'ani.yoyo' becomes 'yoyo(Aniro)') - string winNameFull= CShardNames::getInstance().makeFullNameFromRelative(PlayerSelectedMainland, winNameIn.toString()); + string winNameFull= CShardNames::getInstance().makeFullNameFromRelative(PlayerSelectedMainland, winNameIn); // remove shard name if necessary - ucstring winName= CEntityCL::removeShardFromName(winNameFull); + string winName= CEntityCL::removeShardFromName(winNameFull); // get the color string sWinColor = winColor; @@ -745,12 +742,12 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c // Look if the free teller do not already exists uint32 i; - string sWinName = winName.toString(); + string sWinName = winName; sWinName = toLower(sWinName); for (i = 0; i < _FreeTellers.size(); ++i) { CGroupContainer *pGC = _FreeTellers[i]; - if (toLower(pGC->getUCTitle().toString()) == sWinName) + if (toLower(pGC->getTitle()) == sWinName) break; } // Create container if not present @@ -772,11 +769,11 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c if (!pGC) { delete pIG; - nlwarning(" group is not a container.(%s)", winName.toString().c_str()); + nlwarning(" group is not a container.(%s)", winName.c_str()); return NULL; } // set title from the name - pGC->setUCTitle(winName); + pGC->setTitle(winName); // pGC->setSavable(true); pGC->setEscapable(true); @@ -834,7 +831,7 @@ void CChatGroupWindow::updateAllFreeTellerHeaders() //================================================================================= void CChatGroupWindow::updateFreeTellerHeader(CGroupContainer &ft) { - ucstring name = ft.getUCTitle(); + string name = ft.getTitle(); CCtrlBaseButton *newFriendBut = dynamic_cast(ft.getCtrl("new_friend")); CCtrlBaseButton *ignoreBut = dynamic_cast(ft.getCtrl("ignore")); CCtrlBaseButton *inviteBut = dynamic_cast(ft.getCtrl("invite")); @@ -868,7 +865,7 @@ void CChatGroupWindow::updateFreeTellerHeader(CGroupContainer &ft) } //================================================================================= -void CChatGroupWindow::setActiveFreeTeller(const ucstring &winName, bool bActive) +void CChatGroupWindow::setActiveFreeTeller(const string &winName, bool bActive) { CGroupContainer *pGC = createFreeTeller(winName); if (pGC != NULL) @@ -1166,7 +1163,7 @@ CChatWindow *CChatWindowManager::createChatGroupWindow(const CChatWindowDesc &de } //================================================================================= -CChatWindow *CChatWindowManager::getChatWindow(const ucstring &title) +CChatWindow *CChatWindowManager::getChatWindow(const string &title) { TChatWindowMap::iterator it = _ChatWindowMap.find(title); if (it == _ChatWindowMap.end()) @@ -1179,12 +1176,12 @@ CChatWindow *CChatWindowManager::getChatWindow(const ucstring &title) } //================================================================================= -void CChatWindowManager::removeChatWindow(const ucstring &title) +void CChatWindowManager::removeChatWindow(const string &title) { TChatWindowMap::iterator it = _ChatWindowMap.find(title); if (it == _ChatWindowMap.end()) { - nlwarning("Unknown chat window '%s'", title.toUtf8().c_str()); + nlwarning("Unknown chat window '%s'", title.c_str()); return; } it->second->deleteContainer(); @@ -1213,11 +1210,11 @@ CChatWindow *CChatWindowManager::getChatWindowFromCaller(CCtrlBase *caller) } if (!father) return NULL; - return getChatWindow(father->getUCTitle()); + return getChatWindow(father->getTitle()); } //================================================================================= -bool CChatWindowManager::rename(const ucstring &oldName, const ucstring &newName, bool newNameLocalize) +bool CChatWindowManager::rename(const string &oldName, const string &newName, bool newNameLocalize) { // if (oldName == newName) return true; CChatWindow *newWin = getChatWindow(newName); @@ -1225,8 +1222,8 @@ bool CChatWindowManager::rename(const ucstring &oldName, const ucstring &newName TChatWindowMap::iterator it = _ChatWindowMap.find(oldName); if (it == _ChatWindowMap.end()) return false; _ChatWindowMap[newName] = it->second; - it->second->getContainer()->setLocalize(false); - it->second->getContainer()->setTitle(newName.toUtf8()); + it->second->getContainer()->setLocalize(newNameLocalize); + it->second->getContainer()->setTitle(newName); _ChatWindowMap.erase(it); return true; } diff --git a/ryzom/client/src/interface_v3/chat_window.h b/ryzom/client/src/interface_v3/chat_window.h index 39fc448f9..9a299ebfb 100644 --- a/ryzom/client/src/interface_v3/chat_window.h +++ b/ryzom/client/src/interface_v3/chat_window.h @@ -23,7 +23,7 @@ #ifndef CL_CHAT_WINDOW_H #define CL_CHAT_WINDOW_H -#include "nel/misc/ucstring.h" +#include "nel/misc/ucstring.h" // REMOVE #include "nel/misc/smart_ptr.h" #include "game_share/chat_group.h" @@ -57,7 +57,7 @@ struct CChatWindowDesc { typedef std::vector > TTemplateParams; - ucstring Title; // unique title for the window + std::string Title; // unique title for the window std::string FatherContainer; // name of the father container. If empty, the chat box must be added manually in the hierarchy std::string ChatTemplate; // Template for the chat interface, or "" to use the default one TTemplateParams ChatTemplateParams; // optional template parameters @@ -94,7 +94,7 @@ public: // called by a CChatWindow when it is deleted virtual void chatWindowRemoved(CChatWindow * /* cw */) {} // called by a CChatWindow when a msg has been displayed in it ('displayMessage' has been called) - //virtual void displayMessage(CChatWindow *cw, const ucstring &msg, NLMISC::CRGBA col, uint numBlinks = 0) {} + //virtual void displayMessage(CChatWindow *cw, const std::string &msg, NLMISC::CRGBA col, uint numBlinks = 0) {} }; public: // display a message in this chat box with the given color @@ -110,16 +110,16 @@ public: // set a command to be displayed and eventually executed in this chat window. std::string version for backward compatibility void setCommand(const std::string &command, bool execute); // set a command to be displayed and eventually executed in this chat window - void setCommand(const ucstring &command, bool execute); + void setCommand(const ucstring &command, bool execute); // REMOVE // set a string to be displayed in the edit box of this window (if it has one) - void setEntry(const ucstring &entry); + void setEntry(const std::string &entry); // Set listener to react to a chat entry void setListener(IChatWindowListener *listener) { _Listener = listener; } IChatWindowListener *getListener() const { return _Listener; } // Set the menu for the chat void setMenu(const std::string &menuName); // Set a new prompt for the chat window - void setPrompt(const ucstring &prompt); + void setPrompt(const std::string &prompt); // Set the color for the chat window void setPromptColor(NLMISC::CRGBA col); /** Get the container associated with this chat window @@ -131,7 +131,7 @@ public: /** try to rename the chat window * \return true if success */ - bool rename(const ucstring &newName, bool newNameLocalize); + bool rename(const std::string &newName, bool newNameLocalize); /** delete the container * Don't do it in the dtor, because done automatically at the end of the app by the interface manager. * Useful only if querried by the user @@ -140,7 +140,7 @@ public: // get the last chat window from which a command has been called static CChatWindow *getChatWindowLaunchingCommand() { return _ChatWindowLaunchingCommand; } // get the title of this chat window - ucstring getTitle() const; + std::string getTitle() const; // observers void addObserver(IObserver *obs); void removeObserver(IObserver *obs); @@ -154,7 +154,7 @@ public: void setAHOnCloseButtonParams(const std::string &n); void setHeaderColor(const std::string &n); // - void displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks = 0); + void displayLocalPlayerTell(const std::string &receiver, const std::string &msg, uint numBlinks = 0); /// Encode a color tag '@{RGBA}' in the text. If append is true, append at end of text, otherwise, replace the text static void encodeColorTag(const NLMISC::CRGBA &color, std::string &text, bool append=true); @@ -196,8 +196,8 @@ public: void setTabIndex(sint32 n); // Free Teller - NLGUI::CGroupContainer *createFreeTeller(const ucstring &winName, const std::string &winColor=""); - void setActiveFreeTeller(const ucstring &winName, bool bActive=true); + NLGUI::CGroupContainer *createFreeTeller(const std::string &winName, const std::string &winColor=""); + void setActiveFreeTeller(const std::string &winName, bool bActive=true); std::string getFreeTellerName(const std::string &containerID); bool removeFreeTeller(const std::string &containerID); // Return true if free teller found void removeAllFreeTellers(); @@ -245,9 +245,9 @@ public: CChatWindow *createChatGroupWindow(const CChatWindowDesc &desc); // Get a chat window by its title - CChatWindow *getChatWindow(const ucstring &title); + CChatWindow *getChatWindow(const std::string &title); /// Remove a chat window by its title - void removeChatWindow(const ucstring &title); + void removeChatWindow(const std::string &title); // Remove a chat window by its pointer void removeChatWindow(CChatWindow *cw); /// from a ctrl of a chat box that triggered a menu, or an event, retrieve the associated chat box @@ -255,14 +255,14 @@ public: // Singleton pattern applied to the chat window manager static CChatWindowManager &getInstance(); // try to rename a window - bool rename(const ucstring &oldName, const ucstring &newName, bool newNameLocalize); + bool rename(const std::string &oldName, const std::string &newName, bool newNameLocalize); // warning : this is slow uint getNumChatWindow() const { return (uint)_ChatWindowMap.size(); } // warning : this is slow : for debug only CChatWindow *getChatWindowByIndex(uint index); /////////////////////////////////////////////////////////////////////////////////////// private: - typedef std::map > TChatWindowMap; + typedef std::map > TChatWindowMap; private: // TChatWindowMap _ChatWindowMap; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 63392c583..dcfdc1fc9 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -102,9 +102,9 @@ void CControlSheetInfoWaiter::infoReceived() } -ucstring CControlSheetInfoWaiter::infoValidated() const +string CControlSheetInfoWaiter::infoValidated() const { - ucstring help; + ucstring help; // FIXME: Lua UTF-8 if (CtrlSheet && !LuaMethodName.empty()) { // delegate setup of context he help ( & window ) to lua @@ -131,7 +131,7 @@ ucstring CControlSheetInfoWaiter::infoValidated() const } } - return help; + return help.toUtf8(); } // *************************************************************************** @@ -3443,10 +3443,10 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { // call lua function to update tooltip window _ItemInfoWaiter.sendRequest(); - help = _ItemInfoWaiter.infoValidated().toUtf8(); + help = _ItemInfoWaiter.infoValidated(); // its expected to get at least item name back if (help.empty()) - help = getItemActualName().toUtf8(); + help = getItemActualName(); } else if (!_ContextHelp.empty()) { @@ -3454,7 +3454,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const } else { - help = getItemActualName().toUtf8();; + help = getItemActualName();; } } else @@ -3575,7 +3575,7 @@ void CDBCtrlSheet::getContextHelpToolTip(std::string &help) const if (useItemInfoForFamily(item->Family)) { _ItemInfoWaiter.sendRequest(); - help = _ItemInfoWaiter.infoValidated().toUtf8(); + help = _ItemInfoWaiter.infoValidated(); return; } } @@ -4563,11 +4563,11 @@ void CDBCtrlSheet::initArmourColors() // *************************************************************************** -ucstring CDBCtrlSheet::getItemActualName() const +string CDBCtrlSheet::getItemActualName() const { const CItemSheet *pIS= asItemSheet(); if(!pIS) - return ucstring(); + return string(); else { string ret; @@ -4587,7 +4587,7 @@ ucstring CDBCtrlSheet::getItemActualName() const if (pIS->Family == ITEMFAMILY::SCROLL_R2) { const R2::TMissionItem *mi = R2::getEditor().getPlotItemInfos(getSheetId()); - if (mi) return mi->Name; + if (mi) return mi->Name.toUtf8(); } // if item is not a mp, append faber_quality & faber_stat_type // Don't append quality and stat type for Named Items!!! diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.h b/ryzom/client/src/interface_v3/dbctrl_sheet.h index 9440222f4..dfe3b7140 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -73,7 +73,7 @@ public: : IItemInfoWaiter(), Requesting(false) { } public: - ucstring infoValidated() const; + std::string infoValidated() const; void sendRequest(); virtual void infoReceived(); }; @@ -582,7 +582,7 @@ public: void setItemColor(sint32 val) {if(_UserColor) _UserColor->setValue32(val);} // Get the Actual item name. Localized version of SheetId, or given by server through NAMEID. - ucstring getItemActualName() const; + std::string getItemActualName() const; /// true if support drag copy (with CTRL). action handler has to check control. bool canDragCopy() const {return _DragCopy;} diff --git a/ryzom/client/src/interface_v3/group_career.cpp b/ryzom/client/src/interface_v3/group_career.cpp index d3f3e2563..10cfca35e 100644 --- a/ryzom/client/src/interface_v3/group_career.cpp +++ b/ryzom/client/src/interface_v3/group_career.cpp @@ -63,13 +63,13 @@ bool CGroupCareer::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (Career >= ROLES::NB_ROLES) Career = ROLES::fighter; - ucstring sTmp = ROLES::roleToUCString(Career); + string sTmp = ROLES::roleToUCString(Career); for (uint32 i= 0; i < sTmp.size(); ++i) if (sTmp[i] < 128) if ( (sTmp[i] >= 'a') && (sTmp[i] <= 'z') ) sTmp[i] = sTmp[i] - 'a' + 'A'; - setUCTitle (sTmp); + setTitle (sTmp); return true; } @@ -133,7 +133,7 @@ bool CGroupJob::parse (xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */ // if (sTmp[i] < 128) // if ( (sTmp[i] >= 'a') && (sTmp[i] <= 'z') ) // sTmp[i] = sTmp[i] - 'a' + 'A'; -// setUCTitle (sTmp); +// seUCTitle (sTmp); // // return true; } diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 9494deacf..4c21fee47 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -626,11 +626,11 @@ static DECLARE_INTERFACE_USER_FCT(getChatWin) CChatWindowManager &rCWM = CChatWindowManager::getInstance(); - ucstring title = CI18N::get(args[0].getString()); + string title = CI18N::get(args[0].getString()); CChatWindow *window = rCWM.getChatWindow(title); if (!window) { - nlwarning("Can't find window named %s", title.toString().c_str()); + nlwarning("Can't find window named %s", title.c_str()); return false; } string sTmp = window->getContainer()->getId(); 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 cae4b9d77..7744be7eb 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -313,7 +313,7 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName) // if from ctrlSheet, then take the correct ACTUAL name (ie from NAMEID if not 0) if(ctrlSheet) { - result.setString(ctrlSheet->getItemActualName().toUtf8()); + result.setString(ctrlSheet->getItemActualName()); return true; } // Standard (but less accurate) way diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 1b36c91d5..aa38b6dbf 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -982,7 +982,7 @@ void CInterfaceManager::initInGame() // flush system msg buffer for( uint i=0; i(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); - pGC->setUCTitle( title ); + pGC->setTitle( title ); } isInUpdateForageQQ = false; @@ -2199,7 +2199,7 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */) } // *************************************************************************** -void SBagOptions::setSearchFilter(const ucstring &s) +void SBagOptions::setSearchFilter(const string &s) { SearchQualityMin = 0; SearchQualityMax = 999; @@ -2208,13 +2208,13 @@ void SBagOptions::setSearchFilter(const ucstring &s) if (!s.empty()) { - std::vector words; - splitUCString(toLower(s), ucstring(" "), words); + std::vector words; + splitString(toLower(s), string(" "), words); size_t pos; for(int i = 0; i 0) { bool match = true; - ucstring lcName = toLower(pCS->getItemActualName()); + string lcName = toLower(pCS->getItemActualName()); // add item quality as a keyword to match if (pCS->getQuality() > 1) { - lcName += ucstring(" " + toString(pCS->getQuality())); + lcName += string(" " + toString(pCS->getQuality())); } for (uint i = 0; i< SearchFilter.size(); ++i) { - if (lcName.find(SearchFilter[i]) == ucstring::npos) + if (lcName.find(SearchFilter[i]) == string::npos) { return false; } @@ -2741,7 +2741,7 @@ class CHandlerInvSearchButton : public IActionHandler return; } - ucstring filter; + string filter; std::string id = btn->getParent()->getId() + ":" + sParams + ":eb"; CGroupEditBox *eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id)); if (!eb) @@ -2755,7 +2755,7 @@ class CHandlerInvSearchButton : public IActionHandler { CWidgetManager::getInstance()->setCaptureKeyboard(eb); eb->setSelectionAll(); - filter = eb->getInputStringAsUtf16(); + filter = eb->getInputString(); } CDBGroupListSheetBag *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(btn->getParent()->getId() + ":bag_list")); @@ -2805,10 +2805,10 @@ class CHandlerInvSetSearch : public IActionHandler std::string id = pCaller->getParent()->getParent()->getId(); CDBGroupListSheetBag *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id + ":bag_list")); - if (pList != NULL) pList->setSearchFilter(eb->getInputStringAsUtf16()); + if (pList != NULL) pList->setSearchFilter(eb->getInputString()); CDBGroupIconListBag *pIcons = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id + ":bag_icons")); - if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputStringAsUtf16()); + if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputString()); } }; REGISTER_ACTION_HANDLER( CHandlerInvSetSearch, "inv_set_search" ); diff --git a/ryzom/client/src/interface_v3/inventory_manager.h b/ryzom/client/src/interface_v3/inventory_manager.h index 8c365a0be..6af8414de 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.h +++ b/ryzom/client/src/interface_v3/inventory_manager.h @@ -520,7 +520,7 @@ struct SSortStruct { CDBGroupListSheetText::CSheetChild *SheetText; CDBGroupListSheet::CSheetChild *SheetIcon; - ucstring Pos; + std::string Pos; bool operator < (const SSortStruct &o) const { return Pos < o.Pos; } }; @@ -558,7 +558,7 @@ struct SBagOptions bool SearchFilterChanged; uint16 SearchQualityMin; uint16 SearchQualityMax; - std::vector SearchFilter; + std::vector SearchFilter; // ----------------------- SBagOptions() @@ -576,7 +576,7 @@ struct SBagOptions bool isSomethingChanged(); // From last call ? bool isSearchFilterChanged() const { return SearchFilterChanged; } - void setSearchFilter(const ucstring &s); + void setSearchFilter(const std::string &s); bool getFilterArmor() const { @@ -674,7 +674,7 @@ public: // Return true if the sheet can be displayed due to filters bool canDisplay(CDBCtrlSheet *pCS) { return _BO.canDisplay(pCS); } - void setSearchFilter(const ucstring &s) { _BO.setSearchFilter(s); } + void setSearchFilter(const std::string &s) { _BO.setSearchFilter(s); } private: @@ -707,7 +707,7 @@ public: // Return true if the sheet can be displayed due to filters bool canDisplay(CDBCtrlSheet *pCS) const { return _BO.canDisplay(pCS); } - void setSearchFilter(const ucstring &s) { _BO.setSearchFilter(s); } + void setSearchFilter(const std::string &s) { _BO.setSearchFilter(s); } ////////////////////////////////////////////////////////////////////////// diff --git a/ryzom/client/src/interface_v3/item_special_effect.cpp b/ryzom/client/src/interface_v3/item_special_effect.cpp index 7b659fe6d..fdb53a0ec 100644 --- a/ryzom/client/src/interface_v3/item_special_effect.cpp +++ b/ryzom/client/src/interface_v3/item_special_effect.cpp @@ -51,8 +51,8 @@ void CItemSpecialEffectHelper::registerItemSpecialEffect(const string &name) vector params; // get ui string - ucstring ucs = CI18N::get("uiItemFX_" + name); - CSString p, s = ucs.toString(); + string ucs = CI18N::get("uiItemFX_" + name); + CSString p, s = ucs; // locate and store parameters // %p : percent diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp index aa6ffe213..21977f0bc 100644 --- a/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -87,7 +87,7 @@ using namespace NLMISC; // *************************************************************************** // Add the template key to the parent -void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &shortcutName, bool grayed) +void addKeyLine (CGroupList *pParent, const string &keyName, const string &shortcutName, bool grayed) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); @@ -104,14 +104,14 @@ void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &s CViewText *pViewKeyName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_KEY_NAME)); if (pViewKeyName != NULL) { - pViewKeyName->setText (keyName.toUtf8()); + pViewKeyName->setText (keyName); pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } CViewText *pViewShortcutName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME)); if (pViewShortcutName != NULL) { - pViewShortcutName->setText (shortcutName.toUtf8()); + pViewShortcutName->setText (shortcutName); pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp index 790949352..c7c9e89eb 100644 --- a/ryzom/client/src/interface_v3/music_player.cpp +++ b/ryzom/client/src/interface_v3/music_player.cpp @@ -586,9 +586,17 @@ static void addFromPlaylist(const std::string &playlist, const std::vectorgetTitle().toString()).c_str()); + nlwarning("Window %d : %s", (int) k, (cwm.getChatWindowByIndex(k)->getTitle()).c_str()); } } } @@ -1121,7 +1121,7 @@ void CPeopleInterraction::askAddContact(const string &contactName, CPeopleList * if (pl == &FriendList) list = 0; - ucstring temp = contactName; // TODO: UTF-8 serial + ucstring temp = ucstring::makeFromUtf8(contactName); // TODO: UTF-8 (serial) out.serial(temp); out.serial(list); NetMngr.push(out); @@ -1192,7 +1192,7 @@ void CPeopleInterraction::askMoveContact(uint peopleIndexInSrc, CPeopleList *plS // Fake Local simulation if (ClientCfg.Local) { - ucstring peopleName= plSRC->getName(peopleIndexInSrc); + string peopleName= plSRC->getName(peopleIndexInSrc); plSRC->removePeople(peopleIndexInSrc); sint dstIndex = plDST->addPeople(peopleName); plDST->setOnline(dstIndex, ccs_online); @@ -1252,7 +1252,7 @@ void CPeopleInterraction::askRemoveContact(uint peopleIndex, CPeopleList *pl) //================================================================================================================= void CPeopleInterraction::initContactLists( const std::vector &vFriendListName, const std::vector &vFriendListOnline, - const std::vector &vIgnoreListName ) + const std::vector &vIgnoreListName ) // TODO: UTF-8 (serial) { // clear the current lists if any @@ -1264,18 +1264,18 @@ void CPeopleInterraction::initContactLists( const std::vector &vFriendLi for (uint i = 0; i < vFriendListName.size(); ++i) addContactInList(contactIdPool++, vFriendListName[i], vFriendListOnline[i], 0); for (uint i = 0; i < vIgnoreListName.size(); ++i) - addContactInList(contactIdPool++, vIgnoreListName[i], ccs_offline, 1); + addContactInList(contactIdPool++, vIgnoreListName[i].toUtf8(), ccs_offline, 1); updateAllFreeTellerHeaders(); } //================================================================================================================= -void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nameIn, TCharConnectionState online, uint8 nList) +void CPeopleInterraction::addContactInList(uint32 contactId, const string &nameIn, TCharConnectionState online, uint8 nList) { // select correct people list CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - string name= CEntityCL::removeShardFromName(nameIn.toUtf8()); + string name= CEntityCL::removeShardFromName(nameIn); // add the contact to this list sint index = pl.getIndexFromName(name); @@ -1321,12 +1321,12 @@ void CPeopleInterraction::addContactInList(uint32 contactId, uint32 nameID, TCha } //================================================================================================================= -bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) const +bool CPeopleInterraction::isContactInList(const string &nameIn, uint8 nList) const { // select correct people list const CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - string name= CEntityCL::removeShardFromName(nameIn.toUtf8()); + string name= CEntityCL::removeShardFromName(nameIn); return pl.getIndexFromName(name) != -1; } @@ -1455,12 +1455,14 @@ void CPeopleInterraction::removeContactFromList(uint32 contactId, uint8 nList) } //================================================================================================================= -bool CPeopleInterraction::testValidPartyChatName(const ucstring &title) +bool CPeopleInterraction::testValidPartyChatName(const string &title) { if (title.empty()) return false; // shouldn't begin like 'user chat 1-5' - ucstring userChatStr = CI18N::get("uiUserChat"); - if (title.substr(0, userChatStr.length()) == userChatStr) return false; + const string &userChatStr = CI18N::get("uiUserChat"); + if (NLMISC::startsWith(title, userChatStr)) return false; + // can't match a translation identifier + if (CI18N::hasTranslation(title)) return false; for(uint k = 0; k < PartyChats.size(); ++k) // there shouldn't be that much party chat simultaneously so a linear search is ok { if (PartyChats[k].Window->getTitle() == title) return false; @@ -1471,9 +1473,9 @@ bool CPeopleInterraction::testValidPartyChatName(const ucstring &title) if (GuildChat && title == GuildChat->getTitle()) return false; if (TeamChat && title == TeamChat->getTitle()) return false; sint index; - index = FriendList.getIndexFromName(title.toUtf8()); + index = FriendList.getIndexFromName(title); if (index != -1) return false; - index = IgnoreList.getIndexFromName(title.toUtf8()); + index = IgnoreList.getIndexFromName(title); if (index != -1) return false; // TODO_GAMEDEV server test for the name (not only local), & modify callers of this function // The party chat should NOT have the name of a player @@ -1526,7 +1528,7 @@ void CPeopleInterraction::assignPartyChatMenu(CChatWindow *partyChat) } //================================================================================================================= -bool CPeopleInterraction::createNewPartyChat(const ucstring &title) +bool CPeopleInterraction::createNewPartyChat(const string &title) { // now there are no party chat windows, party chat phrases must be filtered from the main chat @@ -1851,8 +1853,8 @@ void CPeopleInterraction::createUserChat(uint index) return; } CChatWindowDesc chatDesc; - ucstring userChatStr = CI18N::get("uiUserChat"); - userChatStr += ucchar(' ') + ucstring(toString(index + 1)); + string userChatStr = CI18N::get("uiUserChat"); + userChatStr += ' ' + toString(index + 1); //chatDesc.FatherContainer = "ui:interface:communication"; chatDesc.FatherContainer = "ui:interface:contact_list"; chatDesc.Title = userChatStr; @@ -2592,7 +2594,7 @@ public: { for(uint l = 0; l < pl.PartyChats.size(); ++l) { - menu->addLineAtIndex(insertionIndex, pl.PartyChats[l].Window->getTitle().toUtf8(), "chat_target_selected", toString(pl.PartyChats[l].ID)); + menu->addLineAtIndex(insertionIndex, pl.PartyChats[l].Window->getTitle(), "chat_target_selected", toString(pl.PartyChats[l].ID)); ++ insertionIndex; } } @@ -2939,7 +2941,7 @@ class CHandlerSelectChatSource : public IActionHandler { if (pc[l].Filter != NULL) { - menu->addLineAtIndex(insertionIndex, pc[l].Window->getTitle().toUtf8(), FILTER_TOGGLE, toString(pc[l].ID)); + menu->addLineAtIndex(insertionIndex, pc[l].Window->getTitle(), FILTER_TOGGLE, toString(pc[l].ID)); menu->setUserGroupLeft(insertionIndex, createMenuCheckBox(FILTER_TOGGLE, toString(pc[l].ID), pc[l].Filter->isListeningWindow(cw))); ++ insertionIndex; } diff --git a/ryzom/client/src/interface_v3/people_interraction.h b/ryzom/client/src/interface_v3/people_interraction.h index 59230853f..8181c1705 100644 --- a/ryzom/client/src/interface_v3/people_interraction.h +++ b/ryzom/client/src/interface_v3/people_interraction.h @@ -156,12 +156,12 @@ public: CFilteredChat UserChat[MaxNumUserChats]; CFilteredChat TheUserChat; // Id of last people who talked - ucstring LastSenderName; + std::string LastSenderName; // system message struct CSysMsg { - ucstring Str; + std::string Str; std::string Cat; }; // system message buffer @@ -195,13 +195,13 @@ public: */ CFilteredChat *getFilteredChatFromChatWindow(CChatWindow *cw); - bool testValidPartyChatName(const ucstring &name); + bool testValidPartyChatName(const std::string &name); bool removePartyChat(CChatWindow *window); void removeAllPartyChat(); /** * create a named party chat. */ - bool createNewPartyChat(const ucstring &title); + bool createNewPartyChat(const std::string &title); static void assignPartyChatMenu(CChatWindow *partyChat); @@ -215,11 +215,11 @@ public: // init contact list (from server typically) void initContactLists( const std::vector &vFriendListName, const std::vector &vFriendListOnline, - const std::vector &vIgnoreListName ); + const std::vector &vIgnoreListName ); // TODO: UTF-8 (serial) // Friend list == 0 // Ignore list == 1 void addContactInList(uint32 contactId, uint32 nameID, TCharConnectionState Online, uint8 nList); - void addContactInList(uint32 contactId, const ucstring &name, TCharConnectionState Online, uint8 nList); - bool isContactInList(const ucstring &name, uint8 nList) const; + void addContactInList(uint32 contactId, const std::string &name, TCharConnectionState Online, uint8 nList); + bool isContactInList(const std::string &name, uint8 nList) const; // Called each frame to receive name from IOS void updateWaitingContacts(); // server decide to remove a contact (if it does not exists anymore) diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp index f056f4cc5..6650b7ef2 100644 --- a/ryzom/client/src/interface_v3/people_list.cpp +++ b/ryzom/client/src/interface_v3/people_list.cpp @@ -127,10 +127,7 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha _BaseContainer->setSavable(desc.Savable); _BaseContainer->setLocalize(desc.Localize); - if (desc.Localize) - _BaseContainer->setTitle(desc.PeopleListTitle.toString()); - else - _BaseContainer->setUCTitle(desc.PeopleListTitle); + _BaseContainer->setTitle(desc.PeopleListTitle); //_BaseContainer->setId("ui:interface:" + desc.Id); // create the chat window if there's one @@ -162,7 +159,7 @@ sint CPeopleList::getIndexFromName(const string &name) const string sNameIn = toLower(name); for(uint k = 0; k < _Peoples.size(); ++k) { - string sPeopleName = toLower(_Peoples[k].getName().toUtf8()); + string sPeopleName = toLower(_Peoples[k].getName()); if (sPeopleName == sNameIn) return k; } return -1; @@ -198,8 +195,8 @@ bool CPeopleList::sortExByContactId(const CPeople& a, const CPeople& b) //================================================================== bool CPeopleList::sortExByName(const CPeople& a, const CPeople& b) { - ucstring name_a = toUpper(a.getName()); - ucstring name_b = toUpper(b.getName()); + string name_a = toUpper(a.getName()); + string name_b = toUpper(b.getName()); return (name_a < name_b); } @@ -207,8 +204,8 @@ bool CPeopleList::sortExByName(const CPeople& a, const CPeople& b) //================================================================== bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b) { - ucstring name_a = toUpper(a.getName()); - ucstring name_b = toUpper(b.getName()); + string name_a = toUpper(a.getName()); + string name_b = toUpper(b.getName()); // We want order: online/alpha, offworld/alpha, offline/alpha if (a.Online == b.Online) @@ -331,13 +328,13 @@ bool CPeopleList::isPeopleWindowVisible(uint index) const */ //================================================================== -sint CPeopleList::addPeople(const ucstring &name, uint teamMateIndex /*= 0*/) +sint CPeopleList::addPeople(const string &name, uint teamMateIndex /*= 0*/) { if (!_BaseContainer) return - 1; // check if not already inserted - if (getIndexFromName(name.toUtf8()) != -1) + if (getIndexFromName(name) != -1) { - nlwarning(" people %s inserted twice.", name.toString().c_str()); + nlwarning(" people %s inserted twice.", name.c_str()); } vector > properties; @@ -371,11 +368,11 @@ sint CPeopleList::addPeople(const ucstring &name, uint teamMateIndex /*= 0*/) if (!gc) { delete group; - nlwarning(" group is not a container.", name.toString().c_str()); + nlwarning(" group is not a container.", name.c_str()); return -1; } // set title from the name - gc->setUCTitle(name); + gc->setTitle(name); // People inside list are not savable ! gc->setSavable(false); // @@ -694,7 +691,7 @@ std::string CPeopleList::getName(uint index) const nlwarning("bad index"); return "BAD INDEX!"; } - return _Peoples[index].getName().toUtf8(); + return _Peoples[index].getName(); } //================================================================== diff --git a/ryzom/client/src/interface_v3/people_list.h b/ryzom/client/src/interface_v3/people_list.h index 91dbf50d3..ccd8e2f41 100644 --- a/ryzom/client/src/interface_v3/people_list.h +++ b/ryzom/client/src/interface_v3/people_list.h @@ -28,7 +28,6 @@ #include "chat_window.h" #include "interface_pointer.h" // NeL -#include "nel/misc/ucstring.h" #include "nel/misc/rgba.h" @@ -40,7 +39,7 @@ struct CPeopleListDesc { enum TContactType { Team, Contact, Ignore, Unknown }; - ucstring PeopleListTitle; // title of the people list + std::string PeopleListTitle; // title of the people list TContactType ContactType; std::string FatherContainer; // name of the father container std::string BaseContainerTemplateName; // name of the template for the base container @@ -99,7 +98,7 @@ public: /** Add a people to the list, and returns its index or -1 if the creation failed * If this is a team mate, tells its index so that ic can be bound to the database in the right location */ - sint addPeople(const ucstring &name, uint teamMateIndex = 0); + sint addPeople(const std::string &name, uint teamMateIndex = 0); // swap people position between the 2 given indexs void swapPeople(uint index1, uint index2); // Remove the people at the given index @@ -159,7 +158,7 @@ private: bool Blocked; uint32 ContactId; bool operator < (const CPeople &other) const { return getName() < other.getName(); } - ucstring getName() const { return Container->getUCTitle(); } + std::string getName() const { return Container->getTitle(); } }; typedef std::vector TPeopleVect; private: diff --git a/ryzom/client/src/interface_v3/skill_manager.cpp b/ryzom/client/src/interface_v3/skill_manager.cpp index cf35e6bd6..9d10cde0a 100644 --- a/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/ryzom/client/src/interface_v3/skill_manager.cpp @@ -588,8 +588,8 @@ void CSkillManager::checkTitleUnblocked(CHARACTER_TITLE::ECharacterTitle i, bool // This is a new title, send a message string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); - const ucstring newtitle(CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle)); - CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+newtitle.toUtf8()+"|text0="+CI18N::get("uiNewTitleBold")); + const char *newtitle(CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle)); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, string("text1=") + newtitle + "|text0=" + CI18N::get("uiNewTitleBold")); } else { @@ -1097,8 +1097,8 @@ public: { string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); - const ucstring s(CStringManagerClient::getTitleLocalizedName(titleStr,womenTitle)); - pCB->addText(s.toUtf8()); + const char *s = CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle); + pCB->addText(s); pSM->_UIUnblockedTitles.push_back((CHARACTER_TITLE::ECharacterTitle)i); } } diff --git a/ryzom/client/src/interface_v3/sphrase_manager.cpp b/ryzom/client/src/interface_v3/sphrase_manager.cpp index c42d544d1..cf4950fdd 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -3632,7 +3632,7 @@ public: bool Castable; uint32 Type; uint32 Icon; - ucstring Text; + string Text; bool operator<(const CPhraseSortEntry &pse) const { @@ -3840,9 +3840,9 @@ void CSPhraseManager::computePhraseProgression() // replace each number with 001 format. toLower for(uint k=0;ksetText(ucstring(toString(_SheetId.getSInt32()))); + _SheetText->setText(toString(_SheetId.getSInt32())); _SheetText->draw(xOffset,yOffset+20); - _QuantityText->setText(ucstring(toString(_Quantity.getSInt32()))); + _QuantityText->setText(toString(_Quantity.getSInt32())); _QuantityText->draw(xOffset,yOffset+10); - _QualityText->setText(ucstring(toString(_Quality.getSInt32()))); + _QualityText->setText(toString(_Quality.getSInt32())); _QualityText->draw(xOffset,yOffset); */ diff --git a/ryzom/client/src/misc.cpp b/ryzom/client/src/misc.cpp index 4e35cfc2a..0432abf1a 100644 --- a/ryzom/client/src/misc.cpp +++ b/ryzom/client/src/misc.cpp @@ -885,7 +885,7 @@ NLMISC::CRGBA interpClientCfgColor(const string &src, string &dest) colorCode.resize(nextPos - 1); for(uint k = 0; k < nextPos - 1; ++k) { - colorCode[k] = tolower((char) src[k + 1]); + colorCode[k] = tolower((char) src[k + 1]); // TODO: toLowerAscii } std::map::const_iterator it = ClientCfg.SystemInfoParams.find(colorCode); if (it != ClientCfg.SystemInfoParams.end()) @@ -953,7 +953,7 @@ std::string getStringCategoryIfAny(const string &src, string &dest) colorCode.resize( codeSize ); for(ptrdiff_t k = 0; k < (ptrdiff_t)codeSize; ++k) { - colorCode[k] = tolower((char) src[k + startPos + 1]); + colorCode[k] = tolower((char) src[k + startPos + 1]); // TODO: toLowerAscii } string destTmp; if ( startPos != 0 ) diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 6b73acba2..e98d13fe9 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -2494,7 +2494,7 @@ void impulseRemoteAdmin (NLMISC::CBitMemStream &impulse) impulse.serial (cmd); // remove the 2 first rc character if exists, only there to say to the EGS that is a remote command - if (cmd.size()>2 && tolower(cmd[0])=='r' && tolower(cmd[1])=='c') + if (cmd.size()>2 && tolower(cmd[0])=='r' && tolower(cmd[1])=='c') // FIXME: toLowerAscii cmd = cmd.substr(2); mdDisplayVars.clear (); diff --git a/ryzom/client/src/zone_util.cpp b/ryzom/client/src/zone_util.cpp index 33b7fdf68..d7da6810c 100644 --- a/ryzom/client/src/zone_util.cpp +++ b/ryzom/client/src/zone_util.cpp @@ -53,7 +53,7 @@ bool getPosFromZoneName(const std::string &name,NLMISC::CVector2f &dest) while (i < zoneName.size()) { if (!::isalpha(zoneName[i])) return false; - xStr += (char) ::toupper(zoneName[i]); ++i; + xStr += (char) NLMISC::toUpper(zoneName[i]); ++i; } if (xStr.size() != 2) return false; dest.x = 160.f * ((xStr[0] - 'A') * 26 + (xStr[1] - 'A')); @@ -89,7 +89,7 @@ bool getZonePosFromZoneName(const std::string &name, sint &x, sint &y) while (i < zoneName.size()) { if (!::isalpha(zoneName[i])) return false; - xStr += (char) ::toupper(zoneName[i]); ++i; + xStr += (char) NLMISC::toUpper(zoneName[i]); ++i; } if (xStr.size() != 2) return false; x = (xStr[0] - 'A') * 26 + (xStr[1] - 'A'); From 11b453baaa0d5de55eedc08277be3f66c78f443f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 10:10:48 +0800 Subject: [PATCH 15/16] Safe 7-bit upper- and lowercase --- nel/include/nel/misc/common.h | 11 ++++++++ nel/src/misc/common.cpp | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/nel/include/nel/misc/common.h b/nel/include/nel/misc/common.h index bca3372bd..1e99b5e70 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -255,6 +255,17 @@ int compareCaseInsensitive(const char *a, const char *b); int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB); inline int compareCaseInsensitive(const std::string &a, const std::string &b) { return compareCaseInsensitive(&a[0], a.size(), &b[0], b.size()); } +/** ASCII to lowercase. Useful for internal identifiers. +* Characters outside of the 7-bit ASCII space, and control characters, are replaced. +*/ +std::string toLowerAscii(const std::string &str, char replacement); +void toLowerAscii(char *str, char replacement); + +/** ASCII to uppercase. Useful for internal identifiers. +* Characters outside of the 7-bit ASCII space, and control characters, are replaced. +*/ +std::string toUpperAscii(const std::string &str, char replacement); +void toUpperAscii(char *str, char replacement); /** * Convert to an hexadecimal std::string diff --git a/nel/src/misc/common.cpp b/nel/src/misc/common.cpp index 8d046c97c..fce6af69c 100644 --- a/nel/src/misc/common.cpp +++ b/nel/src/misc/common.cpp @@ -689,6 +689,56 @@ void toUpper(char *str) } } +std::string toLowerAscii(const std::string &str, char replacement) +{ + std::string res; + res.reserve(str.size()); + for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it) + { + char c = *it; + if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) res += replacement; + else if (c >= 'A' && c <= 'Z') res += c + ('a' - 'A'); + else res += c; + } + return res; +} + +void toLowerAscii(char *str, char replacement) +{ + for (ptrdiff_t i = 0; str[i]; ++i) + { + char c = str[i]; + if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) str[i] = replacement; + else if (c >= 'A' && c <= 'Z') str[i] = c + ('a' - 'A'); + else str[i] = c; + } +} + +std::string toUpperAscii(const std::string &str, char replacement) +{ + std::string res; + res.reserve(str.size()); + for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it) + { + char c = *it; + if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) res += replacement; + else if (c >= 'a' && c <= 'z') res += c - ('a' - 'A'); + else res += c; + } + return res; +} + +void toUpperAscii(char *str, char replacement) +{ + for (ptrdiff_t i = 0; str[i]; ++i) + { + char c = str[i]; + if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) str[i] = replacement; + else if (c >= 'a' && c <= 'z') str[i] = c - ('a' - 'A'); + else str[i] = c; + } +} + std::string toHexa(const uint8 &b) { return toString("%02hhx", b); From 73b8ba9e4ec054610d345a89f931ab22957207a9 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 11:37:22 +0800 Subject: [PATCH 16/16] UTF-8 various, ryzom/ryzomcore#335 --- nel/include/nel/gui/view_text_id.h | 2 +- nel/src/gui/view_text_id.cpp | 4 +-- .../src/interface_v3/action_handler_help.cpp | 22 ++++++------ .../src/interface_v3/action_handler_item.cpp | 25 +++++++------- .../src/interface_v3/action_handler_misc.cpp | 4 +-- .../interface_v3/action_handler_phrase.cpp | 4 +-- .../src/interface_v3/action_phrase_faber.cpp | 8 ++--- .../bot_chat_page_create_guild.cpp | 6 ++-- .../src/interface_v3/bot_chat_page_trade.cpp | 12 +++---- .../src/interface_v3/chat_text_manager.cpp | 6 ++-- .../src/interface_v3/chat_text_manager.h | 1 - ryzom/client/src/interface_v3/chat_window.cpp | 9 +---- ryzom/client/src/interface_v3/chat_window.h | 3 -- .../client/src/interface_v3/dbctrl_sheet.cpp | 16 ++++----- ryzom/client/src/interface_v3/dbctrl_sheet.h | 2 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 4 +-- .../dbgroup_list_sheet_icon_phrase.cpp | 4 +-- .../interface_v3/dbgroup_list_sheet_mission.h | 2 +- ...roup_list_sheet_text_brick_composition.cpp | 16 ++++----- .../dbgroup_list_sheet_text_phrase.cpp | 4 +-- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_trade.h | 2 +- .../client/src/interface_v3/group_career.cpp | 2 +- .../client/src/interface_v3/group_compas.cpp | 4 +-- .../interface_v3/group_in_scene_bubble.cpp | 6 ++-- .../interface_v3/group_in_scene_user_info.cpp | 20 +++++------ ryzom/client/src/interface_v3/group_map.cpp | 2 +- .../group_phrase_skill_filter.cpp | 6 ++-- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../client/src/interface_v3/interface_ddx.cpp | 4 +-- ryzom/client/src/interface_v3/interface_ddx.h | 2 +- .../src/interface_v3/interface_manager.cpp | 34 +++++++++---------- .../src/interface_v3/interface_manager.h | 10 +++--- .../src/interface_v3/item_special_effect.cpp | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 10 +++--- .../src/interface_v3/people_interraction.cpp | 8 ++--- .../src/interface_v3/sbrick_manager.cpp | 2 +- .../src/interface_v3/sphrase_manager.cpp | 6 ++-- ryzom/client/src/r2/editor.cpp | 6 ++-- ryzom/client/src/zone_util.cpp | 8 ++--- ryzom/common/src/game_share/character_title.h | 4 +-- ryzom/common/src/game_share/utils.h | 9 +++-- 42 files changed, 148 insertions(+), 157 deletions(-) diff --git a/nel/include/nel/gui/view_text_id.h b/nel/include/nel/gui/view_text_id.h index 292f1728a..d29721481 100644 --- a/nel/include/nel/gui/view_text_id.h +++ b/nel/include/nel/gui/view_text_id.h @@ -39,7 +39,7 @@ namespace NLGUI public: virtual ~IOnReceiveTextId() {} // the deriver may change the input text - virtual void onReceiveTextId(ucstring &str) =0; + virtual void onReceiveTextId(std::string &str) =0; }; // *************************************************************************** diff --git a/nel/src/gui/view_text_id.cpp b/nel/src/gui/view_text_id.cpp index 61d97b523..bea55a04d 100644 --- a/nel/src/gui/view_text_id.cpp +++ b/nel/src/gui/view_text_id.cpp @@ -231,9 +231,7 @@ namespace NLGUI // Modify the text? if (_StringModifier) { - ucstring tmp = ucstring::makeFromUtf8(result); - _StringModifier->onReceiveTextId(tmp); // FIXME: UTF-8 - result = tmp.toUtf8(); + _StringModifier->onReceiveTextId(result); } // Set the Text diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index 9cad50e25..102307909 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -2104,9 +2104,7 @@ void getItemText (CDBCtrlSheet *item, string &itemText, const CItemSheet*pIS) INVENTORIES::TInventory inventory = (INVENTORIES::TInventory)item->getInventoryIndex(); sint32 slot = item->getIndexInDB(); string debugText = NLMISC::toString("inventory: %s\nslot: %d\n", INVENTORIES::toString(inventory).c_str(), slot); - ucstring debugText2; - debugText2.fromUtf8(debugText); - itemText = debugText2 + itemText; + itemText = debugText + itemText; #endif } @@ -2536,10 +2534,10 @@ void refreshItemHelp(CSheetHelpSetup &setup) // itemText += CI18N::get("uiRingPlotItemDesc"); // itemText += mi->Description.empty() ? CI18N::get("uiRingPlotItemEmpty") // : mi->Description; -// //itemText += ucstring("\n@{6F6F}") + CI18N::get("uiRingPlotItemComment") + ucstring("\n"); +// //itemText += "\n@{6F6F}" + CI18N::get("uiRingPlotItemComment") + "\n"; // /* // itemText += mi->Comment.empty() ? CI18N::get("uiRingPlotItemEmpty") -// : (ucstring("\n") + mi->Comment); +// : ("\n" + mi->Comment); // */ // } // } @@ -2761,9 +2759,9 @@ void refreshMissionHelp(CSheetHelpSetup &setup, const CPrerequisitInfos &infos) // *************************************************************************** class CPlayerShardNameRemover : public IOnReceiveTextId { - virtual void onReceiveTextId(ucstring &str) + virtual void onReceiveTextId(std::string &str) { - str= CEntityCL::removeShardFromName(str.toUtf8()); + str= CEntityCL::removeShardFromName(str); } }; static CPlayerShardNameRemover PlayerShardNameRemover; @@ -2968,7 +2966,7 @@ void getSabrinaBrickText(CSBrickSheet *pBR, string &brickText) if( pBR->getSkill()==SKILLS::unknown ) { string::size_type pos0= brickText.find(killSkill); - if(pos0 != ucstring::npos) + if(pos0 != string::npos) { string::size_type pos1= brickText.find(killSkill, pos0 + killSkill.size() ); if(pos1 != string::npos) @@ -3668,7 +3666,7 @@ public: } } - ucstring str; + string str; BOMB_IF( minTimeRemaining < 0, "at least one animal should be dead", return; ); str += CI18N::get("uittAnimalDeadPopupToolTip"); @@ -3676,7 +3674,7 @@ public: str += toString(minTimeRemaining); // replace the context help that is required. - CWidgetManager::getInstance()->setContextHelpText(str.toUtf8()); + CWidgetManager::getInstance()->setContextHelpText(str); } }; REGISTER_ACTION_HANDLER( CHandlerAnimalDeadPopupTooltip, "animal_dead_popup_tooltip"); @@ -3800,13 +3798,13 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s CViewText *viewText= dynamic_cast(groupMp->getElement(groupMp->getId()+":text" )); if(viewText) { - ucstring mpCraft; + string mpCraft; // add the Origin filter. string originFilterKey= "iompf" + ITEM_ORIGIN::enumToString((ITEM_ORIGIN::EItemOrigin)itemPart.OriginFilter); mpCraft+= CI18N::get(originFilterKey); - viewText->setText(mpCraft.toUtf8()); + viewText->setText(mpCraft); } diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 1f8cd61b0..cdd47be2a 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -141,14 +141,14 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { - ucstring customText; + string customText; if (!itemInfo.CustomText.empty()) { - customText = itemInfo.CustomText; - strFindReplace(customText, "%mfc", ucstring()); + customText = itemInfo.CustomText.toUtf8(); // TODO: UTF-8 (serial) + strFindReplace(customText, "%mfc", string()); } - editBoxShort->setInputStringAsUtf16(customText); + editBoxShort->setInputString(customText); editShort->setActive(true); editBoxShort->setActive(true); @@ -263,14 +263,14 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() else { - ucstring customText; + string customText; if (!itemInfo.CustomText.empty()) { - customText = itemInfo.CustomText; - strFindReplace(customText, "%mfc", ucstring()); + customText = itemInfo.CustomText.toUtf8(); + strFindReplace(customText, "%mfc", string()); } - editBoxShort->setInputStringAsUtf16(customText); + editBoxShort->setInputString(customText); editShort->setActive(true); editBoxShort->setActive(true); @@ -407,11 +407,11 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) { bool textValid = editShort->getActive(); - ucstring text = editBoxShort->getInputStringAsUtf16(); + string text = editBoxShort->getInputString(); if (!textValid) { textValid = editLarge->getActive(); - text = editBoxLarge->getInputStringAsUtf16(); + text = editBoxLarge->getInputString(); } if (textValid) @@ -428,7 +428,8 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() out.serial(uiInventory); uint32 uiSlot = (uint32)pCSItem->getIndexInDB(); out.serial(uiSlot); - out.serial(text); + ucstring ucText = ucstring::makeFromUtf8(text); // TODO: UTF-8 (serial) + out.serial(ucText); NetMngr.push(out); //nlinfo("impulseCallBack : %s %s %d \"%s\" sent", msgName.c_str(), INVENTORIES::toString((INVENTORIES::TInventory)pCSItem->getInventoryIndex()).c_str(), pCSItem->getIndexInDB(), text.toUtf8().c_str()); } @@ -2123,7 +2124,7 @@ class CHandlerItemMenuCheck : public IActionHandler { std::string name = groupNames[i]; std::string ahParams = "name=" + name; - //Use ucstring because group name can contain accentued characters (and stuff like that) + //Use utf-8 string because group name can contain accentued characters (and stuff like that) pGroupMenu->addLine(name, "", "", name); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 73c967bcb..b9c71bc56 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -924,8 +924,8 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(string &inOut) inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(strNewTitle, Woman); { // Sometimes translation contains another title - ucstring::size_type pos = inOut.find('$'); - if (pos != ucstring::npos) + string::size_type pos = inOut.find('$'); + if (pos != string::npos) { inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut), Woman); } diff --git a/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 16a65e336..489dcbc35 100644 --- a/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -1692,7 +1692,7 @@ public: if(!ctrlSheet) return; - ucstring str(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(CSheetId(ctrlSheet->getSheetId()))); + string str(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(CSheetId(ctrlSheet->getSheetId()))); // According to locked state if(ctrlSheet->getGrayed()) @@ -1700,7 +1700,7 @@ public: else strFindReplace(str, "%comp", CI18N::get("uittPhraseCombatRestrictOK")); - CWidgetManager::getInstance()->setContextHelpText(str.toUtf8()); + CWidgetManager::getInstance()->setContextHelpText(str); } }; REGISTER_ACTION_HANDLER( CHandlerCombatRestrictTooltip, "phrase_combat_restrict_tooltip"); diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 47fda6d00..f23152b8a 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -510,7 +510,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick CViewText *viewText= dynamic_cast(itemReqLineGroup->getView(FaberPhraseText)); if(viewText) { - ucstring text; + string text; if(mpBuild.RequirementType==CMPBuild::ItemPartReq) { text= CI18N::get("uihelpFaberMpHeader"); @@ -524,7 +524,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick { nlstop; } - viewText->setText( text.toUtf8() ); + viewText->setText(text); } // Set as Icon the required MP FaberType / or Sheet Texture (directly...) @@ -1687,7 +1687,7 @@ void CActionPhraseFaber::updateItemResult() CViewText *successView= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseFpSuccessText)); if(successView) { - ucstring text= CI18N::get("uiPhraseFaberSuccessRate"); + string text= CI18N::get("uiPhraseFaberSuccessRate"); // Get the success rate of the related phrase uint phraseSlot= pPM->getMemorizedPhrase(_ExecuteFromMemoryLine, _ExecuteFromMemoryIndex); @@ -1725,7 +1725,7 @@ void CActionPhraseFaber::updateItemResult() + "@{FFFF})"; } strFindReplace(text, "%success", successStr ); - successView->setTextFormatTaged(text.toUtf8()); + successView->setTextFormatTaged(text); } diff --git a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index 143a71837..649f2bd16 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -71,10 +71,10 @@ class CHandlerGuildCreate : public IActionHandler CGroupEditBox *pDesc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildDescWin)); - ucstring guildName = pGEB->getInputStringAsUtf16(); + ucstring guildName = pGEB->getInputStringAsUtf16(); // FIXME: UTF-8 (serial) - ucstring guildDesc; - if (pDesc != NULL) guildDesc = pDesc->getInputStringAsUtf16(); + ucstring guildDesc; // FIXME: UTF-8 (serial) + if (pDesc != NULL) guildDesc = pDesc->getInputStringAsUtf16(); // FIXME: UTF-8 (serial) uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(), pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2()); diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 13e60fff8..2725eedc9 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -1011,9 +1011,9 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal CViewText *itemNameView = dynamic_cast(ig->getView("object_name")); if (itemNameView) { - ucstring itemName; + string itemName; itemName = sheet->getItemActualName(); - itemNameView->setText(itemName.toUtf8()); + itemNameView->setText(itemName); } // set help for item @@ -1678,16 +1678,16 @@ void CBotChatPageTrade::setupFactionPointPrice(bool /* sellMode */, uint default CViewText *vt= dynamic_cast(fpGroup->getView("unit_price_header")); if(vt) { - ucstring fmt= CI18N::get("uiUnitFPPrice"); + string fmt= CI18N::get("uiUnitFPPrice"); strFindReplace(fmt, "%fac", factionName); - vt->setText(fmt.toUtf8()); + vt->setText(fmt); } vt= dynamic_cast(fpGroup->getView("total_price_header")); if(vt) { - ucstring fmt= CI18N::get("uiTotalFPPrice"); + string fmt= CI18N::get("uiTotalFPPrice"); strFindReplace(fmt, "%fac", factionName); - vt->setText(fmt.toUtf8()); + vt->setText(fmt); } // setup icon according to pvp clan diff --git a/ryzom/client/src/interface_v3/chat_text_manager.cpp b/ryzom/client/src/interface_v3/chat_text_manager.cpp index 3e99cd8b5..eb79f4211 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -156,14 +156,14 @@ static CInterfaceGroup *buildLineWithCommand(CInterfaceGroup *commandGroup, CVie return group; } -static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstring::size_type textSize) +static inline bool isUrlTag(const string &s, string::size_type index, string::size_type textSize) { // Format http://, https:// // or markdown style (title)[http://..] if(textSize > index+7) { bool markdown = false; - ucstring::size_type i = index; + string::size_type i = index; // advance index to url section if markdown style link is detected if (s[i] == '(') { @@ -188,7 +188,7 @@ static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstri if (textSize > i + 7) { - bool isUrl = (toLower(s.substr(i, 7)) == ucstring("http://") || toLower(s.substr(i, 8)) == ucstring("https://")); + bool isUrl = (toLower(s.substr(i, 7)) == "http://" || toLower(s.substr(i, 8)) == "https://"); // match "text http://" and not "texthttp://" if (isUrl && i > 0 && !markdown) { diff --git a/ryzom/client/src/interface_v3/chat_text_manager.h b/ryzom/client/src/interface_v3/chat_text_manager.h index 1cf66730e..2cc71dd0e 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.h +++ b/ryzom/client/src/interface_v3/chat_text_manager.h @@ -30,7 +30,6 @@ namespace NLGUI class CInterfaceGroup; } -class ucstring; namespace NLMISC{ class CCDBNodeLeaf; } diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index 816a2016a..e1667839d 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -351,13 +351,6 @@ void CChatWindow::setCommand(const std::string &command, bool execute) _EB->setCommand(command, execute); } -void CChatWindow::setCommand(const ucstring &command,bool execute) -{ - if (!_EB) return; - _EB->setCommand(command.toUtf8(), execute); -} - - //================================================================================= void CChatWindow::setEntry(const string &entry) { @@ -624,7 +617,7 @@ void CChatGroupWindow::displayMessage(const string &msg, NLMISC::CRGBA col, CCha prefix = (title.empty() ? "" : " ") + title; pos = newmsg.find("] "); - if (pos == ucstring::npos) + if (pos == string::npos) newmsg = prefix + newmsg; else newmsg = newmsg.substr(0, pos) + prefix + newmsg.substr(pos); diff --git a/ryzom/client/src/interface_v3/chat_window.h b/ryzom/client/src/interface_v3/chat_window.h index 9a299ebfb..88104e4f9 100644 --- a/ryzom/client/src/interface_v3/chat_window.h +++ b/ryzom/client/src/interface_v3/chat_window.h @@ -23,7 +23,6 @@ #ifndef CL_CHAT_WINDOW_H #define CL_CHAT_WINDOW_H -#include "nel/misc/ucstring.h" // REMOVE #include "nel/misc/smart_ptr.h" #include "game_share/chat_group.h" @@ -109,8 +108,6 @@ public: void enableBlink(uint numBlinks); // set a command to be displayed and eventually executed in this chat window. std::string version for backward compatibility void setCommand(const std::string &command, bool execute); - // set a command to be displayed and eventually executed in this chat window - void setCommand(const ucstring &command, bool execute); // REMOVE // set a string to be displayed in the edit box of this window (if it has one) void setEntry(const std::string &entry); // Set listener to react to a chat entry diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index dcfdc1fc9..ee01fc913 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1665,7 +1665,7 @@ void CDBCtrlSheet::setupSBrick () } // *************************************************************************** -void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector &bricks, const ucstring &phraseName) +void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector &bricks, const string &phraseName) { CSBrickManager *pBM = CSBrickManager::getInstance(); @@ -1718,7 +1718,7 @@ void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector &bri { // Compute the text from the phrase only if needed // string iconName= phraseName.toString(); - string iconName= phraseName.toUtf8(); + const string &iconName = phraseName; if( _NeedSetup || iconName != _OptString ) { // recompute text @@ -1741,7 +1741,7 @@ void CDBCtrlSheet::setupSPhrase() CSPhraseSheet *pSPS = dynamic_cast(SheetMngr.get(CSheetId(sheet))); if (pSPS && !pSPS->Bricks.empty()) { - const ucstring phraseName(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(CSheetId(sheet))); + const char *phraseName = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(CSheetId(sheet)); setupDisplayAsPhrase(pSPS->Bricks, phraseName); } else @@ -1799,7 +1799,7 @@ void CDBCtrlSheet::setupSPhraseId () } else { - setupDisplayAsPhrase(phrase.Bricks, phrase.Name); + setupDisplayAsPhrase(phrase.Bricks, phrase.Name.toUtf8()); // FIXME: UTF-8 (serial) } } @@ -3512,11 +3512,11 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const game = game["game"]; game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1); // retrieve result from stack - ucstring tmpHelp; + ucstring tmpHelp; // FIXME: Lua UTF-8 if (!ls->empty()) { CLuaIHM::pop(*ls, tmpHelp); // FIXME: Lua UTF-8 - help = tmpHelp.toUtf8(); + help = tmpHelp.toUtf8(); // FIXME: Lua UTF-8 } else { @@ -3537,10 +3537,10 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const if (phraseSheetID != 0) { // is it a built-in phrase? - ucstring desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID)); + string desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID)); if (!desc.empty()) { - help += ucstring("\n\n@{CCCF}") + desc; + help += "\n\n@{CCCF}" + desc; } } */ diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.h b/ryzom/client/src/interface_v3/dbctrl_sheet.h index dfe3b7140..a26a74b22 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -626,7 +626,7 @@ protected: // optSheet is for special faber void setupDisplayAsSBrick(sint32 sheet, sint32 optSheet= 0); // setup icon from phrases - void setupDisplayAsPhrase(const std::vector &bricks, const ucstring &phraseName); + void setupDisplayAsPhrase(const std::vector &bricks, const std::string &phraseName); // draw a number and returns the width of the drawn number sint32 drawNumber(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, NLMISC::CRGBA color, sint32 value, bool rightAlign=true); diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index 4f173088d..cbc183f35 100644 --- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -296,7 +296,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase) CSBrickManager *pBM= CSBrickManager::getInstance(); - ucstring name; + string name; // if phrase empty (new phrase), invent a new name if(phrase.empty()) @@ -310,7 +310,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase) else { // copy name - name= phrase.Name; + name= phrase.Name.toUtf8(); // get the root Brick. Must exist. CSBrickSheet *rootBrick= pBM->getBrick(phrase.Bricks[0]); diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp index 19083e4ee..e0d4654c8 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp @@ -136,13 +136,13 @@ void CDBGroupListSheetIconPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin CViewText *name = dynamic_cast(pIG->getView("name")); if (name != NULL) { - ucstring sectionText= CI18N::get("uiPhraseSectionFmt"); + string sectionText= CI18N::get("uiPhraseSectionFmt"); uint32 minLevel, maxLevel; CSPhraseManager *pPM= CSPhraseManager::getInstance(); pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%max", toString(maxLevel)); - name->setText (sectionText.toUtf8()); + name->setText (sectionText); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h index b2781eff6..59913998d 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.h @@ -36,7 +36,7 @@ public: // A child node struct CSheetChildMission : public CDBGroupListSheetText::CSheetChild { - virtual void updateText(CDBGroupListSheetText * /* pFather */, ucstring &/* text */) {} + //virtual void updateText(CDBGroupListSheetText * /* pFather */, std::string &/* text */) {} virtual CViewText *createViewText() const; virtual void updateViewText(CDBGroupListSheetText *pFather); virtual bool isInvalidated(CDBGroupListSheetText *pFather); diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp index e8ad3a2e8..842cb4ba7 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp @@ -110,11 +110,11 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::init(CDBGroupListS // *************************************************************************** -bool hasOnlyBlankChars(const ucstring &str) +bool hasOnlyBlankChars(const char *str) { - for(uint i=0;i!=str.size();++i) + for (ptrdiff_t i = 0; str[i]; ++i) { - if(str[i]!=' ') + if (str[i] != ' ') return false; } @@ -128,20 +128,20 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB CSBrickManager *pBM= CSBrickManager::getInstance(); CDBGroupListSheetTextBrickComposition *compoList= (CDBGroupListSheetTextBrickComposition*)pFather; - ucstring text; + string text; if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SBrick) return; // Get the compo description of the phrase (Desc2) CSheetId brickSheetId= CSheetId(Ctrl->getSheetId()); // Temp if the Desc2 is empty, set Name - ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); - if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation - Text->setText(desc2.toUtf8()); + const char *desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); + if( *desc2 && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation + Text->setText(desc2); else { desc2 = STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheetId); - Text->setText(desc2.toUtf8()); + Text->setText(desc2); } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp index cad06e699..80209c99e 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp @@ -168,13 +168,13 @@ void CDBGroupListSheetTextPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin CViewText *name = dynamic_cast(pIG->getView("name")); if (name != NULL) { - ucstring sectionText= CI18N::get("uiPhraseSectionFmt"); + string sectionText= CI18N::get("uiPhraseSectionFmt"); uint32 minLevel, maxLevel; CSPhraseManager *pPM= CSPhraseManager::getInstance(); pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%max", toString(maxLevel)); - name->setText (sectionText.toUtf8()); + name->setText (sectionText); } } 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 f8b5d4b56..a09e69801 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -432,7 +432,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT // else display the name of the vendor (not if this is the player himself, to avoid flood) else if (LastSellerType == BOTCHATTYPE::Resale) { - text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString.toUtf8(); + text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString; } } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h index 5d6e121d5..0678ab145 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h @@ -96,7 +96,7 @@ public: CInterfaceProperty CurrentVendorNameId; CInterfaceProperty CurrentFactionType; CInterfaceProperty CurrentFactionPointPrice; - ucstring VendorNameString; + std::string VendorNameString; virtual void init(CDBGroupListSheetText *pFather, uint index); virtual bool isInvalidated(CDBGroupListSheetText *pFather); diff --git a/ryzom/client/src/interface_v3/group_career.cpp b/ryzom/client/src/interface_v3/group_career.cpp index 10cfca35e..c04d98841 100644 --- a/ryzom/client/src/interface_v3/group_career.cpp +++ b/ryzom/client/src/interface_v3/group_career.cpp @@ -128,7 +128,7 @@ bool CGroupJob::parse (xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */ // return false; // } // -// ucstring sTmp = JOBS::jobToUCString(Job); +// string sTmp = JOBS::jobToUCString(Job); // for (uint32 i= 0; i < sTmp.size(); ++i) // if (sTmp[i] < 128) // if ( (sTmp[i] >= 'a') && (sTmp[i] <= 'z') ) diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index a78c94681..f36e6a637 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -750,8 +750,8 @@ void CGroupCompasMenu::setActive (bool state) /*CEntityCL *entity = EntitiesMngr.entity(UserEntity->selection()); if (entity != NULL) {*/ - //ucstring targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); - std::string targetName = CI18N::get("uiTarget"); + //string targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); + string targetName = CI18N::get("uiTarget"); ct.setType(CCompassTarget::Selection); ct.Name = targetName; Targets.push_back(ct); 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 9f03834c8..ab9f1c6c7 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -472,11 +472,11 @@ void CGroupInSceneBubbleManager::update () // Send to the around me window // TODO must get the name of the bot etc... /* - ucstring finalString = res; + string finalString = res; for(;;) { - std::string::size_type index = finalString.find (ucstring("{break}")); - if (index == ucstring::npos) break; + std::string::size_type index = finalString.find ("{break}"); + if (index == string::npos) break; finalString = finalString.substr (0, index) + finalString.substr(index+7,finalString.size()); } 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 ee2f6c526..276f248a5 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 @@ -212,10 +212,10 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) entityTitle.clear(); } - ucstring entityTag1 = entity->getTag(1); - ucstring entityTag2 = entity->getTag(2); - ucstring entityTag3 = entity->getTag(3); - ucstring entityTag4 = entity->getTag(4); + string entityTag1 = entity->getTag(1); + string entityTag2 = entity->getTag(2); + string entityTag3 = entity->getTag(3); + string entityTag4 = entity->getTag(4); string entityPermanentContent = entity->getPermanentStatutIcon(); @@ -471,17 +471,17 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) { bitmap = dynamic_cast(leftGroup->getView ("rp_logo_1")); if (bitmap) - bitmap->setTexture(entityTag1.toString()); + bitmap->setTexture(entityTag1); bitmap = dynamic_cast(leftGroup->getView ("rp_logo_2")); if (bitmap) - bitmap->setTexture(entityTag2.toString()); + bitmap->setTexture(entityTag2); } bitmap = dynamic_cast(leftGroup->getView ("rp_logo_3")); if (bitmap) - bitmap->setTexture(entityTag3.toString()); + bitmap->setTexture(entityTag3); bitmap = dynamic_cast(leftGroup->getView ("rp_logo_4")); if (bitmap) - bitmap->setTexture(entityTag4.toString()); + bitmap->setTexture(entityTag4); } // Get the permanent content bitmap @@ -959,14 +959,14 @@ void CGroupInSceneUserInfo::updateDynamicData () { _Name->setColor(entityColor); _Name->setModulateGlobalColor(false); - ucstring entityName = _Entity->getDisplayName(); + string entityName = _Entity->getDisplayName(); if (entityName.empty()) entityName = _Entity->getTitle(); if (pPlayer != NULL) if (pPlayer->isAFK()) entityName += CI18N::get("uiAFK"); - _Name->setText(entityName.toUtf8()); + _Name->setText(entityName); // Title color get the PVP color if (_Title) diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index 8582b938e..45bcf79c2 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -146,7 +146,7 @@ static void popupLandMarkNameDialog() else { NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(CUserLandMark::Misc)); - eb->setInputStringAsUtf16(ucstring()); + eb->setInputString(string()); } CWidgetManager::getInstance()->setCaptureKeyboard(eb); 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 7d2054fc4..48d3bd8d4 100644 --- a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -191,9 +191,9 @@ void CGroupPhraseSkillFilter::rebuild() uint nCounter = 0; // local variable (avoid realloc in loop) - vector< pair > tempVec(2); - ucstring sSkillName; - string sDBNameSkillValue; + // vector< pair > tempVec(2); + // string sSkillName; + // string sDBNameSkillValue; // Build the hierarchy while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp index 39fe7e05e..6d8a0f864 100644 --- a/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/ryzom/client/src/interface_v3/guild_manager.cpp @@ -1266,7 +1266,7 @@ class CHandlerInvGuildToBag : public IActionHandler if (!bPlaceFound) { - ucstring msg = CI18N::get("msgCantPutItemInBag"); + string msg = CI18N::get("msgCantPutItemInBag"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; diff --git a/ryzom/client/src/interface_v3/interface_ddx.cpp b/ryzom/client/src/interface_v3/interface_ddx.cpp index 36bd17e62..230b7a2c2 100644 --- a/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -351,7 +351,7 @@ void CInterfaceDDX::CParam::updateScrollView(sint32 nVal) { if(ResultView) { - ResultView->setText(toString(nVal) + ResultUnit.toUtf8()); + ResultView->setText(toString(nVal) + ResultUnit); } } @@ -362,7 +362,7 @@ void CInterfaceDDX::CParam::updateScrollView(double nVal) { // allow N digits string fmt= toString("%%.%df", ResultDecimal); - ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit.toUtf8()); + ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit); } } diff --git a/ryzom/client/src/interface_v3/interface_ddx.h b/ryzom/client/src/interface_v3/interface_ddx.h index 48f329053..2be1c84b4 100644 --- a/ryzom/client/src/interface_v3/interface_ddx.h +++ b/ryzom/client/src/interface_v3/interface_ddx.h @@ -79,7 +79,7 @@ private: // The tex view, result of the scroll CViewTextPtr ResultView; // The unit to append to the result string - ucstring ResultUnit; + std::string ResultUnit; // For ScrollBarFloat widget only uint8 ResultDecimal; // For ScrollBarFloat widget only diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index aa38b6dbf..3329a2aae 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1527,7 +1527,7 @@ void CInterfaceManager::updateFrameEvents() if ((T0 - _UpdateWeatherTime) > (1 * 3 * 1000)) { _UpdateWeatherTime = T0; - ucstring str = CI18N::get ("uiTheSeasonIs") + + string str = CI18N::get ("uiTheSeasonIs") + CI18N::get ("uiSeason"+toStringEnum(computeCurrSeason())) + CI18N::get ("uiAndTheWeatherIs") + CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName) + @@ -1537,7 +1537,7 @@ void CInterfaceManager::updateFrameEvents() CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather")); if (pVT != NULL) - pVT->setText(str.toUtf8()); + pVT->setText(str); CCtrlBase *pTooltip= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt")); if (pTooltip != NULL) @@ -1571,7 +1571,7 @@ void CInterfaceManager::updateFrameEvents() pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time")); if (pVT != NULL) - pVT->setText(str.toUtf8()); + pVT->setText(str); str.clear(); // Update the clock in the compass if enabled. @@ -1584,7 +1584,7 @@ void CInterfaceManager::updateFrameEvents() str = getTimestampHuman("%I:%M %p"); else str = getTimestampHuman("%H:%M"); - pVT->setText(str.toUtf8()); + pVT->setText(str); } } } @@ -2389,7 +2389,7 @@ void CInterfaceManager::processServerIDString() } // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucstring &text, const string &masterGroup, TCaseMode caseMode) +void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const string &text, const string &masterGroup, TCaseMode caseMode) { CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + msgBoxGroup)); CViewText *viewText= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + msgBoxGroup + ":text")); @@ -2397,7 +2397,7 @@ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucst if (group && viewText) { viewText->setCaseMode(caseMode); - viewText->setText(text.toUtf8()); + viewText->setText(text); CWidgetManager::getInstance()->enableModalWindow(NULL, group); // don't understand why but need to update coords here group->updateCoords(); @@ -2406,7 +2406,7 @@ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucst } // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBox(const ucstring &text, const string &masterGroup, TCaseMode caseMode) +void CInterfaceManager::messageBox(const string &text, const string &masterGroup, TCaseMode caseMode) { messageBoxInternal("message_box", text, masterGroup, caseMode); } @@ -2435,7 +2435,7 @@ void CInterfaceManager::messageBoxWithHelp(const std::string &text, const std::s // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring &text, const std::string &ahOnOk, +void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const std::string &text, const std::string &ahOnOk, const std::string ¶msOnOk, const std::string &ahOnCancel, const std::string ¶msOnCancel, const string &masterGroup) { CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":valid_message_box")); @@ -2450,7 +2450,7 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring & CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel); // set text and icon - viewText->setText(text.toUtf8()); + viewText->setText(text); if(viewBitmap) { bool active= true; @@ -2978,7 +2978,7 @@ bool CInterfaceManager::deletePlayerKeys (const std::string &playerFileIdent) } // *************************************************************************** -void CInterfaceManager::log(const ucstring &str, const std::string &cat) +void CInterfaceManager::log(const std::string &str, const std::string &cat) { if (_LogState) { @@ -2987,7 +2987,7 @@ void CInterfaceManager::log(const ucstring &str, const std::string &cat) FILE *f = nlfopen(fileName, "at"); if (f != NULL) { - const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8(); + const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str; fprintf(f, "%s\n", finalString.c_str()); fclose(f); } @@ -3176,8 +3176,8 @@ struct CEmoteEntry string::size_type pos1 = path1.find('|'); string::size_type pos2 = path2.find('|'); - ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); - ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); + string s1 = toUpper(CI18N::get(path1.substr(0, pos1))); + string s2 = toUpper(CI18N::get(path2.substr(0, pos2))); sint result = s1.compare(s2); if (result != 0) @@ -3195,14 +3195,14 @@ struct CEmoteEntry } }; -static bool translateEmote(const std::string &id, ucstring &translatedName, std::string &commandName, std::string &commandNameAlt) +static bool translateEmote(const std::string &id, std::string &translatedName, std::string &commandName, std::string &commandNameAlt) { if (CI18N::hasTranslation(id)) { translatedName = CI18N::get(id); // convert command to utf8 since emote translation can have strange chars - commandName = toLower(translatedName).toUtf8(); + commandName = toLower(translatedName); // replace all spaces by _ while (strFindReplace(commandName, " ", "_")); @@ -3301,7 +3301,7 @@ void CInterfaceManager::initEmotes() CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); nlassert(pMenu); - ucstring sTranslatedName; + std::string sTranslatedName; std::string sCommandName; std::string sCommandNameAlt; @@ -3345,7 +3345,7 @@ void CInterfaceManager::initEmotes() translateEmote(sTmp, sTranslatedName, sCommandName, sCommandNameAlt); // Create a line - pMenu->addLine (sTranslatedName.toUtf8() + " (/" + sCommandName + ")", "emote", + pMenu->addLine (sTranslatedName + " (/" + sCommandName + ")", "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), sTmp); } } diff --git a/ryzom/client/src/interface_v3/interface_manager.h b/ryzom/client/src/interface_v3/interface_manager.h index 91178677d..5206e0513 100644 --- a/ryzom/client/src/interface_v3/interface_manager.h +++ b/ryzom/client/src/interface_v3/interface_manager.h @@ -241,7 +241,7 @@ public: // Log system (all chat/tell void setLogState(bool state) { _LogState = state; } bool getLogState() const { return _LogState; } - void log(const ucstring &str, const std::string &cat = ""); + void log(const std::string &str, const std::string &cat = ""); /// Text from here and from server @@ -305,7 +305,7 @@ public: /** Open a MessageBox. this is a simple ModalWindow with a Ok button * ui:interface:message_box must be defined in xml, with a "text" ViewText son */ - void messageBox(const ucstring &text, const std::string &masterGroup="ui:interface", TCaseMode caseMode = CaseFirstSentenceLetterUp); + void messageBox(const std::string &text, const std::string &masterGroup="ui:interface", TCaseMode caseMode = CaseFirstSentenceLetterUp); /** Open a MessageBox. this is a simple ModalWindow with a Ok and a HELP button. * The help button with open a browser on ryzom.com faq * ui:interface:message_box_with_help must be defined in xml, with a "text" ViewText son @@ -321,7 +321,7 @@ public: * \param ahOnCancel => the action handler to call if cancel is pressed. NB: you don't have to call leave_modal in this ah (auto done). * \param paramsOnCancel => params passed to ahOnCancel. */ - void validMessageBox(TValidMessageIcon icon, const ucstring &text, const std::string &ahOnOk, const std::string ¶msOnOk= std::string(), + void validMessageBox(TValidMessageIcon icon, const std::string &text, const std::string &ahOnOk, const std::string ¶msOnOk= std::string(), const std::string &ahOnCancel= std::string(), const std::string ¶msOnCancel= std::string(), const std::string &masterGroup="ui:interface"); /** Get the current running validMessageBox OnOk action. empty if no validMessageBox currently opened @@ -446,7 +446,7 @@ public: */ static char* getTimestampHuman(const char* format = "[%H:%M:%S] "); - /** Parses any tokens in the ucstring like $t$ or $g()$ + /** Parses any tokens in the utf-8 string like $t$ or $g()$ */ static bool parseTokens(std::string& ucstr); @@ -672,7 +672,7 @@ private: CServerToLocalAutoCopy ServerToLocalAutoCopyDMGift; // Pop a new message box. If the message box was found, returns a pointer on it - void messageBoxInternal(const std::string &msgBoxGroup, const ucstring &text, const std::string &masterGroup, TCaseMode caseMode); + void messageBoxInternal(const std::string &msgBoxGroup, const std::string &text, const std::string &masterGroup, TCaseMode caseMode); CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater; }; diff --git a/ryzom/client/src/interface_v3/item_special_effect.cpp b/ryzom/client/src/interface_v3/item_special_effect.cpp index fdb53a0ec..84dbdf785 100644 --- a/ryzom/client/src/interface_v3/item_special_effect.cpp +++ b/ryzom/client/src/interface_v3/item_special_effect.cpp @@ -66,7 +66,7 @@ void CItemSpecialEffectHelper::registerItemSpecialEffect(const string &name) { string tmp = "%"; tmp += s[0]; - if (s.size() >=2 && isdigit(s[1])) + if (s.size() >=2 && (uint8)s[1] < (uint8)'\x80' && isdigit(s[1])) tmp += s[1]; params.push_back(tmp); } diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 0e97c73f7..bd2377bcb 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -825,7 +825,7 @@ int CLuaIHMRyzom::validMessageBox(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 6, LUA_TSTRING); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg, ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); + im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); return 0; } @@ -2889,7 +2889,7 @@ void CLuaIHMRyzom::messageBox(const ucstring &text) { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBox(text); + pIM->messageBox(text.toUtf8()); } // *************************************************************************** @@ -2897,7 +2897,7 @@ void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGr { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBox(text, masterGroup); + pIM->messageBox(text.toUtf8(), masterGroup); } // *************************************************************************** @@ -2910,7 +2910,7 @@ void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGr //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBox(text, masterGroup, (TCaseMode) caseMode); + pIM->messageBox(text.toUtf8(), masterGroup, (TCaseMode) caseMode); } // *************************************************************************** @@ -3652,7 +3652,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.toUtf8()) + ucstring(" "), false); + w->setCommand("tell " + CEntityCL::removeTitleFromName(player.toUtf8()) + " ", 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 98432cdb8..d1c43d897 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -3201,7 +3201,7 @@ NLMISC_COMMAND(party_chat, "Create a new party chat", "") return true; } CPeopleInterraction &pi = PeopleInterraction; - ucstring title = args[0]; + string title = args[0]; if (!pi.testValidPartyChatName(title)) { @@ -3221,16 +3221,16 @@ NLMISC_COMMAND(remove_party_chat, "Remove a party chat", "") displayVisibleSystemMsg(CI18N::get("uiRemovePartyChatCmd")); return true; } - ucstring title = ucstring(args[0]); + string title = ucstring(args[0]); CChatWindow *chat = getChatWndMgr().getChatWindow(title); if (!chat) { - displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiBadPartyChatName")); + displayVisibleSystemMsg(title + " : " + CI18N::get("uiBadPartyChatName")); return true; } if (!PeopleInterraction.removePartyChat(chat)) { - displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiCantRemovePartyChat")); + displayVisibleSystemMsg(title + " : " + CI18N::get("uiCantRemovePartyChat")); return true; } return true; diff --git a/ryzom/client/src/interface_v3/sbrick_manager.cpp b/ryzom/client/src/interface_v3/sbrick_manager.cpp index a2cecf2d4..780b1301c 100644 --- a/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -486,7 +486,7 @@ void CSBrickManager::compileBrickProperties() k++; } // Param Id modifier? (ie read not the 0th value, but the 1th etc... up to 9) - else if(k 0) { int currChar = (int) baseName[lastIndex]; - if (!isdigit(currChar) && + if (((uint8)currChar >= (uint8)'\x80' || !isdigit(currChar)) && currChar != ' ' && currChar != '\t') { @@ -4289,7 +4289,7 @@ ucstring CEditor::genInstanceName(const ucstring &baseName) while (lastIndex > 0) { int currChar = (int) strippedName[lastIndex]; - if (!isdigit(currChar) && + if (((uint8)currChar >= (uint8)'\x80' || !isdigit(currChar)) && currChar != ' ' && currChar != '\t') { diff --git a/ryzom/client/src/zone_util.cpp b/ryzom/client/src/zone_util.cpp index d7da6810c..0f2a84636 100644 --- a/ryzom/client/src/zone_util.cpp +++ b/ryzom/client/src/zone_util.cpp @@ -44,7 +44,7 @@ bool getPosFromZoneName(const std::string &name,NLMISC::CVector2f &dest) uint32 i = 0; while (zoneName[i] != '_') { - if (!::isdigit(zoneName[i])) return false; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isdigit(zoneName[i])) return false; yStr += zoneName[i]; ++i; if (i == zoneName.size()) return false; @@ -52,7 +52,7 @@ bool getPosFromZoneName(const std::string &name,NLMISC::CVector2f &dest) ++i; while (i < zoneName.size()) { - if (!::isalpha(zoneName[i])) return false; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isalpha(zoneName[i])) return false; xStr += (char) NLMISC::toUpper(zoneName[i]); ++i; } if (xStr.size() != 2) return false; @@ -80,7 +80,7 @@ bool getZonePosFromZoneName(const std::string &name, sint &x, sint &y) uint32 i = 0; while (zoneName[i] != '_') { - if (!::isdigit(zoneName[i])) return false; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isdigit(zoneName[i])) return false; yStr += zoneName[i]; ++i; if (i == zoneName.size()) return false; @@ -88,7 +88,7 @@ bool getZonePosFromZoneName(const std::string &name, sint &x, sint &y) ++i; while (i < zoneName.size()) { - if (!::isalpha(zoneName[i])) return false; + if ((uint8)zoneName[i] >= (uint8)'\x80' || !::isalpha(zoneName[i])) return false; xStr += (char) NLMISC::toUpper(zoneName[i]); ++i; } if (xStr.size() != 2) return false; diff --git a/ryzom/common/src/game_share/character_title.h b/ryzom/common/src/game_share/character_title.h index 5ad8c3c10..bae0c2a4b 100644 --- a/ryzom/common/src/game_share/character_title.h +++ b/ryzom/common/src/game_share/character_title.h @@ -301,9 +301,9 @@ inline ECharacterTitle getGMTitleFromPriv (const std::string& priv) //---------------------------------------------------------------------- -inline bool isCsrTitle(const ucstring& title) +inline bool isCsrTitle(const std::string& title) { - ECharacterTitle titleEnum = toCharacterTitle( title.toUtf8() ); + ECharacterTitle titleEnum = toCharacterTitle( title ); bool bIsCsrTitle = (titleEnum >= SGM && titleEnum <= CM); return bIsCsrTitle; diff --git a/ryzom/common/src/game_share/utils.h b/ryzom/common/src/game_share/utils.h index cb22574a4..eb527162f 100644 --- a/ryzom/common/src/game_share/utils.h +++ b/ryzom/common/src/game_share/utils.h @@ -44,7 +44,11 @@ inline std::string capitalize(const std::string & s) if ( s.empty() ) return s; - return NLMISC::toUpper( s.substr(0,1) ) + NLMISC::toLower( s.substr(1,std::string::npos) ); + std::string res; + res.reserve(4); + ptrdiff_t i = 0; + NLMISC::appendToUpper(res, s, i); + return res + NLMISC::toLower(s.substr(i)); } inline ucstring capitalize(const ucstring & s) @@ -52,7 +56,8 @@ inline ucstring capitalize(const ucstring & s) if ( s.empty() ) return s; - return NLMISC::toUpper( s.substr(0,1) ) + NLMISC::toLower( s.substr(1,std::string::npos) ); + // return NLMISC::toUpper( s.substr(0,1) ) + NLMISC::toLower( s.substr(1,std::string::npos) ); + return ucstring::makeFromUtf8(capitalize(s.toUtf8())); }