[7166] Make reserved name check case-insensitive.

Original patch provided by jpmythic.
This commit is contained in:
VladimirMangos 2009-01-25 02:33:33 +03:00
parent df13468ee1
commit 737600a665
3 changed files with 24 additions and 9 deletions

View file

@ -6315,11 +6315,18 @@ void ObjectMgr::LoadReservedPlayersNames()
bar.step(); bar.step();
fields = result->Fetch(); fields = result->Fetch();
std::string name= fields[0].GetCppString(); std::string name= fields[0].GetCppString();
if(normalizePlayerName(name))
std::wstring wstr;
if(!Utf8toWStr (name,wstr))
{ {
m_ReservedNames.insert(name); sLog.outError("Table `reserved_name` have invalid name: %s", name.c_str() );
++count; continue;
} }
wstrToLower(wstr);
m_ReservedNames.insert(wstr);
++count;
} while ( result->NextRow() ); } while ( result->NextRow() );
delete result; delete result;
@ -6328,6 +6335,17 @@ void ObjectMgr::LoadReservedPlayersNames()
sLog.outString( ">> Loaded %u reserved player names", count ); sLog.outString( ">> Loaded %u reserved player names", count );
} }
bool ObjectMgr::IsReservedName( const std::string& name ) const
{
std::wstring wstr;
if(!Utf8toWStr (name,wstr))
return false;
wstrToLower(wstr);
return m_ReservedNames.find(wstr) != m_ReservedNames.end();
}
enum LanguageType enum LanguageType
{ {
LT_BASIC_LATIN = 0x0000, LT_BASIC_LATIN = 0x0000,

View file

@ -702,10 +702,7 @@ class ObjectMgr
// reserved names // reserved names
void LoadReservedPlayersNames(); void LoadReservedPlayersNames();
bool IsReservedName(const std::string& name) const bool IsReservedName(const std::string& name) const;
{
return m_ReservedNames.find(name) != m_ReservedNames.end();
}
// name with valid structure and symbols // name with valid structure and symbols
static bool IsValidName( const std::string& name, bool create = false ); static bool IsValidName( const std::string& name, bool create = false );
@ -834,7 +831,7 @@ class ObjectMgr
PetCreateSpellMap mPetCreateSpell; PetCreateSpellMap mPetCreateSpell;
//character reserved names //character reserved names
typedef std::set<std::string> ReservedNamesMap; typedef std::set<std::wstring> ReservedNamesMap;
ReservedNamesMap m_ReservedNames; ReservedNamesMap m_ReservedNames;
GraveYardMap mGraveYardMap; GraveYardMap mGraveYardMap;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7165" #define REVISION_NR "7166"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__