summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char/char.c10
-rw-r--r--src/char/int_auction.c4
-rw-r--r--src/char/int_guild.c1
-rw-r--r--src/char/int_homun.c2
-rw-r--r--src/char/int_mail.c2
-rw-r--r--src/char/int_quest.c2
-rw-r--r--src/char/int_storage.c2
-rw-r--r--src/char/inter.c1
-rw-r--r--src/char/inter.h6
-rw-r--r--src/common/HPMi.h4
-rw-r--r--src/common/console.c3
-rw-r--r--src/common/console.h8
-rw-r--r--src/common/sql.c114
-rw-r--r--src/common/sql.h78
-rw-r--r--src/login/account.h6
-rw-r--r--src/login/account_sql.c31
-rw-r--r--src/login/ipban_sql.c2
-rw-r--r--src/login/loginlog_sql.c2
-rw-r--r--src/map/log.c17
-rw-r--r--src/map/log.h4
-rw-r--r--src/map/map.c1
-rw-r--r--src/map/map.h5
-rw-r--r--src/map/mapreg_sql.c2
-rw-r--r--src/map/npc.c6
-rw-r--r--src/map/pc.c1
-rw-r--r--src/map/script.c3
-rw-r--r--src/map/script.h4
-rw-r--r--src/plugins/db2sql.c1
28 files changed, 174 insertions, 148 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 6cfeb7d1a..23f5d1ea0 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -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);
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 464a2092b..2c9942dac 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -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;
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index c637f12fd..ab15d5ef9 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"
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index e5fde2330..bfb0009e6 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);
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_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..4e1adbe15 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"
diff --git a/src/char/inter.h b/src/char/inter.h
index b8bcb2def..84cb6c640 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);
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index cf3e16277..72640b382 100644
--- a/src/common/HPMi.h
+++ b/src/common/HPMi.h
@@ -24,8 +24,8 @@
#include "common/console.h"
#include "common/core.h"
#include "common/showmsg.h"
-#include "common/sql.h"
+struct Sql; // common/sql.h
struct script_state;
struct AtCommandInfo;
struct socket_data;
@@ -242,7 +242,7 @@ struct HPMi_interface {
/* pc group permission */
void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask);
- Sql *sql_handle;
+ struct Sql *sql_handle;
};
#ifdef HERCULES_CORE
#define HPM_SYMBOL(n, s) (HPM->share((s), (n)), true)
diff --git a/src/common/console.c b/src/common/console.c
index 10e1bee1a..0be33e5c3 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -523,7 +523,8 @@ void console_parse_init(void) {
timer->add_func_list(console->input->parse_timer, "console_parse_timer");
timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
}
-void console_setSQL(Sql *SQL_handle) {
+void console_setSQL(struct Sql *SQL_handle)
+{
console->input->SQL = SQL_handle;
}
#endif /* CONSOLE_INPUT */
diff --git a/src/common/console.h b/src/common/console.h
index 43f48b865..57c750a7d 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -24,9 +24,11 @@
#include "common/db.h"
#include "common/mutex.h"
#include "common/spinlock.h"
-#include "common/sql.h"
#include "common/thread.h"
+/* Forward Declarations */
+struct Sql; // common/sql.h
+
/**
* Queue Max
* why is there a limit, why not make it dynamic? - I'm playing it safe, I'd rather not play with memory management between threads
@@ -78,7 +80,7 @@ struct console_input_interface {
VECTOR_DECL(struct CParseEntry *) command_list;
VECTOR_DECL(struct CParseEntry *) commands;
/* */
- Sql *SQL;
+ struct Sql *SQL;
/* */
void (*parse_init) (void);
void (*parse_final) (void);
@@ -90,7 +92,7 @@ struct console_input_interface {
void (*load_defaults) (void);
void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth);
void (*addCommand) (char *name, CParseFunc func);
- void (*setSQL) (Sql *SQL_handle);
+ void (*setSQL) (struct Sql *SQL_handle);
#else // not CONSOLE_INPUT
UNAVAILABLE_STRUCT;
#endif
diff --git a/src/common/sql.c b/src/common/sql.c
index ed93169ea..1dcf5d374 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -79,11 +79,11 @@ struct SqlStmt {
///////////////////////////////////////////////////////////////////////////////
/// Allocates and initializes a new Sql handle.
-Sql* Sql_Malloc(void)
+struct Sql *Sql_Malloc(void)
{
- Sql* self;
+ struct Sql *self;
- CREATE(self, Sql, 1);
+ CREATE(self, struct Sql, 1);
mysql_init(&self->handle);
StrBuf->Init(&self->buf);
self->lengths = NULL;
@@ -93,10 +93,10 @@ Sql* Sql_Malloc(void)
return self;
}
-static int Sql_P_Keepalive(Sql* self);
+static int Sql_P_Keepalive(struct Sql *self);
/// Establishes a connection.
-int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db)
+int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db)
{
if( self == NULL )
return SQL_ERROR;
@@ -119,7 +119,7 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos
}
/// Retrieves the timeout of the connection.
-int Sql_GetTimeout(Sql* self, uint32* out_timeout)
+int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout)
{
if( self && out_timeout && SQL_SUCCESS == SQL->Query(self, "SHOW VARIABLES LIKE 'wait_timeout'") ) {
char* data;
@@ -136,7 +136,7 @@ int Sql_GetTimeout(Sql* self, uint32* out_timeout)
}
/// Retrieves the name of the columns of a table into out_buf, with the separator after each name.
-int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_len, char sep)
+int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep)
{
char* data;
size_t len;
@@ -164,7 +164,7 @@ int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_l
}
/// Changes the encoding of the connection.
-int Sql_SetEncoding(Sql* self, const char* encoding)
+int Sql_SetEncoding(struct Sql *self, const char *encoding)
{
if( self && mysql_set_character_set(&self->handle, encoding) == 0 )
return SQL_SUCCESS;
@@ -172,7 +172,7 @@ int Sql_SetEncoding(Sql* self, const char* encoding)
}
/// Pings the connection.
-int Sql_Ping(Sql* self)
+int Sql_Ping(struct Sql *self)
{
if( self && mysql_ping(&self->handle) == 0 )
return SQL_SUCCESS;
@@ -184,7 +184,7 @@ int Sql_Ping(Sql* self)
/// @private
static int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data)
{
- Sql* self = (Sql*)data;
+ struct Sql *self = (struct Sql *)data;
ShowInfo("Pinging SQL server to keep connection alive...\n");
Sql_Ping(self);
return 0;
@@ -194,7 +194,7 @@ static int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data)
///
/// @return the keepalive timer id, or INVALID_TIMER
/// @private
-static int Sql_P_Keepalive(Sql* self)
+static int Sql_P_Keepalive(struct Sql *self)
{
uint32 timeout, ping_interval;
@@ -214,26 +214,27 @@ static int Sql_P_Keepalive(Sql* self)
}
/// Escapes a string.
-size_t Sql_EscapeString(Sql* self, char *out_to, const char *from)
+size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from)
{
- if( self )
+ if (self != NULL)
return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)strlen(from));
else
return (size_t)mysql_escape_string(out_to, from, (unsigned long)strlen(from));
}
/// Escapes a string.
-size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t from_len)
+size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, size_t from_len)
{
- if( self )
+ if (self != NULL)
return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)from_len);
else
return (size_t)mysql_escape_string(out_to, from, (unsigned long)from_len);
}
/// Executes a query.
-int Sql_Query(Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
-int Sql_Query(Sql *self, const char *query, ...) {
+int Sql_Query(struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
+int Sql_Query(struct Sql *self, const char *query, ...)
+{
int res;
va_list args;
@@ -245,7 +246,7 @@ int Sql_Query(Sql *self, const char *query, ...) {
}
/// Executes a query.
-int Sql_QueryV(Sql* self, const char* query, va_list args)
+int Sql_QueryV(struct Sql *self, const char *query, va_list args)
{
if( self == NULL )
return SQL_ERROR;
@@ -270,7 +271,7 @@ int Sql_QueryV(Sql* self, const char* query, va_list args)
}
/// Executes a query.
-int Sql_QueryStr(Sql* self, const char* query)
+int Sql_QueryStr(struct Sql *self, const char *query)
{
if( self == NULL )
return SQL_ERROR;
@@ -295,33 +296,34 @@ int Sql_QueryStr(Sql* self, const char* query)
}
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query.
-uint64 Sql_LastInsertId(Sql* self)
+uint64 Sql_LastInsertId(struct Sql *self)
{
- if( self )
+ if (self != NULL)
return (uint64)mysql_insert_id(&self->handle);
else
return 0;
}
/// Returns the number of columns in each row of the result.
-uint32 Sql_NumColumns(Sql* self)
+uint32 Sql_NumColumns(struct Sql *self)
{
- if( self && self->result )
+ if (self != NULL && self->result != NULL)
return (uint32)mysql_num_fields(self->result);
return 0;
}
/// Returns the number of rows in the result.
-uint64 Sql_NumRows(Sql* self)
+uint64 Sql_NumRows(struct Sql *self)
{
- if( self && self->result )
+ if (self != NULL && self->result != NULL)
return (uint64)mysql_num_rows(self->result);
return 0;
}
/// Fetches the next row.
-int Sql_NextRow(Sql* self) {
- if( self && self->result ) {
+int Sql_NextRow(struct Sql *self)
+{
+ if (self != NULL && self->result != NULL) {
self->row = mysql_fetch_row(self->result);
if( self->row ) {
self->lengths = mysql_fetch_lengths(self->result);
@@ -335,7 +337,7 @@ int Sql_NextRow(Sql* self) {
}
/// Gets the data of a column.
-int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len)
+int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len)
{
if( self && self->row ) {
if( col < SQL->NumColumns(self) ) {
@@ -351,7 +353,8 @@ int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len)
}
/// Frees the result of the query.
-void Sql_FreeResult(Sql* self) {
+void Sql_FreeResult(struct Sql *self)
+{
if( self && self->result ) {
mysql_free_result(self->result);
self->result = NULL;
@@ -361,7 +364,7 @@ void Sql_FreeResult(Sql* self) {
}
/// Shows debug information (last query).
-void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line)
+void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned long debug_line)
{
if( self == NULL )
ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line);
@@ -372,7 +375,7 @@ void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug
}
/// Frees a Sql handle returned by Sql_Malloc.
-void Sql_Free(Sql* self) {
+void Sql_Free(struct Sql *self) {
if( self )
{
SQL->FreeResult(self);
@@ -515,7 +518,7 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty
/// Reports debug information about a truncated column.
///
/// @private
-static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i)
+static void SqlStmt_P_ShowDebugTruncatedColumn(struct SqlStmt *self, size_t i)
{
MYSQL_RES* meta;
MYSQL_FIELD* field;
@@ -535,8 +538,9 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i)
}
/// Allocates and initializes a new SqlStmt handle.
-SqlStmt* SqlStmt_Malloc(Sql* sql) {
- SqlStmt* self;
+struct SqlStmt *SqlStmt_Malloc(struct Sql *sql)
+{
+ struct SqlStmt *self;
MYSQL_STMT* stmt;
if( sql == NULL )
@@ -547,7 +551,7 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) {
ShowSQL("DB error - %s\n", mysql_error(&sql->handle));
return NULL;
}
- CREATE(self, SqlStmt, 1);
+ CREATE(self, struct SqlStmt, 1);
StrBuf->Init(&self->buf);
self->stmt = stmt;
self->params = NULL;
@@ -562,8 +566,9 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) {
}
/// Prepares the statement.
-int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
-int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) {
+int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
+int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...)
+{
int res;
va_list args;
@@ -575,7 +580,7 @@ int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) {
}
/// Prepares the statement.
-int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
+int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args)
{
if( self == NULL )
return SQL_ERROR;
@@ -595,7 +600,7 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
}
/// Prepares the statement.
-int SqlStmt_PrepareStr(SqlStmt* self, const char* query)
+int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query)
{
if( self == NULL )
return SQL_ERROR;
@@ -615,7 +620,7 @@ int SqlStmt_PrepareStr(SqlStmt* self, const char* query)
}
/// Returns the number of parameters in the prepared statement.
-size_t SqlStmt_NumParams(SqlStmt* self)
+size_t SqlStmt_NumParams(struct SqlStmt *self)
{
if( self )
return (size_t)mysql_stmt_param_count(self->stmt);
@@ -624,7 +629,7 @@ size_t SqlStmt_NumParams(SqlStmt* self)
}
/// Binds a parameter to a buffer.
-int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len)
+int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len)
{
if( self == NULL )
return SQL_ERROR;
@@ -652,7 +657,7 @@ int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, v
}
/// Executes the prepared statement.
-int SqlStmt_Execute(SqlStmt* self)
+int SqlStmt_Execute(struct SqlStmt *self)
{
if( self == NULL )
return SQL_ERROR;
@@ -677,7 +682,7 @@ int SqlStmt_Execute(SqlStmt* self)
}
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
-uint64 SqlStmt_LastInsertId(SqlStmt* self)
+uint64 SqlStmt_LastInsertId(struct SqlStmt *self)
{
if( self )
return (uint64)mysql_stmt_insert_id(self->stmt);
@@ -686,7 +691,7 @@ uint64 SqlStmt_LastInsertId(SqlStmt* self)
}
/// Returns the number of columns in each row of the result.
-size_t SqlStmt_NumColumns(SqlStmt* self)
+size_t SqlStmt_NumColumns(struct SqlStmt *self)
{
if( self )
return (size_t)mysql_stmt_field_count(self->stmt);
@@ -695,7 +700,8 @@ size_t SqlStmt_NumColumns(SqlStmt* self)
}
/// Binds the result of a column to a buffer.
-int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) {
+int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null)
+{
if (self == NULL)
return SQL_ERROR;
@@ -736,16 +742,16 @@ int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type,
}
/// Returns the number of rows in the result.
-uint64 SqlStmt_NumRows(SqlStmt* self)
+uint64 SqlStmt_NumRows(struct SqlStmt *self)
{
- if( self )
+ if (self != NULL)
return (uint64)mysql_stmt_num_rows(self->stmt);
else
return 0;
}
/// Fetches the next row.
-int SqlStmt_NextRow(SqlStmt* self)
+int SqlStmt_NextRow(struct SqlStmt *self)
{
int err;
size_t i;
@@ -828,14 +834,14 @@ int SqlStmt_NextRow(SqlStmt* self)
}
/// Frees the result of the statement execution.
-void SqlStmt_FreeResult(SqlStmt* self)
+void SqlStmt_FreeResult(struct SqlStmt *self)
{
if( self )
mysql_stmt_free_result(self->stmt);
}
/// Shows debug information (with statement).
-void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line)
+void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line)
{
if( self == NULL )
ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line);
@@ -846,7 +852,7 @@ void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned lo
}
/// Frees a SqlStmt returned by SqlStmt_Malloc.
-void SqlStmt_Free(SqlStmt* self)
+void SqlStmt_Free(struct SqlStmt *self)
{
if( self )
{
@@ -919,7 +925,8 @@ void Sql_inter_server_read(const char* cfgName, bool first) {
return;
}
-void Sql_HerculesUpdateCheck(Sql* self) {
+void Sql_HerculesUpdateCheck(struct Sql *self)
+{
char line[22];// "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1
FILE* ifp;/* index fp */
unsigned int performed = 0;
@@ -980,7 +987,8 @@ void Sql_HerculesUpdateCheck(Sql* self) {
StrBuf->Destroy(&buf);
}
-void Sql_HerculesUpdateSkip(Sql* self,const char *filename) {
+void Sql_HerculesUpdateSkip(struct Sql *self, const char *filename)
+{
char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1
char timestamp[11];// "1360186680" (10) + 1
FILE* ifp;/* index fp */
diff --git a/src/common/sql.h b/src/common/sql.h
index e949a8280..3619895b1 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -71,90 +71,86 @@ enum SqlDataType {
SQLDT_LASTID
};
-struct Sql;// Sql handle (private access)
-struct SqlStmt;// Sql statement (private access)
-
-typedef enum SqlDataType SqlDataType;
-typedef struct Sql Sql;
-typedef struct SqlStmt SqlStmt;
+struct Sql; ///< Sql handle (private access)
+struct SqlStmt; ///< Sql statement (private access)
struct sql_interface {
/// Establishes a connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*Connect) (Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db);
+ int (*Connect) (struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db);
/// Retrieves the timeout of the connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*GetTimeout) (Sql* self, uint32* out_timeout);
+ int (*GetTimeout) (struct Sql *self, uint32 *out_timeout);
/// Retrieves the name of the columns of a table into out_buf, with the separator after each name.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*GetColumnNames) (Sql* self, const char* table, char* out_buf, size_t buf_len, char sep);
+ int (*GetColumnNames) (struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep);
/// Changes the encoding of the connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*SetEncoding) (Sql* self, const char* encoding);
+ int (*SetEncoding) (struct Sql *self, const char *encoding);
/// Pings the connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*Ping) (Sql* self);
+ int (*Ping) (struct Sql *self);
/// Escapes a string.
/// The output buffer must be at least strlen(from)*2+1 in size.
///
/// @return The size of the escaped string
- size_t (*EscapeString) (Sql* self, char* out_to, const char* from);
+ size_t (*EscapeString) (struct Sql *self, char *out_to, const char *from);
/// Escapes a string.
/// The output buffer must be at least from_len*2+1 in size.
///
/// @return The size of the escaped string
- size_t (*EscapeStringLen) (Sql* self, char* out_to, const char* from, size_t from_len);
+ size_t (*EscapeStringLen) (struct Sql *self, char *out_to, const char *from, size_t from_len);
/// Executes a query.
/// Any previous result is freed.
/// The query is constructed as if it was sprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*Query) (Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
+ int (*Query) (struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
/// Executes a query.
/// Any previous result is freed.
/// The query is constructed as if it was svprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*QueryV) (Sql* self, const char* query, va_list args);
+ int (*QueryV) (struct Sql *self, const char *query, va_list args);
/// Executes a query.
/// Any previous result is freed.
/// The query is used directly.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*QueryStr) (Sql* self, const char* query);
+ int (*QueryStr) (struct Sql *self, const char *query);
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query.
///
/// @return Value of the auto-increment column
- uint64 (*LastInsertId) (Sql* self);
+ uint64 (*LastInsertId) (struct Sql *self);
/// Returns the number of columns in each row of the result.
///
/// @return Number of columns
- uint32 (*NumColumns) (Sql* self);
+ uint32 (*NumColumns) (struct Sql *self);
/// Returns the number of rows in the result.
///
/// @return Number of rows
- uint64 (*NumRows) (Sql* self);
+ uint64 (*NumRows) (struct Sql *self);
/// Fetches the next row.
/// The data of the previous row is no longer valid.
///
/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA
- int (*NextRow) (Sql* self);
+ int (*NextRow) (struct Sql *self);
/// Gets the data of a column.
/// The data remains valid until the next row is fetched or the result is freed.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*GetData) (Sql* self, size_t col, char** out_buf, size_t* out_len);
+ int (*GetData) (struct Sql *self, size_t col, char **out_buf, size_t *out_len);
/// Frees the result of the query.
- void (*FreeResult) (Sql* self);
+ void (*FreeResult) (struct Sql *self);
/// Shows debug information (last query).
- void (*ShowDebug_) (Sql* self, const char* debug_file, const unsigned long debug_line);
+ void (*ShowDebug_) (struct Sql *self, const char *debug_file, const unsigned long debug_line);
/// Frees a Sql handle returned by Sql_Malloc.
- void (*Free) (Sql* self);
+ void (*Free) (struct Sql *self);
/// Allocates and initializes a new Sql handle.
struct Sql *(*Malloc) (void);
@@ -180,56 +176,56 @@ struct sql_interface {
/// Queries in Sql and SqlStmt are independent and don't affect each other.
///
/// @return SqlStmt handle or NULL if an error occurred
- struct SqlStmt* (*StmtMalloc)(Sql* sql);
+ struct SqlStmt* (*StmtMalloc)(struct Sql *sql);
/// Prepares the statement.
/// Any previous result is freed and all parameter bindings are removed.
/// The query is constructed as if it was sprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*StmtPrepare) (SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
+ int (*StmtPrepare) (struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
/// Prepares the statement.
/// Any previous result is freed and all parameter bindings are removed.
/// The query is constructed as if it was svprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*StmtPrepareV)(SqlStmt* self, const char* query, va_list args);
+ int (*StmtPrepareV)(struct SqlStmt *self, const char *query, va_list args);
/// Prepares the statement.
/// Any previous result is freed and all parameter bindings are removed.
/// The query is used directly.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*StmtPrepareStr)(SqlStmt* self, const char* query);
+ int (*StmtPrepareStr)(struct SqlStmt *self, const char *query);
/// Returns the number of parameters in the prepared statement.
///
/// @return Number or parameters
- size_t (*StmtNumParams)(SqlStmt* self);
+ size_t (*StmtNumParams)(struct SqlStmt *self);
/// Binds a parameter to a buffer.
/// The buffer data will be used when the statement is executed.
/// All parameters should have bindings.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*StmtBindParam)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len);
+ int (*StmtBindParam)(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len);
/// Executes the prepared statement.
/// Any previous result is freed and all column bindings are removed.
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*StmtExecute)(SqlStmt* self);
+ int (*StmtExecute)(struct SqlStmt *self);
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
///
/// @return Value of the auto-increment column
- uint64 (*StmtLastInsertId)(SqlStmt* self);
+ uint64 (*StmtLastInsertId)(struct SqlStmt *self);
/// Returns the number of columns in each row of the result.
///
/// @return Number of columns
- size_t (*StmtNumColumns)(SqlStmt* self);
+ size_t (*StmtNumColumns)(struct SqlStmt *self);
/// Binds the result of a column to a buffer.
/// The buffer will be filled with data when the next row is fetched.
@@ -237,26 +233,26 @@ struct sql_interface {
/// and the null-terminator (an extra byte).
///
/// @return SQL_SUCCESS or SQL_ERROR
- int (*StmtBindColumn)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null);
+ int (*StmtBindColumn)(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null);
/// Returns the number of rows in the result.
///
/// @return Number of rows
- uint64 (*StmtNumRows)(SqlStmt* self);
+ uint64 (*StmtNumRows)(struct SqlStmt *self);
/// Fetches the next row.
/// All column bindings will be filled with data.
///
/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA
- int (*StmtNextRow)(SqlStmt* self);
+ int (*StmtNextRow)(struct SqlStmt *self);
/// Frees the result of the statement execution.
- void (*StmtFreeResult)(SqlStmt* self);
+ void (*StmtFreeResult)(struct SqlStmt *self);
/// Frees a SqlStmt returned by SqlStmt_Malloc.
- void (*StmtFree)(SqlStmt* self);
+ void (*StmtFree)(struct SqlStmt *self);
- void (*StmtShowDebug_)(SqlStmt* self, const char* debug_file, const unsigned long debug_line);
+ void (*StmtShowDebug_)(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line);
};
@@ -265,8 +261,8 @@ void sql_defaults(void);
void Sql_Init(void);
-void Sql_HerculesUpdateCheck(Sql* self);
-void Sql_HerculesUpdateSkip(Sql* self,const char *filename);
+void Sql_HerculesUpdateCheck(struct Sql *self);
+void Sql_HerculesUpdateSkip(struct Sql *self, const char *filename);
#endif // HERCULES_CORE
HPShared struct sql_interface *SQL;
diff --git a/src/login/account.h b/src/login/account.h
index 151a2863d..7e1930ad4 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -23,7 +23,9 @@
#include "common/cbasetypes.h"
#include "common/mmo.h" // ACCOUNT_REG2_NUM
-#include "common/sql.h" // Sql
+
+/* Forward declarations */
+struct Sql; // common/sql.h
typedef struct AccountDB AccountDB;
typedef struct AccountDBIterator AccountDBIterator;
@@ -158,7 +160,7 @@ struct AccountDB
};
#ifdef HERCULES_CORE
-Sql *account_db_sql_up(AccountDB* self);
+struct Sql *account_db_sql_up(AccountDB* self);
void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id);
void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id);
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index 2a7401f1b..6d0e795f6 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -43,7 +43,7 @@ typedef struct AccountDB_SQL
{
AccountDB vtable; // public interface
- Sql* accounts; // SQL accounts storage
+ struct Sql *accounts; // SQL accounts storage
// global sql settings
char global_db_hostname[32];
@@ -144,7 +144,7 @@ AccountDB* account_db_sql(void)
static bool account_db_sql_init(AccountDB* self)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle;
+ struct Sql *sql_handle;
const char* username;
const char* password;
const char* hostname;
@@ -379,7 +379,7 @@ static bool account_db_sql_set_property(AccountDB* self, const char* key, const
static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle;
+ struct Sql *sql_handle;
// decide on the account id to assign
int account_id;
@@ -433,7 +433,7 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc)
static bool account_db_sql_remove(AccountDB* self, const int account_id)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle;
+ struct Sql *sql_handle;
bool result = false;
nullpo_ret(db);
@@ -470,7 +470,7 @@ static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, co
static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid)
{
AccountDB_SQL* db = (AccountDB_SQL*)self;
- Sql* sql_handle;
+ struct Sql *sql_handle;
char esc_userid[2*NAME_LENGTH+1];
int account_id;
char* data;
@@ -540,7 +540,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account
{
AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self;
AccountDB_SQL* db;
- Sql* sql_handle;
+ struct Sql *sql_handle;
char* data;
nullpo_ret(iter);
@@ -575,7 +575,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account
static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id)
{
- Sql* sql_handle;
+ struct Sql *sql_handle;
char* data;
nullpo_ret(db);
@@ -620,8 +620,8 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new)
{
- Sql* sql_handle;
- SqlStmt* stmt;
+ struct Sql *sql_handle;
+ struct SqlStmt *stmt;
bool result = false;
nullpo_ret(db);
@@ -701,12 +701,14 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
return result;
}
-Sql* account_db_sql_up(AccountDB* self) {
+struct Sql *account_db_sql_up(AccountDB* self)
+{
AccountDB_SQL* db = (AccountDB_SQL*)self;
return db ? db->accounts : NULL;
}
-void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
- Sql* sql_handle;
+void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id)
+{
+ struct Sql *sql_handle;
AccountDB_SQL* db = (AccountDB_SQL*)self;
int count = RFIFOW(fd, 12);
@@ -756,8 +758,9 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
}
}
-void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
- Sql* sql_handle;
+void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id)
+{
+ struct Sql *sql_handle;
AccountDB_SQL* db = (AccountDB_SQL*)self;
char* data;
int plen = 0;
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index 301d22c18..bec0217f4 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -49,7 +49,7 @@ static char ipban_codepage[32] = "";
static char ipban_table[32] = "ipbanlist";
// globals
-static Sql* sql_handle = NULL;
+static struct Sql *sql_handle = NULL;
static int cleanup_timer_id = INVALID_TIMER;
static bool ipban_inited = false;
diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c
index 356bba3b4..16accfada 100644
--- a/src/login/loginlog_sql.c
+++ b/src/login/loginlog_sql.c
@@ -47,7 +47,7 @@ static char log_db_database[32] = "";
static char log_codepage[32] = "";
static char log_login_db[256] = "loginlog";
-static Sql* sql_handle = NULL;
+static struct Sql *sql_handle = NULL;
static bool enabled = false;
diff --git a/src/map/log.c b/src/map/log.c
index 072f7b6fd..245229a15 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -119,8 +119,9 @@ bool should_log_item(int nameid, int amount, int refine, struct item_data *id) {
return false;
}
-void log_branch_sub_sql(struct map_session_data* sd) {
- SqlStmt* stmt;
+void log_branch_sub_sql(struct map_session_data* sd)
+{
+ struct SqlStmt *stmt;
nullpo_retv(sd);
stmt = SQL->StmtMalloc(logs->mysql_handle);
@@ -279,8 +280,9 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp)
logs->mvpdrop_sub(sd,monster_id,log_mvp);
}
-void log_atcommand_sub_sql(struct map_session_data* sd, const char* message) {
- SqlStmt* stmt;
+void log_atcommand_sub_sql(struct map_session_data* sd, const char* message)
+{
+ struct SqlStmt *stmt;
nullpo_retv(sd);
nullpo_retv(message);
@@ -322,8 +324,9 @@ void log_atcommand(struct map_session_data* sd, const char* message)
logs->atcommand_sub(sd,message);
}
-void log_npc_sub_sql(struct map_session_data *sd, const char *message) {
- SqlStmt* stmt;
+void log_npc_sub_sql(struct map_session_data *sd, const char *message)
+{
+ struct SqlStmt *stmt;
nullpo_retv(sd);
nullpo_retv(message);
@@ -379,7 +382,7 @@ void log_npc(struct map_session_data* sd, const char* message)
*/
void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char *dst_charname, const char *message)
{
- SqlStmt* stmt;
+ struct SqlStmt* stmt;
nullpo_retv(dst_charname);
nullpo_retv(message);
diff --git a/src/map/log.h b/src/map/log.h
index 69622adc6..0a5e13208 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -22,11 +22,11 @@
#define MAP_LOG_H
#include "common/hercules.h"
-#include "common/sql.h"
/**
* Declarations
**/
+struct Sql; // common/sql.h
struct item;
struct item_data;
struct map_session_data;
@@ -127,7 +127,7 @@ struct log_interface {
char db_id[32];
char db_pw[100];
char db_name[32];
- Sql* mysql_handle;
+ struct Sql *mysql_handle;
/* */
void (*pick_pc) (struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data);
void (*pick_mob) (struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data);
diff --git a/src/map/map.c b/src/map/map.c
index f2e47be74..a93fb3fd3 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -69,6 +69,7 @@
#include "common/random.h"
#include "common/showmsg.h"
#include "common/socket.h" // WFIFO*()
+#include "common/sql.h"
#include "common/strlib.h"
#include "common/timer.h"
#include "common/utils.h"
diff --git a/src/map/map.h b/src/map/map.h
index 54b0c3575..e61c64f2d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -27,11 +27,12 @@
#include "common/db.h"
#include "common/mapindex.h"
#include "common/mmo.h"
-#include "common/sql.h"
#include <stdio.h>
#include <stdarg.h>
+/* Forward Declarations */
+struct Sql; // common/sql.h
struct mob_data;
struct npc_data;
struct channel_data;
@@ -993,7 +994,7 @@ struct map_interface {
char server_id[32];
char server_pw[100];
char server_db[32];
- Sql* mysql_handle;
+ struct Sql *mysql_handle;
int port;
int users;
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index 46962ac14..f3ab36950 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -190,7 +190,7 @@ void script_load_mapreg(void) {
| varname | index | value |
+-------------------------+
*/
- SqlStmt* stmt = SQL->StmtMalloc(map->mysql_handle);
+ struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle);
char varname[SCRIPT_VARNAME_LENGTH+1];
int index;
char value[255+1];
diff --git a/src/map/npc.c b/src/map/npc.c
index 93981e312..7fad5dd7c 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -47,6 +47,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"
#include "common/utils.h"
@@ -1514,8 +1515,9 @@ int npc_buylist_sub(struct map_session_data *sd, struct itemlist *item_list, str
/**
* Loads persistent NPC Market Data from SQL
**/
-void npc_market_fromsql(void) {
- SqlStmt* stmt = SQL->StmtMalloc(map->mysql_handle);
+void npc_market_fromsql(void)
+{
+ struct SqlStmt *stmt = SQL->StmtMalloc(map->mysql_handle);
char name[NAME_LENGTH+1];
int itemid;
int amount;
diff --git a/src/map/pc.c b/src/map/pc.c
index e958f32b6..4b70a49f3 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -63,6 +63,7 @@
#include "common/random.h"
#include "common/showmsg.h"
#include "common/socket.h"
+#include "common/sql.h"
#include "common/strlib.h" // safestrncpy()
#include "common/sysinfo.h"
#include "common/timer.h"
diff --git a/src/map/script.c b/src/map/script.c
index 3482165f8..aeff221d4 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -63,6 +63,7 @@
#include "common/random.h"
#include "common/showmsg.h"
#include "common/socket.h" // usage: getcharip
+#include "common/sql.h"
#include "common/strlib.h"
#include "common/sysinfo.h"
#include "common/timer.h"
@@ -15932,7 +15933,7 @@ BUILDIN(setd)
return true;
}
-int buildin_query_sql_sub(struct script_state* st, Sql* handle)
+int buildin_query_sql_sub(struct script_state *st, struct Sql *handle)
{
int i, j;
struct map_session_data *sd = NULL;
diff --git a/src/map/script.h b/src/map/script.h
index b8e9d1997..e5a8d3edd 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -25,7 +25,6 @@
#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h" // struct item
-#include "common/sql.h" // Sql
#include "common/strlib.h" //StringBuf
#include <errno.h>
@@ -34,6 +33,7 @@
/**
* Declarations
**/
+struct Sql; // common/sql.h
struct eri;
struct item_data;
@@ -773,7 +773,7 @@ struct script_interface {
int (*playbgm_sub) (struct block_list *bl, va_list ap);
int (*playbgm_foreachpc_sub) (struct map_session_data *sd, va_list args);
int (*soundeffect_sub) (struct block_list *bl, va_list ap);
- int (*buildin_query_sql_sub) (struct script_state *st, Sql *handle);
+ int (*buildin_query_sql_sub) (struct script_state *st, struct Sql *handle);
int (*buildin_instance_warpall_sub) (struct block_list *bl, va_list ap);
int (*buildin_mobuseskill_sub) (struct block_list *bl, va_list ap);
int (*cleanfloor_sub) (struct block_list *bl, va_list ap);
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
index 86708ebbc..510a56e2c 100644
--- a/src/plugins/db2sql.c
+++ b/src/plugins/db2sql.c
@@ -25,6 +25,7 @@
#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
+#include "common/sql.h"
#include "common/strlib.h"
#include "map/battle.h"
#include "map/itemdb.h"