summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/login')
-rw-r--r--src/login/account_sql.c82
-rw-r--r--src/login/ipban_sql.c6
-rw-r--r--src/login/login.c26
3 files changed, 57 insertions, 57 deletions
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index d3a7aafff..14dd8ad9d 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -583,7 +583,7 @@ 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 = db->accounts;
- SqlStmt* stmt = SqlStmt_Malloc(sql_handle);
+ SqlStmt* stmt = SQL->StmtMalloc(sql_handle);
bool result = false;
int i;
@@ -599,48 +599,48 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
if( is_new )
{// insert into account table
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
"INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
db->account_db)
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 12, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
- || SQL_SUCCESS != SqlStmt_Execute(stmt)
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 5, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 9, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 10, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 11, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
}
} else {// update account table
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
- || SQL_SUCCESS != SqlStmt_Execute(stmt)
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 4, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 8, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 9, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 10, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 11, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
@@ -654,16 +654,16 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
break;
}
// insert new account regs
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , ? , ? );", db->accreg_db, acc->account_id) )
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , ? , ? );", db->accreg_db, acc->account_id) )
{
SqlStmt_ShowDebug(stmt);
break;
}
for( i = 0; i < acc->account_reg2_num; ++i )
{
- if( SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->account_reg2[i].str, strlen(acc->account_reg2[i].str))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->account_reg2[i].value, strlen(acc->account_reg2[i].value))
- || SQL_SUCCESS != SqlStmt_Execute(stmt)
+ if( SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)acc->account_reg2[i].str, strlen(acc->account_reg2[i].str))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->account_reg2[i].value, strlen(acc->account_reg2[i].value))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
@@ -682,7 +682,7 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
// finally
result &= ( SQL_SUCCESS == SQL->QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return result;
}
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index 701d3bc1d..fd9f1a4a1 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -86,8 +86,8 @@ void ipban_init(void)
if( login_config.ipban_cleanup_interval > 0 )
{ // set up periodic cleanup of connection history and active bans
- add_timer_func_list(ipban_cleanup, "ipban_cleanup");
- cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000);
+ iTimer->add_timer_func_list(ipban_cleanup, "ipban_cleanup");
+ cleanup_timer_id = iTimer->add_timer_interval(iTimer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000);
} else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups
ipban_cleanup(0,0,0,0);
}
@@ -100,7 +100,7 @@ void ipban_final(void)
if( login_config.ipban_cleanup_interval > 0 )
// release data
- delete_timer(cleanup_timer_id, ipban_cleanup);
+ iTimer->delete_timer(cleanup_timer_id, ipban_cleanup);
ipban_cleanup(0,0,0,0); // always clean up on login-server stop
diff --git a/src/login/login.c b/src/login/login.c
index 2bfb9c730..e8f136ba9 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -119,7 +119,7 @@ struct online_login_data* add_online_user(int char_server, int account_id)
p->char_server = char_server;
if( p->waiting_disconnect != INVALID_TIMER )
{
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
return p;
@@ -132,7 +132,7 @@ void remove_online_user(int account_id)
if( p == NULL )
return;
if( p->waiting_disconnect != INVALID_TIMER )
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
idb_remove(online_db, account_id);
}
@@ -161,7 +161,7 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap)
p->char_server = -1;
if( p->waiting_disconnect != INVALID_TIMER )
{
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
}
@@ -804,7 +804,7 @@ int parse_fromchar(int fd)
p->char_server = id;
if (p->waiting_disconnect != INVALID_TIMER)
{
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
}
@@ -913,12 +913,12 @@ int parse_fromchar(int fd)
int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) {
static int num_regs = 0; // registration counter
static unsigned int new_reg_tick = 0;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
struct mmo_account acc;
//Account Registration Flood Protection by [Kevin]
if( new_reg_tick == 0 )
- new_reg_tick = gettick();
+ new_reg_tick = iTimer->gettick();
if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) {
ShowNotice("Account registration denied (registration limit exceeded)\n");
return 3;
@@ -1162,7 +1162,7 @@ void login_auth_ok(struct login_session_data* sd)
WBUFL(buf,2) = sd->account_id;
charif_sendallwos(-1, buf, 6);
if( data->waiting_disconnect == INVALID_TIMER )
- data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
+ data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
@@ -1229,7 +1229,7 @@ void login_auth_ok(struct login_session_data* sd)
data = add_online_user(-1, sd->account_id);
// schedule deletion of this node
- data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
+ data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
}
}
@@ -1836,7 +1836,7 @@ int do_init(int argc, char** argv)
// Online user database init
online_db = idb_alloc(DB_OPT_RELEASE_DATA);
- add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer");
+ iTimer->add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer");
// Interserver auth init
auth_db = idb_alloc(DB_OPT_RELEASE_DATA);
@@ -1845,13 +1845,13 @@ int do_init(int argc, char** argv)
set_defaultparse(parse_login);
// every 10 minutes cleanup online account db.
- add_timer_func_list(online_data_cleanup, "online_data_cleanup");
- add_timer_interval(gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000);
+ iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup");
+ iTimer->add_timer_interval(iTimer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000);
// add timer to detect ip address change and perform update
if (login_config.ip_sync_interval) {
- add_timer_func_list(sync_ip_addresses, "sync_ip_addresses");
- add_timer_interval(gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval);
+ iTimer->add_timer_func_list(sync_ip_addresses, "sync_ip_addresses");
+ iTimer->add_timer_interval(iTimer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval);
}
// Account database init