summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-16 03:05:29 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-16 03:05:29 +0000
commitbc2b385a1898407fe5978b66c0f795b8235d52cd (patch)
treeaea92c868a2e9de37045cfae8627f723e1d50a4e /src/map
parent2152f7e6123dabf84f622a53ab43bb63003a2549 (diff)
downloadhercules-bc2b385a1898407fe5978b66c0f795b8235d52cd.tar.gz
hercules-bc2b385a1898407fe5978b66c0f795b8235d52cd.tar.bz2
hercules-bc2b385a1898407fe5978b66c0f795b8235d52cd.tar.xz
hercules-bc2b385a1898407fe5978b66c0f795b8235d52cd.zip
- Merged Adam's patch to let the char-server handle validation of pet-name-change requests through the allowed char letters config.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7192 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/intif.c44
-rw-r--r--src/map/intif.h1
-rw-r--r--src/map/pet.c5
-rw-r--r--src/map/pet.h2
5 files changed, 45 insertions, 9 deletions
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);