summaryrefslogtreecommitdiff
path: root/src/map/guild.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-11 20:43:34 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-11 20:43:34 +0000
commit9fbe8dc7492c25bd0673d386e31982aa5026fdbc (patch)
treed2ea3f04c4aee6107d31c452aef33c78df607713 /src/map/guild.c
parente563484415eb4dd39831a71cc0055b7fe4bceccb (diff)
downloadhercules-9fbe8dc7492c25bd0673d386e31982aa5026fdbc.tar.gz
hercules-9fbe8dc7492c25bd0673d386e31982aa5026fdbc.tar.bz2
hercules-9fbe8dc7492c25bd0673d386e31982aa5026fdbc.tar.xz
hercules-9fbe8dc7492c25bd0673d386e31982aa5026fdbc.zip
- Added various guild packet related missing checks
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9467 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/guild.c')
-rw-r--r--src/map/guild.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index 0b3be181b..6ad15968e 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -638,6 +638,9 @@ int guild_invite(struct map_session_data *sd,struct map_session_data *tsd)
if(tsd==NULL || g==NULL)
return 0;
+ if( (i=guild_getposition(sd,g))<0 || !(g->position[i].mode&0x0001) )
+ return 0; //Invite permission.
+
if(!battle_config.invite_request_check) {
if (tsd->party_invite>0 || tsd->trade_partner) { // 相手が取引中かどうか
clif_guild_inviteack(sd,0);
@@ -651,7 +654,7 @@ int guild_invite(struct map_session_data *sd,struct map_session_data *tsd)
clif_guild_inviteack(sd,0);
return 0;
}
-
+
// 定員確認
for(i=0;i<g->max_member;i++)
if(g->member[i].account_id==0)
@@ -770,7 +773,6 @@ int guild_leave(struct map_session_data *sd,int guild_id,
int account_id,int char_id,const char *mes)
{
struct guild *g;
- int i;
nullpo_retr(0, sd);
@@ -779,18 +781,12 @@ int guild_leave(struct map_session_data *sd,int guild_id,
if(g==NULL)
return 0;
- if( sd->status.account_id!=account_id ||
+ if(sd->status.account_id!=account_id ||
sd->status.char_id!=char_id || sd->status.guild_id!=guild_id ||
map[sd->bl.m].flag.gvg_castle) //Can't leave inside guild castles.
return 0;
- for(i=0;i<g->max_member;i++){ // 所属しているか
- if( g->member[i].account_id==sd->status.account_id &&
- g->member[i].char_id==sd->status.char_id ){
- intif_guild_leave(g->guild_id,sd->status.account_id,sd->status.char_id,0,mes);
- return 0;
- }
- }
+ intif_guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes);
return 0;
}
// ギルド追放要求
@@ -811,15 +807,14 @@ int guild_expulsion(struct map_session_data *sd,int guild_id,
return 0;
if( (ps=guild_getposition(sd,g))<0 || !(g->position[ps].mode&0x0010) )
- return 0; // 処罰権限無し
+ return 0; //Expulsion permission
for(i=0;i<g->max_member;i++){ // 所属しているか
- if( g->member[i].account_id==account_id &&
+ if(g->member[i].account_id==account_id &&
g->member[i].char_id==char_id ){
+ if(!strcmp(g->member[i].name,g->master))
+ return 0; //Can't expel the GM!
intif_guild_leave(g->guild_id,account_id,char_id,1,mes);
- //It's wrong way, member info will erased later
- //see guild_member_leaved [LuzZza]
- //malloc_set(&g->member[i],0,sizeof(struct guild_member));
return 0;
}
}
@@ -1023,21 +1018,19 @@ int guild_memberposition_changed(struct guild *g,int idx,int pos)
return 0;
}
// ギルド役職変更
-int guild_change_position(struct map_session_data *sd,int idx,
+int guild_change_position(int guild_id,int idx,
int mode,int exp_mode,const char *name)
{
struct guild_position p;
- nullpo_retr(0, sd);
-
- if(exp_mode>battle_config.guild_exp_limit)
- exp_mode=battle_config.guild_exp_limit;
- if(exp_mode<0)exp_mode=0;
- p.mode=mode;
+ exp_mode = cap_value(exp_mode, 0, battle_config.guild_exp_limit);
+ //Mode 0x01 <- Invite
+ //Mode 0x10 <- Expel.
+ p.mode=mode&0x11;
p.exp_mode=exp_mode;
memcpy(p.name,name,NAME_LENGTH-1);
p.name[NAME_LENGTH-1] = '\0'; //Security check... [Skotlex]
- return intif_guild_position(sd->status.guild_id,idx,&p);
+ return intif_guild_position(guild_id,idx,&p);
}
// ギルド役職変更通知
int guild_position_changed(int guild_id,int idx,struct guild_position *p)
@@ -1658,7 +1651,7 @@ int guild_break(struct map_session_data *sd,char *name)
return 0;
if(strcmp(g->name,name)!=0)
return 0;
- if(strcmp(sd->status.name,g->master)!=0)
+ if(!sd->state.gmaster_flag)
return 0;
for(i=0;i<g->max_member;i++){
if( g->member[i].account_id>0 && (