summaryrefslogtreecommitdiff
path: root/src/char/int_pet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/int_pet.c')
-rw-r--r--src/char/int_pet.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 2867aed77..0f7c683f8 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -2,26 +2,30 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/mmo.h"
-#include "../common/malloc.h"
-#include "../common/socket.h"
-#include "../common/strlib.h"
-#include "../common/showmsg.h"
-#include "../common/utils.h"
-#include "../common/sql.h"
-#include "char.h"
-#include "inter.h"
+#define HERCULES_CORE
+
+#include "int_pet.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "char.h"
+#include "inter.h"
+#include "../common/malloc.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/sql.h"
+#include "../common/strlib.h"
+#include "../common/utils.h"
+
struct s_pet *pet_pt;
//---------------------------------------------------------
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`)
+ //`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));
@@ -31,10 +35,10 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
if( pet_id == -1 )
{// New pet.
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`) "
+ "(`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->incuvate) )
+ p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate) )
{
Sql_ShowDebug(sql_handle);
return 0;
@@ -43,9 +47,9 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
}
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',`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->incuvate, p->pet_id) )
+ p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate, p->pet_id) )
{
Sql_ShowDebug(sql_handle);
return 0;
@@ -67,9 +71,9 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
#endif
memset(p, 0, sizeof(struct s_pet));
- //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
+ //`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`,`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`,`incubate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
{
Sql_ShowDebug(sql_handle);
return 0;
@@ -88,7 +92,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
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->GetData(sql_handle, 11, &data, NULL); p->incubate = atoi(data);
SQL->FreeResult(sql_handle);
@@ -122,18 +126,18 @@ int inter_pet_delete(int pet_id){
//------------------------------------------------------
int mapif_pet_created(int fd, int account_id, struct s_pet *p)
{
- WFIFOHEAD(fd, 11);
- WFIFOW(fd, 0) =0x3880;
- WFIFOL(fd, 2) =account_id;
+ WFIFOHEAD(fd, 12);
+ WFIFOW(fd, 0) = 0x3880;
+ WFIFOL(fd, 2) = account_id;
if(p!=NULL){
- WFIFOB(fd, 6)=0;
- WFIFOL(fd, 7) =p->pet_id;
+ WFIFOW(fd, 6) = p->class_;
+ WFIFOL(fd, 8) = p->pet_id;
ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name);
}else{
- WFIFOB(fd, 6)=1;
- WFIFOL(fd, 7)=0;
+ WFIFOB(fd, 6) = 0;
+ WFIFOL(fd, 8) = 0;
}
- WFIFOSET(fd, 11);
+ WFIFOSET(fd, 12);
return 0;
}
@@ -182,11 +186,11 @@ int mapif_delete_pet_ack(int fd, int flag){
}
int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
- short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name)
+ short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name)
{
memset(pet_pt, 0, sizeof(struct s_pet));
safestrncpy(pet_pt->name, pet_name, NAME_LENGTH);
- if(incuvate == 1)
+ if(incubate == 1)
pet_pt->account_id = pet_pt->char_id = 0;
else {
pet_pt->account_id = account_id;
@@ -199,7 +203,7 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short
pet_pt->intimate = intimate;
pet_pt->hungry = hungry;
pet_pt->rename_flag = rename_flag;
- pet_pt->incuvate = incuvate;
+ pet_pt->incubate = incubate;
if(pet_pt->hungry < 0)
pet_pt->hungry = 0;
@@ -225,7 +229,7 @@ int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){
inter_pet_fromsql(pet_id, pet_pt);
if(pet_pt!=NULL) {
- if(pet_pt->incuvate == 1) {
+ if(pet_pt->incubate == 1) {
pet_pt->account_id = pet_pt->char_id = 0;
mapif_pet_info(fd, account_id, pet_pt);
}