diff --git a/nel/include/nel/misc/common.h b/nel/include/nel/misc/common.h index 9ed33c8d8..6a4480e5a 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -250,6 +250,10 @@ void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i); void appendToUpper(std::string &res, const char *str, ptrdiff_t &i); void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i); +/** UTF-8 case insensitive compare */ +int compareCaseInsensitive(const char *a, const char *b); +int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB); + /** * Convert to an hexadecimal std::string diff --git a/nel/src/misc/unicode.cpp b/nel/src/misc/unicode.cpp index b38344d4a..6e00afe88 100644 --- a/nel/src/misc/unicode.cpp +++ b/nel/src/misc/unicode.cpp @@ -4732,8 +4732,8 @@ static const char **s_UtfLowerToUpperMap[16] = { NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrdiff_t &i) { - char c = str[i]; - char d, e; + unsigned char c = str[i]; + unsigned char d, e; if (c < 0x80) { if (c >= 'A' && c <= 'Z') @@ -4824,8 +4824,8 @@ void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i) NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrdiff_t &i) { - char c = str[i]; - char d, e; + unsigned char c = str[i]; + unsigned char d, e; if (c < 0x80) { if (c >= 'a' && c <= 'z') @@ -4910,6 +4910,230 @@ void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i) appendToUpperAsUtf8(res, &str[0], i); } +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +static const char s_UpperAscii[] = { + 'A', 0, 'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F', 0, 'G', 0, + 'H', 0, 'I', 0, 'J', 0, 'K', 0, 'L', 0, 'M', 0, 'N', 0, + 'O', 0, 'P', 0, 'Q', 0, 'R', 0, 'S', 0, 'T', 0, 'U', 0, + 'V', 0, 'W', 0, 'X', 0, 'Y', 0, 'Z', 0, 0, 0, 0, 0 +}; + +const char *fetchToUpperAsUtf8(const char **str) +{ + unsigned char c = *(*str); + unsigned char d, e; + if (c < 0x80) + { + if (c >= 'a' && c <= 'z') + { + // 1-byte UTF-8 + ++(*str); + return &s_UpperAscii[(c - 'a') << 1]; + } + } + else if ((c & 0xE0) == 0xC0 && ((d = (*str)[1]) & 0xC0) == 0x80) + { + // 2-byte UTF-8 + const char *table = s_Utf8LowerToUpperTables[c & 0x1F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + (*str) += 2; + return &table[idx]; + } + } + } + else if ((c & 0xF0) == 0xE0 && ((d = (*str)[1]) & 0xC0) == 0x80 && ((e = (*str)[2]) & 0xC0) == 0x80) + { + // 3-byte UTF-8 + const char **map = s_UtfLowerToUpperMap[c & 0x0F]; + if (map) + { + const char *table = map[d & 0x3F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + (*str) += 3; + return &table[idx]; + } + } + } + } + return NULL; +} + +int compareCaseInsensitive(const char *a, const char *b) +{ + // while (*a != 0 && *b != 0) + for (; ;) + { + const char *ca = fetchToUpperAsUtf8(&a); + const char *cb = fetchToUpperAsUtf8(&b); + if (!ca && !cb) + { + // Easy case, ASCII compare or junk + if (*a != *b) + { + if (*a > * b) return 1; + else return -1; + } + else if (!*a) // Equal and NUL, ends both + { + return 0; + } + ++a; + ++b; + } + else if (!cb) + { + // String a changed lowercase, iterate ca until NUL alongside b + nlassert(*ca); + do + { + if (*ca != *b) + { + if (*ca > *b) return 1; + else return -1; + } + ++ca; + ++b; + } while (*ca); + } + else if (!ca) + { + // String b changed lowercase, iterate a alongside cb until NUL + nlassert(*cb); + do + { + if (*a != *cb) + { + if (*a > *cb) return 1; + else return -1; + } + ++a; + ++cb; + } while (*cb); + } + else + { + // Both strings changed lowercase + if (ca != cb) // Only check if it's a different result + { + do + { + if (*ca != *cb) + { + if (*ca > *cb) return 1; + else return -1; + } + ++ca; + ++cb; + } while (*ca && *cb); + } + } + } + // if (*a == *b) return 0; + // if (*a > *b) return 1; + // return -1; +} + +int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB) +{ + const char *ma = a + lenA; + const char *mb = b + lenB; + for (; ;) + { + if (a >= ma) + { + if (b >= mb) + { + return 0; // Both strings ended + } + else + { + return 1; // A is longer + } + } + if (b >= mb) + { + return -1; // B is longer + } + const char *ca = fetchToUpperAsUtf8(&a); + const char *cb = fetchToUpperAsUtf8(&b); + if (!ca && !cb) + { + // Easy case, ASCII compare or junk + if (*a != *b) + { + if (*a > * b) return 1; + else return -1; + } + /* + else if (!*a) // Equal and NUL, ends both + { + return 0; + } + */ + ++a; + ++b; + } + else if (!cb) + { + // String a changed lowercase, iterate ca until NUL alongside b + nlassert(*ca); + do + { + if (*ca != *b) + { + if (*ca > *b) return 1; + else return -1; + } + ++ca; + ++b; + } while (*ca); + } + else if (!ca) + { + // String b changed lowercase, iterate a alongside cb until NUL + nlassert(*cb); + do + { + if (*a != *cb) + { + if (*a > *cb) return 1; + else return -1; + } + ++a; + ++cb; + } while (*cb); + } + else + { + // Both strings changed lowercase + if (ca != cb) // Only check if it's a different result + { + do + { + if (*ca != *cb) + { + if (*ca > *cb) return 1; + else return -1; + } + ++ca; + ++cb; + } while (*ca && *cb); + } + } + } +} + // *************************************************************************** #else diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index 84b058902..d68a836de 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -811,7 +811,7 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual // Get the fauna name in the sheet const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); if (creatureName.find(ucstring("(EntitiesMngr.getEntityByName(sender, true, true)); bool bWoman = entity && entity->getGender() == GSGENDER::female; - name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); + name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman); { // Sometimes translation contains another title ucstring::size_type pos = name.find('$'); if (pos != ucstring::npos) { - name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman); + name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name.toUtf8()), bWoman); } } } else { // Does the char have a CSR title? - csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring(""); } result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; @@ -1018,13 +1018,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde } // Format the sentence with the provided sender name - ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender); + ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender.toUtf8()); ucstring csr; // Does the char have a CSR title? - csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring(""); - if (UserEntity && senderName == UserEntity->getDisplayName()) + if (UserEntity && senderName.toUtf8() == UserEntity->getDisplayName()) { // The player talks switch(type) @@ -1046,13 +1046,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde // We need the gender to display the correct title bool bWoman = entity && entity->getGender() == GSGENDER::female; - senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); + senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman); { // Sometimes translation contains another title ucstring::size_type pos = senderName.find('$'); if (pos != ucstring::npos) { - senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman); + senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName.toUtf8()), bWoman); } } } diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index a491d5e57..1fa7efb9f 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -145,8 +145,8 @@ string CharNameValidDBLink; uint8 PlayerSelectedSlot = 0; string PlayerSelectedFileName; TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!! -ucstring PlayerSelectedHomeShardName; -ucstring PlayerSelectedHomeShardNameWithParenthesis; +std::string PlayerSelectedHomeShardName; +std::string PlayerSelectedHomeShardNameWithParenthesis; extern std::string CurrentCookie; ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created @@ -1441,7 +1441,7 @@ Deprecated { ucstring::size_type pos = sValue.find('$'); if (pos != ucstring::npos) { - sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle); + sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue.toUtf8()), womanTitle); } } setTarget (pCaller, sTarget, sValue); @@ -3348,7 +3348,7 @@ class CAHLoadScenario : public IActionHandler ucstring res; if (pSMC->getString(val,res)) { - string charName = CEntityCL::removeTitleAndShardFromName(res).toString(); + string charName = CEntityCL::removeTitleAndShardFromName(res.toUtf8()); sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName); if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult"))) diff --git a/ryzom/client/src/connection.h b/ryzom/client/src/connection.h index 67bda815c..bb6f4cd24 100644 --- a/ryzom/client/src/connection.h +++ b/ryzom/client/src/connection.h @@ -30,8 +30,8 @@ extern std::vector Mainlands; extern uint8 PlayerSelectedSlot; extern std::string PlayerSelectedFileName; extern TSessionId PlayerSelectedMainland; // This is the mainland selected at the SELECT perso!! -extern ucstring PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) -extern ucstring PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis +extern std::string PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) +extern std::string PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis extern std::vector CharacterSummaries; extern std::string UserPrivileges; extern sint LoginCharsel; diff --git a/ryzom/client/src/debug_client.cpp b/ryzom/client/src/debug_client.cpp index 88df4be99..cbceca4ef 100644 --- a/ryzom/client/src/debug_client.cpp +++ b/ryzom/client/src/debug_client.cpp @@ -514,7 +514,7 @@ string getDebugInformation() if(UserEntity) { - str += toString("Player Name: '%s'\n", UserEntity->getEntityName().toString().c_str()); + str += toString("Player Name: '%s'\n", UserEntity->getEntityName().c_str()); str += toString("UserPosition: %.2f %.2f %.2f\n", UserEntity->pos().x, UserEntity->pos().y, UserEntity->pos().z); } else diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 9d3f446eb..9e57b3acb 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -2097,7 +2097,7 @@ bool CEntityCL::clipped (const std::vector &clippingPlanes, cons // Set the name of the entity. Handle replacement tag if any // to insert NPC task translated. //--------------------------------------------------- -void CEntityCL::setEntityName(const ucstring &name) +void CEntityCL::setEntityName(const std::string &name) { _EntityName = name; } @@ -2264,7 +2264,7 @@ void CEntityCL::load() // virtual //----------------------------------------------- void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) { - _EntityName = value; + _EntityName = value.toUtf8(); // remove the shard name if possible _EntityName= removeShardFromName(_EntityName); @@ -2303,7 +2303,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) if (pos != ucstring::npos) { ucstring sn = replacement; - _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos)); + _EntityName = sn.substr(0, pos).toUtf8(); ucstring::size_type pos2 = sn.find('$', pos + 1); _TitleRaw = sn.substr(pos+1, pos2 - pos - 1); replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); @@ -2370,32 +2370,32 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) //----------------------------------------------- // getTitleFromName //----------------------------------------------- -ucstring CEntityCL::getTitleFromName(const ucstring &name) +std::string CEntityCL::getTitleFromName(const std::string &name) { - ucstring::size_type p1 = name.find('$'); + std::string::size_type p1 = name.find('$'); if (p1 != ucstring::npos) { - ucstring::size_type p2 = name.find('$', p1 + 1); - if (p2 != ucstring::npos) + std::string::size_type p2 = name.find('$', p1 + 1); + if (p2 != std::string::npos) return name.substr(p1+1, p2-p1-1); } - return ucstring(""); + return std::string(); }// getTitleFromName // //----------------------------------------------- // removeTitleFromName //----------------------------------------------- -ucstring CEntityCL::removeTitleFromName(const ucstring &name) +std::string CEntityCL::removeTitleFromName(const std::string &name) { - ucstring::size_type p1 = name.find('$'); + std::string::size_type p1 = name.find('$'); if (p1 == ucstring::npos) { return name; } else { - ucstring::size_type p2 = name.find('$', p1 + 1); + std::string::size_type p2 = name.find('$', p1 + 1); if (p2 != ucstring::npos) { return name.substr(0, p1) + name.substr(p2 + 1); @@ -2410,16 +2410,16 @@ ucstring CEntityCL::removeTitleFromName(const ucstring &name) //----------------------------------------------- // removeShardFromName //----------------------------------------------- -ucstring CEntityCL::removeShardFromName(const ucstring &name) +std::string CEntityCL::removeShardFromName(const std::string &name) { // The string must contains a '(' and a ')' - ucstring::size_type p0= name.find('('); - ucstring::size_type p1= name.find(')'); - if(p0==ucstring::npos || p1==ucstring::npos || p1<=p0) + std::string::size_type p0= name.find('('); + std::string::size_type p1= name.find(')'); + if(p0==std::string::npos || p1==std::string::npos || p1<=p0) return name; // if it is the same as the shard name of the user, remove it - if(ucstrnicmp(name, (uint)p0+1, (uint)(p1-p0-1), PlayerSelectedHomeShardName)==0) + if (!NLMISC::compareCaseInsensitive(name.c_str() + p0 + 1, p1-p0-1, PlayerSelectedHomeShardName.c_str(), PlayerSelectedHomeShardName.size())) return name.substr(0,p0) + name.substr(p1+1); // else don't modify else @@ -2429,7 +2429,7 @@ ucstring CEntityCL::removeShardFromName(const ucstring &name) //----------------------------------------------- // removeTitleAndShardFromName //----------------------------------------------- -ucstring CEntityCL::removeTitleAndShardFromName(const ucstring &name) +std::string CEntityCL::removeTitleAndShardFromName(const std::string &name) { return removeTitleFromName(removeShardFromName(name)); } diff --git a/ryzom/client/src/entity_cl.h b/ryzom/client/src/entity_cl.h index e2985493a..5b53c3027 100644 --- a/ryzom/client/src/entity_cl.h +++ b/ryzom/client/src/entity_cl.h @@ -334,19 +334,19 @@ public: */ //@{ /// Return the Name of the entity. There may be a specification in it (guard, trader, etc ...). It is then surrounded by '$' - const ucstring &getEntityName() const {return _EntityName;} + const std::string &getEntityName() const {return _EntityName;} /// Return the title from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..) - static ucstring getTitleFromName(const ucstring &name); + static std::string getTitleFromName(const std::string &name); /// Remove the specification from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..) - static ucstring removeTitleFromName(const ucstring &name); + static std::string removeTitleFromName(const std::string &name); /// Remove the shard from a name (if player from the same shard). The shard is surrounded by (), and tells the incoming shard of the entity (aniro, leanon etc...) - static ucstring removeShardFromName(const ucstring &name); + static std::string removeShardFromName(const std::string &name); /// Remove both title and shard from name - static ucstring removeTitleAndShardFromName(const ucstring &name); + static std::string removeTitleAndShardFromName(const std::string &name); /// Change the entity name. - void setEntityName(const ucstring &name); + void setEntityName(const std::string &name); /// Return a displayable name - ucstring getDisplayName() const + std::string getDisplayName() const { return removeTitleAndShardFromName(_EntityName); } @@ -931,7 +931,7 @@ protected: // Flags to know what is possible to do with the entity (selectable, liftable, etc.). CProperties _Properties; // Current Name for the entity - ucstring _EntityName; + std::string _EntityName; // Current entity title ucstring _Title; // Current entity tags diff --git a/ryzom/client/src/forage_source_cl.cpp b/ryzom/client/src/forage_source_cl.cpp index 46249ed9e..7f538a2f0 100644 --- a/ryzom/client/src/forage_source_cl.cpp +++ b/ryzom/client/src/forage_source_cl.cpp @@ -508,9 +508,9 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/* CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName += ucstring(" [") + prospectorName + ucstring("]"); + _EntityName += " [" + prospectorName + "]"; } } @@ -539,15 +539,15 @@ void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* game const ucchar *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); if ( name ) { - _EntityName = name; + _EntityName = ucstring(name).toUtf8(); if ( _ProspectorSlot != 255 ) { CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + std::string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName += ucstring(" [") + prospectorName + ucstring("]"); + _EntityName += " [" + prospectorName + "]"; } } // Rebuild inscene interface @@ -568,9 +568,9 @@ void CForageSourceCL::updateVisualPropertyTarget(const NLMISC::TGameCycle &/* ga CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; // NULL if entity not received if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + std::string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName = _EntityName + ucstring(" [") + prospectorName + ucstring("]"); + _EntityName = _EntityName + " [" + prospectorName + "]"; } // Rebuild inscene interface diff --git a/ryzom/client/src/init_main_loop.cpp b/ryzom/client/src/init_main_loop.cpp index a5bfa67df..e2566e48f 100644 --- a/ryzom/client/src/init_main_loop.cpp +++ b/ryzom/client/src/init_main_loop.cpp @@ -225,8 +225,8 @@ struct CStatThread : public NLMISC::IRunnable string cookie() { string name; - if(UserEntity && !UserEntity->getEntityName().toString().empty()) - name = UserEntity->getEntityName().toString(); + if(UserEntity && !UserEntity->getEntityName().empty()) + name = UserEntity->getEntityName(); std::string userid = toString("u%d", NetMngr.getUserId())+name; return toUpper(getMD5((const uint8 *)userid.c_str(), (uint32)userid.size()).toString()); @@ -236,7 +236,7 @@ struct CStatThread : public NLMISC::IRunnable bool connect() { //nlinfo("connect"); - if(!UserEntity || UserEntity->getEntityName().toString().empty()) + if(!UserEntity || UserEntity->getEntityName().empty()) return false; referer = ContinentMngr.getCurrentContinentSelectName(); @@ -260,7 +260,7 @@ struct CStatThread : public NLMISC::IRunnable timeinfo = localtime ( &rawtime ); strftime (buffer,80,"%H%%3A%M", timeinfo); addParam(params, "localtime", buffer); - addParam(params, "cv_name", UserEntity->getEntityName().toUtf8()); + addParam(params, "cv_name", UserEntity->getEntityName()); //addParam(params, "cv_email", ""); //addParam(params, "cv_avatar", ""); addParam(params, "cv_Userid", toString(NetMngr.getUserId())); diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index cf25d00c5..4da75a8da 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -1959,13 +1959,13 @@ public: if (pChar != NULL) womanTitle = pChar->getGender() == GSGENDER::female; - STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); + STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout.toUtf8()), womanTitle); // Sometimes translation contains another title ucstring::size_type pos = copyInout.find('$'); if (pos != ucstring::npos) { - copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); + copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout.toUtf8()), womanTitle); } CStringPostProcessRemoveTitle::cbIDStringReceived(copyInout); diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index dc64feae1..2ccbf963a 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -670,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler if (selection == NULL) return; //if(selection->isNPC()) { - ucstring name = selection->getEntityName(); + std::string name = selection->getEntityName(); if(name.empty()) { // try to get the name from the string manager (for npc) @@ -679,7 +679,7 @@ class CHandlerOpenTitleHelp : public IActionHandler { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); pSMC->getString (nDBid, name); - ucstring copyName = name; + std::string copyName = name; name = CEntityCL::removeTitleAndShardFromName(name); if (name.empty()) { @@ -689,18 +689,18 @@ class CHandlerOpenTitleHelp : public IActionHandler woman = pChar->getGender() == GSGENDER::female; // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(copyName); + std::string strNewTitle = CEntityCL::getTitleFromName(copyName); // retrieve the translated string if (!strNewTitle.empty()) - name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(strNewTitle, woman); + name = ucstring(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(ucstring::makeFromUtf8(strNewTitle), woman)).toUtf8(); else name.clear(); } } } if(!name.empty()) - CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)selection->Type)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name+"|ptype="+toString((int)selection->Type)); return; } } @@ -2762,7 +2762,7 @@ class CPlayerShardNameRemover : public IOnReceiveTextId { virtual void onReceiveTextId(ucstring &str) { - str= CEntityCL::removeShardFromName(str); + str= CEntityCL::removeShardFromName(str.toUtf8()); } }; static CPlayerShardNameRemover PlayerShardNameRemover; @@ -3629,7 +3629,7 @@ public: CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) { - CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt).toUtf8()); + CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt.toUtf8())); } } }; diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index e3ee653aa..0edd74491 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1737,7 +1737,7 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet) ucstring creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( itemInfo.CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + if ( toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString.toUtf8())) isCraftedByUserEntity = true; } @@ -1845,7 +1845,7 @@ class CHandlerItemMenuCheck : public IActionHandler ucstring creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( getInventory().getItemInfo(getInventory().getItemSlotId(pCS)).CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString.toUtf8())) isTextEditionActive = true; } } diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 8b379f6d1..63d491deb 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -836,7 +836,7 @@ class CAHReplyTeller : public IActionHandler { w->setKeyboardFocus(); w->enableBlink(1); - PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName)); + PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8())); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -863,7 +863,7 @@ class CAHReplyTellerOnce : public IActionHandler { w->setKeyboardFocus(); w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName) + ucstring(" "), false); + w->setCommand(ucstring("tell ") + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8()) + ucstring(" "), false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -916,7 +916,7 @@ NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "") bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) { // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(inOut); + ucstring strNewTitle = CEntityCL::getTitleFromName(inOut.toUtf8()); // retrieve the translated string if (!strNewTitle.empty()) @@ -927,7 +927,7 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) ucstring::size_type pos = inOut.find('$'); if (pos != ucstring::npos) { - inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut), Woman); + inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut.toUtf8()), Woman); } } } @@ -940,14 +940,14 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) // *************************************************************************** bool CStringPostProcessRemoveTitle::cbIDStringReceived(ucstring &inOut) { - inOut = CEntityCL::removeTitleAndShardFromName(inOut); + inOut = CEntityCL::removeTitleAndShardFromName(inOut.toUtf8()); return true; } // *************************************************************************** bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut) { - ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut); + ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut.toUtf8()); if (sOut.empty()) { CStringPostProcessRemoveName SPPRM; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index a461d0194..3d59ea644 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -692,7 +692,7 @@ void CDBGroupListSheetTrade::checkCoords () ucstring result; if( pSMC->getString ( cst->LastVendorNameId, result) ) { - cst->VendorNameString = CEntityCL::removeShardFromName(result); + cst->VendorNameString = CEntityCL::removeShardFromName(result.toUtf8()); set< CSheetChildTrade *>::iterator itTmp = it; ++it; VendorNameIdToUpdate.erase(itTmp); diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index a5e443da6..d5b8d7e9c 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -560,7 +560,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) CStringManagerClient *pSMC = CStringManagerClient::instance(); ucstring name; if (pSMC->getString(nameNode->getValue32(), name)) - ct.Name = CEntityCL::removeTitleAndShardFromName(name); // TODO : dynamic support for name + ct.Name = CEntityCL::removeTitleAndShardFromName(name.toUtf8()); // TODO : dynamic support for name else ct.Name = CI18N::get("uiNotReceived"); return true; diff --git a/ryzom/client/src/interface_v3/group_html_webig.cpp b/ryzom/client/src/interface_v3/group_html_webig.cpp index 985ae3f20..d190b83b6 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -97,7 +97,7 @@ void addWebIGParams (string &url, bool trustedDomain) if (url.find('$') != string::npos) { strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); - strFindReplace(url, "$displayName$", UserEntity->getDisplayName().toString()); + strFindReplace(url, "$displayName$", UserEntity->getDisplayName()); // FIXME: UrlEncode... strFindReplace(url, "$posx$", toString(UserEntity->pos().x)); strFindReplace(url, "$posy$", toString(UserEntity->pos().y)); strFindReplace(url, "$posz$", toString(UserEntity->pos().z)); @@ -113,7 +113,7 @@ void addWebIGParams (string &url, bool trustedDomain) if (target) { strFindReplace(url, "$tdatasetid$", toString(target->dataSetId())); - strFindReplace(url, "$tdisplayName$", target->getDisplayName().toString()); + strFindReplace(url, "$tdisplayName$", target->getDisplayName()); // FIXME: UrlEncode... strFindReplace(url, "$tposx$", toString(target->pos().x)); strFindReplace(url, "$tposy$", toString(target->pos().y)); strFindReplace(url, "$tposz$", toString(target->pos().z)); diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index ce6d21021..7725d45f9 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -1201,7 +1201,7 @@ void CGroupMap::checkCoords() CEntityCL *sel = EntitiesMngr.entity(UserEntity->selection()); if (sel) { - _TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName()).toUtf8()); + _TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName())); } } } @@ -1405,8 +1405,8 @@ void CGroupMap::checkCoords() if (pSMC->getString(val,res)) { - res = CEntityCL::removeTitleAndShardFromName(res); - _TeammateLM[i]->setDefaultContextHelp(res.toUtf8()); + std::string res2 = CEntityCL::removeTitleAndShardFromName(res.toUtf8()); + _TeammateLM[i]->setDefaultContextHelp(res2); } } updateLMPosFromDBPos(_TeammateLM[i], px, py); diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp index e3a1b6b41..328579d06 100644 --- a/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/ryzom/client/src/interface_v3/guild_manager.cpp @@ -359,7 +359,7 @@ void CGuildManager::update() for (uint i = 0; i < _GuildMembers.size(); ++i) { if (!pSMC->getString (_GuildMembers[i].NameID, _GuildMembers[i].Name)) bAllValid = false; - else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name); + else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name.toUtf8()); } // If all is valid no more need update and if guild is opened update the interface @@ -875,7 +875,7 @@ class CAHGuildSheetOpen : public IActionHandler CCtrlBase *inviteButton = pLine->getCtrl("invite_button"); if (inviteButton != NULL) - inviteButton->setActive(rGuildMembers[i].Online != ccs_offline && rGuildMembers[i].Name != UserEntity->getEntityName()); + inviteButton->setActive(rGuildMembers[i].Online != ccs_offline && rGuildMembers[i].Name.toUtf8() != UserEntity->getEntityName()); // Enter Date CViewText *pViewEnterDate = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_ENTER_DATE)); diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 24ab75058..40413914e 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -358,7 +358,7 @@ public: } else { - std::string name = UserEntity->getEntityName().toUtf8(); + std::string name = UserEntity->getEntityName(); if (*it == 'P') name = toUpper(name); formatedResult += name; } @@ -391,7 +391,7 @@ public: } else { - botName = entity->getDisplayName().toUtf8(); + botName = entity->getDisplayName(); } CCharacterCL *pChar = dynamic_cast(entity); if (pChar != NULL) @@ -405,7 +405,7 @@ public: spprn.Woman = womanTitle; spprn.cbIDStringReceived(sTitleTranslated); - botName = CEntityCL::removeTitleAndShardFromName(botName).toUtf8(); + botName = CEntityCL::removeTitleAndShardFromName(botName); // short name (with no title such as 'guard', 'merchant' ...) if (*it == 's') @@ -4214,7 +4214,7 @@ bool CInterfaceManager::parseTokens(string& ucstr) // Parse the parameter if (token_param == "name") { - string name = pTokenSubjectEntity->getDisplayName().toUtf8(); + string name = pTokenSubjectEntity->getDisplayName(); // special case where there is only a title, very rare case for some NPC if (name.empty()) { diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index e448b1f4a..c9dc2767e 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1363,7 +1363,7 @@ int CLuaIHMRyzom::getPlayerGender(CLuaState &ls) int CLuaIHMRyzom::getPlayerName(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerName", 0); - ls.push(UserEntity->getEntityName().toUtf8()); + ls.push(UserEntity->getEntityName()); return 1; } @@ -1441,7 +1441,7 @@ int CLuaIHMRyzom::getTargetName(CLuaState &ls) if (!target) return 0; - ls.push(target->getEntityName().toUtf8()); + ls.push(target->getEntityName()); return 1; } @@ -3274,7 +3274,7 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string if (UserEntity) { - userName = UserEntity->getDisplayName().toString(); + userName = UserEntity->getDisplayName(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); ucstring ucsTmp; pSMC->getString(UserEntity->getGuildNameID(), ucsTmp); @@ -3648,7 +3648,7 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) CInterfaceManager *im = CInterfaceManager::getInstance(); w->setKeyboardFocus(); w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player) + ucstring(" "), false); + w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player.toUtf8()) + ucstring(" "), false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index 948b45e51..de7c9023a 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -1276,7 +1276,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8()); // add the contact to this list sint index = pl.getIndexFromName(name); @@ -1327,7 +1327,7 @@ bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) c // select correct people list const CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8()); return pl.getIndexFromName(name) != -1; } @@ -2250,7 +2250,7 @@ public: if (peopleList) { // don't add if it is the player name - if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputStringAsUtf16())) + if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputString())) { displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList")); } diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index f1f622836..e2d55e250 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -832,7 +832,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c } if (!senderName.empty()) { - CEntityCL *senderEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(senderName), true, true); + CEntityCL *senderEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()), true, true); if (senderEntity) { if (senderEntity->Type != CEntityCL::Player) @@ -845,7 +845,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c } else { - CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName), false, true); + CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName.toUtf8()), false, true); if (destEntity) { destEntity->removeStateFx(); @@ -866,7 +866,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // if tell, bkup sendername if (mode == CChatGroup::tell && windowVisible && !senderName.empty()) { - PeopleInterraction.LastSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + PeopleInterraction.LastSenderName = CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()); } } @@ -928,7 +928,7 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); bool windowVisible; - ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()); // The sender part is up to and including the first ":" after the goodSenderName ucstring::size_type pos = finalString.find(goodSenderName); diff --git a/ryzom/client/src/r2/displayer_visual_entity.cpp b/ryzom/client/src/r2/displayer_visual_entity.cpp index 72b4c3ddb..01eaf0bc0 100644 --- a/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -1017,7 +1017,7 @@ void CDisplayerVisualEntity::updateName() { //BENCH(setEntityName) - _Entity->setEntityName(ucName); + _Entity->setEntityName(ucName.toUtf8()); } { //BENCH(buildInSceneInterface) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 06c3523b4..ec493e3d3 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -734,7 +734,7 @@ restartLoop: // If the shard name is the same as the player home shard name, remove it uint len= (uint)PlayerSelectedHomeShardNameWithParenthesis.size(); uint start= (uint)str.size()-len; - if(ucstrnicmp(str, start, len, PlayerSelectedHomeShardNameWithParenthesis)==0) + if(ucstrnicmp(str, start, len, PlayerSelectedHomeShardNameWithParenthesis)==0) // TODO: NLMISC::compareCaseInsensitive str.resize(start); } } @@ -744,7 +744,7 @@ restartLoop: ucstring::size_type pos = str.find('$'); if ( ! str.empty() && pos != ucstring::npos) { - str = CEntityCL::removeTitleFromName(str); + str = CEntityCL::removeTitleFromName(str.toUtf8()); } // append this string