diff options
author | markzd <markzd@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2013-01-07 05:13:54 +0000 |
---|---|---|
committer | markzd <markzd@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2013-01-07 05:13:54 +0000 |
commit | 24987d8513307094064f59d3c9f9c35d0f6a6e87 (patch) | |
tree | c535cefbdf72d7de8ec676f4d9d89fcaebbd8668 /src/map | |
parent | 92880a66754afb8b3b4285276c70c0fc6aa75c1f (diff) | |
download | hercules-24987d8513307094064f59d3c9f9c35d0f6a6e87.tar.gz hercules-24987d8513307094064f59d3c9f9c35d0f6a6e87.tar.bz2 hercules-24987d8513307094064f59d3c9f9c35d0f6a6e87.tar.xz hercules-24987d8513307094064f59d3c9f9c35d0f6a6e87.zip |
* Implemented Unique identifier for Non stackable items. (tid:69380)
* Set as off by default, it can be changed in /src/config/core.h.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@17080 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/itemdb.c | 49 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/log.c | 10 | ||||
-rw-r--r-- | src/map/pc.c | 6 |
4 files changed, 59 insertions, 7 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index e0c964de3..810e85a4a 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1252,6 +1252,51 @@ static int itemdb_read_sqldb(void) { return 0; } +/*========================================== +* Unique item ID function +* Only one operation by once +* Flag: +* 0 return new id +* 1 set new value, checked with current value +* 2 set new value bypassing anything +* 3/other return last value +*------------------------------------------*/ +uint64 itemdb_nsiuid(int8 flag, int64 value) { + static uint64 item_uid = 0; + + if(flag) + { + if(flag == 1) + { if(item_uid < value) + return (item_uid = value); + }else if(flag == 2) + return (item_uid = value); + + return item_uid; + } + + return ++item_uid; +} +int itemdb_uid_load(){ + + char * uid; + if (SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `value` FROM `interreg` WHERE `varname`='nsiuid'")) + Sql_ShowDebug(mmysql_handle); + + if( SQL_SUCCESS != Sql_NextRow(mmysql_handle) ) + { + ShowError("itemdb_uid_load: Unable to fetch nsiuid data\n"); + Sql_FreeResult(mmysql_handle); + return -1; + } + + Sql_GetData(mmysql_handle, 0, &uid, NULL); + itemdb_nsiuid(1, (uint64)strtoull(uid, NULL, 10)); + Sql_FreeResult(mmysql_handle); + + return 0; +} + /*==================================== * read all item-related databases *------------------------------------*/ @@ -1269,7 +1314,9 @@ static void itemdb_read(void) { sv_readdb(db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade); sv_readdb(db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); sv_readdb(db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack); - sv_readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); + sv_readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); + + itemdb_uid_load(); } /*========================================== diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 2bc418cc4..e8c6d6487 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -219,6 +219,7 @@ int itemdb_isequip2(struct item_data *); int itemdb_isidentified(int); int itemdb_isstackable(int); int itemdb_isstackable2(struct item_data *); +uint64 itemdb_nsiuid(int8 flag, int64 value); // Unique Item ID void itemdb_reload(void); diff --git a/src/map/log.c b/src/map/log.c index 8a114d989..9d50be62a 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -188,12 +188,12 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it #ifdef BETA_THREAD_TEST char entry[512]; int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", - log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"" ); + e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `nsiuid`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", + log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->nsiuid); queryThread_log(entry,e_length); #else - if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", - log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"") ) + if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `nsiuid`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", + log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->nsiuid) ) { Sql_ShowDebug(logmysql_handle); return; @@ -210,7 +210,7 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:""); + fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->nsiuid); fclose(logfp); } } diff --git a/src/map/pc.c b/src/map/pc.c index c7d5b87f0..0ad272d1d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3820,7 +3820,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l } } } - + if( i >= MAX_INVENTORY ) { i = pc_search_inventory(sd,0); @@ -3836,6 +3836,10 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l sd->inventory_data[i] = data; clif_additem(sd,i,amount,0); } +#ifdef NSI_UNIQUE_ID + if( !itemdb_isstackable2(data) && !item_data->nsiuid ) + sd->status.inventory[i].nsiuid = itemdb_nsiuid(0,0); +#endif log_pick_pc(sd, log_type, amount, &sd->status.inventory[i]); sd->weight += w; |