summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-01 15:56:34 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-01 15:56:34 +0000
commit911c0ea64888157f7a9496a4a5c516af92c0d11c (patch)
tree7a4d5fa04cdca47d9b7eadf8ffddca92b39ed6a8 /src/map/map.c
parentf15995cea6ac172a676b17fc91fb0940f97ae87f (diff)
downloadhercules-911c0ea64888157f7a9496a4a5c516af92c0d11c.tar.gz
hercules-911c0ea64888157f7a9496a4a5c516af92c0d11c.tar.bz2
hercules-911c0ea64888157f7a9496a4a5c516af92c0d11c.tar.xz
hercules-911c0ea64888157f7a9496a4a5c516af92c0d11c.zip
- Added a missing break in battle_check_target
- Added config setting "partial_name_scan", which specifies whether @ given names should use a partial string lookup or absolute name lookup. Defaults to no (gm.conf) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8578 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 61527cadb..87300b2e4 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1787,15 +1787,32 @@ struct map_session_data * map_nick2sd(char *nick) {
if (nick == NULL)
return NULL;
- pl_allsd = map_getallusers(&users);
-
- for (i = 0; i < users; i++) {
- pl_sd = pl_allsd[i];
- // Without case sensitive check (increase the number of similar character names found)
- if (strcasecmp(pl_sd->status.name, nick) == 0)
- return pl_sd;
- }
- // Exact character name is not found and 0 or more than 1 similar characters have been found ==> we say not found
+ pl_allsd = map_getallusers(&users);
+ if (battle_config.partial_name_scan)
+ {
+ int qty = 0, nicklen = strlen(nick);
+ struct map_session_data *sd = NULL;
+ for (i = 0; i < users; i++) {
+ pl_sd = pl_allsd[i];
+ // Without case sensitive check (increase the number of similar character names found)
+ if (strnicmp(pl_sd->status.name, nick, nicklen) == 0) {
+ // Strict comparison (if found, we finish the function immediatly with correct value)
+ if (strcmp(pl_sd->status.name, nick) == 0)
+ return pl_sd;
+ qty++;
+ sd = pl_sd;
+ }
+ }
+ // We return the found index of a similar account ONLY if there is 1 similar character
+ if (qty == 1)
+ return sd;
+ } else { //Exact Search
+ for (i = 0; i < users; i++) {
+ if (strcasecmp(pl_allsd[i]->status.name, nick) == 0)
+ return pl_allsd[i];
+ }
+ }
+ //Not found.
return NULL;
}