summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-15 16:47:08 -0300
committershennetsind <ind@henn.et>2013-05-15 16:47:08 -0300
commit0aee4fd57f2f4135361f4182a08a98cf52ed9d10 (patch)
treed7f43f0a5a63e73e21291f906e33109232ce7830 /src/char/char.c
parent75942979098d34d52adc2537b6f28e02be7d7bae (diff)
downloadhercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.gz
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.bz2
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.xz
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.zip
HPM Update
Made SQL and strlib functions HPM-friendly, special thanks to Yommy for bringing the issue up. Added partial map.c support, for the all-handy map[] array, beware that soon the whole map.c renewal design will be commit and when that happens your usage of map.c functions in plugins might require some updates. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c474
1 files changed, 237 insertions, 237 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 975b1d77b..f5a75964c 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -226,7 +226,7 @@ void 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) )
+ 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);
//Check to see for online conflicts
@@ -271,7 +271,7 @@ void 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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id) )
Sql_ShowDebug(sql_handle);
}
else
@@ -281,7 +281,7 @@ void set_char_offline(int char_id, int account_id)
if (cp)
idb_remove(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) )
+ 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);
}
@@ -376,11 +376,11 @@ void set_all_offline(int id)
void set_all_offline_sql(void)
{
//Set all players to 'OFFLINE'
- if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) )
+ 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) )
+ 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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `connect_member` = '0'", guild_db) )
Sql_ShowDebug(sql_handle);
}
@@ -411,7 +411,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
cp = idb_ensure(char_db_, char_id, create_charstatus);
- StringBuf_Init(&buf);
+ StrBuf->Init(&buf);
memset(save_status, 0, sizeof(save_status));
//map inventory data
@@ -464,7 +464,7 @@ int 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(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',"
@@ -501,7 +501,7 @@ int 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(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'"
@@ -536,29 +536,29 @@ int 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(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, p->char_id) )
{
Sql_ShowDebug(sql_handle);
errors++;
}
//insert here.
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`map`,`x`,`y`) VALUES ", memo_db);
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s`(`char_id`,`map`,`x`,`y`) VALUES ", memo_db);
for( i = 0, count = 0; i < MAX_MEMOPOINTS; ++i )
{
if( p->memo_point[i].map )
{
if( count )
- StringBuf_AppendStr(&buf, ",");
- Sql_EscapeString(sql_handle, esc_mapname, mapindex_id2name(p->memo_point[i].map));
- StringBuf_Printf(&buf, "('%d', '%s', '%d', '%d')", char_id, esc_mapname, p->memo_point[i].x, p->memo_point[i].y);
+ StrBuf->AppendStr(&buf, ",");
+ SQL->EscapeString(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, StringBuf_Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
Sql_ShowDebug(sql_handle);
errors++;
@@ -570,13 +570,13 @@ int 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) ) {
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) {
Sql_ShowDebug(sql_handle);
errors++;
}
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`,`flag`) VALUES ", skill_db);
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`,`flag`) VALUES ", skill_db);
//insert here.
for( i = 0, count = 0; i < MAX_SKILL; ++i ) {
if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY ) {
@@ -586,8 +586,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
if( p->skill[i].flag != SKILL_FLAG_PERMANENT && p->skill[i].flag != SKILL_FLAG_PERM_GRANTED && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 )
continue;
if( count )
- StringBuf_AppendStr(&buf, ",");
- StringBuf_Printf(&buf, "('%d','%d','%d','%d')", char_id, p->skill[i].id,
+ StrBuf->AppendStr(&buf, ",");
+ StrBuf->Printf(&buf, "('%d','%d','%d','%d')", char_id, p->skill[i].id,
( (p->skill[i].flag == SKILL_FLAG_PERMANENT || p->skill[i].flag == SKILL_FLAG_PERM_GRANTED) ? p->skill[i].lv : p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0),
p->skill[i].flag == SKILL_FLAG_PERM_GRANTED ? p->skill[i].flag : 0);/* other flags do not need to be saved */
++count;
@@ -595,7 +595,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
if( count )
{
- if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
Sql_ShowDebug(sql_handle);
errors++;
@@ -616,27 +616,27 @@ int 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(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) )
{
Sql_ShowDebug(sql_handle);
errors++;
}
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s` (`char_id`, `friend_account`, `friend_id`) VALUES ", friend_db);
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s` (`char_id`, `friend_account`, `friend_id`) VALUES ", friend_db);
for( i = 0, count = 0; i < MAX_FRIENDS; ++i )
{
if( p->friends[i].char_id > 0 )
{
if( count )
- StringBuf_AppendStr(&buf, ",");
- StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->friends[i].account_id, p->friends[i].char_id);
+ StrBuf->AppendStr(&buf, ",");
+ StrBuf->Printf(&buf, "('%d','%d','%d')", char_id, p->friends[i].account_id, p->friends[i].char_id);
count++;
}
}
if( count )
{
- if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
Sql_ShowDebug(sql_handle);
errors++;
@@ -647,20 +647,20 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
#ifdef HOTKEY_SAVING
// hotkeys
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "REPLACE INTO `%s` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`) VALUES ", hotkey_db);
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "REPLACE INTO `%s` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`) VALUES ", hotkey_db);
diff = 0;
for(i = 0; i < ARRAYLENGTH(p->hotkeys); i++){
if(memcmp(&p->hotkeys[i], &cp->hotkeys[i], sizeof(struct hotkey)))
{
if( diff )
- StringBuf_AppendStr(&buf, ",");// not the first hotkey
- StringBuf_Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (unsigned int)i, (unsigned int)p->hotkeys[i].type, p->hotkeys[i].id , (unsigned int)p->hotkeys[i].lv);
+ StrBuf->AppendStr(&buf, ",");// not the first hotkey
+ StrBuf->Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (unsigned int)i, (unsigned int)p->hotkeys[i].type, p->hotkeys[i].id , (unsigned int)p->hotkeys[i].lv);
diff = 1;
}
}
if(diff) {
- if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
Sql_ShowDebug(sql_handle);
errors++;
@@ -668,7 +668,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
strcat(save_status, " hotkeys");
}
#endif
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
if (save_status[0]!='\0' && save_log)
ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status);
if (!errors)
@@ -706,19 +706,19 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
// This approach is more complicated than a trivial delete&insert, but
// it significantly reduces cpu load on the database server.
- StringBuf_Init(&buf);
- StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`");
+ StrBuf->Init(&buf);
+ StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`");
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`", j);
- StringBuf_Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id);
+ StrBuf->Printf(&buf, ", `card%d`", j);
+ StrBuf->Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id);
stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
+ if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SqlStmt_Execute(stmt) )
{
SqlStmt_ShowDebug(stmt);
SqlStmt_Free(stmt);
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
return 1;
}
@@ -763,14 +763,14 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
else
{
// update all fields.
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u'",
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u'",
tablename, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time);
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
- StringBuf_Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.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, StringBuf_Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
Sql_ShowDebug(sql_handle);
errors++;
@@ -783,7 +783,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
}
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(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) )
{
Sql_ShowDebug(sql_handle);
errors++;
@@ -792,11 +792,11 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
}
SqlStmt_Free(stmt);
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `unique_id`", tablename, selectoption);
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `unique_id`", tablename, selectoption);
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`", j);
- StringBuf_AppendStr(&buf, ") VALUES ");
+ StrBuf->Printf(&buf, ", `card%d`", j);
+ StrBuf->AppendStr(&buf, ") VALUES ");
found = false;
// insert non-matched items into the db as new items
@@ -807,27 +807,27 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
continue;
if( found )
- StringBuf_AppendStr(&buf, ",");
+ StrBuf->AppendStr(&buf, ",");
else
found = true;
- StringBuf_Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%"PRIu64"'",
+ StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%"PRIu64"'",
id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].unique_id);
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", '%d'", items[i].card[j]);
- StringBuf_AppendStr(&buf, ")");
+ StrBuf->Printf(&buf, ", '%d'", items[i].card[j]);
+ StrBuf->AppendStr(&buf, ")");
updateLastUid(items[i].unique_id); // Unique Non Stackable Item ID
}
dbUpdateUid(sql_handle); // Unique Non Stackable Item ID
- if( found && SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
+ if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
Sql_ShowDebug(sql_handle);
errors++;
}
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
aFree(flag);
return errors;
@@ -850,19 +850,19 @@ int inventory_to_sql(const struct item items[], int max, int id) {
// This approach is more complicated than a trivial delete&insert, but
// it significantly reduces cpu load on the database server.
- StringBuf_Init(&buf);
- StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`");
+ StrBuf->Init(&buf);
+ StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`");
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`", j);
- StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, id);
+ StrBuf->Printf(&buf, ", `card%d`", j);
+ StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, id);
stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
+ if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SqlStmt_Execute(stmt) )
{
SqlStmt_ShowDebug(stmt);
SqlStmt_Free(stmt);
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
return 1;
}
@@ -906,14 +906,14 @@ int inventory_to_sql(const struct item items[], int max, int id) {
; //Do nothing.
else {
// update all fields.
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `favorite`='%d'",
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `favorite`='%d'",
inventory_db, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite);
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`=%d", j, items[i].card[j]);
- StringBuf_Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.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, StringBuf_Value(&buf)) ) {
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
Sql_ShowDebug(sql_handle);
errors++;
}
@@ -924,7 +924,7 @@ int 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) ) {
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", inventory_db, item.id) ) {
Sql_ShowDebug(sql_handle);
errors++;
}
@@ -932,11 +932,11 @@ int inventory_to_sql(const struct item items[], int max, int id) {
}
SqlStmt_Free(stmt);
- StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `unique_id`", inventory_db);
+ StrBuf->Clear(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `unique_id`", inventory_db);
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`", j);
- StringBuf_AppendStr(&buf, ") VALUES ");
+ StrBuf->Printf(&buf, ", `card%d`", j);
+ StrBuf->AppendStr(&buf, ") VALUES ");
found = false;
// insert non-matched items into the db as new items
@@ -946,26 +946,26 @@ int inventory_to_sql(const struct item items[], int max, int id) {
continue;
if( found )
- StringBuf_AppendStr(&buf, ",");
+ StrBuf->AppendStr(&buf, ",");
else
found = true;
- StringBuf_Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%d', '%"PRIu64"'",
+ StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%d', '%"PRIu64"'",
id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].unique_id);
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", '%d'", items[i].card[j]);
- StringBuf_AppendStr(&buf, ")");
+ StrBuf->Printf(&buf, ", '%d'", items[i].card[j]);
+ StrBuf->AppendStr(&buf, ")");
updateLastUid(items[i].unique_id);// Unique Non Stackable Item ID
}
dbUpdateUid(sql_handle);
- if( found && SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) {
+ if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
Sql_ShowDebug(sql_handle);
errors++;
}
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
aFree(flag);
return errors;
@@ -1208,13 +1208,13 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read inventory
//`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `favorite`, `unique_id`)
- StringBuf_Init(&buf);
- StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `unique_id`");
+ StrBuf->Init(&buf);
+ StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `unique_id`");
for( i = 0; i < MAX_SLOTS; ++i )
- StringBuf_Printf(&buf, ", `card%d`", i);
- StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY);
+ StrBuf->Printf(&buf, ", `card%d`", i);
+ StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
+ if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
|| SQL_ERROR == SqlStmt_Execute(stmt)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
@@ -1239,13 +1239,13 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read cart
//`cart_inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, expire_time`, `unique_id`)
- StringBuf_Clear(&buf);
- StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `unique_id`");
+ StrBuf->Clear(&buf);
+ StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `unique_id`");
for( j = 0; j < MAX_SLOTS; ++j )
- StringBuf_Printf(&buf, ", `card%d`", j);
- StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART);
+ StrBuf->Printf(&buf, ", `card%d`", j);
+ StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
+ if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
|| SQL_ERROR == SqlStmt_Execute(stmt)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
@@ -1334,7 +1334,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly!
SqlStmt_Free(stmt);
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
/* load options into proper vars */
if( opt & OPT_ALLOW_PARTY )
@@ -1382,14 +1382,14 @@ bool char_slotchange(struct char_session_data *sd, int fd, unsigned short from,
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]) )
+ 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);
else
result = true;
- if( SQL_ERROR == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) {
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) {
Sql_ShowDebug(sql_handle);
result = false;
}
@@ -1397,14 +1397,14 @@ bool char_slotchange(struct char_session_data *sd, int fd, unsigned short from,
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] ) ) {
+ 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);
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 ) ) {
+ 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);
return false;
}
@@ -1429,16 +1429,16 @@ int 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(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(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) )
{
Sql_ShowDebug(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(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);
return 3;
@@ -1454,7 +1454,7 @@ int rename_char_sql(struct char_session_data *sd, int char_id)
// log change
if( log_char )
{
- if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
+ if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
"VALUES (NOW(), '%s', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')",
charlog_db, "change char name", sd->account_id, char_dat.slot, esc_name) )
Sql_ShowDebug(sql_handle);
@@ -1498,17 +1498,17 @@ int check_char_name(char * name, char * esc_name)
return -2;
}
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) ) {
+ 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);
return -2;
}
} else {
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) {
+ if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) {
Sql_ShowDebug(sql_handle);
return -2;
}
}
- if( Sql_NumRows(sql_handle) > 0 )
+ if( SQL->NumRows(sql_handle) > 0 )
return -1; // name already exists
return 0;
@@ -1530,7 +1530,7 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
safestrncpy(name, name_, NAME_LENGTH);
normalize_name(name,TRIM_CHARS);
- Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
flag = check_char_name(name,esc_name);
if( flag < 0 )
@@ -1557,14 +1557,14 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
// validation success, log result
if (log_char) {
- if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
+ if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
"VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
charlog_db, "make new char", sd->account_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) )
Sql_ShowDebug(sql_handle);
}
#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(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,
@@ -1576,7 +1576,7 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
}
#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(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,
@@ -1588,11 +1588,11 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
}
#endif
//Retrieve the newly auto-generated char id
- char_id = (int)Sql_LastInsertId(sql_handle);
+ char_id = (int)SQL->NumRows(sql_handle);
//Give the char the default items
for (k = 0; k < ARRAYLENGTH(start_items) && start_items[k] != 0; k += 2) {
- if( SQL_ERROR == Sql_Query(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) )
+ if( SQL_ERROR == SQL->Query(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);
}
@@ -1607,9 +1607,9 @@ int 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) )
+ 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) )
+ 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);
WBUFW(buf,0) = 0x2b12;
@@ -1634,30 +1634,30 @@ int 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))
+ 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_SUCCESS != Sql_NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
{
ShowError("delete_char_sql: Unable to fetch character data, deletion aborted.\n");
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(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(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);
elemental_id = atoi(data);
- Sql_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
- Sql_FreeResult(sql_handle);
+ SQL->EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
+ SQL->FreeResult(sql_handle);
//check for config char del condition [Lupus]
// TODO: Move this out to packet processing (0x68/0x1fb).
@@ -1677,9 +1677,9 @@ int 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) )
+ 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) )
+ 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);
WBUFW(buf,0) = 0x2b25;
@@ -1695,13 +1695,13 @@ int 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 `incuvate` = '0'", pet_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `incuvate` = '0'", pet_db, char_id) )
Sql_ShowDebug(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) )
+ 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) )
+ 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);
/* remove homunculus */
@@ -1716,69 +1716,69 @@ int delete_char_sql(int char_id)
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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) )
Sql_ShowDebug(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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `friend_id` = '%d'", friend_db, char_id) )
Sql_ShowDebug(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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", hotkey_db, char_id) )
Sql_ShowDebug(sql_handle);
#endif
/* delete inventory */
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", inventory_db, char_id) )
Sql_ShowDebug(sql_handle);
/* delete cart inventory */
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", cart_db, char_id) )
Sql_ShowDebug(sql_handle);
/* delete memo areas */
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", memo_db, char_id) )
Sql_ShowDebug(sql_handle);
/* delete character registry */
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
Sql_ShowDebug(sql_handle);
/* delete skills */
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, char_id) )
Sql_ShowDebug(sql_handle);
/* delete mails (only received) */
- if (SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `dest_id`='%d'", mail_db, char_id))
+ if (SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `dest_id`='%d'", mail_db, char_id))
Sql_ShowDebug(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) )
+ 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);
#endif
if (log_char) {
- if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')",
+ if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')",
charlog_db, account_id, 0, char_id, esc_name) )
Sql_ShowDebug(sql_handle);
}
/* delete character */
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
Sql_ShowDebug(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) )
+ 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(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `char_id` = '%d'", guild_db, char_id) )
+ 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 )
+ else if( SQL->NumRows(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.
@@ -1937,66 +1937,66 @@ int mmo_char_send006b(int fd, struct char_session_data* sd)
int 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) )
+ 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) )
+ else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
{
char* data;
- Sql_GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(sql_handle, 0, &data, NULL);
if( pl2 == atoi(data) )
{
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
return 1;
}
}
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
return 0;
}
int 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) )
+ 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) )
+ else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
{
char* data;
- Sql_GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(sql_handle, 0, &data, NULL);
if( child_id == atoi(data) )
{
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
return 1;
}
}
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
return 0;
}
int 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) )
+ 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) )
+ else while( SQL_SUCCESS == SQL->NextRow(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(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);
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(sql_handle);
return childid;
}
}
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
return 0;
}
@@ -2279,13 +2279,13 @@ int parse_fromlogin(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) )
+ 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 )
+ for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->NextRow(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(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);
}
num = i;
for( i = 0; i < num; ++i )
@@ -2315,13 +2315,13 @@ int parse_fromlogin(int fd) {
class_[i] = (sex ? JOB_KAGEROU : JOB_OBORO);
}
- if( SQL_ERROR == Sql_Query(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]) )
+ if( SQL_ERROR == SQL->Query(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);
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(sql_handle);
// disconnect player if online on char-server
disconnect_player(acc);
@@ -2506,51 +2506,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) )
+ 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 )
+ for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
{
// char_id
- Sql_GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(sql_handle, 0, &data, NULL);
smith_fame_list[i].id = atoi(data);
// fame
- Sql_GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(sql_handle, 1, &data, &len);
smith_fame_list[i].fame = atoi(data);
// name
- Sql_GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(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) )
+ 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 )
+ for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
{
// char_id
- Sql_GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(sql_handle, 0, &data, NULL);
chemist_fame_list[i].id = atoi(data);
// fame
- Sql_GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(sql_handle, 1, &data, &len);
chemist_fame_list[i].fame = atoi(data);
// name
- Sql_GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(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) )
+ 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 )
+ for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
{
// char_id
- Sql_GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(sql_handle, 0, &data, NULL);
taekwon_fame_list[i].id = atoi(data);
// fame
- Sql_GetData(sql_handle, 1, &data, &len);
+ SQL->GetData(sql_handle, 1, &data, &len);
taekwon_fame_list[i].fame = atoi(data);
// name
- Sql_GetData(sql_handle, 2, &data, &len);
+ SQL->GetData(sql_handle, 2, &data, &len);
memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH));
}
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
}
// Send map-servers the fame ranking lists
@@ -2607,11 +2607,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) )
+ 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) )
+ else if( SQL_SUCCESS == SQL->NextRow(sql_handle) )
{
- Sql_GetData(sql_handle, 0, &data, &len);
+ SQL->GetData(sql_handle, 0, &data, &len);
safestrncpy(name, data, NAME_LENGTH);
return 1;
}
@@ -2662,7 +2662,7 @@ 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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `index`='%d'", ragsrvinfo_db, server[id].fd) )
Sql_ShowDebug(sql_handle);
online_char_db->foreach(online_char_db,char_db_setoffline,id); //Tag relevant chars as 'in disconnected' server.
mapif_server_destroy(id);
@@ -2789,13 +2789,13 @@ int parse_frommap(int fd)
int aid, cid;
aid = RFIFOL(fd,2);
cid = RFIFOL(fd,6);
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(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);
break;
}
- if( Sql_NumRows(sql_handle) > 0 )
+ if( SQL->NumRows(sql_handle) > 0 )
{
struct status_change_data scdata;
int count;
@@ -2805,14 +2805,14 @@ int parse_frommap(int fd)
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(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(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);
memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
}
if (count >= 50)
@@ -2824,11 +2824,11 @@ int parse_frommap(int fd)
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) )
+ 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);
}
}
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
#endif
RFIFOSKIP(fd, 10);
}
@@ -3028,7 +3028,7 @@ int parse_frommap(int fd)
int char_id, friend_id;
char_id = RFIFOL(fd,2);
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(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);
break;
@@ -3080,16 +3080,16 @@ int parse_frommap(int fd)
short second = RFIFOW(fd,42);
RFIFOSKIP(fd,44);
- Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
+ SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
Sql_ShowDebug(sql_handle);
else
- if( Sql_NumRows(sql_handle) == 0 )
+ if( SQL->NumRows(sql_handle) == 0 )
{
result = 1; // 1-player not found
}
else
- if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
Sql_ShowDebug(sql_handle);
//FIXME: set proper result value?
else
@@ -3098,8 +3098,8 @@ int parse_frommap(int fd)
int account_id;
char* data;
- 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, 0, &data, NULL); account_id = atoi(data);
+ SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
if( login_fd <= 0 )
result = 3; // 3-login-server offline
@@ -3150,7 +3150,7 @@ int parse_frommap(int fd)
}
}
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
// send answer if a player ask, not if the server ask
if( acc != -1 && type != 5) { // Don't send answer for changesex
@@ -3233,9 +3233,9 @@ int parse_frommap(int fd)
{
char esc_server_name[sizeof(server_name)*2+1];
- Sql_EscapeString(sql_handle, esc_server_name, server_name);
+ SQL->EscapeString(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(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);
RFIFOSKIP(fd,14);
@@ -3286,19 +3286,19 @@ int parse_frommap(int fd)
StringBuf buf;
int i;
- StringBuf_Init(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
+ StrBuf->Init(&buf);
+ StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
for( i = 0; i < count; ++i )
{
memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
if( i > 0 )
- StringBuf_AppendStr(&buf, ", ");
- StringBuf_Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
+ StrBuf->AppendStr(&buf, ", ");
+ 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, StringBuf_Value(&buf)) )
+ if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
Sql_ShowDebug(sql_handle);
- StringBuf_Destroy(&buf);
+ StrBuf->Destroy(&buf);
}
#endif
RFIFOSKIP(fd, RFIFOW(fd, 2));
@@ -3561,14 +3561,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(sql_handle, "SELECT `delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) )
{
Sql_ShowDebug(sql_handle);
char_delete2_ack(fd, char_id, 3, 0);
return;
}
- Sql_GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
+ SQL->GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
if( delete_date ) {// character already queued for deletion
char_delete2_ack(fd, char_id, 0, 0);
@@ -3595,7 +3595,7 @@ 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(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", char_db, (unsigned long)delete_date, char_id) )
{
Sql_ShowDebug(sql_handle);
char_delete2_ack(fd, char_id, 3, 0);
@@ -3636,15 +3636,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(sql_handle, "SELECT `base_level`,`delete_date` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) )
{// data error
Sql_ShowDebug(sql_handle);
char_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(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);
if( !delete_date || delete_date>time(NULL) )
{// not queued or delay not yet passed
@@ -3697,7 +3697,7 @@ 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 char_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(sql_handle, "UPDATE `%s` SET `delete_date`='0' WHERE `char_id`='%d'", char_db, char_id) )
{
Sql_ShowDebug(sql_handle);
char_delete2_cancel_ack(fd, char_id, 2);
@@ -3849,12 +3849,12 @@ int parse_char(int fd)
}
}
#endif
- 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(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) )
{ //Not found?? May be forged packet.
Sql_ShowDebug(sql_handle);
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x6c;
WFIFOB(fd,2) = 0; // rejected from server
@@ -3863,7 +3863,7 @@ int parse_char(int fd)
}
char_id = atoi(data);
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
/* set char as online prior to loading its data so 3rd party applications will realise the sql data is not reliable */
set_char_online(-2,char_id,sd->account_id);
@@ -3884,8 +3884,8 @@ int parse_char(int fd)
if (log_char) {
char esc_name[NAME_LENGTH*2+1];
- Sql_EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
- if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')",
+ SQL->EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
+ if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')",
charlog_db, sd->account_id, slot, esc_name) )
Sql_ShowDebug(sql_handle);
}
@@ -4130,7 +4130,7 @@ int parse_char(int fd)
break;
normalize_name(name,TRIM_CHARS);
- Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
if( !check_char_name(name,esc_name) ) {
i = 1;
safestrncpy(sd->new_name, name, NAME_LENGTH);
@@ -4162,7 +4162,7 @@ int parse_char(int fd)
break;
normalize_name(name,TRIM_CHARS);
- Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
+ SQL->EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
if( !check_char_name(name,esc_name) )
{
i = 1;
@@ -4872,7 +4872,7 @@ void do_final(void)
do_final_mapif();
do_final_loginif();
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
Sql_ShowDebug(sql_handle);
char_db_->destroy(char_db_, NULL);
@@ -4885,7 +4885,7 @@ void do_final(void)
char_fd = -1;
}
- Sql_Free(sql_handle);
+ SQL->Free(sql_handle);
mapindex_final();
ShowStatus("Finished.\n");
@@ -4981,15 +4981,15 @@ int do_init(int argc, char **argv) {
//Cleaning the tables for NULL entrys @ startup [Sirius]
//Chardb clean
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) )
Sql_ShowDebug(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) )
+ 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);
//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) )
+ 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);
set_defaultparse(parse_char);