diff options
author | shennetsind <ind@henn.et> | 2013-02-16 22:33:13 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-02-16 22:33:13 -0200 |
commit | b8379d2dc56197dc970db8bf1c0ba60ae4835819 (patch) | |
tree | aca11affcf4392479304800ab56bd0281cd29ab5 /src | |
parent | 4ce4adceac3bde1e778c2b9e53b4a4954049f349 (diff) | |
download | hercules-b8379d2dc56197dc970db8bf1c0ba60ae4835819.tar.gz hercules-b8379d2dc56197dc970db8bf1c0ba60ae4835819.tar.bz2 hercules-b8379d2dc56197dc970db8bf1c0ba60ae4835819.tar.xz hercules-b8379d2dc56197dc970db8bf1c0ba60ae4835819.zip |
@skillid Improvement
As suggested by Streusel and backed by the development team, @skillid now supports partial search.
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 42 | ||||
-rw-r--r-- | src/map/skill.c | 2 | ||||
-rw-r--r-- | src/map/skill.h | 8 |
3 files changed, 37 insertions, 15 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e54166019..320ca83ff 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5379,27 +5379,47 @@ ACMD_FUNC(clearcart) * @skillid by [MouseJstr] * lookup a skill by name *------------------------------------------*/ -ACMD_FUNC(skillid) -{ - int skillen, idx; +#define MAX_SKILLID_PARTIAL_RESULTS 5 +#define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 /* "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33) */ +ACMD_FUNC(skillid) { + int skillen, idx, i, found = 0; + DBIterator* iter; + DBKey key; + DBData *data; + char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN]; + nullpo_retr(-1, sd); - if (!message || !*message) - { + if (!message || !*message) { clif_displaymessage(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>). return -1; } skillen = strlen(message); - - for (idx = 0; idx < MAX_SKILL_DB; idx++) { - if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) - { - sprintf(atcmd_output, msg_txt(1164), idx, skill_db[idx].desc); // skill %d: %s + + iter = db_iterator(skilldb_name2id); + + for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) { + idx = skill_get_index(db_data2i(data)); + if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) { + sprintf(atcmd_output, msg_txt(1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s) clif_displaymessage(fd, atcmd_output); + } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) { + snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(1164), db_data2i(data), skill_db[idx].desc, key.str); } } - + + dbi_destroy(iter); + + if( found ) { + sprintf(atcmd_output, msg_txt(1398), found); // -- Displaying first %d partial matches + clif_displaymessage(fd, atcmd_output); + } + + for(i = 0; i < found; i++) { /* partials */ + clif_displaymessage(fd, partials[i]); + } + return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index ccf25f911..51124e93b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -63,8 +63,6 @@ static struct eri *skill_timer_ers = NULL; //For handling skill_timerskills [Sko DBMap* skillunit_db = NULL; // int id -> struct skill_unit* -DBMap* skilldb_name2id = NULL; - /** * Skill Cool Down Delay Saving * Struct skill_cd is not a member of struct map_session_data diff --git a/src/map/skill.h b/src/map/skill.h index 9b6ba1b0c..94159d524 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1,10 +1,12 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #ifndef _SKILL_H_ #define _SKILL_H_ #include "../common/mmo.h" // MAX_SKILL, struct square +#include "../common/db.h" #include "map.h" // struct block_list struct map_session_data; struct homun_data; @@ -22,6 +24,8 @@ struct status_change_entry; #define MAX_SKILL_LEVEL 100 +DBMap* skilldb_name2id; + //Constants to identify the skill's inf value: enum e_skill_inf { |