summaryrefslogtreecommitdiff
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
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
-rw-r--r--Changelog-Trunk.txt9
-rw-r--r--src/char_sql/int_guild.c1
-rw-r--r--src/map/clif.c17
-rw-r--r--src/map/guild.c41
-rw-r--r--src/map/guild.h3
5 files changed, 39 insertions, 32 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 6ad76bae6..b75908e3e 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,14 +4,15 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/12/11
- * made @hominfo display the six basic stats. [Skotlex]
+ * Added various missing checks when parsing several guild actions.
+ * made @hominfo display the six basic stats.
* Simplified the MD_DETECTOR checks, since now all insects/demons have it
set, and it's no longer needed to check for the race. [Skotlex]
* Updated sql files [Playtester]
- * Spirit of Sin and Enchant Deadly Poison now stack. [Skotlex]
- * Fixed skill damage card bonuses not working on magic skills. [Skotlex]
+ * Spirit of Sin and Enchant Deadly Poison now stack.
+ * Fixed skill damage card bonuses not working on magic skills.
* Moved the setting of sd->npc_id = 0 in npc_dequeue to the beginning,
- since this function is called when a script is cancelled [Skotlex]
+ since this function is called when a script is cancelled
* Made homunc's speed be recalculated when you respawn it from rest state.
[Skotlex]
* Fixed @revive not reviving the good char [Toms]
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index dbb9bc1ad..9132f9ec2 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -1773,7 +1773,6 @@ int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position
memcpy(&g->position[idx],p,sizeof(struct guild_position));
mapif_guild_position(g,idx);
- ShowInfo("int_guild: position data changed (Guild %d, position %d)\n",guild_id, idx);
g->position[idx].modified = GS_POSITION_MODIFIED;
g->save_flag |= GS_POSITION; // Change guild_position
return 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index b2e680b93..9b8bcfdeb 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10578,6 +10578,7 @@ void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) {
*/
void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) {
RFIFOHEAD(fd);
+ if (!sd->status.guild_id) return;
switch(RFIFOL(fd,2)){
case 0: // ギルド基本情報、同盟敵対情報
clif_guild_basicinfo(sd);
@@ -10612,8 +10613,11 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
int i;
RFIFOHEAD(fd);
+ if(!sd->state.gmaster_flag)
+ return;
+
for(i = 4; i < RFIFOW(fd,2); i += 40 ){
- guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
+ guild_change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
}
}
@@ -10624,6 +10628,9 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) {
int i;
RFIFOHEAD(fd);
+
+ if(!sd->state.gmaster_flag)
+ return;
for(i=4;i<RFIFOW(fd,2);i+=12){
guild_change_memberposition(sd->status.guild_id,
@@ -10649,6 +10656,10 @@ void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) {
*/
void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
RFIFOHEAD(fd);
+
+ if(!sd->state.gmaster_flag)
+ return;
+
guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4));
}
@@ -10658,6 +10669,10 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
*/
void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) {
RFIFOHEAD(fd);
+
+ if(!sd->state.gmaster_flag)
+ return;
+
guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
}
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 && (
diff --git a/src/map/guild.h b/src/map/guild.h
index 69174e021..7de747b8d 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -63,8 +63,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online);
int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_);
int guild_change_memberposition(int guild_id,int account_id,int char_id,int idx);
int guild_memberposition_changed(struct guild *g,int idx,int pos);
-int guild_change_position(struct map_session_data *sd,int idx,
- int mode,int exp_mode,const char *name);
+int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char *name);
int guild_position_changed(int guild_id,int idx,struct guild_position *p);
int guild_change_notice(struct map_session_data *sd,int guild_id,const char *mes1,const char *mes2);
int guild_notice_changed(int guild_id,const char *mes1,const char *mes2);