summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c28
-rw-r--r--src/char/char.h16
-rw-r--r--src/char/int_auction.c8
-rw-r--r--src/char/int_auction.h6
-rw-r--r--src/char/int_guild.c25
-rw-r--r--src/char/int_guild.h6
-rw-r--r--src/char/int_homun.c6
-rw-r--r--src/char/int_mail.c2
-rw-r--r--src/char/int_party.h6
-rw-r--r--src/char/int_quest.c2
-rw-r--r--src/char/int_storage.c2
-rw-r--r--src/char/inter.c5
-rw-r--r--src/char/inter.h8
13 files changed, 64 insertions, 56 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 6cfeb7d1a..929473e33 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -162,7 +162,7 @@ unsigned short skillid2idx[MAX_SKILL_ID];
//-----------------------------------------------------
#define AUTH_TIMEOUT 30000
-static DBMap* auth_db; // int account_id -> struct char_auth_node*
+static struct DBMap *auth_db; // int account_id -> struct char_auth_node*
//-----------------------------------------------------
// Online User Database
@@ -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));
@@ -702,7 +702,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
int char_memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch)
{
StringBuf buf;
- SqlStmt *stmt = NULL;
+ struct SqlStmt *stmt = NULL;
int i, j;
const char *tablename = NULL;
const char *selectoption = NULL;
@@ -915,7 +915,7 @@ int char_mmo_gender(const struct char_session_data *sd, const struct mmo_charsta
// Loads the basic character rooster for the given account. Returns total buffer used.
int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
{
- SqlStmt* stmt;
+ struct SqlStmt *stmt;
struct mmo_charstatus p;
int j = 0, i;
char last_map[MAP_NAME_LENGTH_EXT];
@@ -1015,7 +1015,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
char t_msg[128] = "";
struct mmo_charstatus* cp;
StringBuf buf;
- SqlStmt* stmt;
+ struct SqlStmt *stmt;
char last_map[MAP_NAME_LENGTH_EXT];
char save_map[MAP_NAME_LENGTH_EXT];
char point_map[MAP_NAME_LENGTH_EXT];
@@ -2341,7 +2341,7 @@ int char_parse_fromlogin_changesex_reply(int fd)
int char_id = 0, class_ = 0, guild_id = 0;
int i;
struct char_auth_node *node;
- SqlStmt *stmt;
+ struct SqlStmt *stmt;
int acc = RFIFOL(fd,2);
int sex = RFIFOB(fd,6);
@@ -3277,7 +3277,7 @@ void char_ban(int account_id, int char_id, time_t *unban_time, short year, short
{
time_t timestamp;
struct tm *tmtime;
- SqlStmt* stmt = SQL->StmtMalloc(inter->sql_handle);
+ struct SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
nullpo_retv(unban_time);
@@ -3298,8 +3298,8 @@ void char_ban(int account_id, int char_id, time_t *unban_time, short year, short
if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
"UPDATE `%s` SET `unban_time` = ? WHERE `char_id` = ? LIMIT 1",
char_db)
- || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_LONG, (void*)&timestamp, sizeof(timestamp))
- || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_INT, (void*)&char_id, sizeof(char_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_LONG, &timestamp, sizeof(timestamp))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_INT, &char_id, sizeof(char_id))
|| SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
@@ -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..9cde18e96 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -98,8 +98,8 @@ struct char_interface {
struct mmo_map_server server[MAX_MAP_SERVERS];
int login_fd;
int char_fd;
- DBMap* online_char_db; // int account_id -> struct online_char_data*
- DBMap* char_db_;
+ struct DBMap *online_char_db; // int account_id -> struct online_char_data*
+ struct DBMap *char_db_;
char userid[NAME_LENGTH];
char passwd[NAME_LENGTH];
char server_name[20];
@@ -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_auction.c b/src/char/int_auction.c
index 464a2092b..51acb32a6 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -47,7 +47,7 @@ static int inter_auction_count(int char_id, bool buy)
{
int i = 0;
struct auction_data *auction;
- DBIterator *iter = db_iterator(inter_auction->db);
+ struct DBIterator *iter = db_iterator(inter_auction->db);
for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
{
@@ -63,7 +63,7 @@ void inter_auction_save(struct auction_data *auction)
{
int j;
StringBuf buf;
- SqlStmt* stmt;
+ struct SqlStmt *stmt;
if( !auction )
return;
@@ -93,7 +93,7 @@ unsigned int inter_auction_create(struct auction_data *auction)
{
int j;
StringBuf buf;
- SqlStmt* stmt;
+ struct SqlStmt *stmt;
if( !auction )
return false;
@@ -280,7 +280,7 @@ void mapif_parse_auction_requestlist(int fd)
int price = RFIFOL(fd,10);
short type = RFIFOW(fd,8), page = max(1,RFIFOW(fd,14));
unsigned char buf[5 * sizeof(struct auction_data)];
- DBIterator *iter = db_iterator(inter_auction->db);
+ struct DBIterator *iter = db_iterator(inter_auction->db);
struct auction_data *auction;
short i = 0, j = 0, pages = 1;
diff --git a/src/char/int_auction.h b/src/char/int_auction.h
index 29b068dfd..ccd5bfbf5 100644
--- a/src/char/int_auction.h
+++ b/src/char/int_auction.h
@@ -22,14 +22,16 @@
#define CHAR_INT_AUCTION_H
#include "common/hercules.h"
-#include "common/db.h"
#include "common/mmo.h"
+/* Forward Declarations */
+struct DBMap; // common/db.h
+
/**
* inter_auction_interface interface
**/
struct inter_auction_interface {
- DBMap* db; // int auction_id -> struct auction_data*
+ struct DBMap *db; // int auction_id -> struct auction_data*
int (*count) (int char_id, bool buy);
void (*save) (struct auction_data *auction);
unsigned int (*create) (struct auction_data *auction);
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 2ba50d277..21f38d049 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -33,6 +33,7 @@
#include "common/nullpo.h"
#include "common/showmsg.h"
#include "common/socket.h"
+#include "common/sql.h"
#include "common/strlib.h"
#include "common/timer.h"
@@ -58,8 +59,8 @@ static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9
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;
+ struct DBIterator *iter = db_iterator(inter_guild->guild_db);
+ union DBKey key;
struct guild* g;
if( last_id == 0 ) //Save the first guild in the list.
@@ -748,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);
@@ -1547,17 +1548,17 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
switch(type)
{
case GMI_POSITION:
- {
- g->member[i].position=*((const short *)data);
+ {
+ g->member[i].position = *(const short *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER;
break;
- }
+ }
case GMI_EXP:
{
uint64 old_exp = g->member[i].exp;
- g->member[i].exp=*((const uint64 *)data);
+ g->member[i].exp = *(const uint64 *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
if (g->member[i].exp > old_exp) {
uint64 exp = g->member[i].exp - old_exp;
@@ -1582,7 +1583,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_HAIR:
{
- g->member[i].hair=*((const short *)data);
+ g->member[i].hair = *(const short *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1590,7 +1591,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_HAIR_COLOR:
{
- g->member[i].hair_color=*((const short *)data);
+ g->member[i].hair_color = *(const short *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1598,7 +1599,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_GENDER:
{
- g->member[i].gender=*((const short *)data);
+ g->member[i].gender = *(const short *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1606,7 +1607,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_CLASS:
{
- g->member[i].class_=*((const short *)data);
+ g->member[i].class_ = *(const short *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
@@ -1614,7 +1615,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
case GMI_LEVEL:
{
- g->member[i].lv=*((const short *)data);
+ g->member[i].lv = *(const short *)data;
g->member[i].modified = GS_MEMBER_MODIFIED;
mapif->guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
g->save_flag |= GS_MEMBER; //Save new data.
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index 40728c3b2..252c2dc47 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -44,8 +44,8 @@ enum {
* inter_guild interface
**/
struct inter_guild_interface {
- DBMap* guild_db; // int guild_id -> struct guild*
- DBMap* castle_db;
+ struct DBMap *guild_db; // int guild_id -> struct guild*
+ struct DBMap *castle_db;
unsigned int exp[MAX_GUILDLEVEL];
int (*save_timer) (int tid, int64 tick, int id, intptr_t data);
@@ -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/int_homun.c b/src/char/int_homun.c
index e5fde2330..90643699c 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -163,7 +163,7 @@ bool mapif_homunculus_save(const struct s_homunculus *hd)
flag = false;
} else {
int i;
- SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
+ struct SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
if (SQL_ERROR == SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", skill_homunculus_db, hd->hom_id)) {
SqlStmt_ShowDebug(stmt);
@@ -171,8 +171,8 @@ bool mapif_homunculus_save(const struct s_homunculus *hd)
} else {
for (i = 0; i < MAX_HOMUNSKILL; ++i) {
if (hd->hskill[i].id > 0 && hd->hskill[i].lv != 0) {
- SQL->StmtBindParam(stmt, 0, SQLDT_USHORT, (void*)&hd->hskill[i].id, 0); // FIXME: StmtBindParam should take const void
- SQL->StmtBindParam(stmt, 1, SQLDT_USHORT, (void*)&hd->hskill[i].lv, 0); // FIXME: StmtBindParam should take const void
+ SQL->StmtBindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0);
+ SQL->StmtBindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0);
if (SQL_ERROR == SQL->StmtExecute(stmt)) {
SqlStmt_ShowDebug(stmt);
flag = false;
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index b75a362fb..bf3403b5f 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -129,7 +129,7 @@ static int inter_mail_fromsql(int char_id, struct mail_data* md)
int inter_mail_savemessage(struct mail_message* msg)
{
StringBuf buf;
- SqlStmt* stmt;
+ struct SqlStmt *stmt;
int j;
nullpo_ret(msg);
diff --git a/src/char/int_party.h b/src/char/int_party.h
index e6ad75bb8..62fef4192 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -22,9 +22,11 @@
#define CHAR_INT_PARTY_H
#include "common/hercules.h"
-#include "common/db.h"
#include "common/mmo.h"
+/* Forward Declarations */
+struct DBMap; // common/db.h
+
//Party Flags on what to save/delete.
enum {
PS_CREATE = 0x01, //Create a new party entry (index holds leader's info)
@@ -47,7 +49,7 @@ struct party_data {
**/
struct inter_party_interface {
struct party_data *pt;
- DBMap* db; // int party_id -> struct party_data*
+ struct DBMap *db; // int party_id -> struct party_data*
int (*check_lv) (struct party_data *p);
void (*calc_state) (struct party_data *p);
int (*tosql) (struct party *p, int flag, int index);
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index b28c81331..cf93db51e 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -52,7 +52,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
{
struct quest *questlog = NULL;
struct quest tmp_quest;
- SqlStmt *stmt;
+ struct SqlStmt *stmt;
StringBuf buf;
int i;
int sqlerror = SQL_SUCCESS;
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 705aa02d2..e46a1c80f 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -277,7 +277,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
{
#ifdef GP_BOUND_ITEMS
StringBuf buf;
- SqlStmt* stmt;
+ struct SqlStmt *stmt;
struct item item;
int j, i=0, s=0, bound_qt=0;
struct item items[MAX_INVENTORY];
diff --git a/src/char/inter.c b/src/char/inter.c
index 4ef94efdf..9fea2885c 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -42,6 +42,7 @@
#include "common/nullpo.h"
#include "common/showmsg.h"
#include "common/socket.h"
+#include "common/sql.h"
#include "common/strlib.h"
#include "common/timer.h"
@@ -82,7 +83,7 @@ struct WisData {
int64 tick;
unsigned char src[24], dst[24], msg[512];
};
-static DBMap* wis_db = NULL; // int wis_id -> struct WisData*
+static struct DBMap *wis_db = NULL; // int wis_id -> struct WisData*
static int wis_dellist[WISDELLIST_MAX], wis_delnum;
#define MAX_JOB_NAMES 150
@@ -1037,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 b8bcb2def..4e8d113ce 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -23,15 +23,17 @@
#include "common/hercules.h"
#include "common/db.h"
-#include "common/sql.h"
#include <stdarg.h>
+/* Forward Declarations */
+struct Sql; // common/sql.h
+
/**
* inter interface
**/
struct inter_interface {
- Sql* sql_handle;
+ struct Sql *sql_handle;
const char* (*msg_txt) (int msg_number);
bool (*msg_config_read) (const char *cfg_name, bool allow_override);
void (*do_final_msg) (void);
@@ -45,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);