- Fixed map_nick2sd so that searching for "Adam" will not match a char named "Adam Smith". Thanks to Adam for reporting it out.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7172 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2006-06-15 01:40:59 +00:00
parent ce995d0bbf
commit 38f30d053d
2 changed files with 5 additions and 15 deletions

View File

@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/06/14 2006/06/14
* Fixed map_nick2sd so that searching for "Adam" will not match a char
named "Adam Smith". Thanks to Adam for reporting it out. [Skotlex]
* Modified how luk reduces status changes by reducing the gap. Eg: resist = * Modified how luk reduces status changes by reducing the gap. Eg: resist =
vit; resist += (max - resist)*luk/300; [Skotlex] vit; resist += (max - resist)*luk/300; [Skotlex]
* Added battle settings pc_max_sc_luk/mob_max_sc_luk to handle which is the * Added battle settings pc_max_sc_luk/mob_max_sc_luk to handle which is the

View File

@ -1744,33 +1744,21 @@ struct map_session_data * map_charid2sd(int id) {
*------------------------------------------ *------------------------------------------
*/ */
struct map_session_data * map_nick2sd(char *nick) { struct map_session_data * map_nick2sd(char *nick) {
int i, quantity=0, nicklen, users; int i, quantity=0, users;
struct map_session_data *sd = NULL; struct map_session_data *sd = NULL;
struct map_session_data *pl_sd = NULL, **pl_allsd; struct map_session_data *pl_sd = NULL, **pl_allsd;
if (nick == NULL) if (nick == NULL)
return NULL; return NULL;
nicklen = strlen(nick);
pl_allsd = map_getallusers(&users); pl_allsd = map_getallusers(&users);
for (i = 0; i < users; i++) { for (i = 0; i < users; i++) {
pl_sd = pl_allsd[i]; pl_sd = pl_allsd[i];
// Without case sensitive check (increase the number of similar character names found) // Without case sensitive check (increase the number of similar character names found)
if (strnicmp(pl_sd->status.name, nick, nicklen) == 0) { if (strcasecmp(pl_sd->status.name, nick) == 0)
// Strict comparison (if found, we finish the function immediatly with correct value)
if (strcmp(pl_sd->status.name, nick) == 0)
return pl_sd; return pl_sd;
quantity++;
sd = pl_sd;
} }
}
// Here, the exact character name is not found
// We return the found index of a similar account ONLY if there is 1 similar character
if (quantity == 1)
return sd;
// Exact character name is not found and 0 or more than 1 similar characters have been found ==> we say not found // Exact character name is not found and 0 or more than 1 similar characters have been found ==> we say not found
return NULL; return NULL;
} }