summaryrefslogtreecommitdiff
path: root/src/char/int_pet.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-09 21:09:03 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-15 11:47:30 +0300
commitc60c9292886f436eb12d4042a05af1e462705e3d (patch)
treed6a5cd0f78d9c845e966e18ecfb386e0b31515b2 /src/char/int_pet.c
parent63075b84ecf52e329ee524e1e90878469c388f9d (diff)
downloadhercules-c60c9292886f436eb12d4042a05af1e462705e3d.tar.gz
hercules-c60c9292886f436eb12d4042a05af1e462705e3d.tar.bz2
hercules-c60c9292886f436eb12d4042a05af1e462705e3d.tar.xz
hercules-c60c9292886f436eb12d4042a05af1e462705e3d.zip
Move global variable into interface in inter.c
Diffstat (limited to 'src/char/int_pet.c')
-rw-r--r--src/char/int_pet.c48
1 files changed, 24 insertions, 24 deletions
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;
}
//------------------------------------------------------