summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/parse.c74
-rw-r--r--src/map/parse.h5
-rw-r--r--src/map/send.c9
-rw-r--r--src/map/send.h1
5 files changed, 82 insertions, 8 deletions
diff --git a/src/map/init.c b/src/map/init.c
index b6142ca..fa2371a 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -98,6 +98,7 @@ HPExport void plugin_init (void)
do_init_langs();
addPacket(0x7530, 22, map_parse_version, hpClif_Parse);
+ addPacket(0xb07, 26, map_parse_join_channel, hpClif_Parse);
addHookPre("pc->readparam", epc_readparam_pre);
addHookPre("pc->setregistry", epc_setregistry);
addHookPre("pc->equipitem_pos", epc_equipitem_pos);
diff --git a/src/map/parse.c b/src/map/parse.c
index 0d09163..7b7fbe7 100644
--- a/src/map/parse.c
+++ b/src/map/parse.c
@@ -10,6 +10,8 @@
#include "../../../common/mmo.h"
#include "../../../common/socket.h"
#include "../../../common/strlib.h"
+#include "../../../map/clif.h"
+#include "../../../map/pc.h"
#include "map/parse.h"
#include "map/data/session.h"
@@ -17,10 +19,74 @@
void map_parse_version(int fd)
{
-// struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
-// if (!sd)
-// return;
-
struct SessionExt *data = session_get(fd);
data->clientVersion = RFIFOL(fd, 2);
}
+
+void map_parse_join_channel(int fd)
+{
+ char name[24];
+ char *p;
+ struct hChSysCh *channel = NULL;
+ struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
+ int res = 0;
+ if (!sd)
+ return;
+
+ safestrncpy(name, RFIFOP(fd, 2), 24);
+ if (name[0] == '#')
+ p = name + 1;
+ else
+ p = name;
+
+ if (clif->hChSys->local && strcmpi(p, clif->hChSys->local_name) == 0)
+ {
+ if (!map->list[sd->bl.m].channel)
+ clif->chsys_mjoin(sd);
+ channel = map->list[sd->bl.m].channel;
+ res = 1;
+ }
+ else if (clif->hChSys->ally && sd->status.guild_id && strcmpi(p, clif->hChSys->ally_name) == 0)
+ {
+ struct guild *g = sd->guild;
+ if (g)
+ channel = g->channel;
+ }
+ if (!res && (channel || (channel = strdb_get(clif->channel_db,p ))))
+ {
+ int k;
+ for (k = 0; k < sd->channel_count; k++)
+ {
+ if (sd->channels[k] == channel)
+ break;
+ }
+ if (k < sd->channel_count)
+ {
+ res = 2;
+ }
+ 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;
+ for (k = 0; k < MAX_GUILDALLIANCE; k++)
+ {
+ if (g->alliance[k].opposition == 0 && g->alliance[k].guild_id && (sg = guild->search(g->alliance[k].guild_id)))
+ {
+ if (!(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id)))
+ clif->chsys_join(sg->channel,sd);
+ }
+ }
+ }
+ clif->chsys_join(channel,sd);
+ res = 1;
+ }
+ else
+ {
+ res = 0;
+ }
+ }
+
+ send_join_ack(fd, name, res);
+}
+
diff --git a/src/map/parse.h b/src/map/parse.h
index ea45975..8d28c6a 100644
--- a/src/map/parse.h
+++ b/src/map/parse.h
@@ -5,9 +5,6 @@
#define EVOL_MAP_PARSE
void map_parse_version(int fd);
-void sample_packet0f3(int fd);
-
-int epc_parse_setparam_pre(struct map_session_data *sd, int *type, int *val);
-int epc_parse_readparam_pre(struct map_session_data* sd, int *type);
+void map_parse_join_channel(int fd);
#endif // EVOL_MAP_PARSE
diff --git a/src/map/send.c b/src/map/send.c
index 029df93..0e281b6 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -183,3 +183,12 @@ void send_changenpc_title (struct map_session_data *sd, const int npcId, const c
strcpy (WFIFOP (fd, 10), name);
WFIFOSET (fd, sz);
}
+
+void send_join_ack(int fd, const char *const name, int flag)
+{
+ WFIFOHEAD (fd, 27);
+ WFIFOW (fd, 0) = 0xb08;
+ safestrncpy (WFIFOP (fd, 2), name, 24);
+ WFIFOB (fd, 26) = flag;
+ WFIFOSET (fd, 27);
+}
diff --git a/src/map/send.h b/src/map/send.h
index 0993624..fbd93c9 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -14,5 +14,6 @@ void send_mob_info(struct block_list* bl1, struct block_list* bl2, enum send_tar
void send_advmoving(struct unit_data* ud, struct block_list *tbl, enum send_target target);
void send_changemusic_brodcast(const int map, const char *music);
void send_changenpc_title (struct map_session_data *sd, const int npcId, const char *name);
+void send_join_ack(int fd, const char *const name, int flag);
#endif // EVOL_MAP_PC