summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-22 18:37:56 +0100
committerHaru <haru@dotalux.com>2015-01-24 14:37:25 +0100
commit30ac667346838d1777eed6cf90ce24341c6d2914 (patch)
tree9d0ae008e5bb036a4c524367e5c09d08a6a5a79e /src/map/clif.c
parent5066af1700e95b5db24f9998cf1ff052b45f5fa0 (diff)
downloadhercules-30ac667346838d1777eed6cf90ce24341c6d2914.tar.gz
hercules-30ac667346838d1777eed6cf90ce24341c6d2914.tar.bz2
hercules-30ac667346838d1777eed6cf90ce24341c6d2914.tar.xz
hercules-30ac667346838d1777eed6cf90ce24341c6d2914.zip
Channels refactoring: search
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index c66176d45..269b72ae1 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10040,31 +10040,13 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
return;
}
} else if( target[0] == '#' ) {
- // TODO: Split to channel.c
- struct channel_data *chan = NULL;
- char* chname = target;
+ char *chname = target;
+ struct channel_data *chan = channel->search(chname, sd);
- chname++;
-
- if (channel->config->local && strcmpi(chname, channel->config->local_name) == 0) {
- if( !map->list[sd->bl.m].channel ) {
- channel->map_join(sd);
- }
- chan = map->list[sd->bl.m].channel;
- } else if (channel->config->ally && sd->status.guild_id && strcmpi(chname, channel->config->ally_name) == 0) {
- struct guild *g = sd->guild;
- if( !g ) return;
- chan = g->channel;
- }
- if( chan || (chan = strdb_get(channel->db,chname)) ) {
+ if (chan) {
int k;
- for( k = 0; k < sd->channel_count; k++ ) {
- if( sd->channels[k] == chan )
- break;
- }
- if (k < sd->channel_count) {
- channel->send(chan,sd,message);
- } else if (channel->join(chan, sd, NULL, true) == HCS_STATUS_OK) {
+ ARR_FIND(0, sd->channel_count, k, sd->channels[k] == chan);
+ if (k < sd->channel_count || channel->join(chan, sd, NULL, true) == HCS_STATUS_OK) {
channel->send(chan,sd,message);
} else {
clif->message(fd, msg_txt(1402));