summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/messages.conf7
-rw-r--r--src/map/atcommand.c42
-rw-r--r--src/map/skill.c2
-rw-r--r--src/map/skill.h8
4 files changed, 42 insertions, 17 deletions
diff --git a/conf/messages.conf b/conf/messages.conf
index a554c116d..9b1af268a 100644
--- a/conf/messages.conf
+++ b/conf/messages.conf
@@ -1,4 +1,4 @@
-// Hercules msg_athena.conf
+// Hercules messages.conf
// Message Configuration
// For translation, just change msg here (second line), no need to modify source code,
// or alternatively, use conf/import/msg_conf.txt
@@ -1013,7 +1013,7 @@
// @skillid
1163: Please enter a skill name to look up (usage: @skillid <skill name>).
-1164: skill %d: %s
+1164: skill %d: %s (%s)
// @useskill
1165: Usage: @useskill <skill ID> <skill level> <target>
@@ -1406,5 +1406,8 @@
1396: You do not have a cart to be cleaned.
1397: Your cart was cleaned.
+// @skillid (extension)
+1398: -- Displaying first %d partial matches
+
//Custom translations
import: conf/import/msg_conf.txt
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
{