Well, in traditional LOTF, go to DataBase.cs and add this new method somewhere.
Code:
public static bool CharExists(string Name)
{
MySqlDataAdapter DataAdapter = new MySqlDataAdapter("SELECT COUNT(*) FROM `characters` WHERE `CharName` = '" + Name + "' LIMIT 1;", Connection);
DataSet DSet = new DataSet();
DataAdapter.Fill(DSet, "CharLookup");
return (DSet.Tables[0].Rows.Count > 0);
}
The above method queries the character database for the name specified. It returns true or false based on the number of rows returned in the query.
After adding that method, find the Character Creation Packet in Client.cs (dec 1001 / hex 0x3E9). You will see the boolean ValidName referenced several times, checking if the name from the character creation dialog in-game passes the sanity-checks. This is what we want.
You want to place this as the last sanity-check before it tries to make the character. In tradition LOTF, I would lay mine out like this:
Code:
if (CharName.IndexOfAny(new char[3] { ' ', '[', ']' }) > -1)
ValidName = false;
if (ValidName)
foreach (string name in DataBase.ForbiddenNames)
{
if (name == CharName)
{
ValidName = false;
break;
}
}
if (ValidName)
ValidName = DataBase.CharExists(CharName);
That's about it.. and it's untested.