diff --git a/ryzom/server/src/ai_service/ai_grp_npc.cpp b/ryzom/server/src/ai_service/ai_grp_npc.cpp index 056293a25..7d6b9a9df 100644 --- a/ryzom/server/src/ai_service/ai_grp_npc.cpp +++ b/ryzom/server/src/ai_service/ai_grp_npc.cpp @@ -586,7 +586,7 @@ void CGroupNpc::addParameter(std::string const& parameter) std::string key, tail; // force lowercase - std::string p = NLMISC::toLower(parameter); + std::string p = NLMISC::toLowerAscii(parameter); AI_SHARE::stringToKeywordAndTail(p, key, tail); breakable diff --git a/ryzom/server/src/ai_service/ai_instance.h b/ryzom/server/src/ai_service/ai_instance.h index 9f59129ce..2d4e3d30e 100644 --- a/ryzom/server/src/ai_service/ai_instance.h +++ b/ryzom/server/src/ai_service/ai_instance.h @@ -187,7 +187,7 @@ public: /// Store mapping 'name:variant' -> squad to be used later by getSquadByVariantName() void registerSquadVariant(const std::string& nameAndVariant, CGroupDesc *squad ) { - if ( ! _SquadVariantNameToGroupDesc.insert( std::make_pair( NLMISC::toLower( nameAndVariant ), squad ) ).second ) + if ( ! _SquadVariantNameToGroupDesc.insert( std::make_pair( NLMISC::toLowerAscii( nameAndVariant ), squad ) ).second ) nlwarning( "Duplicate squad template / squad variant '%s'", nameAndVariant.c_str() ); } @@ -200,7 +200,7 @@ public: /// Get a squad by name:variant (works only during primitive parsing), or NULL if not found. Not case-sensitive. CGroupDesc *getSquadByVariantName(const std::string& nameAndVariant) { - std::map > >::iterator it = _SquadVariantNameToGroupDesc.find( NLMISC::toLower( nameAndVariant ) ); + std::map > >::iterator it = _SquadVariantNameToGroupDesc.find( NLMISC::toLowerAscii( nameAndVariant ) ); if ( it != _SquadVariantNameToGroupDesc.end() ) return (*it).second; else diff --git a/ryzom/server/src/ai_service/ai_outpost_actions.cpp b/ryzom/server/src/ai_service/ai_outpost_actions.cpp index 25513ea06..1ef54747e 100644 --- a/ryzom/server/src/ai_service/ai_outpost_actions.cpp +++ b/ryzom/server/src/ai_service/ai_outpost_actions.cpp @@ -648,7 +648,7 @@ DEFINE_ACTION_TEMPLATE1(ContextOutpostGroupDesc,GT_GPRM,FamilyT) string param; args[i].get(param); - param = NLMISC::toLower(param); + param = NLMISC::toLowerAscii(param); if ( param == "contact camp" || param == "contact outpost" diff --git a/ryzom/server/src/ai_service/continent_inline.h b/ryzom/server/src/ai_service/continent_inline.h index 2116d6ab4..9f0dbe54b 100644 --- a/ryzom/server/src/ai_service/continent_inline.h +++ b/ryzom/server/src/ai_service/continent_inline.h @@ -1053,7 +1053,7 @@ DEFINE_ACTION_TEMPLATE1(ContextGroupDesc,GT_GPRM,FamilyT) std::string param; args[i].get(param); - param = NLMISC::toLower(param); + param = NLMISC::toLowerAscii(param); if ( param == "contact camp" || param == "contact outpost" diff --git a/ryzom/server/src/entities_game_service/admin.cpp b/ryzom/server/src/entities_game_service/admin.cpp index a35f7671b..815259749 100644 --- a/ryzom/server/src/entities_game_service/admin.cpp +++ b/ryzom/server/src/entities_game_service/admin.cpp @@ -38,6 +38,7 @@ #include "nel/misc/algo.h" #include "nel/misc/sstring.h" #include "nel/misc/i18n.h" +#include "nel/misc/string_view.h" #include "nel/net/admin.h" #include "nel/net/service.h" @@ -4493,24 +4494,25 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " getUserDynChannel(name); + string name = args[1]; + string nameLwr = toCaseInsensitive(args[1]); + TChanID channel = inst->getUserDynChannel(nameLwr); if (args.size() < 3) - pass = toLower(name); + pass = nameLwr; else pass = args[2]; - if ( (channel == DYN_CHAT_INVALID_CHAN) && (pass != string("*")) && (pass != string("***")) ) - channel = inst->createUserChannel(name, pass); + if ( (channel == DYN_CHAT_INVALID_CHAN) && (pass != nlstr("*")) && (pass != nlstr("***")) ) + channel = inst->createUserChannel(nameLwr, pass); if (channel != DYN_CHAT_INVALID_CHAN) { string channelPass = inst->getPassUserChannel(channel); - if ( (channel != DYN_CHAT_INVALID_CHAN) && (pass == string("***")) && (c->havePriv(":DEV:") || c->havePriv(":SGM:") || c->havePriv(":GM:") || c->havePriv(":EM:"))) + if ( (channel != DYN_CHAT_INVALID_CHAN) && (pass == nlstr("***")) && (c->havePriv(":DEV:") || c->havePriv(":SGM:") || c->havePriv(":GM:") || c->havePriv(":EM:"))) { - inst->deleteUserChannel(name); + inst->deleteUserChannel(nameLwr); } else if (channelPass == pass) { @@ -4521,7 +4523,7 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " addFactionChannelToCharacter(channel, c, true, true); } - else if (pass == string("*")) + else if (pass == nlstr("*")) { inst->removeFactionChannelForCharacter(channel, c, true); } @@ -4529,7 +4531,7 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " setFullPVP(true); - else if (value=="0" || value=="off" || toLower(value)=="false" ) + else if (value=="0" || value=="off" || toLowerAscii(value)=="false" ) c->setFullPVP(false); // c->setPVPRecentActionFlag(); CPVPManager2::getInstance()->setPVPModeInMirror(c); diff --git a/ryzom/server/src/entities_game_service/fame_pd.cpp b/ryzom/server/src/entities_game_service/fame_pd.cpp index 2e201412a..c10547b01 100644 --- a/ryzom/server/src/entities_game_service/fame_pd.cpp +++ b/ryzom/server/src/entities_game_service/fame_pd.cpp @@ -39,7 +39,7 @@ void CFameTrend::init() for (i=0; i<3; ++i) { _StrTable[TFameTrendConvert[i].Value] = TFameTrendConvert[i].Name; - _ValueMap[NLMISC::toLower(std::string(TFameTrendConvert[i].Name))] = TFameTrendConvert[i].Value; + _ValueMap[NLMISC::toLowerAscii(std::string(TFameTrendConvert[i].Name))] = TFameTrendConvert[i].Value; } _Initialised = true; } diff --git a/ryzom/server/src/entities_game_service/fame_pd_inline.h b/ryzom/server/src/entities_game_service/fame_pd_inline.h index 5bd913b35..acaf28fa2 100644 --- a/ryzom/server/src/entities_game_service/fame_pd_inline.h +++ b/ryzom/server/src/entities_game_service/fame_pd_inline.h @@ -43,7 +43,7 @@ inline CFameTrend::TFameTrend CFameTrend::fromString(const std::string& v) { return Unknown; } - const std::map::const_iterator it = _ValueMap.find(NLMISC::toLower(v)); + const std::map::const_iterator it = _ValueMap.find(NLMISC::toLowerAscii(v)); if (it == _ValueMap.end()) { nlwarning("TFameTrend::toString(): string '%s' is not matched, 'Unknown' enum value returned", v.c_str()); diff --git a/ryzom/server/src/entities_game_service/guild_manager/guild_manager.cpp b/ryzom/server/src/entities_game_service/guild_manager/guild_manager.cpp index a84f797dd..afa7e3d5a 100644 --- a/ryzom/server/src/entities_game_service/guild_manager/guild_manager.cpp +++ b/ryzom/server/src/entities_game_service/guild_manager/guild_manager.cpp @@ -856,7 +856,7 @@ void CGuildManager::createGuildStep2(uint32 guildId, const ucstring &guildName, /// end current bot chat proxy.endBotChat(); proxy.updateTarget(); - _ExistingGuildNames.insert( NLMISC::toLower( guild->getName().toString() ) ); + _ExistingGuildNames.insert( NLMISC::toCaseInsensitive( guild->getName().toUtf8() ) ); // ask the client to open it's guild interface PlayerManager.sendImpulseToClient( proxy.getId(),"GUILD:OPEN_GUILD_WINDOW" ); @@ -903,7 +903,7 @@ void CGuildManager::deleteGuild(uint32 id) CStatDB::getInstance()->removeGuild(id); } - _ExistingGuildNames.erase( NLMISC::toLower( guild->getName().toString() ) ); + _ExistingGuildNames.erase( NLMISC::toCaseInsensitive( guild->getName().toUtf8() ) ); guild->unregisterGuild(); if (!guild->isProxy()) @@ -1423,7 +1423,7 @@ void CGuildManager::registerGuildAfterLoading(CGuild *guildToRegister) // _GuildsAwaitingString.insert( make_pair( str, guildToRegister->getId() ) ); // } - _ExistingGuildNames.insert( NLMISC::toLower( guildToRegister->getName().toString() ) ); + _ExistingGuildNames.insert( NLMISC::toCaseInsensitive( guildToRegister->getName().toUtf8() ) ); } } @@ -1477,7 +1477,7 @@ bool CGuildManager::checkGuildStrings(CGuildCharProxy & proxy,const ucstring & n return false; } // check if name already exists in the guild list - if ( _ExistingGuildNames.find( NLMISC::toLower( name.toString() ) ) != _ExistingGuildNames.end() ) + if ( _ExistingGuildNames.find( NLMISC::toCaseInsensitive( name.toUtf8() ) ) != _ExistingGuildNames.end() ) { proxy.sendSystemMessage("GUILD_NAME_ALREADY_EXISTS"); return false; @@ -1491,6 +1491,7 @@ bool CGuildManager::checkGuildStrings(CGuildCharProxy & proxy,const ucstring & n return false; } + // FIXME: Allow unicode guild names https://github.com/kaetemi/ryzomclassic/issues/187 if ( !isalpha(name[0]) || !isalpha(name[name.size()-1]) ) { proxy.sendSystemMessage("GUILD_NAME_BAD_CHAR"); @@ -1512,6 +1513,7 @@ bool CGuildManager::checkGuildStrings(CGuildCharProxy & proxy,const ucstring & n else { prevBlank = false; + // FIXME: Allow unicode guild names https://github.com/kaetemi/ryzomclassic/issues/187 if (!isalpha (name[i])) { proxy.sendSystemMessage("GUILD_NAME_BAD_CHAR"); diff --git a/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp b/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp index d38672173..08d006c20 100644 --- a/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp +++ b/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp @@ -2726,8 +2726,8 @@ class CMissionActionFailMissionCat : public IMissionAction MISLOGSYNTAXERROR(""); return false; } - _MissionCategory = NLMISC::toLower(CMissionParser::getNoBlankString(script[1])); - if (NLMISC::toLower(missionData.Template->MissionCategory) == _MissionCategory) + _MissionCategory = NLMISC::toLowerAscii(CMissionParser::getNoBlankString(script[1])); + if (NLMISC::toLowerAscii(missionData.Template->MissionCategory) == _MissionCategory) { MISLOGERROR1("a mission cannot make fail its own category '%s'", _MissionCategory.c_str()); return false; @@ -2762,7 +2762,7 @@ class CMissionActionFailMissionCat : public IMissionAction pMissTemplate = pMM->getTemplate(pMiss->getTemplateId()); if (pMissTemplate != NULL) { - if (NLMISC::toLower(pMissTemplate->MissionCategory) == _MissionCategory) + if (NLMISC::toLowerAscii(pMissTemplate->MissionCategory) == _MissionCategory) { pMiss->onFailure(true, false); bFailed = true; @@ -2775,7 +2775,7 @@ class CMissionActionFailMissionCat : public IMissionAction pMissTemplate = pMM->getTemplate(pMiss->getMainMissionTemplateId()); if (pMissTemplate != NULL) { - if (NLMISC::toLower(pMissTemplate->MissionCategory) == _MissionCategory) + if (NLMISC::toLowerAscii(pMissTemplate->MissionCategory) == _MissionCategory) pMiss->onFailure(true, false); } } diff --git a/ryzom/server/src/entities_game_service/phrase_manager/special_power_mod_defense.h b/ryzom/server/src/entities_game_service/phrase_manager/special_power_mod_defense.h index 90c1baefe..f0d9253f0 100644 --- a/ryzom/server/src/entities_game_service/phrase_manager/special_power_mod_defense.h +++ b/ryzom/server/src/entities_game_service/phrase_manager/special_power_mod_defense.h @@ -55,10 +55,10 @@ public: _Modifier1 = modifier1; _Modifier2 = modifier2; - if( NLMISC::toLower(_DefenseMode) == "dodge" ) + if( NLMISC::toLowerAscii(_DefenseMode) == "dodge" ) _PowerType = POWERS::ModDodgeSkill; else - if( NLMISC::toLower(_DefenseMode) == "parry" ) + if( NLMISC::toLowerAscii(_DefenseMode) == "parry" ) _PowerType = POWERS::ModParrySkill; else _PowerType = POWERS::ModDefenseSkill; diff --git a/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp b/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp index a3eb72c76..562c580ef 100644 --- a/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/player_manager.cpp @@ -2489,8 +2489,7 @@ static void mailNotification(const std::string& to, const std::string& from) return; // first, build a valid character (upper case first, then lower case); - ucstring ucCharname = toLower(to); // lower case - ucCharname[0] = toUpper(ucCharname[0]); // first upper case + ucstring ucCharname = ucstring::makeFromUtf8(capitalize(to)); // second, get char id that matches the name CEntityId charId = NLMISC::CEntityIdTranslator::getInstance()->getByEntity(ucCharname); diff --git a/ryzom/server/src/input_output_service/parameter_traits.cpp b/ryzom/server/src/input_output_service/parameter_traits.cpp index 108f5bf88..53da8edb7 100644 --- a/ryzom/server/src/input_output_service/parameter_traits.cpp +++ b/ryzom/server/src/input_output_service/parameter_traits.cpp @@ -85,7 +85,7 @@ bool CStringManager::CParameterTraits::eval(CStringManager::TLanguages lang,cons } uint32 stringId = ew.getStringId(rowIndex, colIndex); - std::string str = NLMISC::toLower(SM->getString(stringId).toString()); + std::string str = NLMISC::toLowerAscii(SM->getString(stringId).toString()); LOG("SM : (paramTraits) eval condition for property %s [%s] %s [%s]", cond.Property.c_str(), str.c_str(), OperatorNames[cond.Operator], cond.ReferenceStr.c_str()); @@ -583,11 +583,11 @@ public: std::string op1; if (cond.Property == "name") { - op1 = NLMISC::toLower(si.SheetName); + op1 = NLMISC::toLowerAscii(si.SheetName); } else if (cond.Property == "gender") { - op1 = NLMISC::toLower(GSGENDER::toString(si.Gender)); + op1 = NLMISC::toLowerAscii(GSGENDER::toString(si.Gender)); } else { @@ -984,7 +984,7 @@ public: return false; } const CStringManager::TSheetInfo &si = SM->getSheetInfo(sheetId); - op1 = NLMISC::toLower(si.SheetName); + op1 = NLMISC::toLowerAscii(si.SheetName); } else if (cond.Property == "gender") { @@ -994,7 +994,7 @@ public: nlwarning("Could not find character info for EId %s to check property %s", EId.toString().c_str(), cond.Property.c_str()); return false; } - op1 = NLMISC::toLower(GSGENDER::toString(charInfo->getGender())); + op1 = NLMISC::toLowerAscii(GSGENDER::toString(charInfo->getGender())); } else { @@ -1080,14 +1080,14 @@ public: } else if (cond.Property == "role") { - op1 = NLMISC::toLower(si.ChatProfile); + op1 = NLMISC::toLowerAscii(si.ChatProfile); } else if (cond.Property == "title") { // we need to retrieve the charInfo CCharacterInfos *ci = IOS->getCharInfos(EId); if (ci != NULL) - op1 = NLMISC::toLower(ci->Title); + op1 = NLMISC::toLowerAscii(ci->Title); else { nlwarning("No character info for bot %s, can't test property 'title' !", EId.toString().c_str()); @@ -1453,11 +1453,11 @@ public: // check if checked property is gender or name if (cond.Property == "gender") { - value = NLMISC::toLower(GSGENDER::toString(charInfo->getGender())); + value = NLMISC::toLowerAscii(GSGENDER::toString(charInfo->getGender())); } else if (cond.Property == "name") { - value = NLMISC::toLower(charInfo->ShortName.toString()); + value = NLMISC::toLowerAscii(charInfo->ShortName.toString()); } else { diff --git a/ryzom/server/src/input_output_service/string_manager.cpp b/ryzom/server/src/input_output_service/string_manager.cpp index 1bffbec5d..5b6f005d7 100644 --- a/ryzom/server/src/input_output_service/string_manager.cpp +++ b/ryzom/server/src/input_output_service/string_manager.cpp @@ -912,7 +912,7 @@ uint32 CStringManager::translateTitle(const std::string &title, TLanguages lang { const std::string colName("name"); const CStringManager::CEntityWords &ew = getEntityWords(language, STRING_MANAGER::title); - std::string rowName = NLMISC::toLower(title); + std::string rowName = NLMISC::toLowerAscii(title); uint32 stringId; stringId = ew.getStringId(rowName, colName); @@ -1198,7 +1198,7 @@ NLMISC_CATEGORISED_COMMAND(stringmanager, mergeWordFile, "Merge a word file into return false; std::string lang = args[0]; - std::string word = toLower(args[1]); + std::string word = toLowerAscii(args[1]); std::string file = args[2]; // get language @@ -1215,7 +1215,7 @@ NLMISC_CATEGORISED_COMMAND(stringmanager, mergeWordFile, "Merge a word file into uint i; for (i=0; i= typeNames.size()) diff --git a/ryzom/server/src/log_analyser_service/commands.cpp b/ryzom/server/src/log_analyser_service/commands.cpp index 90bfcf09c..35e59f842 100644 --- a/ryzom/server/src/log_analyser_service/commands.cpp +++ b/ryzom/server/src/log_analyser_service/commands.cpp @@ -602,7 +602,7 @@ NLMISC_CATEGORISED_COMMAND(pd_log, displayTableDescription, useFile = logpath + args[2]; } - std::string tableName = toLower(args[1]); + std::string tableName = toLowerAscii(args[1]); CDBDescriptionParser desc; if (!desc.loadDescriptionFile(logpath + useFile)) @@ -612,7 +612,7 @@ NLMISC_CATEGORISED_COMMAND(pd_log, displayTableDescription, uint i; for (i=0; i TLocatorClient; @@ -134,7 +134,7 @@ namespace ENTITYLOC // current connected character TCharMap _ConnectedChars; - typedef CHashMap TCharNameMap; + typedef CHashMap TCharNameMap; // Index of connected character by name TCharNameMap _ConnectedCharsByName; @@ -285,7 +285,7 @@ namespace ENTITYLOC TCharMap::iterator next = first; ++next; // erase the name mapping - _ConnectedCharsByName.erase(toLower(first->second.CharName)); + _ConnectedCharsByName.erase(toCaseInsensitive(first->second.CharName)); // erase the connected char info _ConnectedChars.erase(first); // add it to the (dis)connection event list @@ -394,7 +394,7 @@ namespace ENTITYLOC NLNET::IModuleProxy *getLocatorModuleForChar(const ucstring &charName) { - TCharNameMap::iterator it(_ConnectedCharsByName.find(toLower(charName))); + TCharNameMap::iterator it(_ConnectedCharsByName.find(toCaseInsensitive(charName.toUtf8()))); // FIXME: UTF-8 if (it == _ConnectedCharsByName.end()) { // not online @@ -411,7 +411,7 @@ namespace ENTITYLOC uint32 getShardIdForChar(const ucstring &charName) { - TCharNameMap::iterator it(_ConnectedCharsByName.find(toLower(charName))); + TCharNameMap::iterator it(_ConnectedCharsByName.find(toCaseInsensitive(charName.toUtf8()))); // FIXME: UTF-8 if (it == _ConnectedCharsByName.end()) { // not online @@ -447,7 +447,7 @@ namespace ENTITYLOC void onCharacterNameUpdated(uint32 charId, const std::string &oldName, const std::string &newName) { // lookup this char in online players map - TCharNameMap::iterator it(_ConnectedCharsByName.find(toLower(oldName))); + TCharNameMap::iterator it(_ConnectedCharsByName.find(toCaseInsensitive(oldName))); if (it != _ConnectedCharsByName.end()) { @@ -455,7 +455,7 @@ namespace ENTITYLOC nlassert(charId == it->second); _ConnectedCharsByName.erase(it); - _ConnectedCharsByName.insert(make_pair(toLower(newName), charId)); + _ConnectedCharsByName.insert(make_pair(toCaseInsensitive(newName), charId)); } } @@ -617,7 +617,7 @@ namespace ENTITYLOC _ConnectedChars.insert(make_pair(charId, ci)); // store char by name info - _ConnectedCharsByName.insert(make_pair(toLower(ci.CharName), charId)); + _ConnectedCharsByName.insert(make_pair(toCaseInsensitive(ci.CharName), charId)); } // load the nel user to read privileges @@ -683,7 +683,7 @@ namespace ENTITYLOC else { // erase the information - _ConnectedCharsByName.erase(toLower(it->second.CharName)); + _ConnectedCharsByName.erase(toCaseInsensitive(it->second.CharName)); _ConnectedChars.erase(it); } @@ -887,7 +887,7 @@ namespace ENTITYLOC { log.displayNL(" Character %u '%s' [%u:%u] connected on shard %u", first->first, - first->second.CharName.toUtf8().c_str(), + first->second.CharName.c_str(), first->first>>4, first->first&0xf, first->second.ShardId); diff --git a/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp b/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp index c1b2c1485..375019217 100644 --- a/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp +++ b/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp @@ -584,7 +584,7 @@ namespace RSMGR for (uint i=0; igetRequiredState().toString()) + if (_DontUsePerm || string("ds_")+toLowerAscii(userAccessPriv[i]) == shard->getRequiredState().toString()) { // ok, this one is accessible // this server is better (i.e had less player in it) @@ -4323,7 +4323,7 @@ endOfWelcomeUserResult: } } - TAccessLevel al = string("ds_")+toLower(args[1]); + TAccessLevel al = string("ds_")+toLowerAscii(args[1]); if (al == TAccessLevel::invalid_val) { log.displayNL("Invalid access state '%s'", args[1].c_str());