Debian Codegraph @

src/bnetd/channel.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1998 Mark Baysinger ([email protected])
3 * Copyright (C) 1998,1999,2000 Ross Combs ([email protected])
4 * Copyright (C) 2000,2001 Marco Ziech ([email protected])
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20 #define CHANNEL_INTERNAL_ACCESScxx . . $ `src/bnetd/channel.cpp:20:9`!
21 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
22 #include "channel.h"cxx . . $ `<file>/src/bnetd/channel.h`/
23
24 #include <cstring>
25 #include <cerrno>
26 #include <cstdlib>
27
28 #include "compat/strdup.h"cxx . . $ `<file>/src/compat/strdup.h`/
29 #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/
30 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
31 #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/
32 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
33 #include "common/token.h"cxx . . $ `<file>/src/common/token.h`/
34 #include "common/tag.h"cxx . . $ `<file>/src/common/tag.h`/
35 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
36
37 #include "connection.h"cxx . . $ `<file>/src/bnetd/connection.h`/
38 #include "message.h"cxx . . $ `<file>/src/bnetd/message.h`/
39 #include "account.h"cxx . . $ `<file>/src/bnetd/account.h`/
40 #include "account_wrap.h"cxx . . $ `<file>/src/bnetd/account_wrap.h`/
41 #include "prefs.h"cxx . . $ `<file>/src/bnetd/prefs.h`/
42 #include "irc.h"cxx . . $ `<file>/src/bnetd/irc.h`/
43 #include "i18n.h"cxx . . $ `<file>/src/bnetd/i18n.h`/
44 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
45
46 #ifdef WITH_LUA
47 #include "luainterface.h"
48 #endif
49
50 namespace pvpgncxx . . $ pvpgn/
51 {
52
53 namespace bnetdcxx . . $ pvpgn/bnetd/
54 {
55
56 static t_list * channellist_headcxx . . $ pvpgn/bnetd/channellist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
57
58 static t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# * memberlist_currcxx . . $ pvpgn/bnetd/memberlist_curr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
59 static int totalcountcxx . . $ pvpgn/bnetd/totalcount. = 0;
60
61
62 static int channellist_load_permanentcxx . . $ pvpgn/bnetd/channellist_load_permanent(5c4306d8553b3696).(char const * filename);
63 static t_channelcxx . . $ pvpgn/bnetd/t_channel# * channellist_find_channel_by_fullnamecxx . . $ pvpgn/bnetd/channellist_find_channel_by_fullname(f12a4ef8c587c05b).(char const * name);
64 static char * channel_format_namecxx . . $ pvpgn/bnetd/channel_format_name(372a565fc04e0cf9).(char const * sname, char const * country, char const * realmname, unsigned int id);
65
66 extern int channel_set_userflagscxx . . $ pvpgn/bnetd/channel_set_userflags(c4dfbc2386fe4fc3).(t_connection * c);
67
68 extern t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel_createcxx . . $ pvpgn/bnetd/channel_create(e3bab94272034c0f).(char const * fullname, char const * shortname, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, int permflag, int botflag, int operflag, int logflag, char const * country, char const * realmname, int maxmembers, int moderated, int clanflag, int autoname, t_list * channellist)
69 {
70 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
71
72 if (!fullname)
73 {
74 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL fullname");
75 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
76 }
77 if (fullname[0] == '\0')
78 {
79 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got empty fullname");
80 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
81 }
82 if (shortname && shortname[0] == '\0')
83 {
84 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got empty shortname");
85 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
86 }
87
88 /* non-permanent already checks for this in conn_set_channel */
89 if (permflag)
90 {
91 if ((channel = channellist_find_channel_by_fullnamecxx . . $ pvpgn/bnetd/channellist_find_channel_by_fullname(f12a4ef8c587c05b).(fullname)))
92 {
93 if ((channel_get_clienttagcxx . . $ pvpgn/bnetd/channel_get_clienttag(6768ecacf43d05ec).(channel)) && (clienttag) && (channel_get_clienttagcxx . . $ pvpgn/bnetd/channel_get_clienttag(6768ecacf43d05ec).(channel) == clienttag))
94 {
95 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not create duplicate permanent channel (fullname \"{}\")", fullname);
96 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
97 }
98 else if (((channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowbotscxx . . $ pvpgn/bnetd/channel_flags_allowbots.) != (botflag ? channel_flags_allowbotscxx . . $ pvpgn/bnetd/channel_flags_allowbots. : 0)) ||
99 ((channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowoperscxx . . $ pvpgn/bnetd/channel_flags_allowopers.) != (operflag ? channel_flags_allowoperscxx . . $ pvpgn/bnetd/channel_flags_allowopers. : 0)) ||
100 (channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers. != maxmembers) ||
101 ((channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_moderatedcxx . . $ pvpgn/bnetd/channel_flags_moderated.) != (moderated ? channel_flags_moderatedcxx . . $ pvpgn/bnetd/channel_flags_moderated. : 0)) ||
102 (channel->lognamecxx . . $ pvpgn/bnetd/channel#logname. && logflag == 0) || (!(channel->lognamecxx . . $ pvpgn/bnetd/channel#logname.) && logflag == 1))
103 {
104 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "channel parameters do not match for \"{}\" and \"{}\"", fullname, channel->namecxx . . $ pvpgn/bnetd/channel#name.);
105 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
106 }
107 }
108 }
109
110 channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_channel));
111
112 if (permflag)
113 {
114 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. = channel_flags_publiccxx . . $ pvpgn/bnetd/channel_flags_public.;
115 if (clienttag && maxmembers != -1) /* approximation.. we want things like "Starcraft USA-1" */
116 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_systemcxx . . $ pvpgn/bnetd/channel_flags_system.;
117 }
118 else
119 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. = channel_flags_nonecxx . . $ pvpgn/bnetd/channel_flags_none.;
120
121 if (moderated)
122 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_moderatedcxx . . $ pvpgn/bnetd/channel_flags_moderated.;
123
124 if (shortname && (!strcasecmp(shortname, CHANNEL_NAME_KICKEDcxx . . $ `src/bnetd/channel.h:126:9`!)
125 || !strcasecmp(shortname, CHANNEL_NAME_BANNEDcxx . . $ `src/bnetd/channel.h:125:9`!)))
126 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_thevoidcxx . . $ pvpgn/bnetd/channel_flags_thevoid.;
127
128 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "creating new channel \"{}\" shortname={}{}{} clienttag={}{}{} country={}{}{} realm={}{}{}", fullname,
129 shortname ? "\"" : "(", /* all this is doing is printing the name in quotes else "none" in parens */
130 shortname ? shortname : "none",
131 shortname ? "\"" : ")",
132 clienttag ? "\"" : "(",
133 clienttag ? clienttag_uint_to_str(clienttag) : "none",
134 clienttag ? "\"" : ")",
135 country ? "\"" : "(",
136 country ? country : "none",
137 country ? "\"" : ")",
138 realmname ? "\"" : "(",
139 realmname ? realmname : "none",
140 realmname ? "\"" : ")");
141
142
143 channel->namecxx . . $ pvpgn/bnetd/channel#name. = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(fullname);
144
145 if (!shortname)
146 channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
147 else
148 channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname. = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(shortname);
149
150 channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag. = clienttag;
151
152 if (country)
153 channel->countrycxx . . $ pvpgn/bnetd/channel#country. = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(country);
154 else
155 channel->countrycxx . . $ pvpgn/bnetd/channel#country. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
156
157 if (realmname)
158 channel->realmnamecxx . . $ pvpgn/bnetd/channel#realmname. = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(realmname);
159 else
160 channel->realmnamecxx . . $ pvpgn/bnetd/channel#realmname. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
161
162 channel->banlistcxx . . $ pvpgn/bnetd/channel#banlist. = list_create();
163
164 totalcountcxx . . $ pvpgn/bnetd/totalcount.++;
165 if (totalcountcxx . . $ pvpgn/bnetd/totalcount. == 0) /* if we wrap (yeah right), don't use id 0 */
166 totalcountcxx . . $ pvpgn/bnetd/totalcount. = 1;
167 channel->idcxx . . $ pvpgn/bnetd/channel#id. = totalcountcxx . . $ pvpgn/bnetd/totalcount.;
168 channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers. = maxmembers;
169 channel->currmemberscxx . . $ pvpgn/bnetd/channel#currmembers. = 0;
170 channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
171
172 if (permflag) channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.;
173 if (botflag) channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_allowbotscxx . . $ pvpgn/bnetd/channel_flags_allowbots.;
174 if (operflag) channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_allowoperscxx . . $ pvpgn/bnetd/channel_flags_allowopers.;
175 if (clanflag) channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_clancxx . . $ pvpgn/bnetd/channel_flags_clan.;
176 if (autoname) channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_autonamecxx . . $ pvpgn/bnetd/channel_flags_autoname.;
177
178 if (logflag)
179 {
180 stdcxx . . $ std/::time_tcxx . . $ std/time_t# now;
181 struct stdcxx . . $ std/::tmcxx . . $ tm# * tmnow;
182 char dstr[64];
183 char timetemp[CHANLOG_TIME_MAXLENcxx . . $ CHANLOG_TIME_MAXLEN.];
184
185 now = stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
186
187 if (!(tmnow = stdcxx . . $ std/::localtimecxx . . $ std/localtime(7d91c9e5f6bb884b).(&now)))
188 dstr[0] = '\0';
189 else
190 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(dstr, "%04d%02d%02d%02d%02d%02d",
191 1900 + tmnow->tm_yearcxx . . $ tm#tm_year.,
192 tmnow->tm_moncxx . . $ tm#tm_mon. + 1,
193 tmnow->tm_mdaycxx . . $ tm#tm_mday.,
194 tmnow->tm_hourcxx . . $ tm#tm_hour.,
195 tmnow->tm_mincxx . . $ tm#tm_min.,
196 tmnow->tm_seccxx . . $ tm#tm_sec.);
197
198 channel->lognamecxx . . $ pvpgn/bnetd/channel#logname. = (char*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(std::strlen(prefs_get_chanlogdir()) + 9 + std::strlen(dstr) + 1 + 6 + 1); /* dir + "/chanlog-" + dstr + "-" + id + NUL */
199 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(channel->lognamecxx . . $ pvpgn/bnetd/channel#logname., "%s/chanlog-%s-%06u", prefs_get_chanlogdircxx . . $ pvpgn/bnetd/prefs_get_chanlogdir(33a1f659e94feb42).(), dstr, channel->idcxx . . $ pvpgn/bnetd/channel#id.);
200
201 if (!(channel->logcxx . . $ pvpgn/bnetd/channel#log. = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(channel->lognamecxx . . $ pvpgn/bnetd/channel#logname., "w")))
202 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not open channel log \"{}\" for writing (std::fopen: {})", channel->lognamecxx . . $ pvpgn/bnetd/channel#logname., stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
203 else
204 {
205 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "name=\"%s\"\n", channel->namecxx . . $ pvpgn/bnetd/channel#name.);
206 if (channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.)
207 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "shortname=\"%s\"\n", channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.);
208 else
209 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "shortname=none\n");
210 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "permanent=\"%s\"\n", (channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.) ? "true" : "false");
211 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "allowbotse=\"%s\"\n", (channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowbotscxx . . $ pvpgn/bnetd/channel_flags_allowbots.) ? "true" : "false");
212 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "allowopers=\"%s\"\n", (channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowoperscxx . . $ pvpgn/bnetd/channel_flags_allowopers.) ? "true" : "false");
213 if (channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag.)
214 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "clienttag=\"%s\"\n", clienttag_uint_to_str(channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag.));
215 else
216 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "clienttag=none\n");
217
218 if (tmnow)
219 stdcxx . . $ std/::strftimecxx . . $ std/strftime(689617e6f2fd1a9a).(timetemp, sizeof(timetemp), CHANLOG_TIME_FORMATcxx . . $ `src/common/setup_before.h:111:9`!, tmnow);
220 else
221 stdcxx . . $ std/::strcpy(timetemp, "?");
222 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "created=\"%s\"\n\n", timetemp);
223 stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(channel->logcxx . . $ pvpgn/bnetd/channel#log.);
224 }
225 }
226 else
227 {
228 channel->lognamecxx . . $ pvpgn/bnetd/channel#logname. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
229 channel->logcxx . . $ pvpgn/bnetd/channel#log. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
230 }
231
232 channel->gameTypecxx . . $ pvpgn/bnetd/channel#gameType. = 0;
233 channel->gameExtensioncxx . . $ pvpgn/bnetd/channel#gameExtension. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
234
235 if (channellist)
236 list_append_data(channellist, channel);
237 else
238 DEBUG0cxx . . $ `src/common/eventlog.h:88:9`!("channel was not added into any channellist");
239
240 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "channel created successfully");
241 return channel;
242 }
243
244 extern t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel_createcxx . . $ pvpgn/bnetd/channel_create(4ddcb5bef4c114f7).(char const * fullname, char const * shortname, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, int permflag, int botflag, int operflag, int logflag, char const * country, char const * realmname, int maxmembers, int moderated, int clanflag, int autoname)
245 {
246 return channel_createcxx . . $ pvpgn/bnetd/channel_create(e3bab94272034c0f).(fullname, shortname, clienttag, permflag, botflag, operflag, logflag, country, realmname, maxmembers, moderated, clanflag, autoname, channellist_headcxx . . $ pvpgn/bnetd/channellist_head.);
247 }
248
249 extern int channel_destroycxx . . $ pvpgn/bnetd/channel_destroy(aa13f85fad4de15c).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, t_elem ** curr)
250 {
251 t_elem * ban;
252
253 if (!channel)
254 {
255 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
256 return -1;
257 }
258
259 if (channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.)
260 {
261 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "channel is not empty, deferring");
262 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. &= ~channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.; /* make it go away when the last person leaves */
263 return -1;
264 }
265
266 if (list_remove_data(channellist_headcxx . . $ pvpgn/bnetd/channellist_head., channel, curr) < 0)
267 {
268 // eventlog(eventlog_level_error,__FUNCTION__,"could not remove item from list");
269 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "channel was not removed from any list");
270 // return -1;
271 }
272
273 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "destroying channel \"{}\"", channel->namecxx . . $ pvpgn/bnetd/channel#name.);
274
275 if (channel->gameExtensioncxx . . $ pvpgn/bnetd/channel#gameExtension.)
276 xfreecxx . . $ `src/common/xalloc.h:51:9`!(channel->gameExtension);
277
278 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channel->banlist, ban)
279 {
280 char const * banned;
281
282 if (!(banned = (char*)elem_get_data(ban)))
283 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL name in banlist");
284 else
285 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)banned); /* avoid warning */
286 if (list_remove_elem(channel->banlistcxx . . $ pvpgn/bnetd/channel#banlist., &ban) < 0)
287 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "unable to remove item from list");
288 }
289 list_destroy(channel->banlistcxx . . $ pvpgn/bnetd/channel#banlist.);
290
291 if (channel->logcxx . . $ pvpgn/bnetd/channel#log.)
292 {
293 stdcxx . . $ std/::time_tcxx . . $ std/time_t# now;
294 struct stdcxx . . $ std/::tmcxx . . $ tm# * tmnow;
295 char timetemp[CHANLOG_TIME_MAXLENcxx . . $ CHANLOG_TIME_MAXLEN.];
296
297 now = stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
298 if ((!(tmnow = stdcxx . . $ std/::localtimecxx . . $ std/localtime(7d91c9e5f6bb884b).(&now))))
299 stdcxx . . $ std/::strcpy(timetemp, "?");
300 else
301 stdcxx . . $ std/::strftimecxx . . $ std/strftime(689617e6f2fd1a9a).(timetemp, sizeof(timetemp), CHANLOG_TIME_FORMATcxx . . $ `src/common/setup_before.h:111:9`!, tmnow);
302 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "\ndestroyed=\"%s\"\n", timetemp);
303
304 if (stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(channel->logcxx . . $ pvpgn/bnetd/channel#log.) < 0)
305 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not close channel log \"{}\" after writing (std::fclose: {})", channel->lognamecxx . . $ pvpgn/bnetd/channel#logname., stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
306 }
307
308 if (channel->lognamecxx . . $ pvpgn/bnetd/channel#logname.)
309 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)channel->logname); /* avoid warning */
310
311 if (channel->countrycxx . . $ pvpgn/bnetd/channel#country.)
312 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)channel->country); /* avoid warning */
313
314 if (channel->realmnamecxx . . $ pvpgn/bnetd/channel#realmname.)
315 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)channel->realmname); /* avoid warning */
316
317 if (channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.)
318 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)channel->shortname); /* avoid warning */
319
320 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)channel->name); /* avoid warning */
321
322 xfreecxx . . $ `src/common/xalloc.h:51:9`!(channel);
323
324 return 0;
325 }
326
327
328 extern char const * channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
329 {
330 if (!channel)
331 {
332 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn., __FUNCTION__, "got NULL channel");
333 return "";
334 }
335
336 return channel->namecxx . . $ pvpgn/bnetd/channel#name.;
337 }
338
339
340 extern t_clienttagcxx . . $ pvpgn/t_clienttag# channel_get_clienttagcxx . . $ pvpgn/bnetd/channel_get_clienttag(6768ecacf43d05ec).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
341 {
342 if (!channel)
343 {
344 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
345 return 0;
346 }
347
348 return channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag.;
349 }
350
351
352 extern unsigned channel_get_flagscxx . . $ pvpgn/bnetd/channel_get_flags(6768ecacf43d05ec).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
353 {
354 if (!channel)
355 {
356 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
357 return channel_flags_nonecxx . . $ pvpgn/bnetd/channel_flags_none.;
358 }
359
360 return channel->flagscxx . . $ pvpgn/bnetd/channel#flags.;
361 }
362
363 extern int channel_set_flagscxx . . $ pvpgn/bnetd/channel_set_flags(2ef76a208426d92b).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, unsigned flags)
364 {
365 if (!channel)
366 {
367 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
368 return -1;
369 }
370 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. = flags;
371
372 return 0;
373 }
374
375 extern int channel_get_permanentcxx . . $ pvpgn/bnetd/channel_get_permanent(28c764f7c20ec9b2).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
376 {
377 if (!channel)
378 {
379 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
380 return 0;
381 }
382
383 return (channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.);
384 }
385
386
387 extern unsigned int channel_get_channelidcxx . . $ pvpgn/bnetd/channel_get_channelid(6768ecacf43d05ec).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
388 {
389 if (!channel)
390 {
391 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
392 return 0;
393 }
394 return channel->idcxx . . $ pvpgn/bnetd/channel#id.;
395 }
396
397
398 extern int channel_set_channelidcxx . . $ pvpgn/bnetd/channel_set_channelid(2ef76a208426d92b).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, unsigned int channelid)
399 {
400 if (!channel)
401 {
402 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
403 return -1;
404 }
405 channel->idcxx . . $ pvpgn/bnetd/channel#id. = channelid;
406 return 0;
407 }
408
409 extern int channel_rejoincxx . . $ pvpgn/bnetd/channel_rejoin(c4dfbc2386fe4fc3).(t_connection * conn)
410 {
411 t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel;
412 char const * temp;
413 char const * chname;
414
415 if (!(channel = conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(conn)))
416 return -1;
417
418 if (!(temp = channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel)))
419 return -1;
420
421 chname = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(temp);
422 conn_part_channelcxx . . $ pvpgn/bnetd/conn_part_channel(c4dfbc2386fe4fc3).(conn);
423 if (conn_set_channelcxx . . $ pvpgn/bnetd/conn_set_channel(2e9022cda97b266d).(conn, chname) < 0)
424 conn_set_channelcxx . . $ pvpgn/bnetd/conn_set_channel(2e9022cda97b266d).(conn, CHANNEL_NAME_BANNEDcxx . . $ `src/bnetd/channel.h:125:9`!);
425 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)chname);
426 return 0;
427 }
428
429
430 extern int channel_add_connectioncxx . . $ pvpgn/bnetd/channel_add_connection(cf5fcfcfa3727e22).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, t_connection * connection)
431 {
432 t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# * member;
433 t_connection * user;
434
435 if (!channel)
436 {
437 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
438 return -1;
439 }
440 if (!connection)
441 {
442 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection");
443 return -1;
444 }
445
446 if (channel_check_banningcxx . . $ pvpgn/bnetd/channel_check_banning(af8c4400d4e536a9).(channel, connection))
447 {
448 channel_message_logcxx . . $ pvpgn/bnetd/channel_message_log(3119144774c93d10).(channel, connection, 0, "JOIN FAILED (banned)");
449 return -1;
450 }
451
452 member = (t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_channelmember));
453 member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection. = connection;
454 member->nextcxx . . $ pvpgn/bnetd/channelmember#next. = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
455 channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist. = member;
456 channel->currmemberscxx . . $ pvpgn/bnetd/channel#currmembers.++;
457
458 channel_message_logcxx . . $ pvpgn/bnetd/channel_message_log(3119144774c93d10).(channel, connection, 0, "JOINED");
459
460 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(connection, message_type_channelcxx . . $ pvpgn/bnetd/message_type_channel., connection, channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel));
461
462 if ((!(channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.))
463 && (!(channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_thevoidcxx . . $ pvpgn/bnetd/channel_flags_thevoid.))
464 && (!(channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_clancxx . . $ pvpgn/bnetd/channel_flags_clan.))
465 && (channel->currmemberscxx . . $ pvpgn/bnetd/channel#currmembers. == 1)
466 && (account_is_operator_or_admincxx . . $ pvpgn/bnetd/account_is_operator_or_admin(4b12bc5edcfaeac7).(conn_get_accountcxx . . $ pvpgn/bnetd/conn_get_account(8df8b24b7c17a7f3).(connection), channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel)) == 0))
467 {
468 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(connection, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., connection, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(connection, "you are now tempOP for this channel"));
469 conn_set_tmpOP_channelcxx . . $ pvpgn/bnetd/conn_set_tmpOP_channel(2e9022cda97b266d).(connection, (char *)channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel));
470 channel_update_userflagscxx . . $ pvpgn/bnetd/channel_update_userflags(428cd989165da3c5).(connection);
471 }
472 if (!(channel_get_flagscxx . . $ pvpgn/bnetd/channel_get_flags(6768ecacf43d05ec).(channel) & channel_flags_thevoidcxx . . $ pvpgn/bnetd/channel_flags_thevoid.))
473 for (user = channel_get_firstcxx . . $ pvpgn/bnetd/channel_get_first(77c4a1edc1ac6ba1).(channel); user; user = channel_get_nextcxx . . $ pvpgn/bnetd/channel_get_next(181375335219f0cb).())
474 {
475 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(connection, message_type_addusercxx . . $ pvpgn/bnetd/message_type_adduser., user, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
476 /* In WOL gamechannels we send JOINGAME ack explicitely to self */
477 if (!conn_get_gamecxx . . $ pvpgn/bnetd/conn_get_game(692151a8f99bc3ef).(connection))
478 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(user, message_type_joincxx . . $ pvpgn/bnetd/message_type_join., connection, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
479 }
480 else {
481 if (!conn_get_gamecxx . . $ pvpgn/bnetd/conn_get_game(692151a8f99bc3ef).(connection))
482 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(connection, message_type_joincxx . . $ pvpgn/bnetd/message_type_join., connection, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
483 }
484
485 if (conn_is_irc_variantcxx . . $ pvpgn/bnetd/conn_is_irc_variant(c4dfbc2386fe4fc3).(connection) && (!conn_get_gamecxx . . $ pvpgn/bnetd/conn_get_game(692151a8f99bc3ef).(connection))) {
486 channel_set_userflagscxx . . $ pvpgn/bnetd/channel_set_userflags(c4dfbc2386fe4fc3).(connection);
487 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(connection, message_type_topiccxx . . $ pvpgn/bnetd/message_type_topic., connection, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
488 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(connection, message_type_namreplycxx . . $ pvpgn/bnetd/message_type_namreply., connection, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
489 }
490
491 /* please don't remove this notice */
492 if (channel->logcxx . . $ pvpgn/bnetd/channel#log.)
493 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(connection, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., connection, prefs_get_log_noticecxx . . $ pvpgn/bnetd/prefs_get_log_notice(33a1f659e94feb42).());
494
495 #ifdef WITH_LUA
496 lua_handle_channel(channel, connection, NULL, message_type_null, luaevent_channel_userjoin);
497 #endif
498
499 return 0;
500 }
501
502
503 extern int channel_del_connectioncxx . . $ pvpgn/bnetd/channel_del_connection(11eacf26fb1585ff).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, t_connection * connection, t_message_typecxx . . $ pvpgn/bnetd/t_message_type# type, char const * text)
504 {
505 t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# * curr;
506 t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# * temp;
507 t_elem * curr2;
508
509 if (!channel)
510 {
511 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
512 return -1;
513 }
514 if (!connection)
515 {
516 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection");
517 return -1;
518 }
519
520 channel_message_sendcxx . . $ pvpgn/bnetd/channel_message_send(3c4bd88e6f433f89).(channel, type, connection, text);
521 channel_message_logcxx . . $ pvpgn/bnetd/channel_message_log(3119144774c93d10).(channel, connection, 0, "PARTED");
522
523 curr = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
524 if (curr->connectioncxx . . $ pvpgn/bnetd/channelmember#connection. == connection)
525 {
526 channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist. = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
527 xfreecxx . . $ `src/common/xalloc.h:51:9`!(curr);
528 }
529 else
530 {
531 while (curr->nextcxx . . $ pvpgn/bnetd/channelmember#next. && curr->nextcxx . . $ pvpgn/bnetd/channelmember#next.->connectioncxx . . $ pvpgn/bnetd/channelmember#connection. != connection)
532 curr = curr->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
533
534 if (curr->nextcxx . . $ pvpgn/bnetd/channelmember#next.)
535 {
536 temp = curr->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
537 curr->nextcxx . . $ pvpgn/bnetd/channelmember#next. = curr->nextcxx . . $ pvpgn/bnetd/channelmember#next.->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
538 xfreecxx . . $ `src/common/xalloc.h:51:9`!(temp);
539 }
540 else
541 {
542 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] connection not in channel member list", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(connection));
543 return -1;
544 }
545 }
546 channel->currmemberscxx . . $ pvpgn/bnetd/channel#currmembers.--;
547
548 if (conn_get_tmpOP_channelcxx . . $ pvpgn/bnetd/conn_get_tmpOP_channel(5104e66f1dd67144).(connection) &&
549 stdcxx . . $ std/::strcmp(conn_get_tmpOP_channelcxx . . $ pvpgn/bnetd/conn_get_tmpOP_channel(5104e66f1dd67144).(connection), channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel)) == 0)
550 {
551 conn_set_tmpOP_channelcxx . . $ pvpgn/bnetd/conn_set_tmpOP_channel(2e9022cda97b266d).(connection, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
552 }
553
554 #ifdef WITH_LUA
555 lua_handle_channel(channel, connection, text, type, luaevent_channel_userleft);
556 #endif
557
558 if (!channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist. && !(channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.)) /* if channel is empty, delete it unless it's a permanent channel */
559 {
560 channel_destroycxx . . $ pvpgn/bnetd/channel_destroy(aa13f85fad4de15c).(channel, &curr2);
561 }
562
563 return 0;
564 }
565
566
567 extern void channel_update_latencycxx . . $ pvpgn/bnetd/channel_update_latency(428cd989165da3c5).(t_connection * me)
568 {
569 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
570 t_messagecxx . . $ pvpgn/bnetd/t_message# * message;
571 t_connection * c;
572
573 if (!me)
574 {
575 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection");
576 return;
577 }
578 if (!(channel = conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(me)))
579 {
580 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "connection has no channel");
581 return;
582 }
583
584 if (!(message = message_createcxx . . $ pvpgn/bnetd/message_create(e95537b238ea1ff).(message_type_userflagscxx . . $ pvpgn/bnetd/message_type_userflags., me, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!))) /* handles NULL text */
585 return;
586
587 for (c = channel_get_firstcxx . . $ pvpgn/bnetd/channel_get_first(77c4a1edc1ac6ba1).(channel); c; c = channel_get_nextcxx . . $ pvpgn/bnetd/channel_get_next(181375335219f0cb).())
588 if (conn_get_classcxx . . $ pvpgn/bnetd/conn_get_class(1f98a8b9c19f47bc).(c) == conn_class_bnet)
589 message_sendcxx . . $ pvpgn/bnetd/message_send(9d5ee2468ca25dbd).(message, c);
590 message_destroycxx . . $ pvpgn/bnetd/message_destroy(946070d365682f94).(message);
591 }
592
593
594 extern void channel_update_userflagscxx . . $ pvpgn/bnetd/channel_update_userflags(428cd989165da3c5).(t_connection * me)
595 {
596 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
597 t_messagecxx . . $ pvpgn/bnetd/t_message# * message;
598 t_connection * c;
599
600 if (!me)
601 {
602 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection");
603 return;
604 }
605 if (!(channel = conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(me)))
606 {
607 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "connection has no channel");
608 return;
609 }
610
611 if (!(message = message_createcxx . . $ pvpgn/bnetd/message_create(e95537b238ea1ff).(message_type_userflagscxx . . $ pvpgn/bnetd/message_type_userflags., me, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!))) /* handles NULL text */
612 return;
613
614 for (c = channel_get_firstcxx . . $ pvpgn/bnetd/channel_get_first(77c4a1edc1ac6ba1).(channel); c; c = channel_get_nextcxx . . $ pvpgn/bnetd/channel_get_next(181375335219f0cb).())
615 message_sendcxx . . $ pvpgn/bnetd/message_send(9d5ee2468ca25dbd).(message, c);
616
617 message_destroycxx . . $ pvpgn/bnetd/message_destroy(946070d365682f94).(message);
618 }
619
620
621 extern void channel_message_logcxx . . $ pvpgn/bnetd/channel_message_log(3119144774c93d10).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel, t_connection * me, int fromuser, char const * text)
622 {
623 if (!channel)
624 {
625 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
626 return;
627 }
628 if (!me)
629 {
630 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection");
631 return;
632 }
633
634 if (channel->logcxx . . $ pvpgn/bnetd/channel#log.)
635 {
636 stdcxx . . $ std/::time_tcxx . . $ std/time_t# now;
637 struct stdcxx . . $ std/::tmcxx . . $ tm# * tmnow;
638 char timetemp[CHANLOG_TIME_MAXLENcxx . . $ CHANLOG_TIME_MAXLEN.];
639
640 now = stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
641 if ((!(tmnow = stdcxx . . $ std/::localtimecxx . . $ std/localtime(7d91c9e5f6bb884b).(&now))))
642 stdcxx . . $ std/::strcpy(timetemp, "?");
643 else
644 stdcxx . . $ std/::strftimecxx . . $ std/strftime(689617e6f2fd1a9a).(timetemp, sizeof(timetemp), CHANLOGLINE_TIME_FORMATcxx . . $ `src/common/setup_before.h:115:9`!, tmnow);
645
646 if (fromuser)
647 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "%s: \"%s\" \"%s\"\n", timetemp, conn_get_usernamecxx . . $ `src/bnetd/connection.h:361:9`!(me), text);
648 else
649 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(channel->logcxx . . $ pvpgn/bnetd/channel#log., "%s: \"%s\" %s\n", timetemp, conn_get_usernamecxx . . $ `src/bnetd/connection.h:361:9`!(me), text);
650 stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(channel->logcxx . . $ pvpgn/bnetd/channel#log.);
651 }
652 }
653
654
655 extern void channel_message_sendcxx . . $ pvpgn/bnetd/channel_message_send(3c4bd88e6f433f89).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel, t_message_typecxx . . $ pvpgn/bnetd/t_message_type# type, t_connection * me, char const * text)
656 {
657 t_connection * c;
658 unsigned int heard;
659 char const * tname;
660 t_messagecxx . . $ pvpgn/bnetd/t_message# * message1; //send to people with clienttag matching channel clienttag
661 // or everyone when channel has no clienttag set
662 t_messagecxx . . $ pvpgn/bnetd/t_message# * message2; //send to people with clienttag not matching channel clienttag
663 t_messagecxx . . $ pvpgn/bnetd/t_message# * message_to_send;
664 t_accountcxx . . $ pvpgn/bnetd/t_account# * acc;
665
666
667 if (!channel)
668 {
669 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
670 return;
671 }
672 if (!me)
673 {
674 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection");
675 return;
676 }
677
678 acc = conn_get_accountcxx . . $ pvpgn/bnetd/conn_get_account(8df8b24b7c17a7f3).(me);
679
680 if (channel_get_flagscxx . . $ pvpgn/bnetd/channel_get_flags(6768ecacf43d05ec).(channel) & channel_flags_thevoidcxx . . $ pvpgn/bnetd/channel_flags_thevoid.) // no talking in the void
681 if (type != message_type_joincxx . . $ pvpgn/bnetd/message_type_join. && type != message_type_partcxx . . $ pvpgn/bnetd/message_type_part.)
682 return;
683
684 // if user is muted
685 if (account_get_auth_mutecxx . . $ pvpgn/bnetd/account_get_auth_mute(367bfb076f70247b).(acc) == 1)
686 {
687 stdcxx . . $ std/::stringcxx . . $ std/string# msgtempcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).;
688 msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(me, "You can't talk on the channel. Your account has been muted");
689 msgtemp +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). account_get_mutetextcxx . . $ pvpgn/bnetd/account_get_mutetext(47bad2ee332eabb2).(me, acc, false);
690 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(me, message_type_errorcxx . . $ pvpgn/bnetd/message_type_error., me, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).);
691 return;
692 }
693
694 if (channel_get_flagscxx . . $ pvpgn/bnetd/channel_get_flags(6768ecacf43d05ec).(channel) & channel_flags_moderatedcxx . . $ pvpgn/bnetd/channel_flags_moderated.) // moderated channel - only admins,OPs and voices may talk
695 {
696 if (type == message_type_talkcxx . . $ pvpgn/bnetd/message_type_talk. || type == message_type_emotecxx . . $ pvpgn/bnetd/message_type_emote.)
697 {
698 if (!((account_is_operator_or_admincxx . . $ pvpgn/bnetd/account_is_operator_or_admin(4b12bc5edcfaeac7).(acc, channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel))) ||
699 (channel_conn_has_tmpVOICEcxx . . $ pvpgn/bnetd/channel_conn_has_tmpVOICE(7159c29bb3f93f5f).(channel, me)) || (account_get_auth_voicecxx . . $ pvpgn/bnetd/account_get_auth_voice(4b12bc5edcfaeac7).(acc, channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel)) == 1)))
700 {
701 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(me, message_type_errorcxx . . $ pvpgn/bnetd/message_type_error., me, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(me, "This channel is moderated"));
702 return;
703 }
704 }
705 }
706
707 if (!channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag.){
708 if (!(message1 = message_createcxx . . $ pvpgn/bnetd/message_create(e95537b238ea1ff).(type, me, text)))
709 {
710 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not create message1");
711 return;
712 }
713 message2 = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
714 }
715 else {
716 if (!(message1 = message_createcxx . . $ pvpgn/bnetd/message_create(e95537b238ea1ff).(type, me, text)))
717 {
718 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not create message1");
719 return;
720 }
721 if (!(message2 = message_createcxx . . $ pvpgn/bnetd/message_create(e95537b238ea1ff).(type, me, text)))
722 {
723 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not create message2");
724 message_destroycxx . . $ pvpgn/bnetd/message_destroy(946070d365682f94).(message1);
725 return;
726 }
727 }
728
729
730 heard = 0;
731 tname = conn_get_chatnamecxx . . $ pvpgn/bnetd/conn_get_chatname(c99dbccf638f5c6).(me);
732 for (c = channel_get_firstcxx . . $ pvpgn/bnetd/channel_get_first(77c4a1edc1ac6ba1).(channel); c; c = channel_get_nextcxx . . $ pvpgn/bnetd/channel_get_next(181375335219f0cb).())
733 {
734 if (c == me && (type == message_type_talkcxx . . $ pvpgn/bnetd/message_type_talk. || type == message_type_gameopt_talkcxx . . $ pvpgn/bnetd/message_type_gameopt_talk.))
735 continue; /* ignore ourself */
736 if (c == me && (!conn_is_irc_variantcxx . . $ pvpgn/bnetd/conn_is_irc_variant(c4dfbc2386fe4fc3).(c)) && type == message_type_partcxx . . $ pvpgn/bnetd/message_type_part.)
737 continue; /* only on irc we need to inform ourself about leaving the channel */
738 if (c != me && (!conn_is_irc_variantcxx . . $ pvpgn/bnetd/conn_is_irc_variant(c4dfbc2386fe4fc3).(c)) && (channel_get_flagscxx . . $ pvpgn/bnetd/channel_get_flags(6768ecacf43d05ec).(channel) & channel_flags_thevoidcxx . . $ pvpgn/bnetd/channel_flags_thevoid.) && (type == message_type_joincxx . . $ pvpgn/bnetd/message_type_join. || type == message_type_partcxx . . $ pvpgn/bnetd/message_type_part.))
739 continue; /* make sure we even get join part information about self in The Void */
740 if ((type == message_type_talkcxx . . $ pvpgn/bnetd/message_type_talk. || type == message_type_whispercxx . . $ pvpgn/bnetd/message_type_whisper. || type == message_type_emotecxx . . $ pvpgn/bnetd/message_type_emote. || type == message_type_broadcastcxx . . $ pvpgn/bnetd/message_type_broadcast.) &&
741 conn_check_ignoringcxx . . $ pvpgn/bnetd/conn_check_ignoring(6b2655da947c846f).(c, tname) == 1)
742 continue; /* ignore squelched players */
743
744 if (!channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag. || channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag. == conn_get_clienttagcxx . . $ pvpgn/bnetd/conn_get_clienttag(8bd2285a65940781).(c)) {
745 message_to_send = message1;
746 }
747 else {
748 message_to_send = message2;
749 }
750
751 if (message_sendcxx . . $ pvpgn/bnetd/message_send(9d5ee2468ca25dbd).(message_to_send, c) == 0 && c != me)
752 heard = 1;
753 }
754
755 conn_unget_chatnamecxx . . $ pvpgn/bnetd/conn_unget_chatname(6b2655da947c846f).(me, tname);
756
757 message_destroycxx . . $ pvpgn/bnetd/message_destroy(946070d365682f94).(message1);
758 if (message2)
759 message_destroycxx . . $ pvpgn/bnetd/message_destroy(946070d365682f94).(message2);
760
761 if ((conn_get_wolcxx . . $ pvpgn/bnetd/conn_get_wol(c4dfbc2386fe4fc3).(me) == 0))
762 {
763 if (!heard && (type == message_type_talkcxx . . $ pvpgn/bnetd/message_type_talk. || type == message_type_emotecxx . . $ pvpgn/bnetd/message_type_emote.))
764 message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(me, message_type_infocxx . . $ pvpgn/bnetd/message_type_info., me, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(me, "No one hears you."));
765 }
766
767 #ifdef WITH_LUA
768 if (type != message_type_part)
769 lua_handle_channel((t_channel*)channel, me, text, type, luaevent_channel_message);
770 #endif
771 }
772
773 extern int channel_ban_usercxx . . $ pvpgn/bnetd/channel_ban_user(2cba118976651e77).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, char const * user)
774 {
775 t_elem const * curr;
776 char * temp;
777
778 if (!channel)
779 {
780 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
781 return -1;
782 }
783 if (!user)
784 {
785 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL user");
786 return -1;
787 }
788 if (!channel->namecxx . . $ pvpgn/bnetd/channel#name.)
789 {
790 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got channel with NULL name");
791 return -1;
792 }
793
794 if (strcasecmp(channel->namecxx . . $ pvpgn/bnetd/channel#name., CHANNEL_NAME_BANNEDcxx . . $ `src/bnetd/channel.h:125:9`!) == 0 ||
795 strcasecmp(channel->namecxx . . $ pvpgn/bnetd/channel#name., CHANNEL_NAME_KICKEDcxx . . $ `src/bnetd/channel.h:126:9`!) == 0)
796 return -1;
797
798 LIST_TRAVERSE_CONSTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:95:9`!(channel->banlist, curr)
799 if (strcasecmp((char*)elem_get_data(curr), user) == 0)
800 return 0;
801
802 temp = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(user);
803 list_append_data(channel->banlistcxx . . $ pvpgn/bnetd/channel#banlist., temp);
804
805 return 0;
806 }
807
808
809 extern int channel_unban_usercxx . . $ pvpgn/bnetd/channel_unban_user(2cba118976651e77).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, char const * user)
810 {
811 t_elem * curr;
812
813 if (!channel)
814 {
815 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
816 return -1;
817 }
818 if (!user)
819 {
820 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL user");
821 return -1;
822 }
823
824 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channel->banlist, curr)
825 {
826 char const * banned;
827
828 if (!(banned = (char*)elem_get_data(curr)))
829 {
830 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL name in banlist");
831 continue;
832 }
833 if (strcasecmp(banned, user) == 0)
834 {
835 if (list_remove_elem(channel->banlistcxx . . $ pvpgn/bnetd/channel#banlist., &curr) < 0)
836 {
837 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "unable to remove item from list");
838 return -1;
839 }
840 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)banned); /* avoid warning */
841 return 0;
842 }
843 }
844
845 return -1;
846 }
847
848
849 extern int channel_check_banningcxx . . $ pvpgn/bnetd/channel_check_banning(af8c4400d4e536a9).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel, t_connection const * user)
850 {
851 t_elem const * curr;
852
853 if (!channel)
854 {
855 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
856 return -1;
857 }
858 if (!user)
859 {
860 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL user");
861 return -1;
862 }
863
864 if (!(channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowbotscxx . . $ pvpgn/bnetd/channel_flags_allowbots.) && conn_get_classcxx . . $ pvpgn/bnetd/conn_get_class(1f98a8b9c19f47bc).(user) == conn_class_bot)
865 return 1;
866
867 LIST_TRAVERSE_CONSTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:95:9`!(channel->banlist, curr)
868 if (conn_matchcxx . . $ pvpgn/bnetd/conn_match(6b2655da947c846f).(user, (char*)elem_get_data(curr)) == 1)
869 return 1;
870
871 return 0;
872 }
873
874
875 extern int channel_get_lengthcxx . . $ pvpgn/bnetd/channel_get_length(28c764f7c20ec9b2).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
876 {
877 t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# const * curr;
878 int count;
879
880 for (curr = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist., count = 0; curr; curr = curr->nextcxx . . $ pvpgn/bnetd/channelmember#next., count++);
881
882 return count;
883 }
884
885
886 extern t_connection * channel_get_firstcxx . . $ pvpgn/bnetd/channel_get_first(77c4a1edc1ac6ba1).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
887 {
888 if (!channel)
889 {
890 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
891 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
892 }
893
894 memberlist_currcxx . . $ pvpgn/bnetd/memberlist_curr. = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
895
896 return channel_get_nextcxx . . $ pvpgn/bnetd/channel_get_next(181375335219f0cb).();
897 }
898
899 extern t_connection * channel_get_nextcxx . . $ pvpgn/bnetd/channel_get_next(181375335219f0cb).(void)
900 {
901
902 t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# * member;
903
904 if (memberlist_currcxx . . $ pvpgn/bnetd/memberlist_curr.)
905 {
906 member = memberlist_currcxx . . $ pvpgn/bnetd/memberlist_curr.;
907 memberlist_currcxx . . $ pvpgn/bnetd/memberlist_curr. = memberlist_currcxx . . $ pvpgn/bnetd/memberlist_curr.->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
908
909 return member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection.;
910 }
911 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
912 }
913
914
915 extern t_list * channel_get_banlistcxx . . $ pvpgn/bnetd/channel_get_banlist(d2921df08775ee74).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
916 {
917 if (!channel)
918 {
919 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn., __FUNCTION__, "got NULL channel");
920 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
921 }
922
923 return channel->banlistcxx . . $ pvpgn/bnetd/channel#banlist.;
924 }
925
926
927 extern char const * channel_get_shortnamecxx . . $ pvpgn/bnetd/channel_get_shortname(7800017c14723985).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
928 {
929 if (!channel)
930 {
931 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn., __FUNCTION__, "got NULL channel");
932 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
933 }
934
935 return channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.;
936 }
937
938
939 static int channellist_load_permanentcxx . . $ pvpgn/bnetd/channellist_load_permanent(5c4306d8553b3696).(char const * filename)
940 {
941 stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fp;
942 unsigned int line;
943 unsigned int pos;
944 int botflag;
945 int operflag;
946 int logflag;
947 unsigned int modflag;
948 char * buff;
949 char * name;
950 char * sname;
951 char * tag;
952 t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag;
953 char * bot;
954 char * oper;
955 char * log;
956 char * country;
957 char * max;
958 char * moderated;
959 char * newname;
960 char * realmname;
961
962 if (!filename)
963 {
964 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL filename");
965 return -1;
966 }
967
968 if (!(fp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(filename, "r")))
969 {
970 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not open channel file \"{}\" for reading (std::fopen: {})", filename, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
971 return -1;
972 }
973
974 for (line = 1; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(fp)); line++)
975 {
976 if (buff[0] == '#' || buff[0] == '\0')
977 {
978 continue;
979 }
980 pos = 0;
981 if (!(name = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
982 {
983 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing name in line {} in file \"{}\"", line, filename);
984 continue;
985 }
986 if (!(sname = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
987 {
988 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing sname in line {} in file \"{}\"", line, filename);
989 continue;
990 }
991 if (!(tag = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
992 {
993 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing tag in line {} in file \"{}\"", line, filename);
994 continue;
995 }
996 if (!(bot = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
997 {
998 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing bot in line {} in file \"{}\"", line, filename);
999 continue;
1000 }
1001 if (!(oper = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
1002 {
1003 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing oper in line {} in file \"{}\"", line, filename);
1004 continue;
1005 }
1006 if (!(log = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
1007 {
1008 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing log in line {} in file \"{}\"", line, filename);
1009 continue;
1010 }
1011 if (!(country = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
1012 {
1013 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing country in line {} in file \"{}\"", line, filename);
1014 continue;
1015 }
1016 if (!(realmname = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
1017 {
1018 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing realmname in line {} in file \"{}\"", line, filename);
1019 continue;
1020 }
1021 if (!(max = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
1022 {
1023 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing max in line {} in file \"{}\"", line, filename);
1024 continue;
1025 }
1026 if (!(moderated = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos)))
1027 {
1028 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing mod in line {} in file \"{}\"", line, filename);
1029 continue;
1030 }
1031
1032 switch (str_get_boolcxx . . $ pvpgn/str_get_bool(5c4306d8553b3696).(bot))
1033 {
1034 case 1:
1035 botflag = 1;
1036 break;
1037 case 0:
1038 botflag = 0;
1039 break;
1040 default:
1041 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "invalid boolean value \"{}\" for field 4 on line {} in file \"{}\"", bot, line, filename);
1042 continue;
1043 }
1044
1045 switch (str_get_boolcxx . . $ pvpgn/str_get_bool(5c4306d8553b3696).(oper))
1046 {
1047 case 1:
1048 operflag = 1;
1049 break;
1050 case 0:
1051 operflag = 0;
1052 break;
1053 default:
1054 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "invalid boolean value \"{}\" for field 5 on line {} in file \"{}\"", oper, line, filename);
1055 continue;
1056 }
1057
1058 switch (str_get_boolcxx . . $ pvpgn/str_get_bool(5c4306d8553b3696).(log))
1059 {
1060 case 1:
1061 logflag = 1;
1062 break;
1063 case 0:
1064 logflag = 0;
1065 break;
1066 default:
1067 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "invalid boolean value \"{}\" for field 5 on line {} in file \"{}\"", log, line, filename);
1068 continue;
1069 }
1070
1071 switch (str_get_boolcxx . . $ pvpgn/str_get_bool(5c4306d8553b3696).(moderated))
1072 {
1073 case 1:
1074 modflag = 1;
1075 break;
1076 case 0:
1077 modflag = 0;
1078 break;
1079 default:
1080 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "invalid boolean value \"{}\" for field 10 on line {} in file \"{}\"", moderated, line, filename);
1081 continue;
1082 }
1083
1084 if (stdcxx . . $ std/::strcmp(sname, "NULL") == 0)
1085 sname = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1086 if (stdcxx . . $ std/::strcmp(tag, "NULL") == 0)
1087 clienttag = 0;
1088 else
1089 clienttag = clienttag_str_to_uint(tag);
1090 if (stdcxx . . $ std/::strcmp(name, "NONE") == 0)
1091 name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1092 if (stdcxx . . $ std/::strcmp(country, "NULL") == 0)
1093 country = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1094 if (stdcxx . . $ std/::strcmp(realmname, "NULL") == 0)
1095 realmname = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1096
1097 if (name)
1098 {
1099 channel_createcxx . . $ pvpgn/bnetd/channel_create(4ddcb5bef4c114f7).(name, sname, clienttag, 1, botflag, operflag, logflag, country, realmname, stdcxx . . $ std/::atoi(max), modflag, 0, 0);
1100 }
1101 else
1102 {
1103 newname = channel_format_namecxx . . $ pvpgn/bnetd/channel_format_name(372a565fc04e0cf9).(sname, country, realmname, 1);
1104 if (newname)
1105 {
1106 channel_createcxx . . $ pvpgn/bnetd/channel_create(4ddcb5bef4c114f7).(newname, sname, clienttag, 1, botflag, operflag, logflag, country, realmname, stdcxx . . $ std/::atoi(max), modflag, 0, 1);
1107 xfreecxx . . $ `src/common/xalloc.h:51:9`!(newname);
1108 }
1109 else
1110 {
1111 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "cannot format channel name");
1112 }
1113 }
1114
1115 /* FIXME: call channel_delete() on current perm channels and do a
1116 channellist_find_channel() and set the long name, perm flag, etc,
1117 otherwise call channel_create(). This will make HUPing the server
1118 handle re-reading this file correctly. */
1119 }
1120
1121 file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); // clear file_get_line buffer
1122 if (stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp) < 0)
1123 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not close channel file \"{}\" after reading (std::fclose: {})", filename, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
1124 return 0;
1125 }
1126
1127 static char * channel_format_namecxx . . $ pvpgn/bnetd/channel_format_name(372a565fc04e0cf9).(char const * sname, char const * country, char const * realmname, unsigned int id)
1128 {
1129 char * fullname;
1130 unsigned int len;
1131
1132 if (!sname)
1133 {
1134 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL sname");
1135 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1136 }
1137 len = stdcxx . . $ std/::strlen(sname) + 1; /* FIXME: check lengths and format */
1138 if (country)
1139 len = len + stdcxx . . $ std/::strlen(country) + 1;
1140 if (realmname)
1141 len = len + stdcxx . . $ std/::strlen(realmname) + 1;
1142 len = len + 32 + 1;
1143
1144 fullname = (char*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(len);
1145 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(fullname, "%s%s%s%s%s-%u",
1146 realmname ? realmname : "",
1147 realmname ? " " : "",
1148 sname,
1149 country ? " " : "",
1150 country ? country : "",
1151 id);
1152 return fullname;
1153 }
1154
1155 extern int channellist_reloadcxx . . $ pvpgn/bnetd/channellist_reload(b126dc7c1de90089).(void)
1156 {
1157 t_elem * curr;
1158 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, *old_channel;
1159 t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember# * memberlist, *member, *old_member;
1160 t_list * channellist_old;
1161
1162 if (channellist_headcxx . . $ pvpgn/bnetd/channellist_head.)
1163 {
1164
1165 channellist_old = list_create();
1166
1167 /* First pass - get members */
1168 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_head, curr)
1169 {
1170 if (!(channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr)))
1171 {
1172 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "channel list contains NULL item");
1173 continue;
1174 }
1175 /* Trick to avoid automatic channel destruction */
1176 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. |= channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.;
1177 if (channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.)
1178 {
1179 /* we need only channel name and memberlist */
1180
1181 old_channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel# *)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_channel));
1182 old_channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname. = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(channel->shortname);
1183 old_channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1184 member = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
1185
1186 /* First pass */
1187 while (member)
1188 {
1189 old_member = (t_channelmembercxx . . $ pvpgn/bnetd/t_channelmember#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_channelmember));
1190 old_member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection. = member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection.;
1191
1192 if (old_channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.)
1193 old_member->nextcxx . . $ pvpgn/bnetd/channelmember#next. = old_channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
1194 else
1195 old_member->nextcxx . . $ pvpgn/bnetd/channelmember#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1196
1197 old_channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist. = old_member;
1198 member = member->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
1199 }
1200
1201 /* Second pass - remove connections from channel */
1202 member = old_channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
1203 while (member)
1204 {
1205 channel_del_connectioncxx . . $ pvpgn/bnetd/channel_del_connection(11eacf26fb1585ff).(channel, member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection., message_type_quitcxx . . $ pvpgn/bnetd/message_type_quit., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
1206 conn_set_channel_varcxx . . $ pvpgn/bnetd/conn_set_channel_var(681c2fcf151532c2).(member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
1207 member = member->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
1208 }
1209
1210 list_prepend_data(channellist_old, old_channel);
1211 }
1212
1213 /* Channel is empty - Destroying it */
1214 channel->flagscxx . . $ pvpgn/bnetd/channel#flags. &= ~channel_flags_permanentcxx . . $ pvpgn/bnetd/channel_flags_permanent.;
1215 if (channel_destroycxx . . $ pvpgn/bnetd/channel_destroy(aa13f85fad4de15c).(channel, &curr) < 0)
1216 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not destroy channel");
1217
1218 }
1219
1220 /* Cleanup and reload */
1221
1222 if (list_destroy(channellist_headcxx . . $ pvpgn/bnetd/channellist_head.) < 0)
1223 return -1;
1224
1225 channellist_headcxx . . $ pvpgn/bnetd/channellist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1226 channellist_createcxx . . $ pvpgn/bnetd/channellist_create(b126dc7c1de90089).();
1227
1228 /* Now put all users on their previous channel */
1229
1230 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_old, curr)
1231 {
1232 if (!(channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr)))
1233 {
1234 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "old channel list contains NULL item");
1235 continue;
1236 }
1237
1238 memberlist = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
1239 while (memberlist)
1240 {
1241 member = memberlist;
1242 memberlist = memberlist->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
1243 conn_set_channelcxx . . $ pvpgn/bnetd/conn_set_channel(2e9022cda97b266d).(member->connectioncxx . . $ pvpgn/bnetd/channelmember#connection., channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.);
1244 }
1245 }
1246
1247
1248 /* Ross don't blame me for this but this way the code is cleaner */
1249
1250 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_old, curr)
1251 {
1252 if (!(channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr)))
1253 {
1254 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "old channel list contains NULL item");
1255 continue;
1256 }
1257
1258 memberlist = channel->memberlistcxx . . $ pvpgn/bnetd/channel#memberlist.;
1259 while (memberlist)
1260 {
1261 member = memberlist;
1262 memberlist = memberlist->nextcxx . . $ pvpgn/bnetd/channelmember#next.;
1263 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void*)member);
1264 }
1265
1266 if (channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.)
1267 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void*)channel->shortname);
1268
1269 if (list_remove_data(channellist_old, channel, &curr) < 0)
1270 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove item from list");
1271 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void*)channel);
1272
1273 }
1274
1275 if (list_destroy(channellist_old) < 0)
1276 return -1;
1277 }
1278 return 0;
1279
1280 }
1281
1282 extern int channellist_createcxx . . $ pvpgn/bnetd/channellist_create(b126dc7c1de90089).(void)
1283 {
1284 channellist_headcxx . . $ pvpgn/bnetd/channellist_head. = list_create();
1285
1286 return channellist_load_permanentcxx . . $ pvpgn/bnetd/channellist_load_permanent(5c4306d8553b3696).(prefs_get_channelfilecxx . . $ pvpgn/bnetd/prefs_get_channelfile(33a1f659e94feb42).());
1287 }
1288
1289
1290 extern int channellist_destroycxx . . $ pvpgn/bnetd/channellist_destroy(b126dc7c1de90089).(void)
1291 {
1292 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
1293 t_elem * curr;
1294
1295 if (channellist_headcxx . . $ pvpgn/bnetd/channellist_head.)
1296 {
1297 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_head, curr)
1298 {
1299 if (!(channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr))) /* should not happen */
1300 {
1301 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "channel list contains NULL item");
1302 continue;
1303 }
1304
1305 channel_destroycxx . . $ pvpgn/bnetd/channel_destroy(aa13f85fad4de15c).(channel, &curr);
1306 }
1307
1308 if (list_destroy(channellist_headcxx . . $ pvpgn/bnetd/channellist_head.) < 0)
1309 return -1;
1310 channellist_headcxx . . $ pvpgn/bnetd/channellist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1311 }
1312
1313 return 0;
1314 }
1315
1316
1317 extern t_list * channellistcxx . . $ pvpgn/bnetd/channellist(7a6cb11de248e2c9).(void)
1318 {
1319 return channellist_headcxx . . $ pvpgn/bnetd/channellist_head.;
1320 }
1321
1322
1323 extern int channellist_get_lengthcxx . . $ pvpgn/bnetd/channellist_get_length(b126dc7c1de90089).(void)
1324 {
1325 return list_get_length(channellist_headcxx . . $ pvpgn/bnetd/channellist_head.);
1326 }
1327
1328 extern int channel_get_maxcxx . . $ pvpgn/bnetd/channel_get_max(28c764f7c20ec9b2).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
1329 {
1330 if (!channel)
1331 {
1332 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1333 return 0;
1334 }
1335
1336 return channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers.;
1337 }
1338
1339 extern int channel_set_maxcxx . . $ pvpgn/bnetd/channel_set_max(48cee1134ea01a3a).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, int maxmembers)
1340 {
1341 if (!channel)
1342 {
1343 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1344 return 0;
1345 }
1346
1347 if (maxmembers)
1348 channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers. = maxmembers;
1349 return 1;
1350 }
1351
1352 extern int channel_get_currcxx . . $ pvpgn/bnetd/channel_get_curr(28c764f7c20ec9b2).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
1353 {
1354 if (!channel)
1355 {
1356 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1357 return 0;
1358 }
1359
1360 return channel->currmemberscxx . . $ pvpgn/bnetd/channel#currmembers.;
1361
1362 }
1363
1364 extern int channel_conn_is_tmpOPcxx . . $ pvpgn/bnetd/channel_conn_is_tmpOP(7159c29bb3f93f5f).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel, t_connection * c)
1365 {
1366 if (!channel)
1367 {
1368 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1369 return 0;
1370 }
1371
1372 if (!c)
1373 {
1374 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account");
1375 return 0;
1376 }
1377
1378 if (!conn_get_tmpOP_channelcxx . . $ pvpgn/bnetd/conn_get_tmpOP_channel(5104e66f1dd67144).(c)) return 0;
1379
1380 if (stdcxx . . $ std/::strcmp(conn_get_tmpOP_channelcxx . . $ pvpgn/bnetd/conn_get_tmpOP_channel(5104e66f1dd67144).(c), channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel)) == 0) return 1;
1381
1382 return 0;
1383 }
1384
1385 extern int channel_conn_has_tmpVOICEcxx . . $ pvpgn/bnetd/channel_conn_has_tmpVOICE(7159c29bb3f93f5f).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel, t_connection * c)
1386 {
1387 if (!channel)
1388 {
1389 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1390 return 0;
1391 }
1392
1393 if (!c)
1394 {
1395 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL account");
1396 return 0;
1397 }
1398
1399 if (!conn_get_tmpVOICE_channelcxx . . $ pvpgn/bnetd/conn_get_tmpVOICE_channel(5104e66f1dd67144).(c)) return 0;
1400
1401 if (stdcxx . . $ std/::strcmp(conn_get_tmpVOICE_channelcxx . . $ pvpgn/bnetd/conn_get_tmpVOICE_channel(5104e66f1dd67144).(c), channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(channel)) == 0) return 1;
1402
1403 return 0;
1404 }
1405
1406 static t_channelcxx . . $ pvpgn/bnetd/t_channel# * channellist_find_channel_by_fullnamecxx . . $ pvpgn/bnetd/channellist_find_channel_by_fullname(f12a4ef8c587c05b).(char const * name)
1407 {
1408 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
1409 t_elem const * curr;
1410
1411 if (channellist_headcxx . . $ pvpgn/bnetd/channellist_head.)
1412 {
1413 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_head, curr)
1414 {
1415 channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr);
1416 if (!channel->namecxx . . $ pvpgn/bnetd/channel#name.)
1417 {
1418 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found channel with NULL name");
1419 continue;
1420 }
1421
1422 if (strcasecmp(channel->namecxx . . $ pvpgn/bnetd/channel#name., name) == 0)
1423 return channel;
1424 }
1425 }
1426
1427 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1428 }
1429
1430
1431 /* Find a channel based on the name.
1432 * Create a new channel if it is a permanent-type channel and all others
1433 * are full.
1434 */
1435 extern t_channelcxx . . $ pvpgn/bnetd/t_channel# * channellist_find_channel_by_namecxx . . $ pvpgn/bnetd/channellist_find_channel_by_name(7177a8438ab16268).(char const * name, char const * country, char const * realmname)
1436 {
1437 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
1438 t_elem const * curr;
1439 int foundperm;
1440 int foundlang;
1441 int maxchannel; /* the number of "rollover" channels that exist */
1442 char const * saveshortname;
1443 char const * savespecialname;
1444 t_clienttagcxx . . $ pvpgn/t_clienttag# savetag;
1445 int savebotflag;
1446 int saveoperflag;
1447 int savelogflag;
1448 unsigned int savemoderated;
1449 char const * savecountry;
1450 char const * saverealmname;
1451 int savemaxmembers;
1452 t_channelcxx . . $ pvpgn/bnetd/t_channel# * special_channel;
1453
1454 // try to make gcc happy and initialize all variables
1455 saveshortname = savespecialname = savecountry = saverealmname = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1456 savetag = savebotflag = saveoperflag = savelogflag = savemaxmembers = savemoderated = 0;
1457
1458 maxchannel = 0;
1459 foundperm = 0;
1460 foundlang = 0;
1461 if (channellist_headcxx . . $ pvpgn/bnetd/channellist_head.)
1462 {
1463 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_head, curr)
1464 {
1465 channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr);
1466 if (!channel->namecxx . . $ pvpgn/bnetd/channel#name.)
1467 {
1468 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found channel with NULL name");
1469 continue;
1470 }
1471
1472 if (strcasecmp(channel->namecxx . . $ pvpgn/bnetd/channel#name., name) == 0)
1473 {
1474 // eventlog(eventlog_level_debug,__FUNCTION__,"found exact match for \"%s\"",name);
1475 return channel;
1476 }
1477
1478 if (channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname. && strcasecmp(channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname., name) == 0)
1479 {
1480 special_channel = channellist_find_channel_by_namecxx . . $ pvpgn/bnetd/channellist_find_channel_by_name(7177a8438ab16268).(channel->namecxx . . $ pvpgn/bnetd/channel#name., country, realmname);
1481 if (special_channel) channel = special_channel;
1482
1483 /* FIXME: what should we do if the client doesn't have a country? For now, just take the first
1484 * channel that would otherwise match. */
1485 if (((!channel->countrycxx . . $ pvpgn/bnetd/channel#country. && !foundlang) || !country ||
1486 (channel->countrycxx . . $ pvpgn/bnetd/channel#country. && country && (stdcxx . . $ std/::strcmp(channel->countrycxx . . $ pvpgn/bnetd/channel#country., country) == 0))) &&
1487 (!channel->realmnamecxx . . $ pvpgn/bnetd/channel#realmname. || !realmname || !stdcxx . . $ std/::strcmp(channel->realmnamecxx . . $ pvpgn/bnetd/channel#realmname., realmname)))
1488 {
1489 if (channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers. == -1 || channel->currmemberscxx . . $ pvpgn/bnetd/channel#currmembers. < channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers.)
1490 {
1491 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "found permanent channel \"{}\" for \"{}\"", channel->namecxx . . $ pvpgn/bnetd/channel#name., name);
1492 return channel;
1493 }
1494
1495 if (!foundlang && (channel->countrycxx . . $ pvpgn/bnetd/channel#country.)) //remember we had found a language specific channel but it was full
1496 {
1497 foundlang = 1;
1498 if (!(channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_autonamecxx . . $ pvpgn/bnetd/channel_flags_autoname.))
1499 savespecialname = channel->namecxx . . $ pvpgn/bnetd/channel#name.;
1500 maxchannel = 0;
1501 }
1502
1503 maxchannel++;
1504 }
1505
1506 // eventlog(eventlog_level_debug,__FUNCTION__,"countries didn't match");
1507
1508 foundperm = 1;
1509
1510 /* save off some info in case we need to create a new copy */
1511 saveshortname = channel->shortnamecxx . . $ pvpgn/bnetd/channel#shortname.;
1512 savetag = channel->clienttagcxx . . $ pvpgn/bnetd/channel#clienttag.;
1513 savebotflag = channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowbotscxx . . $ pvpgn/bnetd/channel_flags_allowbots.;
1514 saveoperflag = channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_allowoperscxx . . $ pvpgn/bnetd/channel_flags_allowopers.;
1515 if (channel->lognamecxx . . $ pvpgn/bnetd/channel#logname.)
1516 savelogflag = 1;
1517 else
1518 savelogflag = 0;
1519 if (country)
1520 savecountry = country;
1521 else
1522 savecountry = channel->countrycxx . . $ pvpgn/bnetd/channel#country.;
1523 if (realmname)
1524 saverealmname = realmname;
1525 else
1526 saverealmname = channel->realmnamecxx . . $ pvpgn/bnetd/channel#realmname.;
1527 savemaxmembers = channel->maxmemberscxx . . $ pvpgn/bnetd/channel#maxmembers.;
1528 savemoderated = channel->flagscxx . . $ pvpgn/bnetd/channel#flags. & channel_flags_moderatedcxx . . $ pvpgn/bnetd/channel_flags_moderated.;
1529 }
1530 }
1531 }
1532
1533 /* we've gone thru the whole list and either there was no match or the
1534 * channels are all full.
1535 */
1536
1537 if (foundperm) /* All the channels were full, create a new one */
1538 {
1539 char * channelname;
1540
1541 if (!foundlang || !savespecialname)
1542 {
1543 if (!(channelname = channel_format_namecxx . . $ pvpgn/bnetd/channel_format_name(372a565fc04e0cf9).(saveshortname, savecountry, saverealmname, maxchannel + 1)))
1544 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1545 }
1546 else
1547 {
1548 if (!(channelname = channel_format_namecxx . . $ pvpgn/bnetd/channel_format_name(372a565fc04e0cf9).(savespecialname, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, saverealmname, maxchannel + 1)))
1549 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1550 }
1551
1552 channel = channel_createcxx . . $ pvpgn/bnetd/channel_create(4ddcb5bef4c114f7).(channelname, saveshortname, savetag, 1, savebotflag, saveoperflag, savelogflag, savecountry, saverealmname, savemaxmembers, savemoderated, 0, 1);
1553 xfreecxx . . $ `src/common/xalloc.h:51:9`!(channelname);
1554
1555 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "created copy \"{}\" of channel \"{}\"", (channel) ? (channel->namecxx . . $ pvpgn/bnetd/channel#name.) : ("<failed>"), name);
1556 return channel;
1557 }
1558
1559 /* no match */
1560 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "could not find channel \"{}\"", name);
1561 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1562 }
1563
1564
1565 extern t_channelcxx . . $ pvpgn/bnetd/t_channel# * channellist_find_channel_bychannelidcxx . . $ pvpgn/bnetd/channellist_find_channel_bychannelid(ed5f201769bfa7d2).(unsigned int channelid)
1566 {
1567 t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel;
1568 t_elem const * curr;
1569
1570 if (channellist_headcxx . . $ pvpgn/bnetd/channellist_head.)
1571 {
1572 LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(channellist_head, curr)
1573 {
1574 channel = (t_channelcxx . . $ pvpgn/bnetd/t_channel#*)elem_get_data(curr);
1575 if (!channel->namecxx . . $ pvpgn/bnetd/channel#name.)
1576 {
1577 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found channel with NULL name");
1578 continue;
1579 }
1580 if (channel->idcxx . . $ pvpgn/bnetd/channel#id. == channelid)
1581 return channel;
1582 }
1583 }
1584
1585 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1586 }
1587
1588 extern int channel_set_userflagscxx . . $ pvpgn/bnetd/channel_set_userflags(c4dfbc2386fe4fc3).(t_connection * c)
1589 {
1590 unsigned int newflags;
1591 char const * channel;
1592 t_accountcxx . . $ pvpgn/bnetd/t_account# * acc;
1593
1594 if (!c) return -1; // user not connected, no need to update his flags
1595
1596 acc = conn_get_accountcxx . . $ pvpgn/bnetd/conn_get_account(8df8b24b7c17a7f3).(c);
1597
1598 /* well... unfortunatly channel_get_name never returns NULL but "" instead
1599 so we first have to check if user is in a channel at all */
1600 if ((!conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c)) || (!(channel = channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c)))))
1601 return -1;
1602
1603 if (account_get_auth_admincxx . . $ pvpgn/bnetd/account_get_auth_admin(4b12bc5edcfaeac7).(acc, channel) == 1 || account_get_auth_admincxx . . $ pvpgn/bnetd/account_get_auth_admin(4b12bc5edcfaeac7).(acc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) == 1)
1604 newflags = MF_BLIZZARDcxx . . $ `src/common/bnet_protocol.h:2570:9`!;
1605 else if (account_get_auth_operatorcxx . . $ pvpgn/bnetd/account_get_auth_operator(4b12bc5edcfaeac7).(acc, channel) == 1 ||
1606 account_get_auth_operatorcxx . . $ pvpgn/bnetd/account_get_auth_operator(4b12bc5edcfaeac7).(acc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) == 1)
1607 newflags = MF_BNETcxx . . $ `src/common/bnet_protocol.h:2576:9`!;
1608 else if (channel_conn_is_tmpOPcxx . . $ pvpgn/bnetd/channel_conn_is_tmpOP(7159c29bb3f93f5f).(conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c), c))
1609 newflags = MF_GAVELcxx . . $ `src/common/bnet_protocol.h:2572:9`!;
1610 else if ((account_get_auth_voicecxx . . $ pvpgn/bnetd/account_get_auth_voice(4b12bc5edcfaeac7).(acc, channel) == 1) ||
1611 (channel_conn_has_tmpVOICEcxx . . $ pvpgn/bnetd/channel_conn_has_tmpVOICE(7159c29bb3f93f5f).(conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c), c)))
1612 newflags = MF_VOICEcxx . . $ `src/common/bnet_protocol.h:2574:9`!;
1613 else
1614 if ((conn_get_clienttagcxx . . $ pvpgn/bnetd/conn_get_clienttag(8bd2285a65940781).(c) == CLIENTTAG_WARCRAFT3_UINTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/tag.h:111:9`!) ||
1615 (conn_get_clienttagcxx . . $ pvpgn/bnetd/conn_get_clienttag(8bd2285a65940781).(c) == CLIENTTAG_WAR3XP_UINTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/tag.h:113:9`!))
1616 newflags = W3_ICON_SETcxx . . $ `src/common/bnet_protocol.h:2514:9`!;
1617 else
1618 newflags = 0;
1619
1620 if (conn_get_flagscxx . . $ pvpgn/bnetd/conn_get_flags(8bd2285a65940781).(c) != newflags) {
1621 conn_set_flagscxx . . $ pvpgn/bnetd/conn_set_flags(c14bb6458e7562a).(c, newflags);
1622 channel_update_userflagscxx . . $ pvpgn/bnetd/channel_update_userflags(428cd989165da3c5).(c);
1623 }
1624
1625 return 0;
1626 }
1627
1628 /**
1629 * Westwood Online Extensions
1630 */
1631 extern int channel_get_mincxx . . $ pvpgn/bnetd/channel_get_min(28c764f7c20ec9b2).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
1632 {
1633 if (!channel) {
1634 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1635 return 0;
1636 }
1637
1638 return channel->minmemberscxx . . $ pvpgn/bnetd/channel#minmembers.;
1639 }
1640
1641 extern int channel_set_mincxx . . $ pvpgn/bnetd/channel_set_min(48cee1134ea01a3a).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, int minmembers)
1642 {
1643 if (!channel) {
1644 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL channel");
1645 return 0;
1646 }
1647
1648 if (minmembers)
1649 channel->minmemberscxx . . $ pvpgn/bnetd/channel#minmembers. = minmembers;
1650 return 1;
1651 }
1652
1653 extern int channel_wol_get_game_typecxx . . $ pvpgn/bnetd/channel_wol_get_game_type(28c764f7c20ec9b2).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
1654 {
1655 if (!channel)
1656 {
1657 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL channel");
1658 return -1;
1659 }
1660
1661 return channel->gameTypecxx . . $ pvpgn/bnetd/channel#gameType.;
1662 }
1663
1664 extern int channel_wol_set_game_typecxx . . $ pvpgn/bnetd/channel_wol_set_game_type(48cee1134ea01a3a).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, int gameType)
1665 {
1666 if (!channel)
1667 {
1668 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL channel");
1669 return -1;
1670 }
1671
1672 if (gameType)
1673 channel->gameTypecxx . . $ pvpgn/bnetd/channel#gameType. = gameType;
1674
1675 return 0;
1676 }
1677
1678 extern char const * channel_wol_get_game_extensioncxx . . $ pvpgn/bnetd/channel_wol_get_game_extension(7800017c14723985).(t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel)
1679 {
1680 if (!channel)
1681 {
1682 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL channel");
1683 return 0;
1684 }
1685
1686 return channel->gameExtensioncxx . . $ pvpgn/bnetd/channel#gameExtension.;
1687 }
1688
1689 extern int channel_wol_set_game_extensioncxx . . $ pvpgn/bnetd/channel_wol_set_game_extension(2cba118976651e77).(t_channelcxx . . $ pvpgn/bnetd/t_channel# * channel, char const * gameExtension)
1690 {
1691 if (!channel)
1692 {
1693 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL channel");
1694 return -1;
1695 }
1696
1697 if (!gameExtension)
1698 {
1699 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL gameExtension");
1700 return -1;
1701 }
1702
1703 if (channel->gameExtensioncxx . . $ pvpgn/bnetd/channel#gameExtension.)
1704 xfreecxx . . $ `src/common/xalloc.h:51:9`!(channel->gameExtension);
1705
1706 channel->gameExtensioncxx . . $ pvpgn/bnetd/channel#gameExtension. = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(gameExtension);
1707
1708 return 0;
1709 }
1710
1711
1712 }
1713
1714 }