diff options
author | Haru <haru@dotalux.com> | 2019-08-25 18:41:36 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2019-09-22 23:45:32 +0200 |
commit | 205b602a893cb84e99ab61bafe2b84e0338acf9b (patch) | |
tree | f1487b2a1f34e8f38545e23c12872e1c5e800599 /src/map/map.c | |
parent | 92f3ecdcb341b798c93d5c8b0320fb8cb85e759c (diff) | |
download | hercules-205b602a893cb84e99ab61bafe2b84e0338acf9b.tar.gz hercules-205b602a893cb84e99ab61bafe2b84e0338acf9b.tar.bz2 hercules-205b602a893cb84e99ab61bafe2b84e0338acf9b.tar.xz hercules-205b602a893cb84e99ab61bafe2b84e0338acf9b.zip |
Fix several issues caused by the nick partial match feature, when enabled.
Partial match is now disabled in all the internal (source) and script
lookups, while it's enabled for the lookups requested by atcommands and
client.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/map/map.c b/src/map/map.c index f92be52e9..0f542d812 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2268,7 +2268,7 @@ static struct map_session_data *map_charid2sd(int charid) * (without sensitive case if necessary) * return map_session_data pointer or NULL *------------------------------------------*/ -static struct map_session_data *map_nick2sd(const char *nick) +static struct map_session_data *map_nick2sd(const char *nick, bool allow_partial) { struct map_session_data* sd; struct map_session_data* found_sd; @@ -2276,7 +2276,7 @@ static struct map_session_data *map_nick2sd(const char *nick) size_t nicklen; int qty = 0; - if( nick == NULL ) + if (nick == NULL) return NULL; nicklen = strlen(nick); @@ -2284,30 +2284,29 @@ static struct map_session_data *map_nick2sd(const char *nick) found_sd = NULL; for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { - if( battle_config.partial_name_scan ) - {// partial name search - if( strnicmp(sd->status.name, nick, nicklen) == 0 ) - { + if (battle_config.partial_name_scan && allow_partial) { + // partial name search + if (strnicmp(sd->status.name, nick, nicklen) == 0) { found_sd = sd; - if( strcmp(sd->status.name, nick) == 0 ) - {// Perfect Match + if (strcmp(sd->status.name, nick) == 0) { + // Perfect Match qty = 1; break; } qty++; } - } - else if( strcasecmp(sd->status.name, nick) == 0 ) - {// exact search only + } else if (strcasecmp(sd->status.name, nick) == 0) { + // exact search only found_sd = sd; + qty = 1; break; } } mapit->free(iter); - if( battle_config.partial_name_scan && qty != 1 ) + if (battle_config.partial_name_scan && qty != 1) found_sd = NULL; return found_sd; |