summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c560
-rw-r--r--src/char/int_auction.c48
-rw-r--r--src/char/int_elemental.c54
-rw-r--r--src/char/int_guild.c284
-rw-r--r--src/char/int_homun.c90
-rw-r--r--src/char/int_mail.c124
-rw-r--r--src/char/int_mercenary.c70
-rw-r--r--src/char/int_party.c112
-rw-r--r--src/char/int_pet.c48
-rw-r--r--src/char/int_quest.c14
-rw-r--r--src/char/int_storage.c96
-rw-r--r--src/char/inter.c166
-rw-r--r--src/char/inter.h4
13 files changed, 834 insertions, 836 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 4c9182331..6bde6a976 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -246,8 +246,8 @@ void char_set_char_online(int map_id, int char_id, int account_id)
struct mmo_charstatus *cp;
//Update DB
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Check to see for online conflicts
character = (struct online_char_data*)idb_ensure(chr->online_char_db, account_id, chr->create_online_char_data);
@@ -286,8 +286,8 @@ void char_set_char_offline(int char_id, int account_id)
if ( char_id == -1 )
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
else
{
@@ -296,8 +296,8 @@ void char_set_char_offline(int char_id, int account_id)
if (cp)
idb_remove(chr->char_db_,char_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
if ((character = (struct online_char_data*)idb_get(chr->online_char_db, account_id)) != NULL)
@@ -391,12 +391,12 @@ void char_set_all_offline(int id)
void char_set_all_offline_sql(void)
{
//Set all players to 'OFFLINE'
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online` = '0'", guild_member_db) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) )
+ Sql_ShowDebug(inter->sql_handle);
}
/**
@@ -478,7 +478,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
if( p->show_equip )
opt |= OPT_SHOW_EQUIP;
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
@@ -499,15 +499,15 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
p->account_id, p->char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " status");
}
if( p->bank_vault != cp->bank_vault || p->mod_exp != cp->mod_exp || p->mod_drop != cp->mod_drop || p->mod_death != cp->mod_death ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`) VALUES ('%d','%d','%d','%d','%d')",account_data_db,p->account_id,p->bank_vault,p->mod_exp,p->mod_drop,p->mod_death) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`) VALUES ('%d','%d','%d','%d','%d')",account_data_db,p->account_id,p->bank_vault,p->mod_exp,p->mod_drop,p->mod_death) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " accdata");
@@ -523,7 +523,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->fame != cp->fame)
)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `class`='%d',"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `class`='%d',"
"`hair`='%d',`hair_color`='%d',`clothes_color`='%d',"
"`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d',"
"`karma`='%d',`manner`='%d', `fame`='%d'"
@@ -534,7 +534,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
p->karma, p->manner, p->fame,
p->account_id, p->char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " status2");
@@ -558,9 +558,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
char esc_mapname[NAME_LENGTH*2+1];
//`memo` (`memo_id`,`char_id`,`map`,`x`,`y`)
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -573,16 +573,16 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
{
if( count )
StrBuf->AppendStr(&buf, ",");
- SQL->EscapeString(sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map));
+ SQL->EscapeString(inter->sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map));
StrBuf->Printf(&buf, "('%d', '%s', '%d', '%d')", char_id, esc_mapname, p->memo_point[i].x, p->memo_point[i].y);
++count;
}
}
if( count )
{
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -592,8 +592,8 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
//skills
if( memcmp(p->skill, cp->skill, sizeof(p->skill)) ) {
//`skill` (`char_id`, `id`, `lv`)
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -617,9 +617,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
if( count )
{
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -638,9 +638,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
if(diff == 1)
{ //Save friends
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -658,9 +658,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
if( count )
{
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -682,9 +682,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
}
if(diff) {
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
} else
strcat(save_status, " hotkeys");
@@ -735,7 +735,7 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
@@ -796,9 +796,9 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl
StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id);
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -809,9 +809,9 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl
}
if( !found )
{// Item not present in inventory, remove it.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -844,9 +844,9 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl
StrBuf->AppendStr(&buf, ")");
}
- if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
+ if( found && SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -879,7 +879,7 @@ int char_inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
@@ -939,8 +939,8 @@ int char_inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id);
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -950,8 +950,8 @@ int char_inventory_to_sql(const struct item items[], int max, int id) {
}
}
if( !found ) {// Item not present in inventory, remove it.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", inventory_db, item.id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", inventory_db, item.id) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
}
@@ -983,8 +983,8 @@ int char_inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->AppendStr(&buf, ")");
}
- if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
- Sql_ShowDebug(sql_handle);
+ if( found && SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) ) {
+ Sql_ShowDebug(inter->sql_handle);
errors++;
}
@@ -1005,7 +1005,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
time_t unban_time = 0;
char sex[2];
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( stmt == NULL ) {
SqlStmt_ShowDebug(stmt);
return 0;
@@ -1124,7 +1124,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
if (save_log) ShowInfo("Char load request (%d)\n", char_id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( stmt == NULL )
{
SqlStmt_ShowDebug(stmt);
@@ -1466,30 +1466,30 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f
if( sd->found_char[to] > 0 ) {/* moving char to occupied slot */
bool result = false;
/* update both at once */
- if( SQL_SUCCESS != SQL->QueryStr(sql_handle, "START TRANSACTION")
- || SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, from, sd->found_char[to])
- || SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from]) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_SUCCESS != SQL->QueryStr(inter->sql_handle, "START TRANSACTION")
+ || SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, from, sd->found_char[to])
+ || SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from]) )
+ Sql_ShowDebug(inter->sql_handle);
else
result = true;
- if( SQL_ERROR == SQL->QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) {
+ Sql_ShowDebug(inter->sql_handle);
result = false;
}
if( !result )
return false;
} else {/* slot is free. */
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from] ) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from] ) ) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
}
/* update count */
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `slotchange`=`slotchange`-1 WHERE `char_id`='%d' LIMIT 1", char_db, from_id ) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `slotchange`=`slotchange`-1 WHERE `char_id`='%d' LIMIT 1", char_db, from_id ) ) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
@@ -1513,18 +1513,18 @@ int char_rename_char_sql(struct char_session_data *sd, int char_id)
if( char_dat.rename == 0 )
return 1;
- SQL->EscapeStringLen(sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH));
// check if the char exist
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 4;
}
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `name` = '%s', `rename` = '%d' WHERE `char_id` = '%d'", char_db, esc_name, --char_dat.rename, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `name` = '%s', `rename` = '%d' WHERE `char_id` = '%d'", char_db, esc_name, --char_dat.rename, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 3;
}
@@ -1538,11 +1538,11 @@ int char_rename_char_sql(struct char_session_data *sd, int char_id)
// log change
if( log_char )
{
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
"VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')",
charlog_db, "change char name", sd->account_id, char_dat.char_id, char_dat.slot, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
return 0;
@@ -1583,17 +1583,17 @@ int char_check_char_name(char * name, char * esc_name)
return -5;
}
if( name_ignoring_case ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) {
+ Sql_ShowDebug(inter->sql_handle);
return -2;
}
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) {
+ Sql_ShowDebug(inter->sql_handle);
return -2;
}
}
- if( SQL->NumRows(sql_handle) > 0 )
+ if( SQL->NumRows(inter->sql_handle) > 0 )
return -1; // name already exists
return 0;
@@ -1616,7 +1616,7 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
safestrncpy(name, name_, NAME_LENGTH);
normalize_name(name,TRIM_CHARS);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
flag = chr->check_char_name(name,esc_name);
if( flag < 0 )
@@ -1643,41 +1643,41 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
#if PACKETVER >= 20120307
//Insert the new char entry to the database
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `status_point`,`str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `status_point`,`str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
"`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES ("
"'%d', '%d', '%s', '%d', '%d','%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')",
char_db, sd->account_id , slot, esc_name, start_zeny, 48, str, agi, vit, int_, dex, luk,
(40 * (100 + vit)/100) , (40 * (100 + vit)/100 ), (11 * (100 + int_)/100), (11 * (100 + int_)/100), hair_style, hair_color,
mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return -2; //No, stop the procedure!
}
#else
//Insert the new char entry to the database
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
"`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES ("
"'%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d', '%d','%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d')",
char_db, sd->account_id , slot, esc_name, start_zeny, str, agi, vit, int_, dex, luk,
(40 * (100 + vit)/100) , (40 * (100 + vit)/100 ), (11 * (100 + int_)/100), (11 * (100 + int_)/100), hair_style, hair_color,
mapindex_id2name(start_point.map), start_point.x, start_point.y, mapindex_id2name(start_point.map), start_point.x, start_point.y) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return -2; //No, stop the procedure!
}
#endif
//Retrieve the newly auto-generated char id
- char_id = (int)SQL->LastInsertId(sql_handle);
+ char_id = (int)SQL->LastInsertId(inter->sql_handle);
if( !char_id )
return -2;
// Validation success, log result
if (log_char) {
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
"VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
charlog_db, "make new char", sd->account_id, char_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
//Give the char the default items
@@ -1685,21 +1685,21 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
// FIXME: How to define if an item is stackable without having to lookup itemdb? [panikon]
if( start_items[k+2] == 1 )
{
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')",
inventory_db, char_id, start_items[k], start_items[k + 1], 1) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
else if( start_items[k+2] == 0 )
{
// Non-stackable items should have their own entries (issue: 7279)
for( l = 0; l < start_items[k+1]; l++ )
{
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')",
inventory_db, char_id, start_items[k], 1, 1)
)
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -1715,10 +1715,10 @@ int char_divorce_char_sql(int partner_id1, int partner_id2)
{
unsigned char buf[64];
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) )
+ Sql_ShowDebug(inter->sql_handle);
WBUFW(buf,0) = 0x2b12;
WBUFL(buf,2) = partner_id1;
@@ -1742,30 +1742,30 @@ int char_delete_char_sql(int char_id)
char *data;
size_t len;
- if (SQL_ERROR == SQL->Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother`,`elemental_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id))
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother`,`elemental_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id))
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
ShowError("chr->delete_char_sql: Unable to fetch character data, deletion aborted.\n");
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return -1;
}
- SQL->GetData(sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 1, &data, NULL); account_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); party_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); father_id = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); party_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); base_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); hom_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); partner_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); father_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); mother_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL);
elemental_id = atoi(data);
- SQL->EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
- SQL->FreeResult(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, min(len, NAME_LENGTH));
+ SQL->FreeResult(inter->sql_handle);
//check for config char del condition [Lupus]
// TODO: Move this out to packet processing (0x68/0x1fb).
@@ -1785,10 +1785,10 @@ int char_delete_char_sql(int char_id)
{ // Char is Baby
unsigned char buf[64];
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `child`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, father_id, mother_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '410'AND (`char_id`='%d' OR `char_id`='%d')", skill_db, father_id, mother_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `child`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, father_id, mother_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '410'AND (`char_id`='%d' OR `char_id`='%d')", skill_db, father_id, mother_id) )
+ Sql_ShowDebug(inter->sql_handle);
WBUFW(buf,0) = 0x2b25;
WBUFL(buf,2) = father_id;
@@ -1803,14 +1803,14 @@ int char_delete_char_sql(int char_id)
/* delete char's pet */
//Delete the hatched pet if you have one...
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incubate` = '0'", pet_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incubate` = '0'", pet_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Delete all pets that are stored in eggs (inventory + cart)
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, inventory_db, inventory_db, char_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, cart_db, cart_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, inventory_db, inventory_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` JOIN `%s` ON `pet_id` = `card1`|`card2`<<16 WHERE `%s`.char_id = '%d' AND card0 = -256", pet_db, pet_db, cart_db, cart_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* remove homunculus */
if( hom_id )
@@ -1824,72 +1824,72 @@ int char_delete_char_sql(int char_id)
inter_mercenary->owner_delete(char_id);
/* delete char's friends list */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete char from other's friend list */
//NOTE: Won't this cause problems for people who are already online? [Skotlex]
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
#ifdef HOTKEY_SAVING
/* delete hotkeys */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
#endif
/* delete inventory */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete cart inventory */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete memo areas */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete character registry */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete skills */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
/* delete mails (only received) */
- if (SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `dest_id`='%d'", mail_db, char_id))
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `dest_id`='%d'", mail_db, char_id))
+ Sql_ShowDebug(inter->sql_handle);
#ifdef ENABLE_SC_SAVING
/* status changes */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, account_id, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
#endif
/* delete character */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
else if( log_char ) {
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `char_msg`, `name`)"
" VALUES (NOW(), '%d', '%d', '%d', 'Deleted character', '%s')",
charlog_db, account_id, char_id, 0, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
/* No need as we used inter_guild->leave [Skotlex]
// Also delete info from guildtables.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", guild_member_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
*/
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL->NumRows(sql_handle) > 0 )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL->NumRows(inter->sql_handle) > 0 )
mapif->parse_BreakGuild(0,guild_id);
else if( guild_id )
inter_guild->leave(guild_id, account_id, char_id);// Leave your guild.
@@ -2044,8 +2044,8 @@ void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) {
WFIFOL(fd, 4 + (24*c)) = 0;
/* also update on mysql */
sd->unban_time[i] = 0;
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `unban_time`='0' WHERE `char_id`='%d' LIMIT 1", char_db, sd->found_char[i]) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `unban_time`='0' WHERE `char_id`='%d' LIMIT 1", char_db, sd->found_char[i]) )
+ Sql_ShowDebug(inter->sql_handle);
}
c++;
}
@@ -2103,66 +2103,66 @@ int char_mmo_char_send_characters(int fd, struct char_session_data* sd)
int char_char_married(int pl1, int pl2)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if( pl2 == atoi(data) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 1;
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
int char_char_child(int parent_id, int child_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if( child_id == atoi(data) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 1;
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
int char_char_family(int cid1, int cid2, int cid3)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) )
- Sql_ShowDebug(sql_handle);
- else while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) )
+ Sql_ShowDebug(inter->sql_handle);
+ else while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
int charid;
int partnerid;
int childid;
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL); charid = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); partnerid = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); childid = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); charid = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); partnerid = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); childid = atoi(data);
if( (cid1 == charid && ((cid2 == partnerid && cid3 == childid ) || (cid2 == childid && cid3 == partnerid))) ||
(cid1 == partnerid && ((cid2 == charid && cid3 == childid ) || (cid2 == childid && cid3 == charid ))) ||
(cid1 == childid && ((cid2 == charid && cid3 == partnerid) || (cid2 == partnerid && cid3 == charid ))) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return childid;
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
@@ -2441,13 +2441,13 @@ int char_parse_fromlogin_changesex_reply(int fd)
node->sex = sex;
// get characters
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", char_db, acc) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
- SQL->GetData(sql_handle, 0, &data, NULL); char_id[i] = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); class_[i] = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); guild_id[i] = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); char_id[i] = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); class_[i] = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); guild_id[i] = atoi(data);
}
num = i;
for( i = 0; i < num; ++i )
@@ -2477,19 +2477,19 @@ int char_parse_fromlogin_changesex_reply(int fd)
class_[i] = (sex ? JOB_KAGEROU : JOB_OBORO);
}
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `equip`='0' WHERE `char_id`='%d'", inventory_db, char_id[i]) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `equip`='0' WHERE `char_id`='%d'", inventory_db, char_id[i]) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', "
"`head_bottom`='0' WHERE `char_id`='%d'",
char_db, class_[i], char_id[i]) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex]
inter_guild->sex_changed(guild_id[i], acc, char_id[i], sex);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
// disconnect player if online on char-server
chr->disconnect_player(acc);
@@ -2849,51 +2849,51 @@ void char_read_fame_list(void) {
memset(chemist_fame_list, 0, sizeof(chemist_fame_list));
memset(taekwon_fame_list, 0, sizeof(taekwon_fame_list));
// Build Blacksmith ranking list
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, JOB_MECHANIC, JOB_MECHANIC_T, JOB_BABY_MECHANIC, fame_list_size_smith) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_BLACKSMITH, JOB_WHITESMITH, JOB_BABY_BLACKSMITH, JOB_MECHANIC, JOB_MECHANIC_T, JOB_BABY_MECHANIC, fame_list_size_smith) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
// char_id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
smith_fame_list[i].id = atoi(data);
// fame
- SQL->GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(inter->sql_handle, 1, &data, &len);
smith_fame_list[i].fame = atoi(data);
// name
- SQL->GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(inter->sql_handle, 2, &data, &len);
memcpy(smith_fame_list[i].name, data, min(len, NAME_LENGTH));
}
// Build Alchemist ranking list
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, JOB_GENETIC, JOB_GENETIC_T, JOB_BABY_GENETIC, fame_list_size_chemist) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, JOB_GENETIC, JOB_GENETIC_T, JOB_BABY_GENETIC, fame_list_size_chemist) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
// char_id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
chemist_fame_list[i].id = atoi(data);
// fame
- SQL->GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(inter->sql_handle, 1, &data, &len);
chemist_fame_list[i].fame = atoi(data);
// name
- SQL->GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(inter->sql_handle, 2, &data, &len);
memcpy(chemist_fame_list[i].name, data, min(len, NAME_LENGTH));
}
// Build Taekwon ranking list
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) )
- Sql_ShowDebug(sql_handle);
- for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", char_db, JOB_TAEKWON, fame_list_size_taekwon) )
+ Sql_ShowDebug(inter->sql_handle);
+ for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
// char_id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
taekwon_fame_list[i].id = atoi(data);
// fame
- SQL->GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(inter->sql_handle, 1, &data, &len);
taekwon_fame_list[i].fame = atoi(data);
// name
- SQL->GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(inter->sql_handle, 2, &data, &len);
memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH));
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
// Send map-servers the fame ranking lists
@@ -2948,11 +2948,11 @@ int char_loadName(int char_id, char* name)
char* data;
size_t len;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
- SQL->GetData(sql_handle, 0, &data, &len);
+ SQL->GetData(inter->sql_handle, 0, &data, &len);
safestrncpy(name, data, NAME_LENGTH);
return 1;
}
@@ -2999,8 +2999,8 @@ void mapif_server_reset(int id)
WBUFW(buf,2) = j * 4 + 10;
mapif->sendallwos(fd, buf, WBUFW(buf,2));
}
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `index`='%d'", ragsrvinfo_db, server[id].fd) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `index`='%d'", ragsrvinfo_db, server[id].fd) )
+ Sql_ShowDebug(inter->sql_handle);
chr->online_char_db->foreach(chr->online_char_db,chr->db_setoffline,id); //Tag relevant chars as 'in disconnected' server.
mapif->server_destroy(id);
mapif->server_init(id);
@@ -3119,14 +3119,14 @@ void char_parse_frommap_map_names(int fd, int id)
void char_send_scdata(int fd, int aid, int cid)
{
#ifdef ENABLE_SC_SAVING
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
"FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
scdata_db, aid, cid) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return;
}
- if( SQL->NumRows(sql_handle) > 0 ) {
+ if( SQL->NumRows(inter->sql_handle) > 0 ) {
struct status_change_data scdata;
int count;
char* data;
@@ -3136,14 +3136,14 @@ void char_send_scdata(int fd, int aid, int cid)
WFIFOW(fd,0) = 0x2b1d;
WFIFOL(fd,4) = aid;
WFIFOL(fd,8) = cid;
- for( count = 0; count < 50 && SQL_SUCCESS == SQL->NextRow(sql_handle); ++count )
+ for( count = 0; count < 50 && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++count )
{
- SQL->GetData(sql_handle, 0, &data, NULL); scdata.type = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); scdata.type = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
}
if (count >= 50)
@@ -3154,8 +3154,8 @@ void char_send_scdata(int fd, int aid, int cid)
WFIFOSET(fd,WFIFOW(fd,2));
//Clear the data once loaded.
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
+ Sql_ShowDebug(inter->sql_handle);
}
} else { //no sc (needs a response)
WFIFOHEAD(fd,14);
@@ -3166,7 +3166,7 @@ void char_send_scdata(int fd, int aid, int cid)
WFIFOW(fd,12) = 0;
WFIFOSET(fd,WFIFOW(fd,2));
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
#endif
}
@@ -3371,9 +3371,9 @@ void char_parse_frommap_remove_friend(int fd)
{
int char_id = RFIFOL(fd,2);
int friend_id = RFIFOL(fd,6);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1",
friend_db, char_id, friend_id) ) {
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
RFIFOSKIP(fd,10);
}
@@ -3457,7 +3457,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(sql_handle);
+ SqlStmt* stmt = SQL->StmtMalloc(inter->sql_handle);
if (*unban_time == 0 || *unban_time < time(NULL))
timestamp = time(NULL); // new ban
@@ -3497,8 +3497,8 @@ void char_ban(int account_id, int char_id, time_t *unban_time, short year, short
void char_unban(int char_id, int *result)
{
/* handled by char server, so no redirection */
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `unban_time` = '0' WHERE `char_id` = '%d' LIMIT 1", char_db, char_id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `unban_time` = '0' WHERE `char_id` = '%d' LIMIT 1", char_db, char_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
*result = 1;
}
}
@@ -3530,23 +3530,23 @@ void char_parse_frommap_change_account(int fd)
short second = RFIFOW(fd,42);
RFIFOSKIP(fd,44);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`unban_time` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
- else if( SQL->NumRows(sql_handle) == 0 ) {
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`unban_time` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL->NumRows(inter->sql_handle) == 0 ) {
result = 1; // 1-player not found
- } else if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) {
- Sql_ShowDebug(sql_handle);
+ } else if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) ) {
+ Sql_ShowDebug(inter->sql_handle);
result = 1; // 1-player not found
} else {
int account_id, char_id;
char* data;
time_t unban_time;
- SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); unban_time = atol(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); unban_time = atol(data);
if( chr->login_fd <= 0 )
result = 3; // 3-login-server offline
@@ -3585,7 +3585,7 @@ void char_parse_frommap_change_account(int fd)
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
// send answer if a player ask, not if the server ask
if( acc != -1 && type != 5 ) { // Don't send answer for changesex
@@ -3650,12 +3650,12 @@ void char_parse_frommap_ragsrvinfo(int fd)
{
char esc_server_name[sizeof(server_name)*2+1];
- SQL->EscapeString(sql_handle, esc_server_name, server_name);
+ SQL->EscapeString(inter->sql_handle, esc_server_name, server_name);
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
ragsrvinfo_db, fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
RFIFOSKIP(fd,14);
}
@@ -3693,8 +3693,8 @@ void char_parse_frommap_save_status_change_data(int fd)
int count = RFIFOW(fd, 12);
/* clear; ensure no left overs e.g. permanent */
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
+ Sql_ShowDebug(inter->sql_handle);
if( count > 0 )
{
@@ -3712,8 +3712,8 @@ void char_parse_frommap_save_status_change_data(int fd)
StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
data.type, data.tick, data.val1, data.val2, data.val3, data.val4);
}
- if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
}
#endif
@@ -3871,10 +3871,10 @@ void char_parse_frommap_scdata_update(int fd)
int val4 = RFIFOL(fd, 24);
short type = RFIFOW(fd, 10);
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`) VALUES ('%d','%d','%d',-1,'%d','%d','%d','%d')",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`) VALUES ('%d','%d','%d',-1,'%d','%d','%d','%d')",
scdata_db, account_id, char_id, type, val1, val2, val3, val4) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
RFIFOSKIP(fd, 28);
}
@@ -3885,10 +3885,10 @@ void char_parse_frommap_scdata_delete(int fd)
int char_id = RFIFOL(fd, 6);
short type = RFIFOW(fd, 10);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id` = '%d' AND `type` = '%d' LIMIT 1",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id` = '%d' AND `type` = '%d' LIMIT 1",
scdata_db, account_id, char_id, type) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
RFIFOSKIP(fd, 12);
}
@@ -4270,14 +4270,14 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
return;
}
- if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
chr->delete2_ack(fd, char_id, 3, 0);
return;
}
- SQL->GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
if( delete_date ) {// character already queued for deletion
chr->delete2_ack(fd, char_id, 0, 0);
@@ -4289,16 +4289,16 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
// see issue: 7338
if( char_aegis_delete )
{
- if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id)
- || SQL_SUCCESS != SQL->NextRow(sql_handle)
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id)
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle)
)
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
chr->delete2_ack(fd, char_id, 3, 0);
return;
}
- SQL->GetData(sql_handle, 0, &data, NULL); party_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); party_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); guild_id = atoi(data);
if( guild_id )
{
@@ -4316,9 +4316,9 @@ static void char_delete2_req(int fd, struct char_session_data* sd)
// success
delete_date = time(NULL)+char_del_delay;
- if( SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
chr->delete2_ack(fd, char_id, 3, 0);
return;
}
@@ -4356,15 +4356,15 @@ static void char_delete2_accept(int fd, struct char_session_data* sd)
return;
}
- if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{// data error
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
chr->delete2_accept_ack(fd, char_id, 3);
return;
}
- SQL->GetData(sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10);
if( !delete_date || delete_date>time(NULL) )
{// not queued or delay not yet passed
@@ -4413,9 +4413,9 @@ static void char_delete2_cancel(int fd, struct char_session_data* sd)
// there is no need to check, whether or not the character was
// queued for deletion, as the client prints an error message by
// itself, if it was not the case (@see chr->delete2_cancel_ack)
- if( SQL_SUCCESS != SQL->Query(sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) )
+ if( SQL_SUCCESS != SQL->Query(inter->sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
chr->delete2_cancel_ack(fd, char_id, 2);
return;
}
@@ -4589,18 +4589,18 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
return;
}
- if ( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot)
- || SQL_SUCCESS != SQL->NextRow(sql_handle)
- || SQL_SUCCESS != SQL->GetData(sql_handle, 0, &data, NULL) )
+ if ( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot)
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle)
+ || SQL_SUCCESS != SQL->GetData(inter->sql_handle, 0, &data, NULL) )
{ //Not found?? May be forged packet.
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
chr->auth_error(fd, 0);
return;
}
char_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
/* client doesn't let it get to this point if you're banned, so its a forged packet */
if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
@@ -4625,11 +4625,11 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
if (log_char) {
char esc_name[NAME_LENGTH*2+1];
// FIXME: Why are we re-escaping the name if it was already escaped in rename/make_new_char? [Panikon]
- SQL->EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle,
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `name`) VALUES (NOW(), '%d', '%d', '%d', '%s')",
charlog_db, sd->account_id, cd->char_id, slot, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, char_dat.name);
@@ -4844,7 +4844,7 @@ void char_parse_char_rename_char(int fd, struct char_session_data* sd)
return;
normalize_name(name,TRIM_CHARS);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
if( !chr->check_char_name(name,esc_name) ) {
i = 1;
safestrncpy(sd->new_name, name, NAME_LENGTH);
@@ -4870,7 +4870,7 @@ void char_parse_char_rename_char2(int fd, struct char_session_data* sd)
return;
normalize_name(name,TRIM_CHARS);
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
if( !chr->check_char_name(name,esc_name) )
{
i = 1;
@@ -5814,8 +5814,8 @@ int do_final(void) {
do_final_mapif();
do_final_loginif();
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
+ Sql_ShowDebug(inter->sql_handle);
chr->char_db_->destroy(chr->char_db_, NULL);
chr->online_char_db->destroy(chr->online_char_db, NULL);
@@ -5828,7 +5828,7 @@ int do_final(void) {
HPM_char_do_final();
- SQL->Free(sql_handle);
+ SQL->Free(inter->sql_handle);
mapindex->final();
for(i = 0; i < MAX_MAP_SERVERS; i++ )
@@ -5871,7 +5871,7 @@ void do_shutdown(void)
}
void char_hp_symbols(void) {
- HPM->share(sql_handle,"sql_handle");
+ HPM->share(inter->sql_handle,"sql_handle");
}
int do_init(int argc, char **argv) {
@@ -5964,16 +5964,16 @@ int do_init(int argc, char **argv) {
//Cleaning the tables for NULL entries @ startup [Sirius]
//Chardb clean
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) )
+ Sql_ShowDebug(inter->sql_handle);
//guilddb clean
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_lv` = '0' AND `max_member` = '0' AND `exp` = '0' AND `next_exp` = '0' AND `average_lv` = '0'", guild_db) )
+ Sql_ShowDebug(inter->sql_handle);
//guildmemberdb clean
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) )
+ Sql_ShowDebug(inter->sql_handle);
set_defaultparse(chr->parse_char);
@@ -5982,9 +5982,9 @@ int do_init(int argc, char **argv) {
exit(EXIT_FAILURE);
}
- Sql_HerculesUpdateCheck(sql_handle);
+ Sql_HerculesUpdateCheck(inter->sql_handle);
#ifdef CONSOLE_INPUT
- console->input->setSQL(sql_handle);
+ console->input->setSQL(inter->sql_handle);
#endif
ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port);
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index d85c10522..684faa46b 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -57,7 +57,7 @@ void inter_auction_save(struct auction_data *auction)
StrBuf->Printf(&buf, ", `card%d` = '%d'", j, auction->item.card[j]);
StrBuf->Printf(&buf, " WHERE `auction_id` = '%d'", auction->auction_id);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
@@ -92,7 +92,7 @@ unsigned int inter_auction_create(struct auction_data *auction)
StrBuf->Printf(&buf, ",'%d'", auction->item.card[j]);
StrBuf->AppendStr(&buf, ")");
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
@@ -162,8 +162,8 @@ void inter_auction_delete(struct auction_data *auction)
{
unsigned int auction_id = auction->auction_id;
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
+ Sql_ShowDebug(inter->sql_handle);
if( auction->auction_end_timer != INVALID_TIMER )
timer->delete(auction->auction_end_timer, inter_auction->end_timer);
@@ -188,32 +188,32 @@ void inter_auctions_fromsql(void)
StrBuf->Printf(&buf, ",`card%d`", i);
StrBuf->Printf(&buf, " FROM `%s` ORDER BY `auction_id` DESC", auction_db);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
CREATE(auction, struct auction_data, 1);
- SQL->GetData(sql_handle, 0, &data, NULL); auction->auction_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); auction->seller_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 5, &data, NULL); auction->price = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); auction->buynow = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); auction->hours = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); auction->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); auction->auction_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); auction->seller_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); auction->price = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); auction->buynow = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); auction->hours = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); auction->timestamp = atoi(data);
item = &auction->item;
- SQL->GetData(sql_handle, 9, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH);
- SQL->GetData(sql_handle,11, &data, NULL); auction->type = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); auction->type = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
item->identify = 1;
item->amount = 1;
@@ -221,7 +221,7 @@ void inter_auctions_fromsql(void)
for( i = 0; i < MAX_SLOTS; i++ )
{
- SQL->GetData(sql_handle, 15 + i, &data, NULL);
+ SQL->GetData(inter->sql_handle, 15 + i, &data, NULL);
item->card[i] = atoi(data);
}
@@ -234,7 +234,7 @@ void inter_auctions_fromsql(void)
idb_put(inter_auction->db, auction->auction_id, auction);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf)
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index d54a13320..3f8e7b190 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -27,24 +27,24 @@ bool mapif_elemental_save(struct s_elemental* ele) {
bool flag = true;
if( ele->elemental_id == 0 ) { // Create new DB entry
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)"
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')",
elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
- ele->elemental_id = (int)SQL->LastInsertId(sql_handle);
- } else if( SQL_ERROR == SQL->Query(sql_handle,
+ ele->elemental_id = (int)SQL->LastInsertId(inter->sql_handle);
+ } else if( SQL_ERROR == SQL->Query(inter->sql_handle,
"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d',"
"`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d',"
"`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'",
elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2,
ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) )
{ // Update DB entry
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
return flag;
@@ -57,36 +57,36 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
ele->elemental_id = ele_id;
ele->char_id = char_id;
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`,"
"`def`, `mdef`, `flee`, `hit`, `life_time` FROM `%s` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
elemental_db, ele_id, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) {
- SQL->FreeResult(sql_handle);
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) ) {
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- SQL->GetData(sql_handle, 0, &data, NULL); ele->class_ = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); ele->mode = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); ele->hp = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); ele->sp = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); ele->max_hp = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); ele->max_sp = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); ele->atk = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); ele->atk2 = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); ele->matk = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); ele->amotion = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); ele->def = atoi(data);
- SQL->GetData(sql_handle, 11, &data, NULL); ele->mdef = atoi(data);
- SQL->GetData(sql_handle, 12, &data, NULL); ele->flee = atoi(data);
- SQL->GetData(sql_handle, 13, &data, NULL); ele->hit = atoi(data);
- SQL->GetData(sql_handle, 14, &data, NULL); ele->life_time = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); ele->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); ele->mode = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); ele->hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); ele->sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); ele->max_hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); ele->max_sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); ele->atk = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); ele->atk2 = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); ele->matk = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); ele->amotion = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); ele->def = atoi(data);
+ SQL->GetData(inter->sql_handle, 11, &data, NULL); ele->mdef = atoi(data);
+ SQL->GetData(inter->sql_handle, 12, &data, NULL); ele->flee = atoi(data);
+ SQL->GetData(inter->sql_handle, 13, &data, NULL); ele->hit = atoi(data);
+ SQL->GetData(inter->sql_handle, 14, &data, NULL); ele->life_time = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id);
@@ -94,8 +94,8 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
}
bool mapif_elemental_delete(int ele_id) {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) {
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 6f98d81b5..9817f912d 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -83,10 +83,10 @@ int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) {
int inter_guild_removemember_tosql(int account_id, int char_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -120,8 +120,8 @@ int inter_guild_tosql(struct guild *g,int flag)
ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag);
#endif
- SQL->EscapeStringLen(sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH));
- SQL->EscapeStringLen(sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_master, g->master, strnlen(g->master, NAME_LENGTH));
*t_info = '\0';
// Insert a new guild the guild
@@ -130,18 +130,18 @@ int inter_guild_tosql(struct guild *g,int flag)
strcat(t_info, " guild_create");
// Create a new guild
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) "
"VALUES ('%s', '%s', '%d', '%d', '%d', '%d')",
guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
if (g->guild_id == -1)
return 0; //Failed to create guild!
}
else
{
- g->guild_id = (int)SQL->LastInsertId(sql_handle);
+ g->guild_id = (int)SQL->LastInsertId(inter->sql_handle);
new_guild = 1;
}
}
@@ -199,8 +199,8 @@ int inter_guild_tosql(struct guild *g,int flag)
StrBuf->AppendStr(&buf, ", ");
else
add_comma = true;
- SQL->EscapeStringLen(sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1)));
- SQL->EscapeStringLen(sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2)));
+ SQL->EscapeStringLen(inter->sql_handle, esc_mes1, g->mes1, strnlen(g->mes1, sizeof(g->mes1)));
+ SQL->EscapeStringLen(inter->sql_handle, esc_mes2, g->mes2, strnlen(g->mes2, sizeof(g->mes2)));
StrBuf->Printf(&buf, "`mes1`='%s', `mes2`='%s'", esc_mes1, esc_mes2);
}
if (flag & GS_LEVEL)
@@ -213,8 +213,8 @@ int inter_guild_tosql(struct guild *g,int flag)
StrBuf->Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member);
}
StrBuf->Printf(&buf, " WHERE `guild_id`=%d", g->guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "%s", StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "%s", StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
}
@@ -230,18 +230,18 @@ int inter_guild_tosql(struct guild *g,int flag)
continue;
if(m->account_id) {
//Since nothing references guild member table as foreign keys, it's safe to use REPLACE INTO
- SQL->EscapeStringLen(sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) "
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) "
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%"PRIu64"','%d','%d','%d','%s')",
guild_member_db, g->guild_id, m->account_id, m->char_id,
m->hair, m->hair_color, m->gender,
m->class_, m->lv, m->exp, m->exp_payper, m->online, m->position, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
if (m->modified&GS_MEMBER_NEW || new_guild == 1)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'",
char_db, g->guild_id, m->char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
m->modified = GS_MEMBER_UNMODIFIED;
}
@@ -255,10 +255,10 @@ int inter_guild_tosql(struct guild *g,int flag)
struct guild_position *p = &g->position[i];
if (!p->modified)
continue;
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')",
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')",
guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
p->modified = GS_POSITION_UNMODIFIED;
}
}
@@ -269,10 +269,10 @@ int inter_guild_tosql(struct guild *g,int flag)
// NOTE: no need to do it on both sides since both guilds in memory had
// their info changed, not to mention this would also mess up oppositions!
// [Skotlex]
- //if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) )
+ //if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
else
{
@@ -282,11 +282,11 @@ int inter_guild_tosql(struct guild *g,int flag)
struct guild_alliance *a=&g->alliance[i];
if(a->guild_id>0)
{
- SQL->EscapeStringLen(sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) "
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) "
"VALUES ('%d','%d','%d','%s')",
guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -300,11 +300,11 @@ int inter_guild_tosql(struct guild *g,int flag)
if(e->account_id>0){
char esc_mes[sizeof(e->mes)*2+1];
- SQL->EscapeStringLen(sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH));
- SQL->EscapeStringLen(sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes)));
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) "
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes)));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) "
"VALUES ('%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -314,9 +314,9 @@ int inter_guild_tosql(struct guild *g,int flag)
//printf("- Insert guild %d to guild_skill\n",g->guild_id);
for(i=0;i<MAX_GUILDSKILL;i++){
if (g->skill[i].id>0 && g->skill[i].lv>0){
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -346,38 +346,38 @@ struct guild * inter_guild_fromsql(int guild_id)
ShowInfo("Guild load request (%d)...\n", guild_id);
#endif
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` "
"FROM `%s` g LEFT JOIN `%s` c ON c.`char_id` = g.`char_id` WHERE g.`guild_id`='%d'", guild_db, char_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return NULL;// Guild does not exists.
CREATE(g, struct guild, 1);
g->guild_id = guild_id;
- SQL->GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); g->guild_lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); g->connect_member = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); g->max_member = atoi(data);
if( g->max_member > MAX_GUILD )
{ // Fix reduction of MAX_GUILD [PoW]
ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->name, g->max_member, MAX_GUILD);
g->max_member = MAX_GUILD;
}
- SQL->GetData(sql_handle, 5, &data, NULL); g->average_lv = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10);
- SQL->GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data);
- SQL->GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1)));
- SQL->GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2)));
- SQL->GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data);
- SQL->GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data);
- SQL->GetData(sql_handle, 13, &data, &len);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); g->average_lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); g->skill_point = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1)));
+ SQL->GetData(inter->sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2)));
+ SQL->GetData(inter->sql_handle, 11, &data, &len); g->emblem_len = atoi(data);
+ SQL->GetData(inter->sql_handle, 12, &data, &len); g->emblem_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 13, &data, &len);
// convert emblem data from hexadecimal to binary
//TODO: why not store it in the db as binary directly? [ultramage]
for( i = 0, p = g->emblem_data; i < g->emblem_len; ++i, ++p )
@@ -401,92 +401,92 @@ struct guild * inter_guild_fromsql(int guild_id)
}
// load guild member info
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` "
"FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for( i = 0; i < g->max_member && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < g->max_member && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
struct guild_member* m = &g->member[i];
- SQL->GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); m->hair = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); m->hair_color = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); m->gender = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); m->class_ = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); m->lv = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); m->exp = strtoull(data, NULL, 10);
- SQL->GetData(sql_handle, 8, &data, NULL); m->exp_payper = (unsigned int)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); m->online = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); m->position = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); m->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); m->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); m->hair = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); m->hair_color = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); m->gender = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); m->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); m->lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); m->exp = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); m->exp_payper = (unsigned int)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); m->online = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); m->position = atoi(data);
if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW]
m->position = MAX_GUILDPOSITION - 1;
- SQL->GetData(sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
m->modified = GS_MEMBER_UNMODIFIED;
}
//printf("- Read guild_position %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
int position;
struct guild_position *pos;
- SQL->GetData(sql_handle, 0, &data, NULL); position = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); position = atoi(data);
if( position < 0 || position >= MAX_GUILDPOSITION )
continue;// invalid position
pos = &g->position[position];
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(pos->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); pos->mode = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); pos->exp_mode = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(pos->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); pos->mode = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); pos->exp_mode = atoi(data);
pos->modified = GS_POSITION_UNMODIFIED;
}
//printf("- Read guild_alliance %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_GUILDALLIANCE && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
struct guild_alliance* a = &g->alliance[i];
- SQL->GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); a->opposition = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH));
}
//printf("- Read guild_expulsion %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
- for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_GUILDEXPULSION && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
struct guild_expulsion *e = &g->expulsion[i];
- SQL->GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); e->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
}
//printf("- Read guild_skill %d from sql \n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
aFree(g);
return NULL;
}
@@ -496,15 +496,15 @@ struct guild * inter_guild_fromsql(int guild_id)
g->skill[i].id = i + GD_SKILLBASE;
}
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
int id;
- SQL->GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE;
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE;
if( id < 0 || id >= MAX_GUILDSKILL )
continue;// invalid guild skill
- SQL->GetData(sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
idb_put(inter_guild->guild_db, guild_id, g); //Add to cache
g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long.
@@ -529,8 +529,8 @@ int inter_guild_castle_tosql(struct guild_castle *gc)
for (i = 0; i < MAX_GUARDIANS; ++i)
StrBuf->Printf(&buf, ", `visibleG%d`='%d'", i, gc->guardian[i].visible);
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)))
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)))
+ Sql_ShowDebug(inter->sql_handle);
else if(save_log)
ShowInfo("Saved guild castle (%d)\n", gc->castle_id);
@@ -555,8 +555,8 @@ struct guild_castle* inter_guild_castle_fromsql(int castle_id)
for (i = 0; i < MAX_GUARDIANS; ++i)
StrBuf->Printf(&buf, ", `visibleG%d`", i);
StrBuf->Printf(&buf, " FROM `%s` WHERE `castle_id`='%d'", guild_castle_db, castle_id);
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))) {
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return NULL;
}
@@ -565,21 +565,21 @@ struct guild_castle* inter_guild_castle_fromsql(int castle_id)
CREATE(gc, struct guild_castle, 1);
gc->castle_id = castle_id;
- if (SQL_SUCCESS == SQL->NextRow(sql_handle)) {
- SQL->GetData(sql_handle, 1, &data, NULL); gc->guild_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); gc->economy = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); gc->defense = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); gc->triggerE = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); gc->triggerD = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); gc->nextTime = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); gc->payTime = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); gc->createTime = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); gc->visibleC = atoi(data);
+ if (SQL_SUCCESS == SQL->NextRow(inter->sql_handle)) {
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); gc->guild_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); gc->economy = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); gc->defense = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); gc->triggerE = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); gc->triggerD = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); gc->nextTime = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); gc->payTime = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); gc->createTime = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); gc->visibleC = atoi(data);
for (i = 10; i < 10+MAX_GUARDIANS; i++) {
- SQL->GetData(sql_handle, i, &data, NULL); gc->guardian[i-10].visible = atoi(data);
+ SQL->GetData(inter->sql_handle, i, &data, NULL); gc->guardian[i-10].visible = atoi(data);
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
idb_put(inter_guild->castle_db, castle_id, gc);
@@ -610,24 +610,24 @@ int inter_guild_CharOnline(int char_id, int guild_id) {
if (guild_id == -1) {
//Get guild_id from the database
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
guild_id = atoi(data);
}
else
{
guild_id = 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (guild_id == 0)
return 0; //No guild...
@@ -661,24 +661,24 @@ int inter_guild_CharOffline(int char_id, int guild_id)
if (guild_id == -1)
{
//Get guild_id from the database
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
guild_id = atoi(data);
}
else
{
guild_id = 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (guild_id == 0)
return 0; //No guild...
@@ -749,26 +749,26 @@ int inter_guild_search_guildname(char *str)
int guild_id;
char esc_name[NAME_LENGTH*2+1];
- SQL->EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
//Lookup guilds with the same name
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return -1;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
guild_id = atoi(data);
}
else
{
guild_id = 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return guild_id;
}
@@ -1257,8 +1257,8 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
if( g == NULL )
{
// Unknown guild, just update the player
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
// mapif->guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
return 0;
}
@@ -1370,33 +1370,33 @@ int mapif_parse_BreakGuild(int fd, int guild_id)
// Delete guild from sql
//printf("- Delete guild %d from guild\n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
//printf("- Update guild %d of char\n",guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
mapif->guild_broken(guild_id,0);
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index 191789c06..d3cc1c46c 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -95,31 +95,31 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
bool flag = true;
char esc_name[NAME_LENGTH*2+1];
- SQL->EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
if( hd->hom_id == 0 )
{// new homunculus
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`char_id`, `class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) "
"VALUES ('%d', '%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
{
- hd->hom_id = (int)SQL->LastInsertId(sql_handle);
+ hd->hom_id = (int)SQL->LastInsertId(inter->sql_handle);
}
}
else
{
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
@@ -127,7 +127,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
SqlStmt* stmt;
int i;
- stmt = SQL->StmtMalloc(sql_handle);
+ 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);
for( i = 0; i < MAX_HOMUNSKILL; ++i )
@@ -161,61 +161,61 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
memset(hd, 0, sizeof(*hd));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `homun_id`,`char_id`,`class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( !SQL->NumRows(sql_handle) )
+ if( !SQL->NumRows(inter->sql_handle) )
{ //No homunculus found.
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
hd->hom_id = homun_id;
- SQL->GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); hd->prev_class = atoi(data);
- SQL->GetData(sql_handle, 4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
- SQL->GetData(sql_handle, 5, &data, NULL); hd->level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); hd->exp = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 8, &data, NULL); hd->hunger = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); hd->str = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); hd->agi = atoi(data);
- SQL->GetData(sql_handle, 11, &data, NULL); hd->vit = atoi(data);
- SQL->GetData(sql_handle, 12, &data, NULL); hd->int_ = atoi(data);
- SQL->GetData(sql_handle, 13, &data, NULL); hd->dex = atoi(data);
- SQL->GetData(sql_handle, 14, &data, NULL); hd->luk = atoi(data);
- SQL->GetData(sql_handle, 15, &data, NULL); hd->hp = atoi(data);
- SQL->GetData(sql_handle, 16, &data, NULL); hd->max_hp = atoi(data);
- SQL->GetData(sql_handle, 17, &data, NULL); hd->sp = atoi(data);
- SQL->GetData(sql_handle, 18, &data, NULL); hd->max_sp = atoi(data);
- SQL->GetData(sql_handle, 19, &data, NULL); hd->skillpts = atoi(data);
- SQL->GetData(sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data);
- SQL->GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); hd->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); hd->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); hd->prev_class = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); hd->level = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); hd->exp = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); hd->hunger = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); hd->str = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); hd->agi = atoi(data);
+ SQL->GetData(inter->sql_handle, 11, &data, NULL); hd->vit = atoi(data);
+ SQL->GetData(inter->sql_handle, 12, &data, NULL); hd->int_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 13, &data, NULL); hd->dex = atoi(data);
+ SQL->GetData(inter->sql_handle, 14, &data, NULL); hd->luk = atoi(data);
+ SQL->GetData(inter->sql_handle, 15, &data, NULL); hd->hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 16, &data, NULL); hd->max_hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 17, &data, NULL); hd->sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 18, &data, NULL); hd->max_sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 19, &data, NULL); hd->skillpts = atoi(data);
+ SQL->GetData(inter->sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data);
+ SQL->GetData(inter->sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
hd->intimacy = cap_value(hd->intimacy, 0, 100000);
hd->hunger = cap_value(hd->hunger, 0, 100);
// Load Homunculus Skill
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- while( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
// id
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
i = atoi(data);
if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL )
continue;// invalid skill id
@@ -223,10 +223,10 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
hd->hskill[i].id = (unsigned short)atoi(data);
// lv
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
hd->hskill[i].lv = (unsigned char)atoi(data);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name);
@@ -236,10 +236,10 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
bool mapif_homunculus_delete(int homun_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id)
- || SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id)
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id)
+ || SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id)
) {
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
return true;
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index 4bbac9855..c400ea01f 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -45,45 +45,45 @@ static int inter_mail_fromsql(int char_id, struct mail_data* md)
StrBuf->Printf(&buf, " FROM `%s` WHERE `dest_id`='%d' AND `status` < 3 ORDER BY `id` LIMIT %d",
mail_db, char_id, MAIL_MAX_INBOX + 1);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
msg = &md->msg[i];
- SQL->GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
- SQL->GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
- SQL->GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); msg->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
item = &msg->item;
- SQL->GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
- SQL->GetData(sql_handle,11, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle,15, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle,15, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
item->expire_time = 0;
item->bound = 0;
for (j = 0; j < MAX_SLOTS; j++)
{
- SQL->GetData(sql_handle, 16 + j, &data, NULL);
+ SQL->GetData(inter->sql_handle, 16 + j, &data, NULL);
item->card[j] = atoi(data);
}
}
- md->full = ( SQL->NumRows(sql_handle) > MAIL_MAX_INBOX );
+ md->full = ( SQL->NumRows(inter->sql_handle) > MAIL_MAX_INBOX );
md->amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
md->unchecked = 0;
md->unread = 0;
@@ -92,8 +92,8 @@ static int inter_mail_fromsql(int char_id, struct mail_data* md)
msg = &md->msg[i];
if( msg->status == MAIL_NEW )
{
- if ( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
- Sql_ShowDebug(sql_handle);
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
+ Sql_ShowDebug(inter->sql_handle);
msg->status = MAIL_UNREAD;
md->unchecked++;
@@ -126,7 +126,7 @@ int inter_mail_savemessage(struct mail_message* msg)
StrBuf->AppendStr(&buf, ")");
// prepare and execute query
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH))
@@ -160,11 +160,11 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg)
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `id` = '%d'", mail_db, mail_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))
- || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
@@ -172,34 +172,34 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg)
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
- SQL->GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
- SQL->GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
- SQL->GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
- SQL->GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); msg->item.refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); msg->item.attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); msg->item.identify = atoi(data);
- SQL->GetData(sql_handle,15, &data, NULL); msg->item.unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); msg->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); msg->item.refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); msg->item.attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); msg->item.identify = atoi(data);
+ SQL->GetData(inter->sql_handle,15, &data, NULL); msg->item.unique_id = strtoull(data, NULL, 10);
msg->item.expire_time = 0;
msg->item.bound = 0;
for( j = 0; j < MAX_SLOTS; j++ )
{
- SQL->GetData(sql_handle,16 + j, &data, NULL);
+ SQL->GetData(inter->sql_handle,16 + j, &data, NULL);
msg->item.card[j] = atoi(data);
}
}
StrBuf->Destroy(&buf);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return true;
}
@@ -235,8 +235,8 @@ void mapif_parse_mail_requestinbox(int fd)
void mapif_parse_mail_read(int fd)
{
int mail_id = RFIFOL(fd,2);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
/*==========================================
@@ -253,9 +253,9 @@ static bool inter_mail_DeleteAttach(int mail_id)
StrBuf->Printf(&buf, ", `card%d` = '0'", i);
StrBuf->Printf(&buf, " WHERE `id` = '%d'", mail_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
@@ -322,9 +322,9 @@ void mapif_parse_mail_delete(int fd)
int char_id = RFIFOL(fd,2);
int mail_id = RFIFOL(fd,6);
bool failed = false;
- if ( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
failed = true;
}
mapif->mail_delete(fd, char_id, mail_id, failed);
@@ -372,8 +372,8 @@ void mapif_parse_mail_return(int fd)
{
if( msg.dest_id != char_id)
return;
- else if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
- Sql_ShowDebug(sql_handle);
+ else if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
+ Sql_ShowDebug(inter->sql_handle);
else
{
char temp_[MAIL_TITLE_LENGTH];
@@ -426,21 +426,21 @@ void mapif_parse_mail_send(int fd)
memcpy(&msg, RFIFOP(fd,8), sizeof(struct mail_message));
// Try to find the Dest Char by Name
- SQL->EscapeStringLen(sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
else
- if ( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char *data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if (atoi(data) != account_id)
{ // Cannot send mail to char in the same account
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
msg.dest_id = atoi(data);
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
msg.status = MAIL_NEW;
if( msg.dest_id > 0 )
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index 3fd01b3f6..0e91b6785 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -27,36 +27,36 @@ bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
{
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- SQL->GetData(sql_handle, 0, &data, NULL); status->mer_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); status->arch_calls = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); status->arch_faith = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); status->spear_calls = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); status->spear_faith = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); status->sword_calls = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); status->sword_faith = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); status->mer_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); status->arch_calls = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); status->arch_faith = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); status->spear_calls = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); status->spear_faith = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); status->sword_calls = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); status->sword_faith = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
return true;
}
bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
mercenary_owner_db, char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
@@ -65,11 +65,11 @@ bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
bool inter_mercenary_owner_delete(int char_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
return true;
}
@@ -80,21 +80,21 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
if( merc->mercenary_id == 0 )
{ // Create new DB entry
- if( SQL_ERROR == SQL->Query(sql_handle,
+ if( SQL_ERROR == SQL->Query(inter->sql_handle,
"INSERT INTO `%s` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')",
mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
else
- merc->mercenary_id = (int)SQL->LastInsertId(sql_handle);
+ merc->mercenary_id = (int)SQL->LastInsertId(inter->sql_handle);
}
- else if( SQL_ERROR == SQL->Query(sql_handle,
+ else if( SQL_ERROR == SQL->Query(inter->sql_handle,
"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'",
mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) )
{ // Update DB entry
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
flag = false;
}
@@ -109,24 +109,24 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
merc->mercenary_id = merc_id;
merc->char_id = char_id;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", mercenary_db, merc_id, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", mercenary_db, merc_id, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return false;
}
- SQL->GetData(sql_handle, 0, &data, NULL); merc->class_ = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); merc->hp = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); merc->sp = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); merc->kill_count = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); merc->life_time = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); merc->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); merc->hp = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); merc->sp = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); merc->kill_count = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); merc->life_time = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id);
@@ -135,9 +135,9 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
bool mapif_mercenary_delete(int merc_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 269a64a8a..c86ff8c44 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -116,15 +116,15 @@ int inter_party_tosql(struct party *p, int flag, int index)
#ifdef NOISY
ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name);
#endif
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
if( flag & PS_BREAK )
{// Break the party
// we'll skip name-checking and just reset everyone with the same party id [celest]
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(sql_handle);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
//Remove from memory
idb_remove(inter_party->db, party_id);
return 1;
@@ -132,43 +132,43 @@ int inter_party_tosql(struct party *p, int flag, int index)
if( flag & PS_CREATE )
{// Create party
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`name`, `exp`, `item`, `leader_id`, `leader_char`) "
"VALUES ('%s', '%d', '%d', '%d', '%d')",
party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- party_id = p->party_id = (int)SQL->LastInsertId(sql_handle);
+ party_id = p->party_id = (int)SQL->LastInsertId(inter->sql_handle);
}
if( flag & PS_BASIC )
{// Update party info.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
party_db, esc_name, p->exp, p->item, party_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_LEADER )
{// Update leader
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
party_db, p->member[index].account_id, p->member[index].char_id, party_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_ADDMEMBER )
{// Add one party member.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( flag & PS_DELMEMBER )
{// Remove one party member.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
if( save_log )
@@ -201,42 +201,42 @@ struct party_data *inter_party_fromsql(int party_id)
p = inter_party->pt;
memset(p, 0, sizeof(struct party_data));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return NULL;
p->party.party_id = party_id;
- SQL->GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
- SQL->GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); p->party.item = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); leader_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); leader_char = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
// Load members
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return NULL;
}
- for( i = 0; i < MAX_PARTY && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_PARTY && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
m = &p->party.member[i];
- SQL->GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data);
- SQL->GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
- SQL->GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); m->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); m->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); m->lv = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); m->class_ = atoi(data);
m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0);
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
if( save_log )
ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name);
@@ -261,9 +261,9 @@ int inter_party_sql_init(void)
/* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex]
ShowStatus("cleaning party table...\n");
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) )
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
*/
return 0;
}
@@ -282,14 +282,14 @@ struct party_data* inter_party_search_partyname(const char *const str)
char* data;
struct party_data* p = NULL;
- SQL->EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
- Sql_ShowDebug(sql_handle);
- else if( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
p = inter_party->fromsql(atoi(data));
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return p;
}
@@ -587,8 +587,8 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
p = inter_party->fromsql(party_id);
if( p == NULL )
{// Party does not exists?
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -772,18 +772,18 @@ int inter_party_CharOnline(int char_id, int party_id)
{// Get party_id from the database
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return 0; //Eh? No party?
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (party_id == 0)
return 0; //No party...
@@ -818,18 +818,18 @@ int inter_party_CharOffline(int char_id, int party_id) {
{// Get guild_id from the database
char* data;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
return 0; //Eh? No party?
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
party_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
if (party_id == 0)
return 0; //No party...
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 1118baa80..7723075d4 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -29,30 +29,30 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
char esc_name[NAME_LENGTH*2+1];// escaped pet name
- SQL->EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
p->hungry = cap_value(p->hungry, 0, 100);
p->intimate = cap_value(p->intimate, 0, 1000);
if( pet_id == -1 )
{// New pet.
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`) "
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- p->pet_id = (int)SQL->LastInsertId(sql_handle);
+ p->pet_id = (int)SQL->LastInsertId(inter->sql_handle);
}
else
{// Update pet.
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d' WHERE `pet_id`='%d'",
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d' WHERE `pet_id`='%d'",
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate, p->pet_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
}
@@ -74,28 +74,28 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
- if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
p->pet_id = pet_id;
- SQL->GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data);
- SQL->GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
- SQL->GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); p->level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data);
- SQL->GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
- SQL->GetData(sql_handle, 11, &data, NULL); p->incubate = atoi(data);
-
- SQL->FreeResult(sql_handle);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); p->class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); p->account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); p->char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); p->level = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); p->equip = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); p->intimate = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); p->hungry = atoi(data);
+ SQL->GetData(inter->sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
+ SQL->GetData(inter->sql_handle, 11, &data, NULL); p->incubate = atoi(data);
+
+ SQL->FreeResult(inter->sql_handle);
p->hungry = cap_value(p->hungry, 0, 100);
p->intimate = cap_value(p->intimate, 0, 1000);
@@ -120,8 +120,8 @@ void inter_pet_sql_final(void) {
int inter_pet_delete(int pet_id) {
ShowInfo("delete pet request: %d...\n",pet_id);
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
//------------------------------------------------------
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index 978ee8f37..a5721c430 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -44,7 +44,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
if (!count)
return NULL;
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if (stmt == NULL) {
SqlStmt_ShowDebug(stmt);
*count = 0;
@@ -112,8 +112,8 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
*/
bool mapif_quest_delete(int char_id, int quest_id)
{
- if (SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id)) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id)) {
+ Sql_ShowDebug(inter->sql_handle);
return false;
}
@@ -142,8 +142,8 @@ bool mapif_quest_add(int char_id, struct quest qd)
StrBuf->Printf(&buf, ", '%d'", qd.count[i]);
}
StrBuf->AppendStr(&buf, ")");
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))) {
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
@@ -171,8 +171,8 @@ bool mapif_quest_update(int char_id, struct quest qd)
}
StrBuf->Printf(&buf, " WHERE `quest_id` = '%d' AND `char_id` = '%d'", qd.quest_id, char_id);
- if (SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))) {
- Sql_ShowDebug(sql_handle);
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))) {
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 1f23475ed..7cef7e6f0 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -51,31 +51,31 @@ int inter_storage_fromsql(int account_id, struct storage_data* p)
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
item = &p->items[i];
- SQL->GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); item->bound = atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); item->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); item->amount = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); item->equip = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); item->bound = atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
for( j = 0; j < MAX_SLOTS; ++j )
{
- SQL->GetData(sql_handle, 10+j, &data, NULL); item->card[j] = atoi(data);
+ SQL->GetData(inter->sql_handle, 10+j, &data, NULL); item->card[j] = atoi(data);
}
}
p->storage_amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount);
return 1;
@@ -109,30 +109,30 @@ int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p)
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i ) {
+ for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i ) {
item = &p->items[i];
- SQL->GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); item->bound = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); item->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); item->amount = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); item->equip = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); item->bound = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
item->expire_time = 0;
for( j = 0; j < MAX_SLOTS; ++j ) {
- SQL->GetData(sql_handle, 9+j, &data, NULL); item->card[j] = atoi(data);
+ SQL->GetData(inter->sql_handle, 9+j, &data, NULL); item->card[j] = atoi(data);
}
}
p->storage_amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount);
return 0;
@@ -153,14 +153,14 @@ void inter_storage_sql_final(void)
// q?f[^?
int inter_storage_delete(int account_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
int inter_storage_guild_storage_delete(int guild_id)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -169,9 +169,9 @@ int inter_storage_guild_storage_delete(int guild_id)
int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag)
{
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
- Sql_ShowDebug(sql_handle);
- else if( SQL->NumRows(sql_handle) > 0 )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
+ Sql_ShowDebug(inter->sql_handle);
+ else if( SQL->NumRows(inter->sql_handle) > 0 )
{// guild exists
WFIFOHEAD(fd, sizeof(struct guild_storage)+13);
WFIFOW(fd,0) = 0x3818;
@@ -184,7 +184,7 @@ int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag)
return 0;
}
// guild does not exist
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
WFIFOHEAD(fd, 12);
WFIFOW(fd,0) = 0x3818;
WFIFOW(fd,2) = 12;
@@ -226,16 +226,16 @@ int mapif_parse_SaveGuildStorage(int fd)
if (sizeof(struct guild_storage) != len - 12) {
ShowError("inter storage: data size mismatch: %d != %"PRIuS"\n", len - 12, sizeof(struct guild_storage));
} else {
- if (SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) {
- Sql_ShowDebug(sql_handle);
- } else if(SQL->NumRows(sql_handle) > 0) {
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) {
+ Sql_ShowDebug(inter->sql_handle);
+ } else if(SQL->NumRows(inter->sql_handle) > 0) {
// guild exists
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
inter_storage->guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
return 0;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
}
mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
return 0;
@@ -276,11 +276,11 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d' AND `bound` = '%d'",inventory_db,char_id,IBT_GUILD);
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
@@ -304,7 +304,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
memcpy(&items[i],&item,sizeof(struct item));
i++;
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
if(!i) { //No items found - No need to continue
StrBuf->Destroy(&buf);
@@ -339,7 +339,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
@@ -373,7 +373,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
@@ -410,7 +410,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtExecute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
diff --git a/src/char/inter.c b/src/char/inter.c
index 39ebb02d4..5ac065f23 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -39,8 +39,6 @@
struct inter_interface inter_s;
-Sql* sql_handle = NULL;
-
int char_server_port = 3306;
char char_server_ip[32] = "127.0.0.1";
char char_server_id[32] = "ragnarok";
@@ -590,43 +588,43 @@ void mapif_parse_accinfo(int fd)
safestrncpy(query, (char*) RFIFOP(fd,14), NAME_LENGTH);
- SQL->EscapeString(sql_handle, query_esq, query);
+ SQL->EscapeString(inter->sql_handle, query_esq, query);
account_id = atoi(query);
if (account_id < START_ACCOUNT_NUM) { // is string
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
- || SQL->NumRows(sql_handle) == 0 ) {
- if( SQL->NumRows(sql_handle) == 0 ) {
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
+ || SQL->NumRows(inter->sql_handle) == 0 ) {
+ if( SQL->NumRows(inter->sql_handle) == 0 ) {
inter->msg_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query);
} else {
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
inter->msg_to_fd(fd, u_fd, aid, "An error occurred, bother your admin about it.");
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return;
} else {
- if( SQL->NumRows(sql_handle) == 1 ) {//we found a perfect match
- SQL->NextRow(sql_handle);
- SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
- SQL->FreeResult(sql_handle);
+ if( SQL->NumRows(inter->sql_handle) == 1 ) {//we found a perfect match
+ SQL->NextRow(inter->sql_handle);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->FreeResult(inter->sql_handle);
} else {// more than one, listing... [Dekamaster/Nightroad]
- inter->msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(sql_handle));
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ inter->msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(inter->sql_handle));
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
int class_;
short base_level, job_level, online;
char name[NAME_LENGTH];
- SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
- SQL->GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); online = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); base_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); job_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); online = atoi(data);
inter->msg_to_fd(fd, u_fd, aid, "[AID: %d] %s | %s | Level: %d/%d | %s", account_id, name, inter->job_name(class_), base_level, job_level, online?"Online":"Offline");
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return;
}
}
@@ -666,34 +664,34 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
inter->msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
inter->msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
"FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
- || SQL->NumRows(sql_handle) == 0 ) {
- if (SQL->NumRows(sql_handle) == 0) {
+ || SQL->NumRows(inter->sql_handle) == 0 ) {
+ if (SQL->NumRows(inter->sql_handle) == 0) {
inter->msg_to_fd(map_fd, u_fd, u_aid, "This account doesn't have characters.");
} else {
inter->msg_to_fd(map_fd, u_fd, u_aid, "An error occurred, bother your admin about it.");
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
}
} else {
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
char *data;
int char_id, class_;
short char_num, base_level, job_level, online;
char name[NAME_LENGTH];
- SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
- SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); char_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); char_num = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); class_ = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); base_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); job_level = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); online = atoi(data);
inter->msg_to_fd(map_fd, u_fd, u_aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, inter->job_name(class_), base_level, job_level, online?"On":"Off");
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return;
}
@@ -715,37 +713,37 @@ void inter_savereg(int account_id, int char_id, const char *key, unsigned int in
} else if ( key[0] == '#' ) {/* local account reg */
if( is_string ) {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", acc_reg_str_db, account_id, key, index, (char*)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", acc_reg_str_db, account_id, key, index, (char*)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_str_db, account_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_str_db, account_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
} else {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", acc_reg_num_db, account_id, key, index, (int)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", acc_reg_num_db, account_id, key, index, (int)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_num_db, account_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", acc_reg_num_db, account_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
}
} else { /* char reg */
if( is_string ) {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", char_reg_str_db, char_id, key, index, (char*)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", char_reg_str_db, char_id, key, index, (char*)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_str_db, char_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_str_db, char_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
} else {
if( val ) {
- if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", char_reg_num_db, char_id, key, index, (int)val) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", char_reg_num_db, char_id, key, index, (int)val) )
+ Sql_ShowDebug(inter->sql_handle);
} else {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_num_db, char_id, key, index) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", char_reg_num_db, char_id, key, index) )
+ Sql_ShowDebug(inter->sql_handle);
}
}
}
@@ -761,12 +759,12 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
switch( type ) {
case 3: //char reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 2: //account reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_str_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_str_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 1: //account2 reg
ShowError("inter->accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
@@ -792,9 +790,9 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
* str type
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
**/
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
len = strlen(data)+1;
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
@@ -803,12 +801,12 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
- SQL->GetData(sql_handle, 2, &data, NULL);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL);
len = strlen(data)+1;
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */
@@ -840,16 +838,16 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
switch( type ) {
case 3: //char reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 2: //account reg
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_num_db, account_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_num_db, account_id) )
+ Sql_ShowDebug(inter->sql_handle);
break;
case 1: //account2 reg
ShowError("inter->accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
@@ -872,9 +870,9 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
* int type
* { keyLength(B), key(<keyLength>), index(L), value(L) }
**/
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) {
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
len = strlen(data)+1;
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
@@ -883,12 +881,12 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
- SQL->GetData(sql_handle, 2, &data, NULL);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL);
WFIFOL(fd, plen) = atoi(data);
plen += 4;
@@ -917,7 +915,7 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 1;
}
@@ -987,9 +985,9 @@ int inter_vlog(char* fmt, va_list ap)
vsnprintf(str, sizeof(str), fmt, apcopy);
va_end(apcopy);
- SQL->EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str)));
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_str, str, strnlen(str, sizeof(str)));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) )
+ Sql_ShowDebug(inter->sql_handle);
return 0;
}
@@ -1020,18 +1018,18 @@ int inter_init_sql(const char *file)
inter->config_read(file);
//DB connection initialized
- sql_handle = SQL->Malloc();
+ inter->sql_handle = SQL->Malloc();
ShowInfo("Connect Character DB server.... (Character Server)\n");
- if( SQL_ERROR == SQL->Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
+ if( SQL_ERROR == SQL->Connect(inter->sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
{
- Sql_ShowDebug(sql_handle);
- SQL->Free(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->Free(inter->sql_handle);
exit(EXIT_FAILURE);
}
if( *default_codepage ) {
- if( SQL_ERROR == SQL->SetEncoding(sql_handle, default_codepage) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->SetEncoding(inter->sql_handle, default_codepage) )
+ Sql_ShowDebug(inter->sql_handle);
}
wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
@@ -1231,19 +1229,19 @@ int mapif_parse_WisRequest(int fd)
safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]
- SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
// search if character exists before to ask all map-servers
- if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
mapif->wis_response(fd, RFIFOP(fd, 4), 1);
}
else
{// Character exists. So, ask all map-servers
// to be sure of the correct name, rewrite it
- SQL->GetData(sql_handle, 0, &data, &len);
+ SQL->GetData(inter->sql_handle, 0, &data, &len);
memset(name, 0, NAME_LENGTH);
memcpy(name, data, min(len, NAME_LENGTH));
// if source is destination, don't ask other servers.
@@ -1270,7 +1268,7 @@ int mapif_parse_WisRequest(int fd)
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return 0;
}
@@ -1487,6 +1485,8 @@ void inter_defaults(void)
{
inter = &inter_s;
+ inter->sql_handle = NULL;
+
inter->msg_txt = inter_msg_txt;
inter->msg_config_read = inter_msg_config_read;
inter->do_final_msg = inter_do_final_msg;
diff --git a/src/char/inter.h b/src/char/inter.h
index c315d5772..9aa0699cc 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -15,12 +15,10 @@ struct accreg;
extern unsigned int party_share_level;
-extern Sql* sql_handle;
-extern Sql* lsql_handle;
-
void inter_defaults(void);
struct inter_interface {
+ 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);