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/itemdb.c | |
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/itemdb.c')
-rw-r--r-- | src/map/itemdb.c | 49 |
1 files changed, 48 insertions, 1 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(); } /*========================================== |