Check for Bad Names

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Check for Bad Names

Postby Hiatus » Wed May 11, 2011 6:09 pm

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
Last edited by Hiatus on Mon Jan 06, 2014 8:20 am, edited 1 time in total.
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm

Re: Check for Bad Names

Postby Tolakram » Wed May 11, 2011 6:22 pm

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!
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Check for Bad Names

Postby Tolakram » Wed May 11, 2011 6:25 pm

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.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Check for Bad Names

Postby Tolakram » Wed May 11, 2011 6:29 pm

...some posts deleted...

Let's not argue that point, it's not important. Default to off, as a general rule, and let admins decide.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Check for Bad Names

Postby Hiatus » Wed May 11, 2011 6:53 pm

There we go, fixed to meet your standards :D
Last edited by Hiatus on Wed May 11, 2011 7:12 pm, edited 1 time in total.
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm

Re: Check for Bad Names

Postby Tolakram » Wed May 11, 2011 7:02 pm

Excellent, thanks!
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Check for Bad Names

Postby Graveen » Wed May 11, 2011 7:43 pm

Thank you ! It replaces totally invalidnames.txt ?

Good job !
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Check for Bad Names

Postby Hiatus » Wed May 11, 2011 8:53 pm

Yes
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm

Re: Check for Bad Names

Postby geshi » Wed May 11, 2011 9:51 pm

The support for invalidnames.txt still exists, just not sure if it works, invalidnames.txt is also used for last names it seems.
geshi
Contributor
 
Posts: 1826
Joined: Tue Oct 21, 2008 9:16 pm

Re: Check for Bad Names

Postby Tolakram » Wed May 11, 2011 9:55 pm

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.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Check for Bad Names

Postby Hiatus » Mon Jan 06, 2014 4:50 am

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.
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm

Re: Check for Bad Names

Postby Hiatus » Mon Jan 06, 2014 8:04 am

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.
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm

Re: Check for Bad Names

Postby Hiatus » Mon Jan 06, 2014 8:16 am

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
Attachments
checkbadnames.patch
(9.29 KiB) Downloaded 22 times
badnames.rar
sql file
(950 Bytes) Downloaded 24 times
Last edited by Hiatus on Mon Jan 06, 2014 2:24 pm, edited 1 time in total.
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm

Re: Check for Bad Names

Postby Leodagan » Mon Jan 06, 2014 10:04 am

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
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Check for Bad Names

Postby Hiatus » Mon Jan 06, 2014 1:47 pm

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.
Graveen wrote:If you can't see the problem, then this is the problem :mrgreen:
Hiatus
Support Team
 
Posts: 263
Joined: Sat Apr 30, 2011 3:54 pm


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest