Page 1 of 2

Check for Bad Names

PostPosted: Wed May 11, 2011 6:09 pm
by Hiatus
This will send message "Name is not allowed. Please choose another name" at character selection screen. I have provided an SQL files with about 50 names in the db table that are not allowed. The rest can be added if the server managers choose to add or remove some. There is a server property that will allow to enable/disable this feature also. Thank you for reviewing my work or giving your input was greatly appreciated. Spent a long time on this patch but in the end the sense of accomplishment was worth it :D

Edit :

No, I didn't know all of these words :twisted: Google is my friend. :D

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 6:22 pm
by Tolakram
Very nice, but I would like some changes. :mrgreen:

First please use AutoIncrement when creating new tables so we don't have BadNames_ID ... I hate em.

Example:
Code: Select all
[PrimaryKey(AutoIncrement = true)]
public int ID
{
get { return m_id; }
set { m_id = value; }
}

I would also like to see an additional field so we can specify a partial name check. Perhaps just called partial.

Change your SQL Inserts to
Code: Select all
INSERT INTO BadNames ('somebadword', 1);
The ID field never has to be referenced since it will auto increment. Actual table columns will be ID, Name, partial

Finally, in the interest of readability, please make the server property name CHECK_BAD_NAMES and default to false (don't like to turn on new features, let the server admin decide).

Great job, thanks!

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 6:25 pm
by Tolakram
Woops,

and if the name is found please break out of the loop.

Also, your bad name check should not execute if a duplicate is already found.

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 6:29 pm
by Tolakram
...some posts deleted...

Let's not argue that point, it's not important. Default to off, as a general rule, and let admins decide.

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 6:53 pm
by Hiatus
There we go, fixed to meet your standards :D

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 7:02 pm
by Tolakram
Excellent, thanks!

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 7:43 pm
by Graveen
Thank you ! It replaces totally invalidnames.txt ?

Good job !

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 8:53 pm
by Hiatus
Yes

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 9:51 pm
by geshi
The support for invalidnames.txt still exists, just not sure if it works, invalidnames.txt is also used for last names it seems.

Re: Check for Bad Names

PostPosted: Wed May 11, 2011 9:55 pm
by Tolakram
Only used in lastname.cs
Code: Select all
foreach (string invalid in GameServer.Instance.InvalidNames)
{
if (NewLastname.ToLower().IndexOf(invalid) != -1)
{
client.Out.SendMessage(NewLastname + " is not a legal last name! Choose another.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
}
it is also used in

public class BadNameCheckRequestHandler : IPacketHandler

with the classic comment
Code: Select all
//TODO do bad name checks here from some database with
//bad names, this is just a temp testthing here
but I do not believe this is called since the new character create was introduced.
perhaps we can change this to use the new badnames as well, and keyed off the same server property? It was also one of those classic features that loads on startup and requires a restart to update.

Re: Check for Bad Names

PostPosted: Mon Jan 06, 2014 4:50 am
by Hiatus
I believe the patch for this was never committed, but I updated it for latest DOL revision also changed the code to be handled in BadNameCheckRequestHandler instead of DuplicateName or w.e. it was. I also added support for it in the lastname handler at Tola's request.

Re: Check for Bad Names

PostPosted: Mon Jan 06, 2014 8:04 am
by Hiatus
I believe the patch for this was never committed, but I updated it for latest DOL revision also changed the code to be handled in BadNameCheckRequestHandler instead of DuplicateName or w.e. it was. I also added support for it in the lastname handler at Tola's request.
Quick update, took the patches down. Did some testing to find out that the BadNameCheckRequest is not handled anymore :?: Added it into DuplicateNameCheckRequest as a hack for now until I get more clarity on that. I have been testing for hours tonight :S I even tried to add my own handling in packetLibs for BadNameCheck, but nothing seemed to work. I will just base it off of DupNameCheck and repost when I am finished.

Re: Check for Bad Names

PostPosted: Mon Jan 06, 2014 8:16 am
by Hiatus
Here's the newest patch, sorry for all of the posts. Works 100% and ready to be committed. Again, if someone can enlighten me if BadNameRequest actually working, then I will redo the code. If not this is the only way we will be able to check this.

--scripts added--
BadNames.cs (Database Table)

--scripts edited--
DuplicateNameCheckRequestHandler.cs
lastname.cs
BadNameCheckRequestHandler.cs

Re: Check for Bad Names

PostPosted: Mon Jan 06, 2014 10:04 am
by Leodagan
With this patch you're going to check for every table row if it "Contains" BadNames or if it "Contains" PartialNames...

First : This is the same behavior for both field... I'm not sure that the expected functionnality

Second : This will match if any of the field is Empty ! ("abcd".Contains(""); return true !)

http://stackoverflow.com/questions/5882 ... ring-empty

Re: Check for Bad Names

PostPosted: Mon Jan 06, 2014 1:47 pm
by Hiatus
With this patch you're going to check for every table row if it "Contains" BadNames or if it "Contains" PartialNames...

First : This is the same behavior for both field... I'm not sure that the expected functionnality

Second : This will match if any of the field is Empty ! ("abcd".Contains(""); return true !)

http://stackoverflow.com/questions/5882 ... ring-empty

Yes, it is the expected functionality. It is checked the users name against the database table to see if the name is allowed or is not.