summaryrefslogtreecommitdiff
path: root/src/char/int_pet.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_pet.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_pet.c')
-rw-r--r--src/char/int_pet.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 311ccd4be..8d523a133 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -24,13 +24,13 @@ 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`,`incuvate`)
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(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(sql_handle, "INSERT INTO `%s` "
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) "
"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,
@@ -39,11 +39,11 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
Sql_ShowDebug(sql_handle);
return 0;
}
- p->pet_id = (int)Sql_LastInsertId(sql_handle);
+ p->pet_id = (int)SQL->NumRows(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',`incuvate`='%d' WHERE `pet_id`='%d'",
+ 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',`incuvate`='%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->incuvate, p->pet_id) )
{
@@ -69,28 +69,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`,`incuvate`)
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
{
Sql_ShowDebug(sql_handle);
return 0;
}
- if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
+ if( SQL_SUCCESS == SQL->NextRow(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->incuvate = atoi(data);
-
- Sql_FreeResult(sql_handle);
+ 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->incuvate = atoi(data);
+
+ SQL->FreeResult(sql_handle);
p->hungry = cap_value(p->hungry, 0, 100);
p->intimate = cap_value(p->intimate, 0, 1000);
@@ -115,7 +115,7 @@ 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) )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
Sql_ShowDebug(sql_handle);
return 0;
}