summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-02-15 09:20:50 +0100
committerHaru <haru@dotalux.com>2020-04-05 21:20:35 +0200
commitea824742822a2e17b2b83c77d6b28bf0a12aacf4 (patch)
treea7389d0a7316614d3dcec031afca0da500e5ad19 /src/char
parentf6b8fe728b4f0cf97da9fea8935c186893868c4d (diff)
downloadhercules-ea824742822a2e17b2b83c77d6b28bf0a12aacf4.tar.gz
hercules-ea824742822a2e17b2b83c77d6b28bf0a12aacf4.tar.bz2
hercules-ea824742822a2e17b2b83c77d6b28bf0a12aacf4.tar.xz
hercules-ea824742822a2e17b2b83c77d6b28bf0a12aacf4.zip
Apply code style to inter_pet_tosql() function
Diffstat (limited to 'src/char')
-rw-r--r--src/char/int_pet.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index e1ecae766..2ba31b43b 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -43,19 +43,17 @@ struct inter_pet_interface *inter_pet;
/**
* Saves a pet to the SQL database.
*
- * @remark
- * In case of newly created pet, the pet ID is not updated to reflect the
- * newly assigned ID. The caller must do so.
+ * Table structure:
+ * `pet` (`pet_id`, `class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, `intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed`)
+ *
+ * @remark In case of newly created pet, the pet ID is not updated to reflect the newly assigned ID. The caller must do so.
*
* @param p The pet data to save.
- * @return The ID of the saved pet.
- * @retval 0 in case of errors.
- */
+ * @return The ID of the saved pet, or 0 in case of errors.
+ *
+ **/
static int inter_pet_tosql(const struct s_pet *p)
{
- //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
- int pet_id = 0;
-
nullpo_ret(p);
struct SqlStmt *stmt = SQL->StmtMalloc(inter->sql_handle);
@@ -65,9 +63,12 @@ static int inter_pet_tosql(const struct s_pet *p)
return 0;
}
+ int pet_id = 0;
+
if (p->pet_id == 0) { // New pet.
const char *query = "INSERT INTO `%s` "
- "(`class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, `intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed`) "
+ "(`class`, `name`, `account_id`, `char_id`, `level`, `egg_id`, `equip`, "
+ "`intimate`, `hungry`, `rename_flag`, `incubate`, `autofeed`) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if (SQL_ERROR == SQL->StmtPrepare(stmt, query, pet_db) ||
@@ -92,7 +93,8 @@ static int inter_pet_tosql(const struct s_pet *p)
pet_id = (int)SQL->LastInsertId(inter->sql_handle);
} else { // Update pet.
const char *query = "UPDATE `%s` SET "
- "`class`=?, `name`=?, `account_id`=?, `char_id`=?, `level`=?, `egg_id`=?, `equip`=?, `intimate`=?, `hungry`=?, `rename_flag`=?, `incubate`=?, `autofeed`=? "
+ "`class`=?, `name`=?, `account_id`=?, `char_id`=?, `level`=?, `egg_id`=?, `equip`=?, "
+ "`intimate`=?, `hungry`=?, `rename_flag`=?, `incubate`=?, `autofeed`=? "
"WHERE `pet_id`=?";
if (SQL_ERROR == SQL->StmtPrepare(stmt, query, pet_db) ||