Jump to content

  •  

Bug Tracker Migration

June 3rd
Good news everyone! The staff has decided that it is time to slowly kill off this Bug Tracker. We will begin the process of slowly migrating from this Bug Tracker over to our Github Issues which can be found here: https://github.com/HerculesWS/Hercules/issues

Over the next couple of days, I will be closing off any opportunity to create new reports. However, I still will keep the opportunity to reply to existing Bug Reports. Doing this will allow us to slowly fix any bug reports we have listed here so that we can easily migrate over to our Issue Tracker.

Update - June 7th 2015: Creating new bug posts has been disabled. Please use our https://github.com/HerculesWS/Hercules/issues tracker to post bugs. Users are still able to reply to existing bug posts.

- Administration

Issue Information

  • #004700

  • 2 - Fair

  • Fixed

Issue Confirmations

  • Yes (1)No (0)
Photo

Creating identical nicknames

Posted by Hercules Bot on 08 January 2011 - 08:29 PM

Originally posted by EternalFriend
http://www.eathena.w...er&showbug=4700

Hello.
First encountered this problem - create a character with the same nicknames, which in turn are written differently:
TEST, Test, test, teSt - I can create.
In char_athena.conf - as it should - ban:
CODE
// Allow or not identical name for characters but with a different case (upper/lower):
// example: Test-test-TEST-TesT; Value: 0 not allowed (default), 1 allowed
name_ignoring_case: no

Tried to put a value of zero, the effect is not produced.
tried to put the latest on this day (14659) - the same thing.
Different keyboard layouts are excluded.

Sorry for my english, I'm from Russia.
Thx.

Originally posted by xazax
The value is read in char server sql implementation, but not used.

My solution, ( I did not test it yet ):

<br />Index: char.c<br />===================================================================<br />--- char.c	(revision 15270)<br />+++ char.c	(working copy)<br />@@ -1327,11 +1327,31 @@<br />	 }<br /><br />	 // check name (already in use?)<br />-	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) )<br />+	if ( name_ignoring_case )<br />	 {<br />-		Sql_ShowDebug(sql_handle);<br />-		return -2;<br />+		if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) )<br />+		{<br />+			Sql_ShowDebug(sql_handle);<br />+			return -2;<br />+		}<br />	 }<br />+	else<br />+	{<br />+		char lower_esc_name[NAME_LENGTH*2+1];<br />+		int i = 0;<br />+		<br />+		while(esc_name[i])<br />+		{<br />+			lower_esc_name[i] = tolower(esc_name[i]);<br />+			++i;<br />+		}<br />+		<br />+		if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE LOWER(`name`) = '%s' LIMIT 1", char_db, lower_esc_name) )<br />+		{<br />+			Sql_ShowDebug(sql_handle);<br />+			return -2;<br />+		}<br />+	}<br />	 if( Sql_NumRows(sql_handle) > 0 )<br />		 return -1; // name already exists<br /><br /><br />


Originally posted by arp
I've had a chat to xazax about this, and unfortunately his above provided is a little wrong. I've spent a little while looking at this, and have provided a patch that I'm confident will work as intended. It turns out that the piece of code used to lower() a string actually ended up adding garbage on to strings of len(str)==4.

I can't find an attach button, so here's the diff:
http://bawx.depha.se...issue_4700.diff

Originally posted by Ind

I've had a chat to xazax about this, and unfortunately his above provided is a little wrong. I've spent a little while looking at this, and have provided a patch that I'm confident will work as intended. It turns out that the piece of code used to lower() a string actually ended up adding garbage on to strings of len(str)==4.I can't find an attach button, so here's the diff:http://bawx.depha.se...issue_4700.diff

yours is a little wrong too XD I didn't test either yet but at taking a glance at the diff file, for example, you declare a lower_esc_name which is not used anywhere

Originally posted by arp
Ah, I must have missed that out, lower_esc_name is from the old code and I forgot to remove it, I'll attach an updated diff.

Originally posted by arp
Diff has been updated to remove the two unused declarations.

Originally posted by Ind
I've got to this and I've fixed it simply by adding a 'BINARY `name` = <name>'. Fixed in [rev=15374]