From 5de3852d0e203ad08e4bdd748a49f8dba2e028c2 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 1 Feb 2007 21:04:46 +0000 Subject: - Item search is now a bit smarter. When no item is found with the same 'aegis name', then the 'normal' name is used instead. - Updated the @/# commands that take an item name so that you can use quotes when specifying item names with spaces in them. For example, @item "poring card" 1 will work now. Note that only the commands that work on ONE item have been updated, those that do an item list need to be updated as well. - Removed some garbage from the item_data structure. - Improved a bit the description of the mvp item get time config settings. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9767 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 20 ++++++++++++++++---- src/map/charcommand.c | 5 ++++- src/map/itemdb.c | 32 +++++++++++++------------------- src/map/itemdb.h | 2 -- 4 files changed, 33 insertions(+), 26 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0c4809b3a..d11b898e8 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2549,7 +2549,10 @@ int atcommand_item(const int fd, struct map_session_data* sd, const char* comman memset(item_name, '\0', sizeof(item_name)); - if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) { + if (!message || !*message || ( + sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 && + sscanf(message, "%99s %d", item_name, &number) < 1 + )) { clif_displaymessage(fd, "Please, enter an item name/id (usage: @item [quantity])."); return -1; } @@ -2608,7 +2611,10 @@ int atcommand_item2(const int fd, struct map_session_data* sd, const char* comma memset(item_name, '\0', sizeof(item_name)); - if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) { + if (!message || !*message || ( + sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 && + sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 + )) { clif_displaymessage(fd, "Please, enter all informations (usage: @item2 "); clif_displaymessage(fd, " )."); return -1; @@ -3752,7 +3758,10 @@ int atcommand_produce(const int fd, struct map_session_data* sd, const char* com memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(item_name, '\0', sizeof(item_name)); - if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) { + if (!message || !*message || ( + sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 && + sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1 + )) { clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <# of very's>)."); return -1; } @@ -6125,7 +6134,10 @@ int atcommand_chardelitem(const int fd, struct map_session_data* sd, const char* memset(item_name, '\0', sizeof(item_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) { + if (!message || !*message || ( + sscanf(message, "\"%99[^\"]\" %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 && + sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 + ) || number < 1) { clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem )."); return -1; } diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 2c6942c4e..27a80a986 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -1043,7 +1043,10 @@ int charcommand_item( memset(item_name, '\0', sizeof(item_name)); - if (!message || !*message || sscanf(message, "%99s %d %23[^\n]", item_name, &number, character) < 3) { + if (!message || !*message || ( + sscanf(message, "\"%99[^\"]\" %d %23[^\n]", item_name, &number, character) < 3 && + sscanf(message, "%99s %d %23[^\n]", item_name, &number, character) < 3 + )) { clif_displaymessage(fd, "Please, enter an item name/id (usage: #item )."); return -1; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index c2c98f42b..f39e3d809 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -28,29 +28,22 @@ struct item_data dummy_item; //This is the default dummy item used for non-exist // name = item alias, so we should find items aliases first. if not found then look for "jname" (full name) int itemdb_searchname_sub(DBKey key,void *data,va_list ap) { - struct item_data *item=(struct item_data *)data,**dst; + struct item_data *item=(struct item_data *)data,**dst,**dst2; char *str; str=va_arg(ap,char *); dst=va_arg(ap,struct item_data **); + dst2=va_arg(ap,struct item_data **); if(item == &dummy_item) return 0; - if( strcmpi(item->name,str)==0 ) //by lupus + + //Absolute priority to Aegis code name. + if (*dst != NULL) return 0; + if( strcmpi(item->name,str)==0 ) *dst=item; - return 0; -} -/*========================================== - * 名前で検索用 - *------------------------------------------ - */ -int itemdb_searchjname_sub(int key,void *data,va_list ap) -{ - struct item_data *item=(struct item_data *)data,**dst; - char *str; - str=va_arg(ap,char *); - dst=va_arg(ap,struct item_data **); - if(item == &dummy_item) return 0; + //Second priority to Client displayed name. + if (*dst2 != NULL) return 0; if( strcmpi(item->jname,str)==0 ) - *dst=item; + *dst2=item; return 0; } @@ -60,9 +53,10 @@ int itemdb_searchjname_sub(int key,void *data,va_list ap) */ struct item_data* itemdb_searchname(const char *str) { - struct item_data *item=NULL; - item_db->foreach(item_db,itemdb_searchname_sub,str,&item); - return item; + struct item_data *item=NULL, *item2=NULL; + + item_db->foreach(item_db,itemdb_searchname_sub,str,&item,&item2); + return item?item:item2; } static int itemdb_searchname_array_sub(DBKey key,void * data,va_list ap) diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 85a0cdb21..0b9e2a466 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -36,7 +36,6 @@ enum { struct item_data { int nameid; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; - char prefix[NAME_LENGTH],suffix[NAME_LENGTH]; //Do not add stuff between value_buy and wlv (see how getiteminfo works) int value_buy; int value_sell; @@ -68,7 +67,6 @@ struct item_data { unsigned value_notdc : 1; unsigned value_notoc : 1; short no_equip; - unsigned no_use : 1; unsigned no_refine : 1; // [celest] unsigned delay_consume : 1; // Signifies items that are not consumed inmediately upon double-click [Skotlex] unsigned trade_restriction : 7; //Item restrictions mask [Skotlex] -- cgit v1.2.3-70-g09d2