- Added functions mobdb_searchname_array and itemdb_searchname_array which return an array of matches.
- Modified @iteminfo and @mobinfo to search and display various matches instead of just one. - Constant MAX_SEARCH in map.h defines the max size of search results. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5512 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
d4e9bcf863
commit
fbda66933a
@ -4,6 +4,10 @@ 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. EVERYTHING ELSE
|
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE
|
||||||
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
|
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
|
||||||
|
|
||||||
|
2006/03/08
|
||||||
|
* Modified atcommands @mobinfo and @iteminfo to display multiple matches
|
||||||
|
instead of just one. Max number of matches to display is set in map.h
|
||||||
|
(MAX_SEARCH) which is currently 5. [Skotlex]
|
||||||
2006/03/07
|
2006/03/07
|
||||||
* Base for ninja/gunslinger is mostly done. need to work on skills now. [Vicious]
|
* Base for ninja/gunslinger is mostly done. need to work on skills now. [Vicious]
|
||||||
- Updated sql-files/ mob_db.sql and item_db.sql to current txt dbs. [Skotlex]
|
- Updated sql-files/ mob_db.sql and item_db.sql to current txt dbs. [Skotlex]
|
||||||
|
@ -275,7 +275,7 @@
|
|||||||
266: Some of your items cannot be vended and were removed from the shop.
|
266: Some of your items cannot be vended and were removed from the shop.
|
||||||
267: '%s' designated maps reseted!
|
267: '%s' designated maps reseted!
|
||||||
268: Reloaded the Message of the Day.
|
268: Reloaded the Message of the Day.
|
||||||
|
269: Displaying first %d out of %d matches
|
||||||
// Guild Castles Number
|
// Guild Castles Number
|
||||||
// --------------------
|
// --------------------
|
||||||
299: ?? Castles
|
299: ?? Castles
|
||||||
|
@ -5186,7 +5186,7 @@ int atcommand_idsearch(
|
|||||||
{
|
{
|
||||||
char item_name[100];
|
char item_name[100];
|
||||||
unsigned int i, match;
|
unsigned int i, match;
|
||||||
struct item_data *item;
|
struct item_data *item_array[MAX_SEARCH];
|
||||||
nullpo_retr(-1, sd);
|
nullpo_retr(-1, sd);
|
||||||
|
|
||||||
memset(item_name, '\0', sizeof(item_name));
|
memset(item_name, '\0', sizeof(item_name));
|
||||||
@ -5199,13 +5199,15 @@ int atcommand_idsearch(
|
|||||||
|
|
||||||
sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
|
sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
|
||||||
clif_displaymessage(fd, atcmd_output);
|
clif_displaymessage(fd, atcmd_output);
|
||||||
match = 0;
|
match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
|
||||||
for(i = 0; i < 20000; i++) {
|
if (match > MAX_SEARCH) {
|
||||||
if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
|
sprintf(atcmd_output, msg_table[269], MAX_SEARCH, match);
|
||||||
match++;
|
|
||||||
sprintf(atcmd_output, msg_table[78], item->jname, item->nameid); // %s: %d
|
|
||||||
clif_displaymessage(fd, atcmd_output);
|
clif_displaymessage(fd, atcmd_output);
|
||||||
|
match = MAX_SEARCH;
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < match; i++) {
|
||||||
|
sprintf(atcmd_output, msg_table[78], item_array[i]->jname, item_array[i]->nameid); // %s: %d
|
||||||
|
clif_displaymessage(fd, atcmd_output);
|
||||||
}
|
}
|
||||||
sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
|
sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
|
||||||
clif_displaymessage(fd, atcmd_output);
|
clif_displaymessage(fd, atcmd_output);
|
||||||
@ -9251,9 +9253,9 @@ int atcommand_mobinfo(
|
|||||||
unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
|
unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
|
||||||
char atcmd_output2[200];
|
char atcmd_output2[200];
|
||||||
struct item_data *item_data;
|
struct item_data *item_data;
|
||||||
struct mob_db *mob;
|
struct mob_db *mob, *mob_array[MAX_SEARCH];
|
||||||
int mob_id;
|
int mob_id, count;
|
||||||
int i, j;
|
int i, j, k;
|
||||||
|
|
||||||
memset(atcmd_output, '\0', sizeof(atcmd_output));
|
memset(atcmd_output, '\0', sizeof(atcmd_output));
|
||||||
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
|
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
|
||||||
@ -9264,15 +9266,25 @@ int atcommand_mobinfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If monster identifier/name argument is a name
|
// If monster identifier/name argument is a name
|
||||||
if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
|
if ((mob_id = mobdb_checkid(atoi(message))))
|
||||||
mob_id = mobdb_checkid(atoi(message));
|
{
|
||||||
|
mob_array[0] = mob_db(mob_id);
|
||||||
|
count = 1;
|
||||||
|
} else
|
||||||
|
count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
|
||||||
|
|
||||||
if (mob_id == 0) {
|
if (!count) {
|
||||||
clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
|
clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mob = mob_db(mob_id);
|
if (count > MAX_SEARCH) {
|
||||||
|
sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
|
||||||
|
clif_displaymessage(fd, atcmd_output);
|
||||||
|
count = MAX_SEARCH;
|
||||||
|
}
|
||||||
|
for (k = 0; k < count; k++) {
|
||||||
|
mob = mob_array[k];
|
||||||
|
|
||||||
// stats
|
// stats
|
||||||
if (mob->mexp)
|
if (mob->mexp)
|
||||||
@ -9337,7 +9349,7 @@ int atcommand_mobinfo(
|
|||||||
else
|
else
|
||||||
clif_displaymessage(fd, atcmd_output);
|
clif_displaymessage(fd, atcmd_output);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9353,20 +9365,28 @@ int atcommand_iteminfo(
|
|||||||
char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
|
char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
|
||||||
//, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
|
//, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
|
||||||
|
|
||||||
struct item_data *item_data;
|
struct item_data *item_data, *item_array[MAX_SEARCH];
|
||||||
int item_id=0;
|
int i, item_id=0, count = 1;
|
||||||
|
|
||||||
if (!message || !*message) {
|
if (!message || !*message) {
|
||||||
clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
|
clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
|
||||||
|
count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
|
||||||
|
|
||||||
if ((item_data = itemdb_searchname(message)) != NULL ||
|
if (!count) {
|
||||||
(item_data = itemdb_exists(atoi(message))) != NULL)
|
clif_displaymessage(fd, "Item not found.");
|
||||||
item_id = item_data->nameid;
|
return -1;
|
||||||
|
}
|
||||||
if (item_id >= 500) {
|
|
||||||
|
|
||||||
|
if (count > MAX_SEARCH) {
|
||||||
|
sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
|
||||||
|
clif_displaymessage(fd, atcmd_output);
|
||||||
|
count = MAX_SEARCH;
|
||||||
|
}
|
||||||
|
for (i = 0; i < MAX_SEARCH; i++) {
|
||||||
|
item_data = item_array[i];
|
||||||
sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
|
sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
|
||||||
item_data->name,item_data->jname,item_data->slot,item_id,
|
item_data->name,item_data->jname,item_data->slot,item_id,
|
||||||
item_data->type < 12 ? itype[item_data->type] : "BUG!",
|
item_data->type < 12 ? itype[item_data->type] : "BUG!",
|
||||||
|
@ -61,6 +61,7 @@ int itemdb_searchjname_sub(int key,void *data,va_list ap)
|
|||||||
*dst=item;
|
*dst=item;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
* 名前で検索
|
* 名前で検索
|
||||||
*------------------------------------------
|
*------------------------------------------
|
||||||
@ -72,6 +73,30 @@ struct item_data* itemdb_searchname(const char *str)
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int itemdb_searchname_array_sub(DBKey key,void * data,va_list ap)
|
||||||
|
{
|
||||||
|
struct item_data *item=(struct item_data *)data;
|
||||||
|
char *str;
|
||||||
|
str=va_arg(ap,char *);
|
||||||
|
if (item == dummy_item)
|
||||||
|
return 1; //Invalid item.
|
||||||
|
if(strstr(item->jname,str))
|
||||||
|
return 0;
|
||||||
|
if(strstr(item->name,str))
|
||||||
|
return 0;
|
||||||
|
return strcmpi(item->jname,str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==========================================
|
||||||
|
* Founds up to N matches. Returns number of matches [Skotlex]
|
||||||
|
*------------------------------------------
|
||||||
|
*/
|
||||||
|
int itemdb_searchname_array(struct item_data** data, int size, const char *str)
|
||||||
|
{
|
||||||
|
return item_db->getall(item_db,(void**)data,size,itemdb_searchname_array_sub,str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
* 箱系アイテム検索
|
* 箱系アイテム検索
|
||||||
*------------------------------------------
|
*------------------------------------------
|
||||||
|
@ -56,6 +56,7 @@ struct item_group {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct item_data* itemdb_searchname(const char *name);
|
struct item_data* itemdb_searchname(const char *name);
|
||||||
|
int itemdb_searchname_array(struct item_data** data, int size, const char *str);
|
||||||
struct item_data* itemdb_load(int nameid);
|
struct item_data* itemdb_load(int nameid);
|
||||||
struct item_data* itemdb_search(int nameid);
|
struct item_data* itemdb_search(int nameid);
|
||||||
struct item_data* itemdb_exists(int nameid);
|
struct item_data* itemdb_exists(int nameid);
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
#define MOBID_EMPERIUM 1288
|
#define MOBID_EMPERIUM 1288
|
||||||
|
|
||||||
#define MAX_PC_BONUS 10
|
#define MAX_PC_BONUS 10
|
||||||
|
//Designed for search functions, species max number of matches to display.
|
||||||
|
#define MAX_SEARCH 5
|
||||||
#define MAX_DUEL 1024
|
#define MAX_DUEL 1024
|
||||||
|
|
||||||
//These mark the ID of the jobs, as expected by the client. [Skotlex]
|
//These mark the ID of the jobs, as expected by the client. [Skotlex]
|
||||||
|
@ -80,6 +80,39 @@ int mobdb_searchname(const char *str)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int mobdb_searchname_array_sub(struct mob_db* mob, const char *str)
|
||||||
|
{
|
||||||
|
if (mob == mob_dummy)
|
||||||
|
return 1; //Invalid item.
|
||||||
|
if(strstr(mob->jname,str))
|
||||||
|
return 0;
|
||||||
|
if(strstr(mob->name,str))
|
||||||
|
return 0;
|
||||||
|
return strcmpi(mob->jname,str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==========================================
|
||||||
|
* Founds up to N matches. Returns number of matches [Skotlex]
|
||||||
|
*------------------------------------------
|
||||||
|
*/
|
||||||
|
int mobdb_searchname_array(struct mob_db** data, int size, const char *str)
|
||||||
|
{
|
||||||
|
int count = 0, i;
|
||||||
|
struct mob_db* mob;
|
||||||
|
for(i=0;i<=MAX_MOB_DB;i++){
|
||||||
|
mob = mob_db(i);
|
||||||
|
if (mob == mob_dummy)
|
||||||
|
continue;
|
||||||
|
if (!mobdb_searchname_array_sub(mob, str)) {
|
||||||
|
if (count < size)
|
||||||
|
data[count] = mob;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
* Id Mob is checked.
|
* Id Mob is checked.
|
||||||
|
@ -104,6 +104,7 @@ enum {
|
|||||||
|
|
||||||
struct mob_db* mob_db(int class_);
|
struct mob_db* mob_db(int class_);
|
||||||
int mobdb_searchname(const char *str);
|
int mobdb_searchname(const char *str);
|
||||||
|
int mobdb_searchname_array(struct mob_db** data, int size, const char *str);
|
||||||
int mobdb_checkid(const int id);
|
int mobdb_checkid(const int id);
|
||||||
int mob_once_spawn(struct map_session_data *sd,char *mapname,
|
int mob_once_spawn(struct map_session_data *sd,char *mapname,
|
||||||
int x,int y,const char *mobname,int class_,int amount,const char *event);
|
int x,int y,const char *mobname,int class_,int amount,const char *event);
|
||||||
|
@ -5856,11 +5856,12 @@ int pc_heal(struct map_session_data *sd,int hp,int sp)
|
|||||||
|
|
||||||
nullpo_retr(0, sd);
|
nullpo_retr(0, sd);
|
||||||
|
|
||||||
if(hp > 0 && pc_checkoverhp(sd))
|
//Uneeded as the hp range adjustment below will auto-adap itself and make hp = max. [Skotlex]
|
||||||
hp = 0;
|
// if(hp > 0 && pc_checkoverhp(sd))
|
||||||
|
// hp = 0;
|
||||||
|
|
||||||
if(sp > 0 && pc_checkoversp(sd))
|
// if(sp > 0 && pc_checkoversp(sd))
|
||||||
sp = 0;
|
// sp = 0;
|
||||||
|
|
||||||
if(sd->sc.count && sd->sc.data[SC_BERSERK].timer!=-1) //バ?サ?ク中は回復させないらしい
|
if(sd->sc.count && sd->sc.data[SC_BERSERK].timer!=-1) //バ?サ?ク中は回復させないらしい
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user