summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-09 16:22:40 -0300
committershennetsind <ind@henn.et>2013-05-09 16:22:40 -0300
commitcd2f5e4a687b2abbdb9d795e5c91b874aa0d2546 (patch)
treec6499221fc24b6923d2a5e54e9d5761e242be811 /src/map/clif.c
parentf6316ec0dbe6357831698d9bbb8f5fc0cf428344 (diff)
downloadhercules-cd2f5e4a687b2abbdb9d795e5c91b874aa0d2546.tar.gz
hercules-cd2f5e4a687b2abbdb9d795e5c91b874aa0d2546.tar.bz2
hercules-cd2f5e4a687b2abbdb9d795e5c91b874aa0d2546.tar.xz
hercules-cd2f5e4a687b2abbdb9d795e5c91b874aa0d2546.zip
Fixed Ally Chat / Bug #7228
http://hercules.ws/board/tracker/issue-7228-ally-channel-problems/ Signed-off-by: shennetsind <ind@henn.et>
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;
/*------------------------