1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// Copyright (c) 2014 Evol developers
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../../common/HPMi.h"
#include "../../../common/malloc.h"
#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"
#include "map/struct/sessionext.h"
void map_parse_version(int fd)
{
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);
}
void map_parse_part_channel(int fd)
{
char name[24];
char *p;
struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
int k;
if (!sd)
return;
safestrncpy(name, RFIFOP(fd, 2), 24);
if (name[0] == '#')
p = name + 1;
else
p = name;
for (k = 0; k < sd->channel_count; k ++)
{
if (strcmpi(p, sd->channels[k]->name) == 0)
break;
}
if (sd->channels[k]->type == hChSys_ALLY)
{
do
{
for (k = 0; k < sd->channel_count; k++)
{
if (sd->channels[k]->type == hChSys_ALLY)
{
clif->chsys_left(sd->channels[k],sd);
break;
}
}
}
while (k != sd->channel_count);
}
else
{
clif->chsys_left(sd->channels[k],sd);
}
}
|