summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaruna <haru@dotalux.com>2015-03-30 00:39:30 +0200
committerHaruna <haru@dotalux.com>2015-03-30 00:39:30 +0200
commit7ba91558ef5a5a435acbd57025e4693759231416 (patch)
treebd7ec307ccf8b74033f02f050e48697f49dd2cad
parentffde84076fa00eca84a81ff6842e9cc5d3844876 (diff)
parent097b6556514809b5bf4ba6bd57562c0992ba3805 (diff)
downloadhercules-7ba91558ef5a5a435acbd57025e4693759231416.tar.gz
hercules-7ba91558ef5a5a435acbd57025e4693759231416.tar.bz2
hercules-7ba91558ef5a5a435acbd57025e4693759231416.tar.xz
hercules-7ba91558ef5a5a435acbd57025e4693759231416.zip
Merge pull request #475 from 4144/ircext
Add channels.conf option irc_channel_autojoin for auto joining irc channel.
-rw-r--r--conf/channels.conf1
-rw-r--r--src/map/channel.c20
-rw-r--r--src/map/channel.h3
-rw-r--r--src/map/clif.c3
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc1
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc26
7 files changed, 55 insertions, 3 deletions
diff --git a/conf/channels.conf b/conf/channels.conf
index 9700f626c..a3eee122d 100644
--- a/conf/channels.conf
+++ b/conf/channels.conf
@@ -60,5 +60,6 @@ chsys: (
irc_channel_nick: "Hercules_chSysBot" /* nick the bot will use */
irc_channel_nick_pw: "" /* password to this nick (if any) to identify to nick server on the irc network */
irc_channel_use_ghost: false /* whether to send a GHOST command to the nick server (requires irc_channel_nick_pw to be defined) */
+ irc_channel_autojoin: false
}
)
diff --git a/src/map/channel.c b/src/map/channel.c
index 0704bf706..15dcce82e 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -477,6 +477,17 @@ void channel_map_join(struct map_session_data *sd)
channel->join(map->list[sd->bl.m].channel, sd, NULL, false);
}
+void channel_irc_join(struct map_session_data *sd)
+{
+ if (sd->state.autotrade || sd->state.standalone)
+ return;
+ if (!channel->config->irc_name)
+ return;
+ struct channel_data *chan = ircbot->channel;
+ if (chan)
+ channel->join(chan, sd, NULL, false);
+}
+
/**
* Lets a guild's members join a newly allied guild's channel.
*
@@ -574,7 +585,8 @@ void read_channels_config(void)
int ally_enabled = 0, local_enabled = 0,
local_autojoin = 0, ally_autojoin = 0,
allow_user_channel_creation = 0,
- irc_enabled = 0;
+ irc_enabled = 0,
+ irc_autojoin = 0;
if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
@@ -655,11 +667,14 @@ void read_channels_config(void)
libconfig->setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
libconfig->setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
+ libconfig->setting_lookup_bool(settings, "irc_channel_autojoin", &irc_autojoin);
if (local_autojoin)
channel->config->local_autojoin = true;
if (ally_autojoin)
channel->config->ally_autojoin = true;
+ if (irc_autojoin)
+ channel->config->irc_autojoin = true;
libconfig->setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
@@ -768,7 +783,7 @@ int do_init_channel(bool minimal)
return 0;
channel->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HCS_NAME_LENGTH);
- channel->config->ally = channel->config->local = channel->config->irc = channel->config->ally_autojoin = channel->config->local_autojoin = false;
+ channel->config->ally = channel->config->local = channel->config->irc = channel->config->ally_autojoin = channel->config->local_autojoin = channel->config->irc_autojoin = false;
channel->config_read();
return 0;
@@ -828,6 +843,7 @@ void channel_defaults(void)
channel->guild_join_alliance = channel_guild_join_alliance;
channel->guild_leave_alliance = channel_guild_leave_alliance;
channel->quit_guild = channel_quit_guild;
+ channel->irc_join = channel_irc_join;
channel->config_read = read_channels_config;
}
diff --git a/src/map/channel.h b/src/map/channel.h
index ba6aafc79..8fbf08d42 100644
--- a/src/map/channel.h
+++ b/src/map/channel.h
@@ -51,7 +51,7 @@ struct Channel_Config {
char **colors_name;
unsigned char colors_count;
bool local, ally, irc;
- bool local_autojoin, ally_autojoin;
+ bool local_autojoin, ally_autojoin, irc_autojoin;
char local_name[HCS_NAME_LENGTH], ally_name[HCS_NAME_LENGTH], irc_name[HCS_NAME_LENGTH];
unsigned char local_color, ally_color, irc_color;
bool closing;
@@ -106,6 +106,7 @@ struct channel_interface {
void (*guild_join_alliance) (const struct guild *g_source, const struct guild *g_ally);
void (*guild_leave_alliance) (const struct guild *g_source, const struct guild *g_ally);
void (*quit_guild) (struct map_session_data *sd);
+ void (*irc_join) (struct map_session_data *sd);
void (*config_read) (void);
};
diff --git a/src/map/clif.c b/src/map/clif.c
index 22d259006..d28e64cd3 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -9265,6 +9265,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
if (channel->config->local && channel->config->local_autojoin) {
channel->map_join(sd);
}
+ if (channel->config->irc && channel->config->irc_autojoin) {
+ channel->irc_join(sd);
+ }
}
mail->clear(sd);
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
index e394711d1..651b8efc3 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
@@ -297,6 +297,8 @@ struct {
struct HPMHookPoint *HP_channel_guild_leave_alliance_post;
struct HPMHookPoint *HP_channel_quit_guild_pre;
struct HPMHookPoint *HP_channel_quit_guild_post;
+ struct HPMHookPoint *HP_channel_irc_join_pre;
+ struct HPMHookPoint *HP_channel_irc_join_post;
struct HPMHookPoint *HP_channel_config_read_pre;
struct HPMHookPoint *HP_channel_config_read_post;
struct HPMHookPoint *HP_chat_create_pc_chat_pre;
@@ -5502,6 +5504,8 @@ struct {
int HP_channel_guild_leave_alliance_post;
int HP_channel_quit_guild_pre;
int HP_channel_quit_guild_post;
+ int HP_channel_irc_join_pre;
+ int HP_channel_irc_join_post;
int HP_channel_config_read_pre;
int HP_channel_config_read_post;
int HP_chat_create_pc_chat_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
index 0b9804a1c..5cbc20541 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
@@ -156,6 +156,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(channel->guild_join_alliance, HP_channel_guild_join_alliance) },
{ HP_POP(channel->guild_leave_alliance, HP_channel_guild_leave_alliance) },
{ HP_POP(channel->quit_guild, HP_channel_quit_guild) },
+ { HP_POP(channel->irc_join, HP_channel_irc_join) },
{ HP_POP(channel->config_read, HP_channel_config_read) },
/* chat */
{ HP_POP(chat->create_pc_chat, HP_chat_create_pc_chat) },
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index aadf7a6f5..3b2c3f08f 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -3981,6 +3981,32 @@ void HP_channel_quit_guild(struct map_session_data *sd) {
}
return;
}
+void HP_channel_irc_join(struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_channel_irc_join_pre ) {
+ void (*preHookFunc) (struct map_session_data *sd);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_channel_irc_join_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_channel_irc_join_pre[hIndex].func;
+ preHookFunc(sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.channel.irc_join(sd);
+ }
+ if( HPMHooks.count.HP_channel_irc_join_post ) {
+ void (*postHookFunc) (struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_channel_irc_join_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_channel_irc_join_post[hIndex].func;
+ postHookFunc(sd);
+ }
+ }
+ return;
+}
void HP_channel_config_read(void) {
int hIndex = 0;
if( HPMHooks.count.HP_channel_config_read_pre ) {