summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c29
-rw-r--r--src/map/clif.c68
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/guild.c50
4 files changed, 123 insertions, 26 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index bf536f152..f36d5b8a6 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8790,7 +8790,7 @@ ACMD(join) {
}
if( idb_exists(channel->users, sd->status.char_id) ) {
- sprintf(atcmd_output, msg_txt(1434),name); // You're already in the '%s' channel
+ sprintf(atcmd_output, msg_txt(1475),name); // You're already in the '%s' channel
clif->message(fd, atcmd_output);
return false;
}
@@ -8814,7 +8814,17 @@ ACMD(join) {
sprintf(atcmd_output, msg_txt(1403),name); // You're now in the '%s' channel
clif->message(fd, atcmd_output);
}
-
+ if( channel->type == hChSys_ALLY ) {
+ struct guild *g = sd->guild, *sg = NULL;
+ int i;
+ for (i = 0; i < MAX_GUILDALLIANCE; i++) {
+ if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
+ if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id))) {
+ clif->chsys_join((struct hChSysCh *)sg->channel,sd);
+ }
+ }
+ }
+ }
clif->chsys_join(channel,sd);
return true;
@@ -8988,7 +8998,6 @@ ACMD(channel) {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
-
for(k = 0; k < sd->channel_count; k++) {
if( strcmpi(sub1+1,sd->channels[k]->name) == 0 )
break;
@@ -8998,8 +9007,18 @@ ACMD(channel) {
clif->message(fd, atcmd_output);
return false;
}
- clif->chsys_left(sd->channels[k],sd);
- sprintf(atcmd_output, msg_txt(1425),sub1); // You've left the '%s' channel
+ if( sd->channels[k]->type == hChSys_ALLY ) {
+ do {
+ for(k = 0; k < sd->channel_count; k++) {
+ if( sd->channels[k]->type == hChSys_ALLY ) {
+ clif->chsys_left(sd->channels[k],sd);
+ break;
+ }
+ }
+ } while( k != sd->channel_count );
+ } else
+ clif->chsys_left(sd->channels[k],sd);
+ sprintf(atcmd_output, msg_txt(1426),sub1); // You've left the '%s' channel
clif->message(fd, atcmd_output);
} else if ( strcmpi(key,"bindto") == 0 ) {
diff --git a/src/map/clif.c b/src/map/clif.c
index f391cdf2b..251dc98c4 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2058,9 +2058,11 @@ void clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, in
WFIFOSET(fd,packet_len(0x144));
}
void clif_hercules_chsys_join(struct hChSysCh *channel, struct map_session_data *sd) {
+ if( idb_put(channel->users, sd->status.char_id, sd) )
+ return;
+
RECREATE(sd->channels, struct hChSysCh *, ++sd->channel_count);
sd->channels[ sd->channel_count - 1 ] = channel;
- idb_put(channel->users, sd->status.char_id, sd);
if( sd->stealth ) {
sd->stealth = false;
@@ -10087,7 +10089,9 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
void clif_hercules_chsys_left(struct hChSysCh *channel, struct map_session_data *sd) {
unsigned char i;
- idb_remove(channel->users,sd->status.char_id);
+
+ if ( !idb_remove(channel->users,sd->status.char_id) )
+ return;
if( channel == sd->gcbind )
sd->gcbind = NULL;
@@ -10131,7 +10135,9 @@ void clif_hercules_chsys_quitg(struct map_session_data *sd) {
for( i = 0; i < sd->channel_count; i++ ) {
if( (channel = sd->channels[i] ) != NULL && channel->type == hChSys_ALLY ) {
- idb_remove(channel->users,sd->status.char_id);
+
+ if ( !idb_remove(channel->users,sd->status.char_id) )
+ continue;
if( channel == sd->gcbind )
sd->gcbind = NULL;
@@ -10331,6 +10337,16 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if( k < sd->channel_count ) {
clif->chsys_send(channel,sd,message);
} else if( channel->pass[0] == '\0' && !(channel->banned && idb_exists(channel->banned, sd->status.account_id)) ) {
+ if( channel->type == hChSys_ALLY ) {
+ struct guild *g = sd->guild, *sg = NULL;
+ int k;
+ for (k = 0; k < MAX_GUILDALLIANCE; k++) {
+ if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
+ if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
+ clif->chsys_join((struct hChSysCh *)sg->channel,sd);
+ }
+ }
+ }
clif->chsys_join(channel,sd);
clif->chsys_send(channel,sd,message);
} else {
@@ -10593,6 +10609,50 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) {
else if( !hChSys.closing )
strdb_remove(clif->channel_db, channel->name);
}
+void clif_hercules_chsys_gjoin(struct guild *g1,struct guild *g2) {
+ struct map_session_data *sd;
+ struct hChSysCh *channel;
+ int j;
+
+ if( (channel = (struct hChSysCh*)g1->channel) ) {
+ for(j = 0; j < g2->max_member; j++) {
+ if( (sd = g2->member[j].sd) != NULL ) {
+ if( !(((struct hChSysCh*)g1->channel)->banned && idb_exists(((struct hChSysCh*)g1->channel)->banned, sd->status.account_id)))
+ clif->chsys_join(channel,sd);
+ }
+ }
+ }
+
+ if( (channel = (struct hChSysCh*)g2->channel) ) {
+ for(j = 0; j < g1->max_member; j++) {
+ if( (sd = g1->member[j].sd) != NULL ) {
+ if( !(((struct hChSysCh*)g2->channel)->banned && idb_exists(((struct hChSysCh*)g2->channel)->banned, sd->status.account_id)))
+ clif->chsys_join(channel,sd);
+ }
+ }
+ }
+}
+void clif_hercules_chsys_gleave(struct guild *g1,struct guild *g2) {
+ struct map_session_data *sd;
+ struct hChSysCh *channel;
+ int j;
+
+ if( (channel = (struct hChSysCh*)g1->channel) ) {
+ for(j = 0; j < g2->max_member; j++) {
+ if( (sd = g2->member[j].sd) != NULL ) {
+ clif->chsys_left(channel,sd);
+ }
+ }
+ }
+
+ if( (channel = (struct hChSysCh*)g2->channel) ) {
+ for(j = 0; j < g1->max_member; j++) {
+ if( (sd = g1->member[j].sd) != NULL ) {
+ clif->chsys_left(channel,sd);
+ }
+ }
+ }
+}
/// Request to take off an equip (CZ_REQ_TAKEOFF_EQUIP).
/// 00ab <index>.W
@@ -17489,6 +17549,8 @@ void clif_defaults(void) {
clif->chsys_mjoin = clif_hercules_chsys_mjoin;
clif->chsys_quit = clif_hercules_chsys_quit;
clif->chsys_quitg = clif_hercules_chsys_quitg;
+ clif->chsys_gjoin = clif_hercules_chsys_gjoin;
+ clif->chsys_gleave = clif_hercules_chsys_gleave;
clif->cashshop_load = clif_cashshop_db;
clif->bc_ready = clif_bc_ready;
/*------------------------
diff --git a/src/map/clif.h b/src/map/clif.h
index d8b4876de..8abbe8a03 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -876,6 +876,8 @@ struct clif_interface {
void (*chsys_mjoin) (struct map_session_data *sd);
void (*chsys_quit) (struct map_session_data *sd);
void (*chsys_quitg) (struct map_session_data *sd);
+ void (*chsys_gjoin) (struct guild *g1,struct guild *g2);
+ void (*chsys_gleave) (struct guild *g1,struct guild *g2);
void (*bc_ready) (void);
/*------------------------
*- Parse Incoming Packet
diff --git a/src/map/guild.c b/src/map/guild.c
index cc9b3e812..5e8a5897a 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -515,25 +515,36 @@ int guild_recv_info(struct guild *sg) {
clif->chsys_create(channel,NULL,NULL,hChSys.ally_color);
if( hChSys.ally_autojoin ) {
struct s_mapiterator* iter = mapit_getallusers();
+ struct guild *tg[MAX_GUILDALLIANCE];
+ for (i = 0; i < MAX_GUILDALLIANCE; i++) {
+ tg[i] = NULL;
+ if( sg->alliance[i].opposition == 0 && sg->alliance[i].guild_id )
+ tg[i] = guild_search(sg->alliance[i].guild_id);
+ }
+
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) {
if( sd->status.guild_id ) {
if( sd->status.guild_id == sg->guild_id ) {
clif->chsys_join(channel,sd);
sd->guild = g;
- continue;
}
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
- if( sg->alliance[i].guild_id == sd->status.guild_id ) {
- clif->chsys_join(channel,sd);
- break;
+ if( sg->alliance[i].opposition == 0 && sg->alliance[i].guild_id ) {
+ if( sg->alliance[i].guild_id == sd->status.guild_id ) {
+ clif->chsys_join(channel,sd);
+ } else if( tg[i] != NULL ) {
+ if( !(((struct hChSysCh*)tg[i]->channel)->banned && idb_exists(((struct hChSysCh*)tg[i]->channel)->banned, sd->status.account_id)))
+ clif->chsys_join((struct hChSysCh*)tg[i]->channel,sd);
+ }
}
}
}
}
-
+
mapit_free(iter);
+
}
aChSysSave = (void*)channel;
@@ -756,12 +767,11 @@ void guild_member_joined(struct map_session_data *sd)
if( hChSys.ally && hChSys.ally_autojoin ) {
struct guild* sg = NULL;
struct hChSysCh *channel = (struct hChSysCh*)g->channel;
-
+
if( !(channel->banned && idb_exists(channel->banned, sd->status.account_id) ) )
clif->chsys_join(channel,sd);
-
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
- if( g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
+ if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
clif->chsys_join((struct hChSysCh*)sg->channel,sd);
}
@@ -1627,14 +1637,20 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
return 0;
}
+ if( g[0] && g[1] && hChSys.ally && ( flag & 1 ) == 0 ) {
+ if( !(flag & 0x08) ) {
+ if( hChSys.ally_autojoin )
+ clif->chsys_gjoin(g[0],g[1]);
+ } else {
+ clif->chsys_gleave(g[0],g[1]);
+ }
+ }
+
if (!(flag & 0x08)) { // new relationship
- for(i=0;i<2-(flag&1);i++)
- {
- if(g[i]!=NULL)
- {
+ for(i=0;i<2-(flag&1);i++) {
+ if(g[i]!=NULL) {
ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 );
- if( j < MAX_GUILDALLIANCE )
- {
+ if( j < MAX_GUILDALLIANCE ) {
g[i]->alliance[j].guild_id=guild_id[1-i];
memcpy(g[i]->alliance[j].name,guild_name[1-i],NAME_LENGTH);
g[i]->alliance[j].opposition=flag&1;
@@ -1642,10 +1658,8 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
}
}
} else { // remove relationship
- for(i=0;i<2-(flag&1);i++)
- {
- if(g[i]!=NULL)
- {
+ for(i=0;i<2-(flag&1);i++) {
+ if( g[i] != NULL ) {
ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == guild_id[1-i] && g[i]->alliance[j].opposition == (flag&1) );
if( j < MAX_GUILDALLIANCE )
g[i]->alliance[j].guild_id = 0;