summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/itemdb.c42
-rw-r--r--src/map/itemdb.h3
-rw-r--r--src/map/pc.c6
3 files changed, 7 insertions, 44 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index bfcc6f795..abe899412 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1966,44 +1966,10 @@ int itemdb_readdb_sql(const char *tablename) {
/*==========================================
* 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_unique_id(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(map->mysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db))
- Sql_ShowDebug(map->mysql_handle);
+uint64 itemdb_unique_id(struct map_session_data *sd) {
- if( SQL_SUCCESS != SQL->NextRow(map->mysql_handle) ) {
- ShowError("itemdb_uid_load: Unable to fetch unique_id data\n");
- SQL->FreeResult(map->mysql_handle);
- return -1;
- }
-
- SQL->GetData(map->mysql_handle, 0, &uid, NULL);
- itemdb->unique_id(1, (uint64)strtoull(uid, NULL, 10));
- SQL->FreeResult(map->mysql_handle);
-
- return 0;
+ return ((uint64)sd->status.char_id << 32) | sd->status.uniqueitem_counter++;
}
/**
@@ -2057,8 +2023,7 @@ void itemdb_read(bool minimal) {
sv->readdb(map->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack);
sv->readdb(map->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore);
sv->readdb(map->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse);
-
- itemdb->uid_load();
+
}
/**
@@ -2348,7 +2313,6 @@ void itemdb_defaults(void) {
itemdb->readdb_libconfig = itemdb_readdb_libconfig;
itemdb->readdb_sql = itemdb_readdb_sql;
itemdb->unique_id = itemdb_unique_id;
- itemdb->uid_load = itemdb_uid_load;
itemdb->read = itemdb_read;
itemdb->destroy_item_data = destroy_item_data;
itemdb->final_sub = itemdb_final_sub;
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index eebcd5d4d..77fb2e2ec 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -576,8 +576,7 @@ struct itemdb_interface {
int (*readdb_libconfig_sub) (config_setting_t *it, int n, const char *source);
int (*readdb_libconfig) (const char *filename);
int (*readdb_sql) (const char *tablename);
- uint64 (*unique_id) (int8 flag, int64 value);
- int (*uid_load) ();
+ uint64 (*unique_id) (struct map_session_data *sd);
void (*read) (bool minimal);
void (*destroy_item_data) (struct item_data *self, int free_self);
int (*final_sub) (DBKey key, DBData *data, va_list ap);
diff --git a/src/map/pc.c b/src/map/pc.c
index c6bab4cfc..ba66bf7db 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3992,10 +3992,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->unique_id )
- sd->status.inventory[i].unique_id = itemdb->unique_id(0,0);
-#endif
+ sd->status.inventory[i].unique_id = itemdb->unique_id(sd);
+
logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]);
sd->weight += w;