summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-08 15:54:52 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-08 15:54:52 +0000
commit7410adee2a636b1fab6adcd5a581048146d2a9a5 (patch)
tree07b55588a54f6e684ff187fbf2e9641ba032d9ca
parent87ac3c6f8367ba972124231ff1306ed890abc6b8 (diff)
downloadhercules-7410adee2a636b1fab6adcd5a581048146d2a9a5.tar.gz
hercules-7410adee2a636b1fab6adcd5a581048146d2a9a5.tar.bz2
hercules-7410adee2a636b1fab6adcd5a581048146d2a9a5.tar.xz
hercules-7410adee2a636b1fab6adcd5a581048146d2a9a5.zip
Small party/guild creation cleanup. Added packet comments. Removed fake reply packet usage.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12538 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--src/map/clif.c35
-rw-r--r--src/map/guild.c29
-rw-r--r--src/map/guild.h2
-rw-r--r--src/map/party.c14
4 files changed, 49 insertions, 31 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 12c43972f..a5b66d56e 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -5980,7 +5980,12 @@ int clif_mvp_exp(struct map_session_data *sd, unsigned int exp)
}
/*==========================================
- * ギルド作成可否通知
+ * Guild creation result
+ * R 0167 <flag>.B
+ * flag = 0 -> "Guild has been created."
+ * flag = 1 -> "You are already in a Guild."
+ * flag = 2 -> "That Guild Name already exists."
+ * flag = 3 -> "You need the neccessary item to create a Guild."
*------------------------------------------*/
int clif_guild_created(struct map_session_data *sd,int flag)
{
@@ -9696,7 +9701,10 @@ void clif_parse_StoragePassword(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_CreateParty(int fd, struct map_session_data *sd)
{
- if(map[sd->bl.m].flag.partylock)
+ char* name = (char*)RFIFOP(fd,2);
+ name[NAME_LENGTH-1] = '\0';
+
+ if( map[sd->bl.m].flag.partylock )
{// Party locked.
clif_displaymessage(fd, msg_txt(227));
return;
@@ -9707,15 +9715,17 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd)
return;
}
- party_create(sd,(char*)RFIFOP(fd,2),0,0);
+ party_create(sd,name,0,0);
}
-/*==========================================
- * パーティを作る
- *------------------------------------------*/
void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
{
- if(map[sd->bl.m].flag.partylock)
+ char* name = (char*)RFIFOP(fd,2);
+ int item1 = RFIFOB(fd,26);
+ int item2 = RFIFOB(fd,27);
+ name[NAME_LENGTH-1] = '\0';
+
+ if( map[sd->bl.m].flag.partylock )
{// Party locked.
clif_displaymessage(fd, msg_txt(227));
return;
@@ -9726,7 +9736,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
return;
}
- party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
+ party_create(sd,name,item1,item2);
}
/*==========================================
@@ -9951,16 +9961,21 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd)
}
/*==========================================
- * ギルドを作る
+ * Guild creation request
+ * S 0165 <account id>.L <guild name>.24S
*------------------------------------------*/
void clif_parse_CreateGuild(int fd,struct map_session_data *sd)
{
+ char* name = (char*)RFIFOP(fd,6);
+ name[NAME_LENGTH-1] = '\0';
+
if(map[sd->bl.m].flag.guildlock)
{ //Guild locked.
clif_displaymessage(fd, msg_txt(228));
return;
}
- guild_create(sd, (char*)RFIFOP(fd,6));
+
+ guild_create(sd, name);
}
/*==========================================
diff --git a/src/map/guild.c b/src/map/guild.c
index aa91ee3ac..f008f7abf 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -397,28 +397,31 @@ int guild_send_dot_remove(struct map_session_data *sd)
}
//------------------------------------------------------------------------
-// 作成要求
-int guild_create(struct map_session_data *sd,char *name)
+int guild_create(struct map_session_data *sd, const char *name)
{
char tname[NAME_LENGTH];
+ struct guild_member m;
nullpo_retr(0, sd);
safestrncpy(tname, name, NAME_LENGTH);
+ if( strlen(trim(tname)) == 0 )
+ return 0; // empty name
- if(sd->status.guild_id || strlen(trim(tname)) == 0)
- {
- clif_guild_created(sd,1); // すでに所属している
+ if( sd->status.guild_id )
+ {// already in a guild
+ clif_guild_created(sd,1);
return 0;
}
- if(!battle_config.guild_emperium_check || pc_search_inventory(sd,714) >= 0) {
- struct guild_member m;
- guild_makemember(&m,sd);
- m.position=0;
- intif_guild_create(name,&m);
- return 1;
+ if( battle_config.guild_emperium_check && pc_search_inventory(sd,714) == -1 )
+ {// item required
+ clif_guild_created(sd,3);
+ return 0;
}
- clif_guild_created(sd,3); // エンペリウムがいない
- return 0;
+
+ guild_makemember(&m,sd);
+ m.position=0;
+ intif_guild_create(name,&m);
+ return 1;
}
// 作成可否
diff --git a/src/map/guild.h b/src/map/guild.h
index e6383a3e3..61c02124b 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -44,7 +44,7 @@ int guild_getposition(struct guild *g, struct map_session_data *sd);
unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp);
int guild_getexp(struct map_session_data *sd,int exp); // [Celest]
-int guild_create(struct map_session_data *sd,char *name);
+int guild_create(struct map_session_data *sd, const char *name);
int guild_created(int account_id,int guild_id);
int guild_request_info(int guild_id);
int guild_recv_noinfo(int guild_id);
diff --git a/src/map/party.c b/src/map/party.c
index a008d07eb..22bac7467 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -110,16 +110,16 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2)
{
struct party_member leader;
char tname[NAME_LENGTH];
- safestrncpy(tname, name, NAME_LENGTH);
- if(sd->status.party_id) {
- clif_party_created(sd,2);
- return 0; // "already in a party"
+ safestrncpy(tname, name, NAME_LENGTH);
+ if( strlen(trim(tname)) == 0 )
+ {// empty name
+ return 0;
}
- if(strlen(trim(tname)) == 0)
- {
- clif_party_created(sd, 1);
+ if( sd->status.party_id )
+ {// already in a party
+ clif_party_created(sd,2);
return 0;
}