Skip to content

Commit

Permalink
[7166] Make reserved name check case-insensitive.
Browse files Browse the repository at this point in the history
Original patch provided by jpmythic.
  • Loading branch information
VladimirMangos committed Jan 24, 2009
1 parent d31d5f2 commit ee9c4c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
24 changes: 21 additions & 3 deletions src/game/ObjectMgr.cpp
Expand Up @@ -6315,11 +6315,18 @@ void ObjectMgr::LoadReservedPlayersNames()
bar.step();
fields = result->Fetch();
std::string name= fields[0].GetCppString();
if(normalizePlayerName(name))

std::wstring wstr;
if(!Utf8toWStr (name,wstr))
{
m_ReservedNames.insert(name);
++count;
sLog.outError("Table `reserved_name` have invalid name: %s", name.c_str() );
continue;
}

wstrToLower(wstr);

m_ReservedNames.insert(wstr);
++count;
} while ( result->NextRow() );

delete result;
Expand All @@ -6328,6 +6335,17 @@ void ObjectMgr::LoadReservedPlayersNames()
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
{
LT_BASIC_LATIN = 0x0000,
Expand Down
7 changes: 2 additions & 5 deletions src/game/ObjectMgr.h
Expand Up @@ -702,10 +702,7 @@ class ObjectMgr

// reserved names
void LoadReservedPlayersNames();
bool IsReservedName(const std::string& name) const
{
return m_ReservedNames.find(name) != m_ReservedNames.end();
}
bool IsReservedName(const std::string& name) const;

// name with valid structure and symbols
static bool IsValidName( const std::string& name, bool create = false );
Expand Down Expand Up @@ -834,7 +831,7 @@ class ObjectMgr
PetCreateSpellMap mPetCreateSpell;

//character reserved names
typedef std::set<std::string> ReservedNamesMap;
typedef std::set<std::wstring> ReservedNamesMap;
ReservedNamesMap m_ReservedNames;

GraveYardMap mGraveYardMap;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7165"
#define REVISION_NR "7166"
#endif // __REVISION_NR_H__

0 comments on commit ee9c4c4

Please sign in to comment.