diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 2 | ||||
-rw-r--r-- | src/char/int_pet.c | 217 | ||||
-rw-r--r-- | src/char/inter.c | 4 | ||||
-rw-r--r-- | src/char_sql/int_pet.c | 40 | ||||
-rw-r--r-- | src/char_sql/inter.c | 4 | ||||
-rw-r--r-- | src/map/clif.c | 2 | ||||
-rw-r--r-- | src/map/intif.c | 44 | ||||
-rw-r--r-- | src/map/intif.h | 1 | ||||
-rw-r--r-- | src/map/pet.c | 5 | ||||
-rw-r--r-- | src/map/pet.h | 2 |
10 files changed, 218 insertions, 103 deletions
diff --git a/src/char/char.c b/src/char/char.c index 701240f60..fc8631c88 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2376,7 +2376,7 @@ int char_account_reg_reply(int fd,int account_id,int char_id) { return 0;
}
-void char_read_fame_list()
+void char_read_fame_list(void)
{
int i, j, k;
struct fame_list fame_item;
diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 0c029e445..d787b9821 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -217,116 +217,149 @@ int mapif_delete_pet_ack(int fd,int flag) WFIFOB(fd,2)=flag;
WFIFOSET(fd,3);
- return 0;
-}
-
-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)
-{
- struct s_pet *p;
- p= (struct s_pet *) aCalloc(sizeof(struct s_pet), 1);
- if(p==NULL){
- ShowFatalError("int_pet: out of memory !\n");
- mapif_pet_created(fd,account_id,NULL);
return 0;
}
-// memset(p,0,sizeof(struct s_pet)); unnecessary after aCalloc [Skotlex]
- p->pet_id = pet_newid++;
- memcpy(p->name,pet_name,NAME_LENGTH-1);
- if(incuvate == 1)
- p->account_id = p->char_id = 0;
- else {
- p->account_id = account_id;
- p->char_id = char_id;
- }
- p->class_ = pet_class;
- p->level = pet_lv;
- p->egg_id = pet_egg_id;
- p->equip = pet_equip;
- p->intimate = intimate;
- p->hungry = hungry;
- p->rename_flag = rename_flag;
- p->incuvate = incuvate;
- if(p->hungry < 0)
- p->hungry = 0;
- else if(p->hungry > 100)
- p->hungry = 100;
- if(p->intimate < 0)
- p->intimate = 0;
- else if(p->intimate > 1000)
- p->intimate = 1000;
-
- idb_put(pet_db,p->pet_id,p);
-
- mapif_pet_created(fd,account_id,p);
+int mapif_rename_pet_ack(int fd, int account_id, int char_id, int flag, char *name){
+ WFIFOW(fd, 0) =0x3884;
+ WFIFOL(fd, 2) =account_id;
+ WFIFOL(fd, 6) =char_id;
+ WFIFOB(fd, 10) =flag;
+ memcpy(WFIFOP(fd, 11), name, NAME_LENGTH);
+ WFIFOSET(fd, NAME_LENGTH+12);
return 0;
}
-int mapif_load_pet(int fd,int account_id,int char_id,int pet_id)
-{
- struct s_pet *p;
- p= idb_get(pet_db,pet_id);
- if(p!=NULL) {
- if(p->incuvate == 1) {
+ 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)
+ {
+ struct s_pet *p;
+ p= (struct s_pet *) aCalloc(sizeof(struct s_pet), 1);
+ if(p==NULL){
+ ShowFatalError("int_pet: out of memory !\n");
+ mapif_pet_created(fd,account_id,NULL);
+ return 0;
+ }
+ // memset(p,0,sizeof(struct s_pet)); unnecessary after aCalloc [Skotlex]
+ p->pet_id = pet_newid++;
+ memcpy(p->name,pet_name,NAME_LENGTH-1);
+ if(incuvate == 1)
p->account_id = p->char_id = 0;
- mapif_pet_info(fd,account_id,p);
+ else {
+ p->account_id = account_id;
+ p->char_id = char_id;
+ }
+ p->class_ = pet_class;
+ p->level = pet_lv;
+ p->egg_id = pet_egg_id;
+ p->equip = pet_equip;
+ p->intimate = intimate;
+ p->hungry = hungry;
+ p->rename_flag = rename_flag;
+ p->incuvate = incuvate;
+
+ if(p->hungry < 0)
+ p->hungry = 0;
+ else if(p->hungry > 100)
+ p->hungry = 100;
+ if(p->intimate < 0)
+ p->intimate = 0;
+ else if(p->intimate > 1000)
+ p->intimate = 1000;
+
+ idb_put(pet_db,p->pet_id,p);
+
+ mapif_pet_created(fd,account_id,p);
+
+ return 0;
+ }
+
+ int mapif_load_pet(int fd,int account_id,int char_id,int pet_id)
+ {
+ struct s_pet *p;
+ p= idb_get(pet_db,pet_id);
+ if(p!=NULL) {
+ if(p->incuvate == 1) {
+ p->account_id = p->char_id = 0;
+ mapif_pet_info(fd,account_id,p);
+ }
+ else if(account_id == p->account_id && char_id == p->char_id)
+ mapif_pet_info(fd,account_id,p);
+ else
+ mapif_pet_noinfo(fd,account_id);
}
- else if(account_id == p->account_id && char_id == p->char_id)
- mapif_pet_info(fd,account_id,p);
else
mapif_pet_noinfo(fd,account_id);
- }
- else
- mapif_pet_noinfo(fd,account_id);
- return 0;
-}
+ return 0;
+ }
-static void* create_pet(DBKey key, va_list args) {
- struct s_pet *p;
- p=(struct s_pet *)aCalloc(sizeof(struct s_pet),1);
- p->pet_id = key.i;
- return p;
-}
-int mapif_save_pet(int fd,int account_id,struct s_pet *data)
-{
- struct s_pet *p;
- int pet_id, len;
- RFIFOHEAD(fd);
- len=RFIFOW(fd,2);
-
- if(sizeof(struct s_pet)!=len-8) {
- ShowError("inter pet: data size error %d %d\n",sizeof(struct s_pet),len-8);
+ static void* create_pet(DBKey key, va_list args) {
+ struct s_pet *p;
+ p=(struct s_pet *)aCalloc(sizeof(struct s_pet),1);
+ p->pet_id = key.i;
+ return p;
}
- else{
- pet_id = data->pet_id;
- if (pet_id == 0)
- pet_id = data->pet_id = pet_newid++;
- p= idb_ensure(pet_db,pet_id,create_pet);
- if(data->hungry < 0)
- data->hungry = 0;
- else if(data->hungry > 100)
- data->hungry = 100;
- if(data->intimate < 0)
- data->intimate = 0;
- else if(data->intimate > 1000)
- data->intimate = 1000;
- memcpy(p,data,sizeof(struct s_pet));
- if(p->incuvate == 1)
- p->account_id = p->char_id = 0;
+ int mapif_save_pet(int fd,int account_id,struct s_pet *data)
+ {
+ struct s_pet *p;
+ int pet_id, len;
+ RFIFOHEAD(fd);
+ len=RFIFOW(fd,2);
+
+ if(sizeof(struct s_pet)!=len-8) {
+ ShowError("inter pet: data size error %d %d\n",sizeof(struct s_pet),len-8);
+ }
+ else{
+ pet_id = data->pet_id;
+ if (pet_id == 0)
+ pet_id = data->pet_id = pet_newid++;
+ p= idb_ensure(pet_db,pet_id,create_pet);
+ if(data->hungry < 0)
+ data->hungry = 0;
+ else if(data->hungry > 100)
+ data->hungry = 100;
+ if(data->intimate < 0)
+ data->intimate = 0;
+ else if(data->intimate > 1000)
+ data->intimate = 1000;
+ memcpy(p,data,sizeof(struct s_pet));
+ if(p->incuvate == 1)
+ p->account_id = p->char_id = 0;
+
+ mapif_save_pet_ack(fd,account_id,0);
+ }
- mapif_save_pet_ack(fd,account_id,0);
+ return 0;
}
+ int mapif_delete_pet(int fd,int pet_id)
+ {
+ mapif_delete_pet_ack(fd,inter_pet_delete(pet_id));
+
return 0;
}
-int mapif_delete_pet(int fd,int pet_id)
-{
- mapif_delete_pet_ack(fd,inter_pet_delete(pet_id));
+int mapif_rename_pet(int fd, int account_id, int char_id, char *name){
+ int i;
+
+ // Check Authorised letters/symbols in the name of the pet
+ if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
+ for (i = 0; i < NAME_LENGTH && name[i]; i++)
+ if (strchr(char_name_letters, name[i]) == NULL) {
+ mapif_rename_pet_ack(fd, account_id, char_id, 0, name);
+ return 0;
+ }
+ } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
+ for (i = 0; i < NAME_LENGTH && name[i]; i++)
+ if (strchr(char_name_letters, name[i]) != NULL) {
+ mapif_rename_pet_ack(fd, account_id, char_id, 0, name);
+ return 0;
+ }
+ }
+ mapif_rename_pet_ack(fd, account_id, char_id, 1, name);
return 0;
}
@@ -359,6 +392,11 @@ int mapif_parse_DeletePet(int fd) return 0;
}
+int mapif_parse_RenamePet(int fd){
+ mapif_rename_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOP(fd, 10));
+ return 0;
+}
+
// map server からの通信
// ・1パケットのみ解析すること
// ・パケット長データはinter.cにセットしておくこと
@@ -372,6 +410,7 @@ int inter_pet_parse_frommap(int fd) case 0x3081: mapif_parse_LoadPet(fd); break;
case 0x3082: mapif_parse_SavePet(fd); break;
case 0x3083: mapif_parse_DeletePet(fd); break;
+ case 0x3084: mapif_parse_RenamePet(fd); break;
default:
return 0;
}
diff --git a/src/char/inter.c b/src/char/inter.c index adedc6a7b..491eb8f3a 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -49,7 +49,7 @@ int inter_send_packet_length[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
// recv. packet list
int inter_recv_packet_length[] = {
@@ -61,7 +61,7 @@ int inter_recv_packet_length[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3080-0x308f
+ 48,14,-1, 6, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3080-0x308f
};
struct WisData {
diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 15ecd4853..c036a6019 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -195,6 +195,18 @@ int mapif_delete_pet_ack(int fd, int flag){ return 0;
}
+int mapif_rename_pet_ack(int fd, int account_id, int char_id, int flag, char *name){
+ WFIFOW(fd, 0) =0x3884;
+ WFIFOL(fd, 2) =account_id;
+ WFIFOL(fd, 6) =char_id;
+ WFIFOB(fd, 10) =flag;
+ memcpy(WFIFOP(fd, 11), name, NAME_LENGTH);
+ WFIFOSET(fd, NAME_LENGTH+12);
+
+ return 0;
+}
+
+
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){
@@ -283,6 +295,28 @@ int mapif_delete_pet(int fd, int pet_id){ return 0;
}
+int mapif_rename_pet(int fd, int account_id, int char_id, char *name){
+ int i;
+
+ // Check Authorised letters/symbols in the name of the pet
+ if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
+ for (i = 0; i < NAME_LENGTH && name[i]; i++)
+ if (strchr(char_name_letters, name[i]) == NULL) {
+ mapif_rename_pet_ack(fd, account_id, char_id, 0, name);
+ return 0;
+ }
+ } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
+ for (i = 0; i < NAME_LENGTH && name[i]; i++)
+ if (strchr(char_name_letters, name[i]) != NULL) {
+ mapif_rename_pet_ack(fd, account_id, char_id, 0, name);
+ return 0;
+ }
+ }
+
+ mapif_rename_pet_ack(fd, account_id, char_id, 1, name);
+ return 0;
+}
+
int mapif_parse_CreatePet(int fd){
mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18),
RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24));
@@ -304,12 +338,18 @@ int mapif_parse_DeletePet(int fd){ return 0;
}
+int mapif_parse_RenamePet(int fd){
+ mapif_rename_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOP(fd, 10));
+ return 0;
+}
+
int inter_pet_parse_frommap(int fd){
switch(RFIFOW(fd, 0)){
case 0x3080: mapif_parse_CreatePet(fd); break;
case 0x3081: mapif_parse_LoadPet(fd); break;
case 0x3082: mapif_parse_SavePet(fd); break;
case 0x3083: mapif_parse_DeletePet(fd); break;
+ case 0x3084: mapif_parse_RenamePet(fd); break;
default:
return 0;
}
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 137e25d47..f2e00c671 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -67,7 +67,7 @@ int inter_send_packet_length[]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
// recv. packet list
int inter_recv_packet_length[]={
@@ -79,7 +79,7 @@ int inter_recv_packet_length[]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3080-0x308f
+ 48,14,-1, 6, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3080-0x308f
};
struct WisData {
diff --git a/src/map/clif.c b/src/map/clif.c index ba24dd3b1..7e3821ee2 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10416,7 +10416,7 @@ void clif_parse_SendEmotion(int fd, struct map_session_data *sd) { void clif_parse_ChangePetName(int fd, struct map_session_data *sd) {
RFIFOHEAD(fd);
- pet_change_name(sd,(char*)RFIFOP(fd,2));
+ pet_change_name(sd,(char*)RFIFOP(fd,2), 0);
}
// Kick (right click menu for GM "(name) force to quit")
diff --git a/src/map/intif.c b/src/map/intif.c index d26c37d93..8cd66e364 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -21,9 +21,10 @@ #include <string.h>
#include "../common/showmsg.h"
-
-#include "socket.h"
-#include "timer.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/nullpo.h"
+#include "../common/malloc.h"
#include "map.h"
#include "battle.h"
#include "chrif.h"
@@ -34,8 +35,7 @@ #include "party.h"
#include "guild.h"
#include "pet.h"
-#include "nullpo.h"
-#include "malloc.h"
+#include "atcommand.h"
static const int packet_len_table[]={
-1,-1,27,-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
@@ -46,7 +46,7 @@ static const int packet_len_table[]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
+ 11,-1, 7, 3, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
};
extern int char_fd; // inter serverのfdはchar_fdを使う
@@ -122,6 +122,20 @@ int intif_delete_petdata(int pet_id) return 0;
}
+int intif_rename_pet(struct map_session_data *sd,char *name)
+{
+ if (CheckForCharServer())
+ return 1;
+
+ WFIFOHEAD(inter_fd,NAME_LENGTH+11);
+ WFIFOW(inter_fd,0) = 0x3084;
+ WFIFOL(inter_fd,2) = sd->status.account_id;
+ WFIFOL(inter_fd,6) = sd->status.char_id;
+ memcpy(WFIFOP(inter_fd,10),name, NAME_LENGTH);
+ WFIFOSET(inter_fd,NAME_LENGTH+11);
+ return 0;
+}
+
// GMメッセージを送信
int intif_GMmessage(char* mes,int len,int flag)
@@ -1349,6 +1363,23 @@ int intif_parse_DeletePetOk(int fd) return 0;
}
+
+int intif_parse_RenamePetOk(int fd)
+{
+ RFIFOHEAD(fd);
+ struct map_session_data *sd;
+ if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
+ sd->status.char_id != RFIFOL(fd,6))
+ return 0;
+ if (RFIFOB(fd,10) == 0) {
+ clif_displaymessage(sd->fd, msg_txt(280)); // You cannot use this name for your pet.
+ clif_send_petstatus(sd); //Send status so client knows oet name change got rejected.
+ return 0;
+ }
+ pet_change_name(sd, RFIFOP(fd,11),1);
+ return 0;
+}
+
//-----------------------------------------------------------------
// inter serverからの通信
// エラーがあれば0(false)を返すこと
@@ -1423,6 +1454,7 @@ int intif_parse(int fd) case 0x3881: intif_parse_RecvPetData(fd); break;
case 0x3882: intif_parse_SavePetOk(fd); break;
case 0x3883: intif_parse_DeletePetOk(fd); break;
+ case 0x3884: intif_parse_RenamePetOk(fd); break;
default:
if(battle_config.error_log)
ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
diff --git a/src/map/intif.h b/src/map/intif.h index 2306063f1..43a6c17a2 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -57,6 +57,7 @@ int intif_create_pet(int account_id, int char_id, short pet_type, short pet_lv, int intif_request_petdata(int account_id, int char_id, int pet_id);
int intif_save_petdata(int account_id, struct s_pet *p);
int intif_delete_petdata(int pet_id);
+int intif_rename_pet(struct map_session_data *sd, char *name);
int CheckForCharServer(void);
diff --git a/src/map/pet.c b/src/map/pet.c index 091f733da..2c21b85b8 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -682,7 +682,7 @@ int pet_menu(struct map_session_data *sd,int menunum) return 0;
}
-int pet_change_name(struct map_session_data *sd,char *name)
+int pet_change_name(struct map_session_data *sd,char *name, int flag) //flag 0 = check name, 1 = good name
{
int i;
@@ -696,6 +696,9 @@ int pet_change_name(struct map_session_data *sd,char *name) return 1;
}
+ if (!flag)
+ return intif_rename_pet(sd, name);
+
pet_stop_walking(sd->pd,1);
memcpy(sd->pet.name, name, NAME_LENGTH-1);
diff --git a/src/map/pet.h b/src/map/pet.h index 16a0a4b89..619db93d1 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -47,7 +47,7 @@ int pet_catch_process1(struct map_session_data *sd,int target_class); int pet_catch_process2(struct map_session_data *sd,int target_id);
int pet_get_egg(int account_id,int pet_id,int flag);
int pet_menu(struct map_session_data *sd,int menunum);
-int pet_change_name(struct map_session_data *sd,char *name);
+int pet_change_name(struct map_session_data *sd,char *name,int flag); //flag 0 = check name, 1 = good name
int pet_equipitem(struct map_session_data *sd,int index);
int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd);
int pet_attackskill(struct pet_data *pd, int target_id);
|