summaryrefslogtreecommitdiff
path: root/src/char/int_mercenary.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/int_mercenary.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/int_mercenary.c')
-rw-r--r--src/char/int_mercenary.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index 3b3714416..11cc47062 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/mmo.h"
#include "../common/malloc.h"
@@ -19,33 +20,33 @@ bool 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(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);
return false;
}
- if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
{
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(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(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);
return true;
}
bool 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(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);
@@ -57,10 +58,10 @@ bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
bool 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) )
+ 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(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
Sql_ShowDebug(sql_handle);
return true;
@@ -72,7 +73,7 @@ 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(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) )
{
@@ -80,9 +81,9 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
flag = false;
}
else
- merc->mercenary_id = (int)Sql_LastInsertId(sql_handle);
+ merc->mercenary_id = (int)SQL->NumRows(sql_handle);
}
- else if( SQL_ERROR == Sql_Query(sql_handle,
+ else if( SQL_ERROR == SQL->Query(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
@@ -101,24 +102,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(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);
return false;
}
- if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
+ if( SQL_SUCCESS != SQL->NextRow(sql_handle) )
{
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(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(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);
if( save_log )
ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id);
@@ -127,7 +128,7 @@ 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(sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
{
Sql_ShowDebug(sql_handle);
return false;