summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c68
1 files changed, 65 insertions, 3 deletions
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;
/*------------------------