summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-02-20 03:00:09 +0100
committerHaru <haru@dotalux.com>2016-03-20 18:32:07 +0100
commit13dcf1e6c32b672e72f70a6cdbb42b4c3a2df3d8 (patch)
tree28d87e3e5219d5beb5e2dcf0f714e27184818940
parent68c5122499f0cc2f4ce224c1ac82b6ec47d6abbe (diff)
downloadhercules-13dcf1e6c32b672e72f70a6cdbb42b4c3a2df3d8.tar.gz
hercules-13dcf1e6c32b672e72f70a6cdbb42b4c3a2df3d8.tar.bz2
hercules-13dcf1e6c32b672e72f70a6cdbb42b4c3a2df3d8.tar.xz
hercules-13dcf1e6c32b672e72f70a6cdbb42b4c3a2df3d8.zip
Dropped typedefs from union DBKey and struct DBData
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--src/char/char.c12
-rw-r--r--src/char/char.h12
-rw-r--r--src/char/int_guild.c4
-rw-r--r--src/char/int_guild.h2
-rw-r--r--src/char/inter.c2
-rw-r--r--src/char/inter.h2
-rw-r--r--src/common/db.c190
-rw-r--r--src/common/db.h118
-rw-r--r--src/login/login.c6
-rw-r--r--src/login/login.h6
-rw-r--r--src/map/atcommand.c11
-rw-r--r--src/map/atcommand.h2
-rw-r--r--src/map/battleground.c6
-rw-r--r--src/map/battleground.h4
-rw-r--r--src/map/chrif.c9
-rw-r--r--src/map/chrif.h6
-rw-r--r--src/map/guild.c24
-rw-r--r--src/map/guild.h16
-rw-r--r--src/map/intif.c4
-rw-r--r--src/map/itemdb.c12
-rw-r--r--src/map/itemdb.h6
-rw-r--r--src/map/map.c16
-rw-r--r--src/map/map.h12
-rw-r--r--src/map/mapreg.h2
-rw-r--r--src/map/mapreg_sql.c3
-rw-r--r--src/map/npc.c16
-rw-r--r--src/map/npc.h10
-rw-r--r--src/map/party.c3
-rw-r--r--src/map/party.h2
-rw-r--r--src/map/pc.c9
-rw-r--r--src/map/pc.h5
-rw-r--r--src/map/pc_groups.c2
-rw-r--r--src/map/script.c11
-rw-r--r--src/map/script.h8
-rw-r--r--src/map/skill.c3
-rw-r--r--src/map/skill.h2
-rw-r--r--src/map/storage.c4
-rw-r--r--src/map/storage.h4
38 files changed, 293 insertions, 273 deletions
diff --git a/src/char/char.c b/src/char/char.c
index df59eafc9..01262fdcb 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -171,7 +171,7 @@ static DBMap* auth_db; // int account_id -> struct char_auth_node*
/**
* @see DBCreateData
*/
-static DBData char_create_online_char_data(DBKey key, va_list args)
+static struct DBData char_create_online_char_data(union DBKey key, va_list args)
{
struct online_char_data* character;
CREATE(character, struct online_char_data, 1);
@@ -313,7 +313,7 @@ void char_set_char_offline(int char_id, int account_id)
/**
* @see DBApply
*/
-static int char_db_setoffline(DBKey key, DBData *data, va_list ap)
+static int char_db_setoffline(union DBKey key, struct DBData *data, va_list ap)
{
struct online_char_data* character = (struct online_char_data*)DB->data2ptr(data);
int server_id = va_arg(ap, int);
@@ -333,7 +333,7 @@ static int char_db_setoffline(DBKey key, DBData *data, va_list ap)
/**
* @see DBApply
*/
-static int char_db_kickoffline(DBKey key, DBData *data, va_list ap)
+static int char_db_kickoffline(union DBKey key, struct DBData *data, va_list ap)
{
struct online_char_data* character = (struct online_char_data*)DB->data2ptr(data);
int server_id = va_arg(ap, int);
@@ -388,7 +388,7 @@ void char_set_all_offline_sql(void)
/**
* @see DBCreateData
*/
-static DBData char_create_charstatus(DBKey key, va_list args)
+static struct DBData char_create_charstatus(union DBKey key, va_list args)
{
struct mmo_charstatus *cp;
cp = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus));
@@ -5249,7 +5249,7 @@ int char_broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
* Load this character's account id into the 'online accounts' packet
* @see DBApply
*/
-static int char_send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap)
+static int char_send_accounts_tologin_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct online_char_data* character = DB->data2ptr(data);
int* i = va_arg(ap, int*);
@@ -5318,7 +5318,7 @@ static int char_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) {
/**
* @see DBApply
*/
-static int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
+static int char_online_data_cleanup_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct online_char_data *character= DB->data2ptr(data);
nullpo_ret(character);
diff --git a/src/char/char.h b/src/char/char.h
index aedc52fbe..4fe602c45 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -115,18 +115,18 @@ struct char_interface {
int (*waiting_disconnect) (int tid, int64 tick, int id, intptr_t data);
int (*delete_char_sql) (int char_id);
- DBData (*create_online_char_data) (DBKey key, va_list args);
+ struct DBData (*create_online_char_data) (union DBKey key, va_list args);
void (*set_account_online) (int account_id);
void (*set_account_offline) (int account_id);
void (*set_char_charselect) (int account_id);
void (*set_char_online) (int map_id, int char_id, int account_id);
void (*set_char_offline) (int char_id, int account_id);
- int (*db_setoffline) (DBKey key, DBData *data, va_list ap);
- int (*db_kickoffline) (DBKey key, DBData *data, va_list ap);
+ int (*db_setoffline) (union DBKey key, struct DBData *data, va_list ap);
+ int (*db_kickoffline) (union DBKey key, struct DBData *data, va_list ap);
void (*set_login_all_offline) (void);
void (*set_all_offline) (int id);
void (*set_all_offline_sql) (void);
- DBData (*create_charstatus) (DBKey key, va_list args);
+ struct DBData (*create_charstatus) (union DBKey key, va_list args);
int (*mmo_char_tosql) (int char_id, struct mmo_charstatus* p);
int (*memitemdata_to_sql) (const struct item items[], int max, int id, int tableswitch);
int (*mmo_gender) (const struct char_session_data *sd, const struct mmo_charstatus *p, char sex);
@@ -263,10 +263,10 @@ struct char_interface {
int (*parse_char_unknown_packet) (int fd, uint32 ipl);
int (*parse_char) (int fd);
int (*broadcast_user_count) (int tid, int64 tick, int id, intptr_t data);
- int (*send_accounts_tologin_sub) (DBKey key, DBData *data, va_list ap);
+ int (*send_accounts_tologin_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*send_accounts_tologin) (int tid, int64 tick, int id, intptr_t data);
int (*check_connect_login_server) (int tid, int64 tick, int id, intptr_t data);
- int (*online_data_cleanup_sub) (DBKey key, DBData *data, va_list ap);
+ int (*online_data_cleanup_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*online_data_cleanup) (int tid, int64 tick, int id, intptr_t data);
void (*sql_config_read) (const char* cfgName);
void (*config_dispatch) (char *w1, char *w2);
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index ab15d5ef9..c269a8f6f 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -60,7 +60,7 @@ int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
static int last_id = 0; //To know in which guild we were.
int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving.
DBIterator *iter = db_iterator(inter_guild->guild_db);
- DBKey key;
+ union DBKey key;
struct guild* g;
if( last_id == 0 ) //Save the first guild in the list.
@@ -749,7 +749,7 @@ int inter_guild_sql_init(void)
/**
* @see DBApply
*/
-int inter_guild_db_final(DBKey key, DBData *data, va_list ap)
+int inter_guild_db_final(union DBKey key, struct DBData *data, va_list ap)
{
struct guild *g = DB->data2ptr(data);
nullpo_ret(g);
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index 40728c3b2..31c334cbf 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -58,7 +58,7 @@ struct inter_guild_interface {
int (*CharOnline) (int char_id, int guild_id);
int (*CharOffline) (int char_id, int guild_id);
int (*sql_init) (void);
- int (*db_final) (DBKey key, DBData *data, va_list ap);
+ int (*db_final) (union DBKey key, struct DBData *data, va_list ap);
void (*sql_final) (void);
int (*search_guildname) (const char *str);
bool (*check_empty) (struct guild *g);
diff --git a/src/char/inter.c b/src/char/inter.c
index 4e1adbe15..cf648c238 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -1038,7 +1038,7 @@ int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason)
* Existence check of WISP data
* @see DBApply
*/
-int inter_check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
+int inter_check_ttl_wisdata_sub(union DBKey key, struct DBData *data, va_list ap)
{
int64 tick;
struct WisData *wd = DB->data2ptr(data);
diff --git a/src/char/inter.h b/src/char/inter.h
index 84cb6c640..4e8d113ce 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -47,7 +47,7 @@ struct inter_interface {
int (*log) (char* fmt, ...);
int (*init_sql) (const char *file);
int (*mapif_init) (int fd);
- int (*check_ttl_wisdata_sub) (DBKey key, DBData *data, va_list ap);
+ int (*check_ttl_wisdata_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*check_ttl_wisdata) (void);
int (*check_length) (int fd, int length);
int (*parse_frommap) (int fd);
diff --git a/src/common/db.c b/src/common/db.c
index 4b8e16b5d..639d42156 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -161,8 +161,8 @@ typedef struct dbn {
struct dbn *left;
struct dbn *right;
// Node data
- DBKey key;
- DBData data;
+ union DBKey key;
+ struct DBData data;
// Other
enum DBNodeColor color;
unsigned deleted : 1;
@@ -447,7 +447,7 @@ static void db_rotate_right(DBNode *node, DBNode **root)
* @private
* @see #db_rotate_left(DBNode *,DBNode **)
* @see #db_rotate_right(DBNode *,DBNode **)
- * @see #db_obj_put(DBMap*,DBKey,DBData)
+ * @see #db_obj_put()
*/
static void db_rebalance(DBNode *node, DBNode **root)
{
@@ -648,11 +648,11 @@ static void db_rebalance_erase(DBNode *node, DBNode **root)
* @param key Key being tested
* @return not 0 if considered NULL, 0 otherwise
* @private
- * @see #db_obj_get(DBMap*,DBKey)
- * @see #db_obj_put(DBMap*,DBKey,DBData)
- * @see #db_obj_remove(DBMap*,DBKey)
+ * @see #db_obj_get()
+ * @see #db_obj_put()
+ * @see #db_obj_remove()
*/
-static int db_is_key_null(enum DBType type, DBKey key)
+static int db_is_key_null(enum DBType type, union DBKey key)
{
DB_COUNTSTAT(db_is_key_null);
switch (type) {
@@ -673,10 +673,10 @@ static int db_is_key_null(enum DBType type, DBKey key)
* @private
* @see #db_free_add(DBMap_impl*,DBNode *,DBNode **)
* @see #db_free_remove(DBMap_impl*,DBNode *)
- * @see #db_obj_put(DBMap*,DBKey,void *)
- * @see #db_dup_key_free(DBMap_impl*,DBKey)
+ * @see #db_obj_put()
+ * @see #db_dup_key_free()
*/
-static DBKey db_dup_key(DBMap_impl* db, DBKey key)
+static union DBKey db_dup_key(DBMap_impl* db, union DBKey key)
{
char *str;
size_t len;
@@ -702,9 +702,9 @@ static DBKey db_dup_key(DBMap_impl* db, DBKey key)
* @param db Database the key is being used in
* @param key Key to be freed
* @private
- * @see #db_dup_key(DBMap_impl*,DBKey)
+ * @see #db_dup_key()
*/
-static void db_dup_key_free(DBMap_impl* db, DBKey key)
+static void db_dup_key_free(DBMap_impl* db, union DBKey key)
{
DB_COUNTSTAT(db_dup_key_free);
switch (db->type) {
@@ -730,12 +730,12 @@ static void db_dup_key_free(DBMap_impl* db, DBKey key)
* @see DBMap_impl#free_list
* @see DBMap_impl#free_count
* @see DBMap_impl#free_max
- * @see #db_obj_remove(DBMap*,DBKey)
+ * @see #db_obj_remove()
* @see #db_free_remove(DBMap_impl*,DBNode *)
*/
static void db_free_add(DBMap_impl* db, DBNode *node, DBNode **root)
{
- DBKey old_key;
+ union DBKey old_key;
DB_COUNTSTAT(db_free_add);
if (db->free_lock == (unsigned int)~0) {
@@ -779,7 +779,7 @@ static void db_free_add(DBMap_impl* db, DBNode *node, DBNode **root)
* @see #struct db_free
* @see DBMap_impl#free_list
* @see DBMap_impl#free_count
- * @see #db_obj_put(DBMap*,DBKey,DBData)
+ * @see #db_obj_put()
* @see #db_free_add(DBMap_impl*,DBNode**,DBNode*)
*/
static void db_free_remove(DBMap_impl* db, DBNode *node)
@@ -893,7 +893,7 @@ static void db_free_unlock(DBMap_impl* db)
* @see #DBComparator
* @see #db_default_cmp()
*/
-static int db_int_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
+static int db_int_cmp(union DBKey key1, union DBKey key2, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_int_cmp);
@@ -915,7 +915,7 @@ static int db_int_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
* @see #DBComparator
* @see #db_default_cmp()
*/
-static int db_uint_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
+static int db_uint_cmp(union DBKey key1, union DBKey key2, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_uint_cmp);
@@ -936,7 +936,7 @@ static int db_uint_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
* @see #DBComparator
* @see #db_default_cmp()
*/
-static int db_string_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
+static int db_string_cmp(union DBKey key1, union DBKey key2, unsigned short maxlen)
{
DB_COUNTSTAT(db_string_cmp);
return strncmp((const char *)key1.str, (const char *)key2.str, maxlen);
@@ -954,7 +954,7 @@ static int db_string_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
* @see #DBComparator
* @see #db_default_cmp()
*/
-static int db_istring_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
+static int db_istring_cmp(union DBKey key1, union DBKey key2, unsigned short maxlen)
{
DB_COUNTSTAT(db_istring_cmp);
return strncasecmp((const char *)key1.str, (const char *)key2.str, maxlen);
@@ -973,7 +973,7 @@ static int db_istring_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
* @see #DBComparator
* @see #db_default_cmp()
*/
-static int db_int64_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
+static int db_int64_cmp(union DBKey key1, union DBKey key2, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_int64_cmp);
@@ -995,7 +995,7 @@ static int db_int64_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
* @see #DBComparator
* @see #db_default_cmp()
*/
-static int db_uint64_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
+static int db_uint64_cmp(union DBKey key1, union DBKey key2, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_uint64_cmp);
@@ -1016,7 +1016,7 @@ static int db_uint64_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
* @see #DBHasher
* @see #db_default_hash()
*/
-static uint64 db_int_hash(DBKey key, unsigned short maxlen)
+static uint64 db_int_hash(union DBKey key, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_int_hash);
@@ -1034,7 +1034,7 @@ static uint64 db_int_hash(DBKey key, unsigned short maxlen)
* @see #DBHasher
* @see #db_default_hash()
*/
-static uint64 db_uint_hash(DBKey key, unsigned short maxlen)
+static uint64 db_uint_hash(union DBKey key, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_uint_hash);
@@ -1050,7 +1050,7 @@ static uint64 db_uint_hash(DBKey key, unsigned short maxlen)
* @see #DBHasher
* @see #db_default_hash()
*/
-static uint64 db_string_hash(DBKey key, unsigned short maxlen)
+static uint64 db_string_hash(union DBKey key, unsigned short maxlen)
{
const char *k = key.str;
unsigned int hash = 0;
@@ -1076,7 +1076,7 @@ static uint64 db_string_hash(DBKey key, unsigned short maxlen)
* @see enum DBType#DB_ISTRING
* @see #db_default_hash()
*/
-static uint64 db_istring_hash(DBKey key, unsigned short maxlen)
+static uint64 db_istring_hash(union DBKey key, unsigned short maxlen)
{
const char *k = key.str;
unsigned int hash = 0;
@@ -1105,7 +1105,7 @@ static uint64 db_istring_hash(DBKey key, unsigned short maxlen)
* @see #DBHasher
* @see #db_default_hash()
*/
-static uint64 db_int64_hash(DBKey key, unsigned short maxlen)
+static uint64 db_int64_hash(union DBKey key, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_int64_hash);
@@ -1123,7 +1123,7 @@ static uint64 db_int64_hash(DBKey key, unsigned short maxlen)
* @see #DBHasher
* @see #db_default_hash()
*/
-static uint64 db_uint64_hash(DBKey key, unsigned short maxlen)
+static uint64 db_uint64_hash(union DBKey key, unsigned short maxlen)
{
(void)maxlen;//not used
DB_COUNTSTAT(db_uint64_hash);
@@ -1139,7 +1139,7 @@ static uint64 db_uint64_hash(DBKey key, unsigned short maxlen)
* @see #DBReleaser
* @see #db_default_releaser()
*/
-static void db_release_nothing(DBKey key, DBData data, enum DBReleaseOption which)
+static void db_release_nothing(union DBKey key, struct DBData data, enum DBReleaseOption which)
{
(void)key;(void)data;(void)which;//not used
DB_COUNTSTAT(db_release_nothing);
@@ -1154,7 +1154,7 @@ static void db_release_nothing(DBKey key, DBData data, enum DBReleaseOption whic
* @see #DBReleaser
* @see #db_default_release()
*/
-static void db_release_key(DBKey key, DBData data, enum DBReleaseOption which)
+static void db_release_key(union DBKey key, struct DBData data, enum DBReleaseOption which)
{
(void)data;//not used
DB_COUNTSTAT(db_release_key);
@@ -1167,12 +1167,12 @@ static void db_release_key(DBKey key, DBData data, enum DBReleaseOption which)
* @param data Data of the database entry
* @param which What is being requested to be released
* @protected
- * @see #DBData
+ * @see struct DBData
* @see enum DBReleaseOption
* @see #DBReleaser
* @see #db_default_release()
*/
-static void db_release_data(DBKey key, DBData data, enum DBReleaseOption which)
+static void db_release_data(union DBKey key, struct DBData data, enum DBReleaseOption which)
{
(void)key;//not used
DB_COUNTSTAT(db_release_data);
@@ -1188,13 +1188,13 @@ static void db_release_data(DBKey key, DBData data, enum DBReleaseOption which)
* @param data Data of the database entry
* @param which What is being requested to be released
* @protected
- * @see #DBKey
- * @see #DBData
+ * @see union DBKey
+ * @see struct DBData
* @see enum DBReleaseOption
* @see #DBReleaser
* @see #db_default_release()
*/
-static void db_release_both(DBKey key, DBData data, enum DBReleaseOption which)
+static void db_release_both(union DBKey key, struct DBData data, enum DBReleaseOption which)
{
DB_COUNTSTAT(db_release_both);
if (which&DB_RELEASE_KEY) aFree((char*)key.str); // needs to be a pointer
@@ -1247,7 +1247,7 @@ static void db_release_both(DBKey key, DBData data, enum DBReleaseOption which)
* @protected
* @see DBIterator#first
*/
-DBData* dbit_obj_first(DBIterator* self, DBKey* out_key)
+struct DBData *dbit_obj_first(DBIterator* self, union DBKey *out_key)
{
DBIterator_impl* it = (DBIterator_impl*)self;
@@ -1269,7 +1269,7 @@ DBData* dbit_obj_first(DBIterator* self, DBKey* out_key)
* @protected
* @see DBIterator#last
*/
-DBData* dbit_obj_last(DBIterator* self, DBKey* out_key)
+struct DBData *dbit_obj_last(DBIterator* self, union DBKey *out_key)
{
DBIterator_impl* it = (DBIterator_impl*)self;
@@ -1291,7 +1291,7 @@ DBData* dbit_obj_last(DBIterator* self, DBKey* out_key)
* @protected
* @see DBIterator#next
*/
-DBData* dbit_obj_next(DBIterator* self, DBKey* out_key)
+struct DBData *dbit_obj_next(DBIterator* self, union DBKey *out_key)
{
DBIterator_impl* it = (DBIterator_impl*)self;
DBNode *node;
@@ -1348,7 +1348,7 @@ DBData* dbit_obj_next(DBIterator* self, DBKey* out_key)
{// found next entry
it->node = node;
if( out_key )
- memcpy(out_key, &node->key, sizeof(DBKey));
+ memcpy(out_key, &node->key, sizeof(union DBKey));
return &node->data;
}
}
@@ -1367,7 +1367,7 @@ DBData* dbit_obj_next(DBIterator* self, DBKey* out_key)
* @protected
* @see DBIterator#prev
*/
-DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key)
+struct DBData *dbit_obj_prev(DBIterator* self, union DBKey *out_key)
{
DBIterator_impl* it = (DBIterator_impl*)self;
DBNode *node;
@@ -1424,7 +1424,7 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key)
{// found previous entry
it->node = node;
if( out_key )
- memcpy(out_key, &node->key, sizeof(DBKey));
+ memcpy(out_key, &node->key, sizeof(union DBKey));
return &node->data;
}
}
@@ -1462,7 +1462,7 @@ bool dbit_obj_exists(DBIterator* self)
* @see DBMap#remove
* @see DBIterator#remove
*/
-int dbit_obj_remove(DBIterator* self, DBData *out_data)
+int dbit_obj_remove(DBIterator* self, struct DBData *out_data)
{
DBIterator_impl* it = (DBIterator_impl*)self;
DBNode *node;
@@ -1477,7 +1477,7 @@ int dbit_obj_remove(DBIterator* self, DBData *out_data)
db->cache = NULL;
db->release(node->key, node->data, DB_RELEASE_DATA);
if( out_data )
- memcpy(out_data, &node->data, sizeof(DBData));
+ memcpy(out_data, &node->data, sizeof(struct DBData));
retval = 1;
db_free_add(db, node, &db->ht[it->ht_index]);
}
@@ -1541,7 +1541,7 @@ static DBIterator* db_obj_iterator(DBMap* self)
* @protected
* @see DBMap#exists
*/
-static bool db_obj_exists(DBMap* self, DBKey key)
+static bool db_obj_exists(DBMap* self, union DBKey key)
{
DBMap_impl* db = (DBMap_impl*)self;
DBNode *node;
@@ -1591,11 +1591,11 @@ static bool db_obj_exists(DBMap* self, DBKey key)
* @protected
* @see DBMap#get
*/
-static DBData* db_obj_get(DBMap* self, DBKey key)
+static struct DBData *db_obj_get(DBMap* self, union DBKey key)
{
DBMap_impl* db = (DBMap_impl*)self;
DBNode *node;
- DBData *data = NULL;
+ struct DBData *data = NULL;
DB_COUNTSTAT(db_get);
if (db == NULL) return NULL; // nullpo candidate
@@ -1650,7 +1650,7 @@ static DBData* db_obj_get(DBMap* self, DBKey key)
* @protected
* @see DBMap#vgetall
*/
-static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max, DBMatcher match, va_list args)
+static unsigned int db_obj_vgetall(DBMap* self, struct DBData **buf, unsigned int max, DBMatcher match, va_list args)
{
DBMap_impl* db = (DBMap_impl*)self;
unsigned int i;
@@ -1722,7 +1722,7 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
* @see DBMap#vgetall
* @see DBMap#getall
*/
-static unsigned int db_obj_getall(DBMap* self, DBData **buf, unsigned int max, DBMatcher match, ...)
+static unsigned int db_obj_getall(DBMap* self, struct DBData **buf, unsigned int max, DBMatcher match, ...)
{
va_list args;
unsigned int ret;
@@ -1748,14 +1748,14 @@ static unsigned int db_obj_getall(DBMap* self, DBData **buf, unsigned int max, D
* @protected
* @see DBMap#vensure
*/
-static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_list args)
+static struct DBData *db_obj_vensure(DBMap* self, union DBKey key, DBCreateData create, va_list args)
{
DBMap_impl* db = (DBMap_impl*)self;
DBNode *node;
DBNode *parent = NULL;
unsigned int hash;
int c = 0;
- DBData *data = NULL;
+ struct DBData *data = NULL;
DB_COUNTSTAT(db_vensure);
if (db == NULL) return NULL; // nullpo candidate
@@ -1848,10 +1848,10 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li
* @see DBMap#vensure
* @see DBMap#ensure
*/
-static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...)
+static struct DBData *db_obj_ensure(DBMap* self, union DBKey key, DBCreateData create, ...)
{
va_list args;
- DBData *ret = NULL;
+ struct DBData *ret = NULL;
DB_COUNTSTAT(db_ensure);
if (self == NULL) return NULL; // nullpo candidate
@@ -1877,7 +1877,7 @@ static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...)
* FIXME: If this method fails shouldn't it return another value?
* Other functions rely on this to know if they were able to put something [Panikon]
*/
-static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
+static int db_obj_put(DBMap* self, union DBKey key, struct DBData data, struct DBData *out_data)
{
DBMap_impl* db = (DBMap_impl*)self;
DBNode *node;
@@ -1982,7 +1982,7 @@ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
* @see #db_free_add(DBMap_impl*,DBNode*,DBNode **)
* @see DBMap#remove
*/
-static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
+static int db_obj_remove(DBMap* self, union DBKey key, struct DBData *out_data)
{
DBMap_impl* db = (DBMap_impl*)self;
DBNode *node;
@@ -2372,17 +2372,17 @@ static enum DBOptions db_obj_options(DBMap* self)
* db_default_release - Get the default releaser for a type of database with the specified options.
* db_custom_release - Get a releaser that behaves a certain way.
* db_alloc - Allocate a new database.
- * db_i2key - Manual cast from 'int' to 'DBKey'.
- * db_ui2key - Manual cast from 'unsigned int' to 'DBKey'.
- * db_str2key - Manual cast from 'unsigned char *' to 'DBKey'.
- * db_i642key - Manual cast from 'int64' to 'DBKey'.
- * db_ui642key - Manual cast from 'uin64' to 'DBKey'.
- * db_i2data - Manual cast from 'int' to 'DBData'.
- * db_ui2data - Manual cast from 'unsigned int' to 'DBData'.
- * db_ptr2data - Manual cast from 'void*' to 'DBData'.
- * db_data2i - Gets 'int' value from 'DBData'.
- * db_data2ui - Gets 'unsigned int' value from 'DBData'.
- * db_data2ptr - Gets 'void*' value from 'DBData'.
+ * db_i2key - Manual cast from `int` to `union DBKey`.
+ * db_ui2key - Manual cast from `unsigned int` to `union DBKey`.
+ * db_str2key - Manual cast from `unsigned char *` to `union DBKey`.
+ * db_i642key - Manual cast from `int64` to `union DBKey`.
+ * db_ui642key - Manual cast from `uin64` to `union DBKey`.
+ * db_i2data - Manual cast from `int` to `struct DBData`.
+ * db_ui2data - Manual cast from `unsigned int` to `struct DBData`.
+ * db_ptr2data - Manual cast from `void*` to `struct DBData`.
+ * db_data2i - Gets `int` value from `struct DBData`.
+ * db_data2ui - Gets `unsigned int` value from `struct DBData`.
+ * db_data2ptr - Gets `void*` value from `struct DBData`.
* db_init - Initializes the database system.
* db_final - Finalizes the database system.
\*****************************************************************************/
@@ -2421,12 +2421,12 @@ enum DBOptions db_fix_options(enum DBType type, enum DBOptions options)
* @param type Type of database
* @return Comparator for the type of database or NULL if unknown database
* @public
- * @see #db_int_cmp(DBKey,DBKey,unsigned short)
- * @see #db_uint_cmp(DBKey,DBKey,unsigned short)
- * @see #db_string_cmp(DBKey,DBKey,unsigned short)
- * @see #db_istring_cmp(DBKey,DBKey,unsigned short)
- * @see #db_int64_cmp(DBKey,DBKey,unsigned short)
- * @see #db_uint64_cmp(DBKey,DBKey,unsigned short)
+ * @see #db_int_cmp()
+ * @see #db_uint_cmp()
+ * @see #db_string_cmp()
+ * @see #db_istring_cmp()
+ * @see #db_int64_cmp()
+ * @see #db_uint64_cmp()
*/
DBComparator db_default_cmp(enum DBType type)
{
@@ -2449,12 +2449,12 @@ DBComparator db_default_cmp(enum DBType type)
* @param type Type of database
* @return Hasher of the type of database or NULL if unknown database
* @public
- * @see #db_int_hash(DBKey,unsigned short)
- * @see #db_uint_hash(DBKey,unsigned short)
- * @see #db_string_hash(DBKey,unsigned short)
- * @see #db_istring_hash(DBKey,unsigned short)
- * @see #db_int64_hash(DBKey,unsigned short)
- * @see #db_uint64_hash(DBKey,unsigned short)
+ * @see #db_int_hash()
+ * @see #db_uint_hash()
+ * @see #db_string_hash()
+ * @see #db_istring_hash()
+ * @see #db_int64_hash()
+ * @see #db_uint64_hash()
*/
DBHasher db_default_hash(enum DBType type)
{
@@ -2619,9 +2619,9 @@ DBMap* db_alloc(const char *file, const char *func, int line, enum DBType type,
* @return The key as a DBKey union
* @public
*/
-DBKey db_i2key(int key)
+union DBKey db_i2key(int key)
{
- DBKey ret;
+ union DBKey ret;
DB_COUNTSTAT(db_i2key);
ret.i = key;
@@ -2634,9 +2634,9 @@ DBKey db_i2key(int key)
* @return The key as a DBKey union
* @public
*/
-DBKey db_ui2key(unsigned int key)
+union DBKey db_ui2key(unsigned int key)
{
- DBKey ret;
+ union DBKey ret;
DB_COUNTSTAT(db_ui2key);
ret.ui = key;
@@ -2649,9 +2649,9 @@ DBKey db_ui2key(unsigned int key)
* @return The key as a DBKey union
* @public
*/
-DBKey db_str2key(const char *key)
+union DBKey db_str2key(const char *key)
{
- DBKey ret;
+ union DBKey ret;
DB_COUNTSTAT(db_str2key);
ret.str = key;
@@ -2664,9 +2664,9 @@ DBKey db_str2key(const char *key)
* @return The key as a DBKey union
* @public
*/
-DBKey db_i642key(int64 key)
+union DBKey db_i642key(int64 key)
{
- DBKey ret;
+ union DBKey ret;
DB_COUNTSTAT(db_i642key);
ret.i64 = key;
@@ -2679,9 +2679,9 @@ DBKey db_i642key(int64 key)
* @return The key as a DBKey union
* @public
*/
-DBKey db_ui642key(uint64 key)
+union DBKey db_ui642key(uint64 key)
{
- DBKey ret;
+ union DBKey ret;
DB_COUNTSTAT(db_ui642key);
ret.ui64 = key;
@@ -2694,9 +2694,9 @@ DBKey db_ui642key(uint64 key)
* @return The data as a DBData struct
* @public
*/
-DBData db_i2data(int data)
+struct DBData db_i2data(int data)
{
- DBData ret;
+ struct DBData ret;
DB_COUNTSTAT(db_i2data);
ret.type = DB_DATA_INT;
@@ -2710,9 +2710,9 @@ DBData db_i2data(int data)
* @return The data as a DBData struct
* @public
*/
-DBData db_ui2data(unsigned int data)
+struct DBData db_ui2data(unsigned int data)
{
- DBData ret;
+ struct DBData ret;
DB_COUNTSTAT(db_ui2data);
ret.type = DB_DATA_UINT;
@@ -2726,9 +2726,9 @@ DBData db_ui2data(unsigned int data)
* @return The data as a DBData struct
* @public
*/
-DBData db_ptr2data(void *data)
+struct DBData db_ptr2data(void *data)
{
- DBData ret;
+ struct DBData ret;
DB_COUNTSTAT(db_ptr2data);
ret.type = DB_DATA_PTR;
@@ -2743,7 +2743,7 @@ DBData db_ptr2data(void *data)
* @return Integer value of the data.
* @public
*/
-int db_data2i(DBData *data)
+int db_data2i(struct DBData *data)
{
DB_COUNTSTAT(db_data2i);
if (data && DB_DATA_INT == data->type)
@@ -2758,7 +2758,7 @@ int db_data2i(DBData *data)
* @return Unsigned int value of the data.
* @public
*/
-unsigned int db_data2ui(DBData *data)
+unsigned int db_data2ui(struct DBData *data)
{
DB_COUNTSTAT(db_data2ui);
if (data && DB_DATA_UINT == data->type)
@@ -2773,7 +2773,7 @@ unsigned int db_data2ui(DBData *data)
* @return Void* value of the data.
* @public
*/
-void* db_data2ptr(DBData *data)
+void *db_data2ptr(struct DBData *data)
{
DB_COUNTSTAT(db_data2ptr);
if (data && DB_DATA_PTR == data->type)
diff --git a/src/common/db.h b/src/common/db.h
index 02f917923..1c2da3917 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -43,8 +43,7 @@
* 2007/11/09 - Added an iterator to the database. *
* 2.1 (Athena build #???#) - Portability fix *
* - Fixed the portability of casting to union and added the functions *
- * {@link DBMap#ensure(DBMap,DBKey,DBCreateData,...)} and *
- * {@link DBMap#clear(DBMap,DBApply,...)}. *
+ * DBMap#ensure() and {@link DBMap#clear(DBMap,DBApply,...)}. *
* 2.0 (Athena build 4859) - Transition version *
* - Almost everything recoded with a strategy similar to objects, *
* database structure is maintained. *
@@ -69,9 +68,9 @@
* enum DBReleaseOption - Enumeration of release options. *
* enum DBType - Enumeration of database types. *
* enum DBOptions - Bitfield enumeration of database options. *
- * DBKey - Union of used key types. *
+ * union DBKey - Union of used key types. *
* enum DBDataType - Enumeration of data types. *
- * DBData - Struct for used data types. *
+ * struct DBData - Struct for used data types. *
* DBApply - Format of functions applied to the databases. *
* DBMatcher - Format of matchers used in DBMap::getall. *
* DBComparator - Format of the comparators used by the databases. *
@@ -108,7 +107,7 @@ enum DBReleaseOption {
* @param DB_UINT64 Uses uint64's for keys
* @public
* @see enum DBOptions
- * @see #DBKey
+ * @see union DBKey
* @see #db_fix_options()
* @see #db_default_cmp()
* @see #db_default_hash()
@@ -167,13 +166,13 @@ enum DBOptions {
* @see DBMap#put
* @see DBMap#remove
*/
-typedef union DBKey {
+union DBKey {
int i;
unsigned int ui;
const char *str;
int64 i64;
uint64 ui64;
-} DBKey;
+};
/**
* Supported types of database data.
@@ -181,7 +180,7 @@ typedef union DBKey {
* @param DB_DATA_UINT Uses unsigned ints for data.
* @param DB_DATA_PTR Uses void pointers for data.
* @public
- * @see #DBData
+ * @see struct DBData
*/
enum DBDataType {
DB_DATA_INT,
@@ -198,14 +197,14 @@ enum DBDataType {
* @param u.ptr Data of void* type
* @public
*/
-typedef struct DBData {
+struct DBData {
enum DBDataType type;
union {
int i;
unsigned int ui;
void *ptr;
} u;
-} DBData;
+};
/**
* Format of functions that create the data for the key when the entry doesn't
@@ -217,7 +216,7 @@ typedef struct DBData {
* @see DBMap#vensure
* @see DBMap#ensure
*/
-typedef DBData (*DBCreateData)(DBKey key, va_list args);
+typedef struct DBData (*DBCreateData)(union DBKey key, va_list args);
/**
* Format of functions to be applied to an unspecified quantity of entries of
@@ -234,7 +233,7 @@ typedef DBData (*DBCreateData)(DBKey key, va_list args);
* @see DBMap#vdestroy
* @see DBMap#destroy
*/
-typedef int (*DBApply)(DBKey key, DBData *data, va_list args);
+typedef int (*DBApply)(union DBKey key, struct DBData *data, va_list args);
/**
* Format of functions that match database entries.
@@ -247,7 +246,7 @@ typedef int (*DBApply)(DBKey key, DBData *data, va_list args);
* @public
* @see DBMap#getall
*/
-typedef int (*DBMatcher)(DBKey key, DBData data, va_list args);
+typedef int (*DBMatcher)(union DBKey key, struct DBData data, va_list args);
/**
* Format of the comparators used internally by the database system.
@@ -261,7 +260,7 @@ typedef int (*DBMatcher)(DBKey key, DBData data, va_list args);
* @public
* @see #db_default_cmp()
*/
-typedef int (*DBComparator)(DBKey key1, DBKey key2, unsigned short maxlen);
+typedef int (*DBComparator)(union DBKey key1, union DBKey key2, unsigned short maxlen);
/**
* Format of the hashers used internally by the database system.
@@ -273,7 +272,7 @@ typedef int (*DBComparator)(DBKey key1, DBKey key2, unsigned short maxlen);
* @public
* @see #db_default_hash()
*/
-typedef uint64 (*DBHasher)(DBKey key, unsigned short maxlen);
+typedef uint64 (*DBHasher)(union DBKey key, unsigned short maxlen);
/**
* Format of the releaser used by the database system.
@@ -287,7 +286,7 @@ typedef uint64 (*DBHasher)(DBKey key, unsigned short maxlen);
* @see #db_default_releaser()
* @see #db_custom_release()
*/
-typedef void (*DBReleaser)(DBKey key, DBData data, enum DBReleaseOption which);
+typedef void (*DBReleaser)(union DBKey key, struct DBData data, enum DBReleaseOption which);
typedef struct DBIterator DBIterator;
typedef struct DBMap DBMap;
@@ -313,7 +312,7 @@ struct DBIterator
* @return Data of the entry
* @protected
*/
- DBData* (*first)(DBIterator* self, DBKey* out_key);
+ struct DBData *(*first)(DBIterator* self, union DBKey *out_key);
/**
* Fetches the last entry in the database.
@@ -324,7 +323,7 @@ struct DBIterator
* @return Data of the entry
* @protected
*/
- DBData* (*last)(DBIterator* self, DBKey* out_key);
+ struct DBData *(*last)(DBIterator* self, union DBKey *out_key);
/**
* Fetches the next entry in the database.
@@ -335,7 +334,7 @@ struct DBIterator
* @return Data of the entry
* @protected
*/
- DBData* (*next)(DBIterator* self, DBKey* out_key);
+ struct DBData *(*next)(DBIterator* self, union DBKey *out_key);
/**
* Fetches the previous entry in the database.
@@ -346,7 +345,7 @@ struct DBIterator
* @return Data of the entry
* @protected
*/
- DBData* (*prev)(DBIterator* self, DBKey* out_key);
+ struct DBData *(*prev)(DBIterator* self, union DBKey *out_key);
/**
* Returns true if the fetched entry exists.
@@ -369,7 +368,7 @@ struct DBIterator
* @protected
* @see DBMap#remove
*/
- int (*remove)(DBIterator* self, DBData *out_data);
+ int (*remove)(DBIterator* self, struct DBData *out_data);
/**
* Destroys this iterator and unlocks the database.
@@ -406,7 +405,7 @@ struct DBMap {
* @return true is the entry exists
* @protected
*/
- bool (*exists)(DBMap* self, DBKey key);
+ bool (*exists)(DBMap* self, union DBKey key);
/**
* Get the data of the entry identified by the key.
@@ -415,7 +414,7 @@ struct DBMap {
* @return Data of the entry or NULL if not found
* @protected
*/
- DBData* (*get)(DBMap* self, DBKey key);
+ struct DBData *(*get)(DBMap* self, union DBKey key);
/**
* Just calls {@link DBMap#vgetall}.
@@ -434,7 +433,7 @@ struct DBMap {
* @protected
* @see DBMap#vgetall(DBMap*,void **,unsigned int,DBMatcher,va_list)
*/
- unsigned int (*getall)(DBMap* self, DBData** buf, unsigned int max, DBMatcher match, ...);
+ unsigned int (*getall)(DBMap* self, struct DBData **buf, unsigned int max, DBMatcher match, ...);
/**
* Get the data of the entries matched by <code>match</code>.
@@ -452,22 +451,23 @@ struct DBMap {
* @protected
* @see DBMap#getall(DBMap*,void **,unsigned int,DBMatcher,...)
*/
- unsigned int (*vgetall)(DBMap* self, DBData** buf, unsigned int max, DBMatcher match, va_list args);
+ unsigned int (*vgetall)(DBMap* self, struct DBData **buf, unsigned int max, DBMatcher match, va_list args);
/**
- * Just calls {@link DBMap#vensure}.
- * Get the data of the entry identified by the key.
- * If the entry does not exist, an entry is added with the data returned by
- * <code>create</code>.
+ * Just calls DBMap#vensure.
+ *
+ * Get the data of the entry identified by the key. If the entry does
+ * not exist, an entry is added with the data returned by `create`.
+ *
* @param self Database
* @param key Key that identifies the entry
* @param create Function used to create the data if the entry doesn't exist
* @param ... Extra arguments for create
* @return Data of the entry
* @protected
- * @see DBMap#vensure(DBMap*,DBKey,DBCreateData,va_list)
+ * @see DBMap#vensure()
*/
- DBData* (*ensure)(DBMap* self, DBKey key, DBCreateData create, ...);
+ struct DBData *(*ensure)(DBMap* self, union DBKey key, DBCreateData create, ...);
/**
* Get the data of the entry identified by the key.
@@ -479,9 +479,9 @@ struct DBMap {
* @param args Extra arguments for create
* @return Data of the entry
* @protected
- * @see DBMap#ensure(DBMap*,DBKey,DBCreateData,...)
+ * @see DBMap#ensure()
*/
- DBData* (*vensure)(DBMap* self, DBKey key, DBCreateData create, va_list args);
+ struct DBData *(*vensure)(DBMap* self, union DBKey key, DBCreateData create, va_list args);
/**
* Put the data identified by the key in the database.
@@ -494,7 +494,7 @@ struct DBMap {
* @return 1 if if the entry already exists, 0 otherwise
* @protected
*/
- int (*put)(DBMap* self, DBKey key, DBData data, DBData *out_data);
+ int (*put)(DBMap* self, union DBKey key, struct DBData data, struct DBData *out_data);
/**
* Remove an entry from the database.
@@ -506,7 +506,7 @@ struct DBMap {
* @return 1 if if the entry already exists, 0 otherwise
* @protected
*/
- int (*remove)(DBMap* self, DBKey key, DBData *out_data);
+ int (*remove)(DBMap* self, union DBKey key, struct DBData *out_data);
/**
* Just calls {@link DBMap#vforeach}.
@@ -714,7 +714,7 @@ struct DBMap {
#define dbi_exists(dbi) ( (dbi)->exists(dbi) )
#define dbi_destroy(dbi) ( (dbi)->destroy(dbi) )
-/*****************************************************************************\
+/*****************************************************************************
* (2) Section with public functions. *
* db_fix_options - Fix the options for a type of database. *
* db_default_cmp - Get the default comparator for a type of database. *
@@ -723,20 +723,20 @@ struct DBMap {
* with the fixed options. *
* db_custom_release - Get the releaser that behaves as specified. *
* db_alloc - Allocate a new database. *
- * db_i2key - Manual cast from 'int' to 'DBKey'. *
- * db_ui2key - Manual cast from 'unsigned int' to 'DBKey'. *
- * db_str2key - Manual cast from 'unsigned char *' to 'DBKey'. *
- * db_i642key - Manual cast from 'int64' to 'DBKey'. *
- * db_ui642key - Manual cast from 'uint64' to 'DBKey'. *
- * db_i2data - Manual cast from 'int' to 'DBData'. *
- * db_ui2data - Manual cast from 'unsigned int' to 'DBData'. *
- * db_ptr2data - Manual cast from 'void*' to 'DBData'. *
- * db_data2i - Gets 'int' value from 'DBData'. *
- * db_data2ui - Gets 'unsigned int' value from 'DBData'. *
- * db_data2ptr - Gets 'void*' value from 'DBData'. *
+ * db_i2key - Manual cast from `int` to `union DBKey`. *
+ * db_ui2key - Manual cast from `unsigned int` to `union DBKey`. *
+ * db_str2key - Manual cast from `unsigned char *` to `union DBKey`.*
+ * db_i642key - Manual cast from `int64` to `union DBKey`. *
+ * db_ui642key - Manual cast from `uint64` to `union DBKey`. *
+ * db_i2data - Manual cast from `int` to `struct DBData`. *
+ * db_ui2data - Manual cast from `unsigned int` to `struct DBData`. *
+ * db_ptr2data - Manual cast from `void*` to `struct DBData`. *
+ * db_data2i - Gets `int` value from `struct DBData`. *
+ * db_data2ui - Gets `unsigned int` value from `struct DBData`. *
+ * db_data2ptr - Gets `void*` value from `struct DBData`. *
* db_init - Initializes the database system. *
* db_final - Finalizes the database system. *
-\*****************************************************************************/
+ *****************************************************************************/
struct db_interface {
/**
@@ -835,7 +835,7 @@ DBMap* (*alloc) (const char *file, const char *func, int line, enum DBType type,
* @return The key as a DBKey union
* @public
*/
-DBKey (*i2key) (int key);
+union DBKey (*i2key) (int key);
/**
* Manual cast from 'unsigned int' to the union DBKey.
@@ -843,7 +843,7 @@ DBKey (*i2key) (int key);
* @return The key as a DBKey union
* @public
*/
-DBKey (*ui2key) (unsigned int key);
+union DBKey (*ui2key) (unsigned int key);
/**
* Manual cast from 'unsigned char *' to the union DBKey.
@@ -851,7 +851,7 @@ DBKey (*ui2key) (unsigned int key);
* @return The key as a DBKey union
* @public
*/
-DBKey (*str2key) (const char *key);
+union DBKey (*str2key) (const char *key);
/**
* Manual cast from 'int64' to the union DBKey.
@@ -859,7 +859,7 @@ DBKey (*str2key) (const char *key);
* @return The key as a DBKey union
* @public
*/
-DBKey (*i642key) (int64 key);
+union DBKey (*i642key) (int64 key);
/**
* Manual cast from 'uint64' to the union DBKey.
@@ -867,7 +867,7 @@ DBKey (*i642key) (int64 key);
* @return The key as a DBKey union
* @public
*/
-DBKey (*ui642key) (uint64 key);
+union DBKey (*ui642key) (uint64 key);
/**
* Manual cast from 'int' to the struct DBData.
@@ -875,7 +875,7 @@ DBKey (*ui642key) (uint64 key);
* @return The data as a DBData struct
* @public
*/
-DBData (*i2data) (int data);
+struct DBData (*i2data) (int data);
/**
* Manual cast from 'unsigned int' to the struct DBData.
@@ -883,7 +883,7 @@ DBData (*i2data) (int data);
* @return The data as a DBData struct
* @public
*/
-DBData (*ui2data) (unsigned int data);
+struct DBData (*ui2data) (unsigned int data);
/**
* Manual cast from 'void *' to the struct DBData.
@@ -891,7 +891,7 @@ DBData (*ui2data) (unsigned int data);
* @return The data as a DBData struct
* @public
*/
-DBData (*ptr2data) (void *data);
+struct DBData (*ptr2data) (void *data);
/**
* Gets int type data from struct DBData.
@@ -900,7 +900,7 @@ DBData (*ptr2data) (void *data);
* @return Integer value of the data.
* @public
*/
-int (*data2i) (DBData *data);
+int (*data2i) (struct DBData *data);
/**
* Gets unsigned int type data from struct DBData.
@@ -909,7 +909,7 @@ int (*data2i) (DBData *data);
* @return Unsigned int value of the data.
* @public
*/
-unsigned int (*data2ui) (DBData *data);
+unsigned int (*data2ui) (struct DBData *data);
/**
* Gets void* type data from struct DBData.
@@ -918,7 +918,7 @@ unsigned int (*data2ui) (DBData *data);
* @return Void* value of the data.
* @public
*/
-void* (*data2ptr) (DBData *data);
+void* (*data2ptr) (struct DBData *data);
/**
* Initialize the database system.
diff --git a/src/login/login.c b/src/login/login.c
index bd826b300..f7babde86 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -63,7 +63,7 @@ AccountDB* accounts = NULL;
/**
* @see DBCreateData
*/
-static DBData login_create_online_user(DBKey key, va_list args)
+static struct DBData login_create_online_user(union DBKey key, va_list args)
{
struct online_login_data* p;
CREATE(p, struct online_login_data, 1);
@@ -112,7 +112,7 @@ static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t
/**
* @see DBApply
*/
-static int login_online_db_setoffline(DBKey key, DBData *data, va_list ap)
+static int login_online_db_setoffline(union DBKey key, struct DBData *data, va_list ap)
{
struct online_login_data* p = DB->data2ptr(data);
int server_id = va_arg(ap, int);
@@ -134,7 +134,7 @@ static int login_online_db_setoffline(DBKey key, DBData *data, va_list ap)
/**
* @see DBApply
*/
-static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
+static int login_online_data_cleanup_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct online_login_data *character= DB->data2ptr(data);
nullpo_ret(character);
diff --git a/src/login/login.h b/src/login/login.h
index f79f75cb3..81d91eab3 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -158,11 +158,11 @@ struct login_interface {
int (*mmo_auth) (struct login_session_data* sd, bool isServer);
int (*mmo_auth_new) (const char* userid, const char* pass, const char sex, const char* last_ip);
int (*waiting_disconnect_timer) (int tid, int64 tick, int id, intptr_t data);
- DBData (*create_online_user) (DBKey key, va_list args);
+ struct DBData (*create_online_user) (union DBKey key, va_list args);
struct online_login_data* (*add_online_user) (int char_server, int account_id);
void (*remove_online_user) (int account_id);
- int (*online_db_setoffline) (DBKey key, DBData *data, va_list ap);
- int (*online_data_cleanup_sub) (DBKey key, DBData *data, va_list ap);
+ int (*online_db_setoffline) (union DBKey key, struct DBData *data, va_list ap);
+ int (*online_data_cleanup_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*online_data_cleanup) (int tid, int64 tick, int id, intptr_t data);
int (*sync_ip_addresses) (int tid, int64 tick, int id, intptr_t data);
bool (*check_encrypted) (const char* str1, const char* str2, const char* passwd);
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 78d935ddc..fbd8d6517 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5282,8 +5282,8 @@ ACMD(skillid) {
int i, found = 0;
size_t skillen;
DBIterator* iter;
- DBKey key;
- DBData *data;
+ union DBKey key;
+ struct DBData *data;
char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
if (!*message) {
@@ -9057,8 +9057,8 @@ ACMD(channel) {
} else if (strcmpi(subcmd,"banlist") == 0) {
// sub1 = channel name; sub2 = unused; sub3 = unused
DBIterator *iter = NULL;
- DBKey key;
- DBData *data;
+ union DBKey key;
+ struct DBData *data;
bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false;
if (sub1[0] != '#') {
clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
@@ -10222,7 +10222,8 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) {
/**
* @see DBApply
*/
-int atcommand_db_clear_sub(DBKey key, DBData *data, va_list args) {
+int atcommand_db_clear_sub(union DBKey key, struct DBData *data, va_list args)
+{
AtCommandInfo *cmd = DB->data2ptr(data);
aFree(cmd->at_groups);
aFree(cmd->char_groups);
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index a4f9afce7..40db16bbf 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -135,7 +135,7 @@ struct atcommand_interface {
/* */
void (*commands_sub) (struct map_session_data* sd, const int fd, AtCommandType type);
void (*cmd_db_clear) (void);
- int (*cmd_db_clear_sub) (DBKey key, DBData *data, va_list args);
+ int (*cmd_db_clear_sub) (union DBKey key, struct DBData *data, va_list args);
void (*doload) (void);
void (*base_commands) (void);
bool (*add) (char *name, AtCommandFunc func, bool replace);
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 311690ec3..629122c87 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -279,7 +279,8 @@ bool bg_send_message(struct map_session_data *sd, const char *mes, int len) {
/**
* @see DBApply
*/
-int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) {
+int bg_send_xy_timer_sub(union DBKey key, struct DBData *data, va_list ap)
+{
struct battleground_data *bgd = DB->data2ptr(data);
struct map_session_data *sd;
int i;
@@ -925,7 +926,8 @@ void do_init_battleground(bool minimal) {
/**
* @see DBApply
*/
-int bg_team_db_final(DBKey key, DBData *data, va_list ap) {
+int bg_team_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct battleground_data* bgd = DB->data2ptr(data);
HPM->data_store_destroy(&bgd->hdata);
diff --git a/src/map/battleground.h b/src/map/battleground.h
index bb77db125..05458a9b1 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -131,10 +131,10 @@ struct battleground_interface {
int (*create) (unsigned short map_index, short rx, short ry, const char *ev, const char *dev);
int (*team_get_id) (struct block_list *bl);
bool (*send_message) (struct map_session_data *sd, const char *mes, int len);
- int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap);
+ int (*send_xy_timer_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);
int (*afk_timer) (int tid, int64 tick, int id, intptr_t data);
- int (*team_db_final) (DBKey key, DBData *data, va_list ap);
+ int (*team_db_final) (union DBKey key, struct DBData *data, va_list ap);
/* */
enum bg_queue_types (*str2teamtype) (const char *str);
/* */
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 70339c378..52af1137e 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -471,7 +471,8 @@ void chrif_connectack(int fd) {
/**
* @see DBApply
*/
-int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
+int chrif_reconnect(union DBKey key, struct DBData *data, va_list ap)
+{
struct auth_node *node = DB->data2ptr(data);
nullpo_ret(node);
@@ -681,7 +682,8 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
* This can still happen (client times out while waiting for char to confirm auth data)
* @see DBApply
*/
-int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
+int auth_db_cleanup_sub(union DBKey key, struct DBData *data, va_list ap)
+{
struct auth_node *node = DB->data2ptr(data);
nullpo_retr(1, node);
@@ -1617,7 +1619,8 @@ void chrif_del_scdata_single(int account_id, int char_id, short type)
/**
* @see DBApply
*/
-int auth_db_final(DBKey key, DBData *data, va_list ap) {
+int auth_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct auth_node *node = DB->data2ptr(data);
nullpo_ret(node);
diff --git a/src/map/chrif.h b/src/map/chrif.h
index 6a5ec36b6..dc946b1c1 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -133,10 +133,10 @@ struct chrif_interface {
int (*check_connect_char_server) (int tid, int64 tick, int id, intptr_t data);
bool (*auth_logout) (struct map_session_data *sd, enum sd_state state);
void (*save_ack) (int fd);
- int (*reconnect) (DBKey key, DBData *data, va_list ap);
- int (*auth_db_cleanup_sub) (DBKey key, DBData *data, va_list ap);
+ int (*reconnect) (union DBKey key, struct DBData *data, va_list ap);
+ int (*auth_db_cleanup_sub) (union DBKey key, struct DBData *data, va_list ap);
bool (*char_ask_name_answer) (int acc, const char* player_name, uint16 type, uint16 answer);
- int (*auth_db_final) (DBKey key, DBData *data, va_list ap);
+ int (*auth_db_final) (union DBKey key, struct DBData *data, va_list ap);
int (*send_usercount_tochar) (int tid, int64 tick, int id, intptr_t data);
int (*auth_db_cleanup) (int tid, int64 tick, int id, intptr_t data);
diff --git a/src/map/guild.c b/src/map/guild.c
index 13acfc0db..0ceaff518 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -282,7 +282,8 @@ void guild_makemember(struct guild_member *m,struct map_session_data *sd)
* Server cache to be flushed to inter the Guild EXP
* @see DBApply
*/
-int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) {
+int guild_payexp_timer_sub(union DBKey key, struct DBData *data, va_list ap)
+{
int i;
struct guild_expcache *c;
struct guild *g;
@@ -318,7 +319,7 @@ int guild_payexp_timer(int tid, int64 tick, int id, intptr_t data) {
* Taken from party_send_xy_timer_sub. [Skotlex]
* @see DBApply
*/
-int guild_send_xy_timer_sub(DBKey key, DBData *data, va_list ap)
+int guild_send_xy_timer_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct guild *g = DB->data2ptr(data);
int i;
@@ -423,7 +424,7 @@ int guild_npc_request_info(int guild_id,const char *event)
if( event && *event )
{
struct eventlist *ev;
- DBData prev;
+ struct DBData prev;
ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1);
memcpy(ev->name,event,strlen(event));
//The one in the db (if present) becomes the next event from this.
@@ -481,7 +482,7 @@ int guild_recv_info(const struct guild *sg)
{
struct guild *g,before;
int i,bm,m;
- DBData data;
+ struct DBData data;
struct map_session_data *sd;
bool guild_new = false;
struct channel_data *aChSysSave = NULL;
@@ -1262,7 +1263,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
/**
* @see DBCreateData
*/
-DBData create_expcache(DBKey key, va_list args)
+struct DBData create_expcache(union DBKey key, va_list args)
{
struct guild_expcache *c;
struct map_session_data *sd = va_arg(args, struct map_session_data*);
@@ -1720,7 +1721,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
* Notification for the guild disbanded
* @see DBApply
*/
-int guild_broken_sub(DBKey key, DBData *data, va_list ap)
+int guild_broken_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct guild *g = DB->data2ptr(data);
int guild_id=va_arg(ap,int);
@@ -1746,7 +1747,7 @@ int guild_broken_sub(DBKey key, DBData *data, va_list ap)
* Invoked on Castles when a guild is broken. [Skotlex]
* @see DBApply
*/
-int castle_guild_broken_sub(DBKey key, DBData *data, va_list ap)
+int castle_guild_broken_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct guild_castle *gc = DB->data2ptr(data);
int guild_id = va_arg(ap, int);
@@ -2222,7 +2223,8 @@ void guild_flag_remove(struct npc_data *nd) {
/**
* @see DBApply
*/
-int eventlist_db_final(DBKey key, DBData *data, va_list ap) {
+int eventlist_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct eventlist *next = NULL;
struct eventlist *current = DB->data2ptr(data);
while (current != NULL) {
@@ -2236,7 +2238,8 @@ int eventlist_db_final(DBKey key, DBData *data, va_list ap) {
/**
* @see DBApply
*/
-int guild_expcache_db_final(DBKey key, DBData *data, va_list ap) {
+int guild_expcache_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
ers_free(guild->expcache_ers, DB->data2ptr(data));
return 0;
}
@@ -2244,7 +2247,8 @@ int guild_expcache_db_final(DBKey key, DBData *data, va_list ap) {
/**
* @see DBApply
*/
-int guild_castle_db_final(DBKey key, DBData *data, va_list ap) {
+int guild_castle_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct guild_castle* gc = DB->data2ptr(data);
if( gc->temp_guardians )
aFree(gc->temp_guardians);
diff --git a/src/map/guild.h b/src/map/guild.h
index cd796adb3..c0191469b 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -166,15 +166,15 @@ struct guild_interface {
struct map_session_data *(*sd_check) (int guild_id, int account_id, int char_id);
bool (*read_guildskill_tree_db) (char* split[], int columns, int current);
bool (*read_castledb) (char* str[], int columns, int current);
- int (*payexp_timer_sub) (DBKey key, DBData *data, va_list ap);
- int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap);
+ int (*payexp_timer_sub) (union DBKey key, struct DBData *data, va_list ap);
+ int (*send_xy_timer_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);
- DBData (*create_expcache) (DBKey key, va_list args);
- int (*eventlist_db_final) (DBKey key, DBData *data, va_list ap);
- int (*expcache_db_final) (DBKey key, DBData *data, va_list ap);
- int (*castle_db_final) (DBKey key, DBData *data, va_list ap);
- int (*broken_sub) (DBKey key, DBData *data, va_list ap);
- int (*castle_broken_sub) (DBKey key, DBData *data, va_list ap);
+ struct DBData (*create_expcache) (union DBKey key, va_list args);
+ int (*eventlist_db_final) (union DBKey key, struct DBData *data, va_list ap);
+ int (*expcache_db_final) (union DBKey key, struct DBData *data, va_list ap);
+ int (*castle_db_final) (union DBKey key, struct DBData *data, va_list ap);
+ int (*broken_sub) (union DBKey key, struct DBData *data, va_list ap);
+ int (*castle_broken_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*makemember) (struct guild_member *m,struct map_session_data *sd);
int (*check_member) (const struct guild *g);
int (*get_alliance_count) (struct guild *g,int flag);
diff --git a/src/map/intif.c b/src/map/intif.c
index 4b3e913e1..8106c6558 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -302,8 +302,8 @@ int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes)
//Request for saving registry values.
int intif_saveregistry(struct map_session_data *sd) {
DBIterator *iter;
- DBKey key;
- DBData *data;
+ union DBKey key;
+ struct DBData *data;
int plen = 0;
size_t len;
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index ce6232965..38913249b 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -49,7 +49,7 @@ struct itemdb_interface *itemdb;
* name = item alias, so we should find items aliases first. if not found then look for "jname" (full name)
* @see DBApply
*/
-int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap)
+int itemdb_searchname_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct item_data *item = DB->data2ptr(data), **dst, **dst2;
char *str;
@@ -112,7 +112,7 @@ struct item_data* itemdb_name2id(const char *str) {
/**
* @see DBMatcher
*/
-int itemdb_searchname_array_sub(DBKey key, DBData data, va_list ap)
+int itemdb_searchname_array_sub(union DBKey key, struct DBData data, va_list ap)
{
struct item_data *item = DB->data2ptr(&data);
char *str;
@@ -170,10 +170,10 @@ int itemdb_searchname_array(struct item_data** data, int size, const char *str,
// search in the db
if( count < size )
{
- DBData *db_data[MAX_SEARCH];
+ struct DBData *db_data[MAX_SEARCH];
int db_count = 0;
size -= count;
- db_count = itemdb->other->getall(itemdb->other, (DBData**)&db_data, size, itemdb->searchname_array_sub, str);
+ db_count = itemdb->other->getall(itemdb->other, (struct DBData**)&db_data, size, itemdb->searchname_array_sub, str);
for (i = 0; i < db_count; i++)
data[count++] = DB->data2ptr(db_data[i]);
count += db_count;
@@ -2094,7 +2094,7 @@ uint64 itemdb_unique_id(struct map_session_data *sd) {
*/
void itemdb_read(bool minimal) {
int i;
- DBData prev;
+ struct DBData prev;
const char *filename[] = {
DBPATH"item_db.conf",
@@ -2171,7 +2171,7 @@ void destroy_item_data(struct item_data* self, int free_self)
/**
* @see DBApply
*/
-int itemdb_final_sub(DBKey key, DBData *data, va_list ap)
+int itemdb_final_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct item_data *id = DB->data2ptr(data);
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 47446d617..58d19db05 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -612,8 +612,8 @@ struct itemdb_interface {
int (*group_item) (struct item_group *group);
int (*chain_item) (unsigned short chain_id, int *rate);
void (*package_item) (struct map_session_data *sd, struct item_package *package);
- int (*searchname_sub) (DBKey key, DBData *data, va_list ap);
- int (*searchname_array_sub) (DBKey key, DBData data, va_list ap);
+ int (*searchname_sub) (union DBKey key, struct DBData *data, va_list ap);
+ int (*searchname_array_sub) (union DBKey key, struct DBData data, va_list ap);
int (*searchrandomid) (struct item_group *group);
const char* (*typename) (int type);
void (*jobmask2mapid) (uint64 *bclass, uint64 jobmask);
@@ -647,7 +647,7 @@ struct itemdb_interface {
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);
+ int (*final_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*clear) (bool total);
struct item_combo * (*id2combo) (unsigned short id);
bool (*is_item_usable) (struct item_data *item);
diff --git a/src/map/map.c b/src/map/map.c
index a93fb3fd3..1ae094c75 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1658,7 +1658,7 @@ int map_addflooritem(const struct block_list *bl, struct item *item_data, int am
/**
* @see DBCreateData
*/
-DBData create_charid2nick(DBKey key, va_list args)
+struct DBData create_charid2nick(union DBKey key, va_list args)
{
struct charid2nick *p;
CREATE(p, struct charid2nick, 1);
@@ -1695,7 +1695,7 @@ void map_delnickdb(int charid, const char* name)
{
struct charid2nick* p;
struct charid_request* req;
- DBData data;
+ struct DBData data;
if (!map->nick_db->remove(map->nick_db, DB->i2key(charid), &data) || (p = DB->data2ptr(&data)) == NULL)
return;
@@ -3069,7 +3069,7 @@ void map_iwall_remove(const char *wall_name)
/**
* @see DBCreateData
*/
-DBData create_map_data_other_server(DBKey key, va_list args)
+struct DBData create_map_data_other_server(union DBKey key, va_list args)
{
struct map_data_other_server *mdos;
unsigned short map_index = (unsigned short)key.ui;
@@ -3104,7 +3104,7 @@ int map_setipport(unsigned short map_index, uint32 ip, uint16 port)
* Delete all the other maps server management
* @see DBApply
*/
-int map_eraseallipport_sub(DBKey key, DBData *data, va_list va)
+int map_eraseallipport_sub(union DBKey key, struct DBData *data, va_list va)
{
struct map_data_other_server *mdos = DB->data2ptr(data);
if(mdos->cell == NULL) {
@@ -5446,7 +5446,8 @@ bool map_remove_questinfo(int m, struct npc_data *nd) {
/**
* @see DBApply
*/
-int map_db_final(DBKey key, DBData *data, va_list ap) {
+int map_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct map_data_other_server *mdos = DB->data2ptr(data);
if(mdos && iMalloc->verify_ptr(mdos) && mdos->cell == NULL)
@@ -5458,7 +5459,7 @@ int map_db_final(DBKey key, DBData *data, va_list ap) {
/**
* @see DBApply
*/
-int nick_db_final(DBKey key, DBData *data, va_list args)
+int nick_db_final(union DBKey key, struct DBData *data, va_list args)
{
struct charid2nick* p = DB->data2ptr(data);
struct charid_request* req;
@@ -5505,7 +5506,8 @@ int cleanup_sub(struct block_list *bl, va_list ap) {
/**
* @see DBApply
*/
-int cleanup_db_sub(DBKey key, DBData *data, va_list va) {
+int cleanup_db_sub(union DBKey key, struct DBData *data, va_list va)
+{
return map->cleanup_sub(DB->data2ptr(data), va);
}
diff --git a/src/map/map.h b/src/map/map.h
index e61c64f2d..9df2dd586 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1167,7 +1167,7 @@ END_ZEROED_BLOCK;
int (*freeblock_timer) (int tid, int64 tick, int id, intptr_t data);
int (*searchrandfreecell) (int16 m, const struct block_list *bl, int16 *x, int16 *y, int stack);
int (*count_sub) (struct block_list *bl, va_list ap);
- DBData (*create_charid2nick) (DBKey key, va_list args);
+ struct DBData (*create_charid2nick) (union DBKey key, va_list args);
int (*removemobs_sub) (struct block_list *bl, va_list ap);
struct mapcell (*gat2cell) (int gat);
int (*cell2gat) (struct mapcell cell);
@@ -1176,8 +1176,8 @@ END_ZEROED_BLOCK;
int (*sub_getcellp) (struct map_data *m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk);
void (*sub_setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
void (*iwall_nextxy) (int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1);
- DBData (*create_map_data_other_server) (DBKey key, va_list args);
- int (*eraseallipport_sub) (DBKey key, DBData *data, va_list va);
+ struct DBData (*create_map_data_other_server) (union DBKey key, va_list args);
+ int (*eraseallipport_sub) (union DBKey key, struct DBData *data, va_list va);
char* (*init_mapcache) (FILE *fp);
int (*readfromcache) (struct map_data *m, char *buffer);
int (*addmap) (const char *mapname);
@@ -1198,9 +1198,9 @@ END_ZEROED_BLOCK;
unsigned short (*zone_str2skillid) (const char *name);
enum bl_type (*zone_bl_type) (const char *entry, enum map_zone_skill_subtype *subtype);
void (*read_zone_db) (void);
- int (*db_final) (DBKey key, DBData *data, va_list ap);
- int (*nick_db_final) (DBKey key, DBData *data, va_list args);
- int (*cleanup_db_sub) (DBKey key, DBData *data, va_list va);
+ int (*db_final) (union DBKey key, struct DBData *data, va_list ap);
+ int (*nick_db_final) (union DBKey key, struct DBData *data, va_list args);
+ int (*cleanup_db_sub) (union DBKey key, struct DBData *data, va_list va);
int (*abort_sub) (struct map_session_data *sd, va_list ap);
void (*update_cell_bl) (struct block_list *bl, bool increase);
int (*get_new_bonus_id) (void);
diff --git a/src/map/mapreg.h b/src/map/mapreg.h
index dfe1dfb2d..d19b2bb80 100644
--- a/src/map/mapreg.h
+++ b/src/map/mapreg.h
@@ -59,7 +59,7 @@ struct mapreg_interface {
void (*load) (void);
void (*save) (void);
int (*save_timer) (int tid, int64 tick, int id, intptr_t data);
- int (*destroyreg) (DBKey key, DBData *data, va_list ap);
+ int (*destroyreg) (union DBKey key, struct DBData *data, va_list ap);
void (*reload) (void);
bool (*config_read) (const char *w1, const char *w2);
};
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index f3ab36950..d9d8755c2 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -277,7 +277,8 @@ int script_autosave_mapreg(int tid, int64 tick, int id, intptr_t data) {
*
* @see DBApply
*/
-int mapreg_destroyreg(DBKey key, DBData *data, va_list ap) {
+int mapreg_destroyreg(union DBKey key, struct DBData *data, va_list ap)
+{
struct mapreg_save *m = NULL;
if (data->type != DB_DATA_PTR) // Sanity check
diff --git a/src/map/npc.c b/src/map/npc.c
index 7fad5dd7c..68bb81031 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -367,7 +367,7 @@ int npc_event_dequeue(struct map_session_data* sd)
/**
* @see DBCreateData
*/
-DBData npc_event_export_create(DBKey key, va_list args)
+struct DBData npc_event_export_create(union DBKey key, va_list args)
{
struct linkdb_node** head_ptr;
CREATE(head_ptr, struct linkdb_node*, 1);
@@ -2224,7 +2224,7 @@ int npc_remove_map(struct npc_data* nd) {
/**
* @see DBApply
*/
-int npc_unload_ev(DBKey key, DBData *data, va_list ap)
+int npc_unload_ev(union DBKey key, struct DBData *data, va_list ap)
{
struct event_data* ev = DB->data2ptr(data);
char* npcname = va_arg(ap, char *);
@@ -2239,7 +2239,7 @@ int npc_unload_ev(DBKey key, DBData *data, va_list ap)
/**
* @see DBApply
*/
-int npc_unload_ev_label(DBKey key, DBData *data, va_list ap)
+int npc_unload_ev_label(union DBKey key, struct DBData *data, va_list ap)
{
struct linkdb_node **label_linkdb = DB->data2ptr(data);
struct npc_data* nd = va_arg(ap, struct npc_data *);
@@ -3626,7 +3626,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
const char *npc_parse_function(const char *w1, const char *w2, const char *w3, const char *w4, const char *start, const char *buffer, const char *filepath, int *retval)
{
DBMap* func_db;
- DBData old_data;
+ struct DBData old_data;
struct script_code *scriptroot;
const char* end;
const char* script_start;
@@ -4572,8 +4572,8 @@ void npc_read_event_script(void)
for (i = 0; i < NPCE_MAX; i++)
{
DBIterator* iter;
- DBKey key;
- DBData *data;
+ union DBKey key;
+ struct DBData *data;
char name[64]="::";
safestrncpy(name+2,config[i].event_name,62);
@@ -4616,7 +4616,7 @@ void npc_read_event_script(void)
/**
* @see DBApply
*/
-int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args)
+int npc_path_db_clear_sub(union DBKey key, struct DBData *data, va_list args)
{
struct npc_path_data *npd = DB->data2ptr(data);
if (npd->path)
@@ -4627,7 +4627,7 @@ int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args)
/**
* @see DBApply
*/
-int npc_ev_label_db_clear_sub(DBKey key, DBData *data, va_list args)
+int npc_ev_label_db_clear_sub(union DBKey key, struct DBData *data, va_list args)
{
struct linkdb_node **label_linkdb = DB->data2ptr(data);
linkdb_final(label_linkdb); // linked data (struct event_data*) is freed when clearing ev_db
diff --git a/src/map/npc.h b/src/map/npc.h
index 965a34f94..5b4707d00 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -203,7 +203,7 @@ struct npc_interface {
int (*enable) (const char *name, int flag);
struct npc_data* (*name2id) (const char *name);
int (*event_dequeue) (struct map_session_data *sd);
- DBData (*event_export_create) (DBKey key, va_list args);
+ struct DBData (*event_export_create) (union DBKey key, va_list args);
int (*event_export) (struct npc_data *nd, int i);
int (*event_sub) (struct map_session_data *sd, struct event_data *ev, const char *eventname);
void (*event_doall_sub) (void *key, void *data, va_list ap);
@@ -239,8 +239,8 @@ struct npc_interface {
int (*selllist_sub) (struct map_session_data *sd, struct itemlist *item_list, struct npc_data *nd);
int (*selllist) (struct map_session_data *sd, struct itemlist *item_list);
int (*remove_map) (struct npc_data *nd);
- int (*unload_ev) (DBKey key, DBData *data, va_list ap);
- int (*unload_ev_label) (DBKey key, DBData *data, va_list ap);
+ int (*unload_ev) (union DBKey key, struct DBData *data, va_list ap);
+ int (*unload_ev_label) (union DBKey key, struct DBData *data, va_list ap);
int (*unload_dup_sub) (struct npc_data *nd, va_list args);
void (*unload_duplicates) (struct npc_data *nd);
int (*unload) (struct npc_data *nd, bool single);
@@ -282,8 +282,8 @@ struct npc_interface {
int (*parsesrcfile) (const char *filepath, bool runOnInit);
int (*script_event) (struct map_session_data *sd, enum npce_event type);
void (*read_event_script) (void);
- int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args);
- int (*ev_label_db_clear_sub) (DBKey key, DBData *data, va_list args);
+ int (*path_db_clear_sub) (union DBKey key, struct DBData *data, va_list args);
+ int (*ev_label_db_clear_sub) (union DBKey key, struct DBData *data, va_list args);
int (*reload) (void);
bool (*unloadfile) (const char *filepath);
void (*do_clear_npc) (void);
diff --git a/src/map/party.c b/src/map/party.c
index 77f3c2b0b..049c42b1f 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -122,7 +122,8 @@ struct map_session_data *party_sd_check(int party_id, int account_id, int char_i
return sd;
}
-int party_db_final(DBKey key, DBData *data, va_list ap) {
+int party_db_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct party_data *p;
if ((p = DB->data2ptr(data))) {
diff --git a/src/map/party.h b/src/map/party.h
index b66a9770c..750f7d07f 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -145,7 +145,7 @@ struct party_interface {
struct map_session_data *(*sd_check) (int party_id, int account_id, int char_id);
void (*check_state) (struct party_data *p);
struct party_booking_ad_info* (*create_booking_data) (void);
- int (*db_final) (DBKey key, DBData *data, va_list ap);
+ int (*db_final) (union DBKey key, struct DBData *data, va_list ap);
};
#ifdef HERCULES_CORE
diff --git a/src/map/pc.c b/src/map/pc.c
index 4b70a49f3..57b2fe19a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -8991,7 +8991,7 @@ char* pc_readregstr(struct map_session_data* sd, int64 reg) {
void pc_setregstr(struct map_session_data* sd, int64 reg, const char* str) {
struct script_reg_str *p = NULL;
unsigned int index = script_getvaridx(reg);
- DBData prev;
+ struct DBData prev;
if( str[0] ) {
p = ers_alloc(pc->str_reg_ers, struct script_reg_str);
@@ -9114,7 +9114,7 @@ int pc_setregistry(struct map_session_data *sd, int64 reg, int val) {
if( !pc->reg_load )
p->flag.update = 1;/* either way, it will require either delete or replace */
} else if( val ) {
- DBData prev;
+ struct DBData prev;
if( index )
script->array_update(&sd->regs, reg, false);
@@ -9167,7 +9167,7 @@ int pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val)
if( !pc->reg_load )
p->flag.update = 1;/* either way, it will require either delete or replace */
} else if( val[0] ) {
- DBData prev;
+ struct DBData prev;
if( index )
script->array_update(&sd->regs, reg, false);
@@ -11475,7 +11475,8 @@ void pc_autotrade_populate(struct map_session_data *sd) {
/**
* @see DBApply
*/
-int pc_autotrade_final(DBKey key, DBData *data, va_list ap) {
+int pc_autotrade_final(union DBKey key, struct DBData *data, va_list ap)
+{
struct autotrade_vending* at_v = DB->data2ptr(data);
HPM->data_store_destroy(&at_v->hdata);
return 0;
diff --git a/src/map/pc.h b/src/map/pc.h
index 5c5ec131d..728d02734 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -33,8 +33,9 @@
#include "map/status.h" // enum sc_type, OPTION_*
#include "map/unit.h" // struct unit_data, struct view_data
#include "map/vending.h" // struct s_vending
-#include "common/hercules.h"
+#include "common/db.h"
#include "common/ers.h" // struct eri
+#include "common/hercules.h"
#include "common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS
/**
@@ -1084,7 +1085,7 @@ END_ZEROED_BLOCK; /* End */
void (*autotrade_start) (struct map_session_data *sd);
void (*autotrade_prepare) (struct map_session_data *sd);
void (*autotrade_populate) (struct map_session_data *sd);
- int (*autotrade_final) (DBKey key, DBData *data, va_list ap);
+ int (*autotrade_final) (union DBKey key, struct DBData *data, va_list ap);
int (*check_job_name) (const char *name);
void (*update_idle_time) (struct map_session_data* sd, enum e_battle_config_idletime type);
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index b325a8ed7..5b12a45dd 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -465,7 +465,7 @@ void do_init_pc_groups(void) {
/**
* @see DBApply
*/
-static int group_db_clear_sub(DBKey key, DBData *data, va_list args)
+static int group_db_clear_sub(union DBKey key, struct DBData *data, va_list args)
{
GroupSettings *group = DB->data2ptr(data);
if (group->name)
diff --git a/src/map/script.c b/src/map/script.c
index aeff221d4..bb6651ca5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3052,7 +3052,8 @@ unsigned int script_array_highest_key(struct script_state *st, struct map_sessio
}
return 0;
}
-int script_free_array_db(DBKey key, DBData *data, va_list ap) {
+int script_free_array_db(union DBKey key, struct DBData *data, va_list ap)
+{
struct script_array *sa = DB->data2ptr(data);
aFree(sa->members);
ers_free(script->array_ers, sa);
@@ -4595,7 +4596,7 @@ int script_config_read(char *cfgName) {
/**
* @see DBApply
*/
-int db_script_free_code_sub(DBKey key, DBData *data, va_list ap)
+int db_script_free_code_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct script_code *code = DB->data2ptr(data);
if (code)
@@ -4671,7 +4672,8 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint32
/**
* Clears persistent variables from memory
**/
-int script_reg_destroy(DBKey key, DBData *data, va_list ap) {
+int script_reg_destroy(union DBKey key, struct DBData *data, va_list ap)
+{
struct script_reg_state *src;
if( data->type != DB_DATA_PTR )/* got no need for those! */
@@ -5130,7 +5132,8 @@ void script_clear_translations(bool reload) {
/**
*
**/
-int script_translation_db_destroyer(DBKey key, DBData *data, va_list ap) {
+int script_translation_db_destroyer(union DBKey key, struct DBData *data, va_list ap)
+{
DBMap *string_db = DB->data2ptr(data);
if( db_size(string_db) ) {
diff --git a/src/map/script.h b/src/map/script.h
index e5a8d3edd..368247c63 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -751,7 +751,7 @@ struct script_interface {
void (*op_1) (struct script_state *st, int op);
void (*check_buildin_argtype) (struct script_state *st, int func);
void (*detach_state) (struct script_state *st, bool dequeue_event);
- int (*db_free_code_sub) (DBKey key, DBData *data, va_list ap);
+ int (*db_free_code_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*add_autobonus) (const char *autobonus);
int (*menu_countoptions) (const char *str, int max_count, int *total);
int (*buildin_areawarp_sub) (struct block_list *bl, va_list ap);
@@ -794,11 +794,11 @@ struct script_interface {
void (*array_add_member) (struct script_array *sa, unsigned int idx);
unsigned int (*array_size) (struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref);
unsigned int (*array_highest_key) (struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref);
- int (*array_free_db) (DBKey key, DBData *data, va_list ap);
+ int (*array_free_db) (union DBKey key, struct DBData *data, va_list ap);
void (*array_ensure_zero) (struct script_state *st, struct map_session_data *sd, int64 uid, struct reg_db *ref);
/* */
void (*reg_destroy_single) (struct map_session_data *sd, int64 reg, struct script_reg_state *data);
- int (*reg_destroy) (DBKey key, DBData *data, va_list ap);
+ int (*reg_destroy) (union DBKey key, struct DBData *data, va_list ap);
/* */
void (*generic_ui_array_expand) (unsigned int plus);
unsigned int *(*array_cpy_list) (struct script_array *sa);
@@ -808,7 +808,7 @@ struct script_interface {
int (*string_dup) (char *str);
void (*load_translations) (void);
void (*load_translation) (const char *file, uint8 lang_id, uint32 *total);
- int (*translation_db_destroyer) (DBKey key, DBData *data, va_list ap);
+ int (*translation_db_destroyer) (union DBKey key, struct DBData *data, va_list ap);
void (*clear_translations) (bool reload);
int (*parse_cleanup_timer) (int tid, int64 tick, int id, intptr_t data);
uint8 (*add_language) (const char *name);
diff --git a/src/map/skill.c b/src/map/skill.c
index 13418fece..31be52ae3 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -16554,7 +16554,8 @@ int skill_unit_timer_sub_onplace(struct block_list* bl, va_list ap) {
/**
* @see DBApply
*/
-int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
+int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap)
+{
struct skill_unit* su = DB->data2ptr(data);
struct skill_unit_group* group = su->group;
int64 tick = va_arg(ap,int64);
diff --git a/src/map/skill.h b/src/map/skill.h
index fb2acfb62..2f8525654 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -2031,7 +2031,7 @@ struct skill_interface {
int (*blockmerc_end) (int tid, int64 tick, int id, intptr_t data);
int (*split_atoi) (char *str, int *val);
int (*unit_timer) (int tid, int64 tick, int id, intptr_t data);
- int (*unit_timer_sub) (DBKey key, DBData *data, va_list ap);
+ int (*unit_timer_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*init_unit_layout) (void);
bool (*parse_row_skilldb) (char* split[], int columns, int current);
bool (*parse_row_requiredb) (char* split[], int columns, int current);
diff --git a/src/map/storage.c b/src/map/storage.c
index b8ec1e31e..91b37eb19 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -79,7 +79,7 @@ void storage_sortitem(struct item* items, unsigned int size)
* Parses storage and saves 'dirty' ones upon reconnect. [Skotlex]
* @see DBApply
*/
-int storage_reconnect_sub(DBKey key, DBData *data, va_list ap)
+int storage_reconnect_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct guild_storage *stor = DB->data2ptr(data);
if (stor->dirty && stor->storage_status == 0) //Save closed storages.
@@ -366,7 +366,7 @@ void storage_storage_quit(struct map_session_data* sd, int flag) {
/**
* @see DBCreateData
*/
-DBData create_guildstorage(DBKey key, va_list args)
+struct DBData create_guildstorage(union DBKey key, va_list args)
{
struct guild_storage *gs = NULL;
gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1);
diff --git a/src/map/storage.h b/src/map/storage.h
index bddd03770..2c7ee4ffe 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -52,7 +52,7 @@ struct storage_interface {
void (*pc_quit) (struct map_session_data *sd, int flag);
int (*comp_item) (const void *i1_, const void *i2_);
void (*sortitem) (struct item* items, unsigned int size);
- int (*reconnect_sub) (DBKey key, DBData *data, va_list ap);
+ int (*reconnect_sub) (union DBKey key, struct DBData *data, va_list ap);
};
struct guild_storage_interface {
@@ -75,7 +75,7 @@ struct guild_storage_interface {
int (*pc_quit) (struct map_session_data *sd,int flag);
int (*save) (int account_id, int guild_id, int flag);
int (*saved) (int guild_id); //Ack from char server that guild store was saved.
- DBData (*create) (DBKey key, va_list args);
+ struct DBData (*create) (union DBKey key, va_list args);
};
#ifdef HERCULES_CORE