Debian Codegraph @

src/common/tag.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2004 Aaron
3 * Copyright (C) 2004 CreepLord ([email protected])
4 * Copyright (C) 2007,2008 Pelish ([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 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
21 #include "common/tag.h"cxx . . $ `<file>/src/common/tag.h`/
22
23 #include <cstring>
24 #include <cctype>
25 #include <string>
26
27 #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/
28
29 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
30 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
31 #include "common/xstring.h"cxx . . $ `<file>/src/common/xstring.h`/
32 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
33
34 namespace pvpgncxx . . $ pvpgn/
35 {
36
37 /* fixme: have all functions call tag_str_to_uint() */
38 extern t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag_str_to_uintcxx . . $ pvpgn/clienttag_str_to_uint(c61c63047ce273de).(char const * clienttag)
39 {
40 if (!clienttag)
41 {
42 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL clienttag");
43 return CLIENTTAG_UNKNOWN_UINTcxx . . $ `src/common/tag.h:152:9`!;
44 }
45
46 return tag_str_to_uintcxx . . $ pvpgn/tag_str_to_uint(c61c63047ce273de).(clienttag);
47 }
48
49 /* fixme: have all fuctions call tag_uint_to_str() */
50 extern char const * clienttag_uint_to_strcxx . . $ pvpgn/clienttag_uint_to_str(81a3ae90da26a711).(t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag)
51 {
52 switch (clienttag)
53 {
54 case CLIENTTAG_BNCHATBOT_UINTcxx . . $ `src/common/tag.h:85:9`!:
55 return CLIENTTAG_BNCHATBOTcxx . . $ `src/common/tag.h:84:9`!;
56 case CLIENTTAG_STARCRAFT_UINTcxx . . $ `src/common/tag.h:87:9`!:
57 return CLIENTTAG_STARCRAFTcxx . . $ `src/common/tag.h:86:9`!;
58 case CLIENTTAG_BROODWARS_UINTcxx . . $ `src/common/tag.h:89:9`!:
59 return CLIENTTAG_BROODWARScxx . . $ `src/common/tag.h:88:9`!;
60 case CLIENTTAG_SHAREWARE_UINTcxx . . $ `src/common/tag.h:91:9`!:
61 return CLIENTTAG_SHAREWAREcxx . . $ `src/common/tag.h:90:9`!;
62 case CLIENTTAG_DIABLORTL_UINTcxx . . $ `src/common/tag.h:93:9`!:
63 return CLIENTTAG_DIABLORTLcxx . . $ `src/common/tag.h:92:9`!;
64 case CLIENTTAG_DIABLOSHR_UINTcxx . . $ `src/common/tag.h:95:9`!:
65 return CLIENTTAG_DIABLOSHRcxx . . $ `src/common/tag.h:94:9`!;
66 case CLIENTTAG_WARCIIBNE_UINTcxx . . $ `src/common/tag.h:97:9`!:
67 return CLIENTTAG_WARCIIBNEcxx . . $ `src/common/tag.h:96:9`!;
68 case CLIENTTAG_DIABLO2DV_UINTcxx . . $ `src/common/tag.h:99:9`!:
69 return CLIENTTAG_DIABLO2DVcxx . . $ `src/common/tag.h:98:9`!;
70 case CLIENTTAG_STARJAPAN_UINTcxx . . $ `src/common/tag.h:101:9`!:
71 return CLIENTTAG_STARJAPANcxx . . $ `src/common/tag.h:100:9`!;
72 case CLIENTTAG_DIABLO2ST_UINTcxx . . $ `src/common/tag.h:103:9`!:
73 return CLIENTTAG_DIABLO2STcxx . . $ `src/common/tag.h:102:9`!;
74 case CLIENTTAG_DIABLO2XP_UINTcxx . . $ `src/common/tag.h:105:9`!:
75 return CLIENTTAG_DIABLO2XPcxx . . $ `src/common/tag.h:104:9`!;
76 case CLIENTTAG_WARCRAFT3_UINTcxx . . $ `src/common/tag.h:111:9`!:
77 return CLIENTTAG_WARCRAFT3cxx . . $ `src/common/tag.h:110:9`!;
78 case CLIENTTAG_WAR3XP_UINTcxx . . $ `src/common/tag.h:113:9`!:
79 return CLIENTTAG_WAR3XPcxx . . $ `src/common/tag.h:112:9`!;
80 case CLIENTTAG_IIRC_UINTcxx . . $ `src/common/tag.h:116:9`!:
81 return CLIENTTAG_IIRCcxx . . $ `src/common/tag.h:115:9`!;
82 case CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!:
83 return CLIENTTAG_WCHATcxx . . $ `src/common/tag.h:119:9`!;
84 case CLIENTTAG_TIBERNSUN_UINTcxx . . $ `src/common/tag.h:122:9`!:
85 return CLIENTTAG_TIBERNSUNcxx . . $ `src/common/tag.h:121:9`!;
86 case CLIENTTAG_TIBSUNXP_UINTcxx . . $ `src/common/tag.h:124:9`!:
87 return CLIENTTAG_TIBSUNXPcxx . . $ `src/common/tag.h:123:9`!;
88 case CLIENTTAG_REDALERT_UINTcxx . . $ `src/common/tag.h:126:9`!:
89 return CLIENTTAG_REDALERTcxx . . $ `src/common/tag.h:125:9`!;
90 case CLIENTTAG_REDALERT2_UINTcxx . . $ `src/common/tag.h:128:9`!:
91 return CLIENTTAG_REDALERT2cxx . . $ `src/common/tag.h:127:9`!;
92 case CLIENTTAG_DUNE2000_UINTcxx . . $ `src/common/tag.h:130:9`!:
93 return CLIENTTAG_DUNE2000cxx . . $ `src/common/tag.h:129:9`!;
94 case CLIENTTAG_NOX_UINTcxx . . $ `src/common/tag.h:132:9`!:
95 return CLIENTTAG_NOXcxx . . $ `src/common/tag.h:131:9`!;
96 case CLIENTTAG_NOXQUEST_UINTcxx . . $ `src/common/tag.h:134:9`!:
97 return CLIENTTAG_NOXQUESTcxx . . $ `src/common/tag.h:133:9`!;
98 case CLIENTTAG_RENEGADE_UINTcxx . . $ `src/common/tag.h:136:9`!:
99 return CLIENTTAG_RENEGADEcxx . . $ `src/common/tag.h:135:9`!;
100 case CLIENTTAG_RENGDFDS_UINTcxx . . $ `src/common/tag.h:138:9`!:
101 return CLIENTTAG_RENGDFDScxx . . $ `src/common/tag.h:137:9`!;
102 case CLIENTTAG_YURISREV_UINTcxx . . $ `src/common/tag.h:140:9`!:
103 return CLIENTTAG_YURISREVcxx . . $ `src/common/tag.h:139:9`!;
104 case CLIENTTAG_EMPERORBD_UINTcxx . . $ `src/common/tag.h:142:9`!:
105 return CLIENTTAG_EMPERORBDcxx . . $ `src/common/tag.h:141:9`!;
106 case CLIENTTAG_LOFLORE3_UINTcxx . . $ `src/common/tag.h:144:9`!:
107 return CLIENTTAG_LOFLORE3cxx . . $ `src/common/tag.h:143:9`!;
108 case CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!:
109 return CLIENTTAG_WWOLcxx . . $ `src/common/tag.h:145:9`!;
110 default:
111 return CLIENTTAG_UNKNOWNcxx . . $ `src/common/tag.h:151:9`!;
112 }
113 }
114
115 /*****/
116 /* make all letters in string upper case - used in command.cpp*/
117 extern t_tagcxx . . $ pvpgn/t_tag# tag_case_str_to_uintcxx . . $ pvpgn/tag_case_str_to_uint(c61c63047ce273de).(char const * tag_str)
118 {
119 unsigned int i, len;
120 char temp_str[5];
121
122 len = stdcxx . . $ std/::strlen(tag_str);
123 if (len != 4)
124 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn., __FUNCTION__, "got unusual sized clienttag '{}'", tag_str);
125
126 for (i = 0; i < len && i < 4; i++)
127 temp_str[i] = safe_touppercxx . . $ `src/common/xstring.h:40:10`!(tag_str[i]);
128
129 temp_str[4] = '\0';
130
131 return tag_str_to_uintcxx . . $ pvpgn/tag_str_to_uint(c61c63047ce273de).(temp_str);
132 }
133
134 extern t_tagcxx . . $ pvpgn/t_tag# tag_str_to_uintcxx . . $ pvpgn/tag_str_to_uint(c61c63047ce273de).(char const * tag_str)
135 {
136 t_tagcxx . . $ pvpgn/t_tag# tag_uint;
137
138 if (!tag_str) {
139 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL tag");
140 return 0; /* unknown */
141 }
142
143 tag_uint = tag_str[0] << 24;
144 tag_uint |= tag_str[1] << 16;
145 tag_uint |= tag_str[2] << 8;
146 tag_uint |= tag_str[3];
147
148 return tag_uint;
149 }
150 /* tag_uint_to_str()
151 *
152 * from calling function:
153 *
154 * char tag_str[5]; // define first, then send into fuction
155 * tag_uint_to_str(tag_str, tag_uint); // returns pointer to tag_str
156 *
157 * Nothing to malloc, nothing to free
158 */
159 extern const char * tag_uint_to_strcxx . . $ pvpgn/tag_uint_to_str(d172961b102a89a5).(char * tag_str, t_tagcxx . . $ pvpgn/t_tag# tag_uint)
160 {
161 if (!tag_uint) /* return "UNKN" if tag_uint = 0 */
162 return TAG_UNKNOWNcxx . . $ `src/common/tag.h:178:9`!;
163
164 tag_str[0] = ((unsigned char)(tag_uint >> 24));
165 tag_str[1] = ((unsigned char)(tag_uint >> 16) & 0xff);
166 tag_str[2] = ((unsigned char)(tag_uint >> 8) & 0xff);
167 tag_str[3] = ((unsigned char)(tag_uint)& 0xff);
168 tag_str[4] = '\0';
169 return tag_str;
170 }
171 extern stdcxx . . $ std/::stringcxx . . $ std/string# tag_uint_to_str2cxx . . $ pvpgn/tag_uint_to_str2(8297fed3afd4179b).(t_tagcxx . . $ pvpgn/t_tag# tag_uint)
172 {
173 if (!tag_uint) /* return "UNKN" if tag_uint = 0 */
174 return stdcxx . . $ std/::stringcxx . . $ std/string#(TAG_UNKNOWNcxx . . $ `src/common/tag.h:178:9`!);
175
176 char tag_str[5] = {};
177 tag_str[0] = ((unsigned char)(tag_uint >> 24));
178 tag_str[1] = ((unsigned char)(tag_uint >> 16) & 0xff);
179 tag_str[2] = ((unsigned char)(tag_uint >> 8) & 0xff);
180 tag_str[3] = ((unsigned char)(tag_uint)& 0xff);
181 tag_str[4] = '\0';
182 return stdcxx . . $ std/::stringcxx . . $ std/string#(tag_str);
183 }
184
185 extern const char * tag_uint_to_revstrcxx . . $ pvpgn/tag_uint_to_revstr(d172961b102a89a5).(char * tag_str, t_tagcxx . . $ pvpgn/t_tag# tag_uint)
186 {
187 if (!tag_uint) /* return "UNKN" if tag_uint = 0 */
188 return TAG_UNKNOWNcxx . . $ `src/common/tag.h:178:9`!;
189
190 tag_str[0] = ((unsigned char)(tag_uint)& 0xff);
191 tag_str[1] = ((unsigned char)(tag_uint >> 8) & 0xff);
192 tag_str[2] = ((unsigned char)(tag_uint >> 16) & 0xff);
193 tag_str[3] = ((unsigned char)(tag_uint >> 24));
194 tag_str[4] = '\0';
195 return tag_str;
196 }
197
198 extern int tag_check_archcxx . . $ pvpgn/tag_check_arch(4c679297bf94b9eb).(t_tagcxx . . $ pvpgn/t_tag# tag_uint)
199 {
200 switch (tag_uint)
201 {
202 case ARCHTAG_WINX86_UINTcxx . . $ `src/common/tag.h:159:9`!:
203 case ARCHTAG_MACPPC_UINTcxx . . $ `src/common/tag.h:160:9`!:
204 case ARCHTAG_OSXPPC_UINTcxx . . $ `src/common/tag.h:161:9`!:
205 return 1;
206 default:
207 return 0;
208 }
209 }
210
211 extern int tag_check_clientcxx . . $ pvpgn/tag_check_client(4c679297bf94b9eb).(t_tagcxx . . $ pvpgn/t_tag# tag_uint)
212 {
213 switch (tag_uint)
214 {
215 case CLIENTTAG_BNCHATBOT_UINTcxx . . $ `src/common/tag.h:85:9`!:
216 case CLIENTTAG_STARCRAFT_UINTcxx . . $ `src/common/tag.h:87:9`!:
217 case CLIENTTAG_BROODWARS_UINTcxx . . $ `src/common/tag.h:89:9`!:
218 case CLIENTTAG_SHAREWARE_UINTcxx . . $ `src/common/tag.h:91:9`!:
219 case CLIENTTAG_DIABLORTL_UINTcxx . . $ `src/common/tag.h:93:9`!:
220 case CLIENTTAG_DIABLOSHR_UINTcxx . . $ `src/common/tag.h:95:9`!:
221 case CLIENTTAG_WARCIIBNE_UINTcxx . . $ `src/common/tag.h:97:9`!:
222 case CLIENTTAG_DIABLO2DV_UINTcxx . . $ `src/common/tag.h:99:9`!:
223 case CLIENTTAG_STARJAPAN_UINTcxx . . $ `src/common/tag.h:101:9`!:
224 case CLIENTTAG_DIABLO2ST_UINTcxx . . $ `src/common/tag.h:103:9`!:
225 case CLIENTTAG_DIABLO2XP_UINTcxx . . $ `src/common/tag.h:105:9`!:
226 case CLIENTTAG_WARCRAFT3_UINTcxx . . $ `src/common/tag.h:111:9`!:
227 case CLIENTTAG_WAR3XP_UINTcxx . . $ `src/common/tag.h:113:9`!:
228 case CLIENTTAG_IIRC_UINTcxx . . $ `src/common/tag.h:116:9`!:
229 case CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!:
230 case CLIENTTAG_TIBERNSUN_UINTcxx . . $ `src/common/tag.h:122:9`!:
231 case CLIENTTAG_TIBSUNXP_UINTcxx . . $ `src/common/tag.h:124:9`!:
232 case CLIENTTAG_REDALERT_UINTcxx . . $ `src/common/tag.h:126:9`!:
233 case CLIENTTAG_REDALERT2_UINTcxx . . $ `src/common/tag.h:128:9`!:
234 case CLIENTTAG_DUNE2000_UINTcxx . . $ `src/common/tag.h:130:9`!:
235 case CLIENTTAG_NOX_UINTcxx . . $ `src/common/tag.h:132:9`!:
236 case CLIENTTAG_NOXQUEST_UINTcxx . . $ `src/common/tag.h:134:9`!:
237 case CLIENTTAG_RENEGADE_UINTcxx . . $ `src/common/tag.h:136:9`!:
238 case CLIENTTAG_RENGDFDS_UINTcxx . . $ `src/common/tag.h:138:9`!:
239 case CLIENTTAG_YURISREV_UINTcxx . . $ `src/common/tag.h:140:9`!:
240 case CLIENTTAG_EMPERORBD_UINTcxx . . $ `src/common/tag.h:142:9`!:
241 case CLIENTTAG_LOFLORE3_UINTcxx . . $ `src/common/tag.h:144:9`!:
242 case CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!:
243 return 1;
244 default:
245 return 0;
246 }
247 }
248
249 extern int tag_check_wolv1cxx . . $ pvpgn/tag_check_wolv1(4c679297bf94b9eb).(t_tagcxx . . $ pvpgn/t_tag# tag_uint)
250 {
251 switch (tag_uint) {
252 case CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!:
253 return 1;
254 default:
255 return 0;
256 }
257 }
258
259 extern int tag_check_wolv2cxx . . $ pvpgn/tag_check_wolv2(4c679297bf94b9eb).(t_tagcxx . . $ pvpgn/t_tag# tag_uint)
260 {
261 switch (tag_uint) {
262 case CLIENTTAG_TIBERNSUN_UINTcxx . . $ `src/common/tag.h:122:9`!:
263 case CLIENTTAG_TIBSUNXP_UINTcxx . . $ `src/common/tag.h:124:9`!:
264 case CLIENTTAG_REDALERT_UINTcxx . . $ `src/common/tag.h:126:9`!:
265 case CLIENTTAG_REDALERT2_UINTcxx . . $ `src/common/tag.h:128:9`!:
266 case CLIENTTAG_DUNE2000_UINTcxx . . $ `src/common/tag.h:130:9`!:
267 case CLIENTTAG_NOX_UINTcxx . . $ `src/common/tag.h:132:9`!:
268 case CLIENTTAG_NOXQUEST_UINTcxx . . $ `src/common/tag.h:134:9`!:
269 case CLIENTTAG_RENEGADE_UINTcxx . . $ `src/common/tag.h:136:9`!:
270 case CLIENTTAG_RENGDFDS_UINTcxx . . $ `src/common/tag.h:138:9`!:
271 case CLIENTTAG_YURISREV_UINTcxx . . $ `src/common/tag.h:140:9`!:
272 case CLIENTTAG_EMPERORBD_UINTcxx . . $ `src/common/tag.h:142:9`!:
273 case CLIENTTAG_LOFLORE3_UINTcxx . . $ `src/common/tag.h:144:9`!:
274 case CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!:
275 return 1;
276 default:
277 return 0;
278 }
279 }
280
281 extern char const * clienttag_get_titlecxx . . $ pvpgn/clienttag_get_title(81a3ae90da26a711).(t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag)
282 {
283 switch (clienttag)
284 {
285 case CLIENTTAG_WAR3XP_UINTcxx . . $ `src/common/tag.h:113:9`!:
286 return "Warcraft III Frozen Throne";
287 case CLIENTTAG_WARCRAFT3_UINTcxx . . $ `src/common/tag.h:111:9`!:
288 return "Warcraft III";
289 case CLIENTTAG_DIABLO2XP_UINTcxx . . $ `src/common/tag.h:105:9`!:
290 return "Diablo II Lord of Destruction";
291 case CLIENTTAG_DIABLO2DV_UINTcxx . . $ `src/common/tag.h:99:9`!:
292 return "Diablo II";
293 case CLIENTTAG_STARJAPAN_UINTcxx . . $ `src/common/tag.h:101:9`!:
294 return "Starcraft (Japan)";
295 case CLIENTTAG_WARCIIBNE_UINTcxx . . $ `src/common/tag.h:97:9`!:
296 return "Warcraft II";
297 case CLIENTTAG_DIABLOSHR_UINTcxx . . $ `src/common/tag.h:95:9`!:
298 return "Diablo I (Shareware)";
299 case CLIENTTAG_DIABLORTL_UINTcxx . . $ `src/common/tag.h:93:9`!:
300 return "Diablo I";
301 case CLIENTTAG_SHAREWARE_UINTcxx . . $ `src/common/tag.h:91:9`!:
302 return "Starcraft (Shareware)";
303 case CLIENTTAG_BROODWARS_UINTcxx . . $ `src/common/tag.h:89:9`!:
304 return "Starcraft: Brood War";
305 case CLIENTTAG_STARCRAFT_UINTcxx . . $ `src/common/tag.h:87:9`!:
306 return "Starcraft";
307 case CLIENTTAG_BNCHATBOT_UINTcxx . . $ `src/common/tag.h:85:9`!:
308 return "Chat";
309 case CLIENTTAG_IIRC_UINTcxx . . $ `src/common/tag.h:116:9`!:
310 return "Internet Relay Chat";
311 case CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!:
312 return "Westwood Chat";
313 case CLIENTTAG_TIBERNSUN_UINTcxx . . $ `src/common/tag.h:122:9`!:
314 return "Tiberian Sun";
315 case CLIENTTAG_TIBSUNXP_UINTcxx . . $ `src/common/tag.h:124:9`!:
316 return "Tiberian Sun: Firestorm";
317 case CLIENTTAG_REDALERT_UINTcxx . . $ `src/common/tag.h:126:9`!:
318 return "Red Alert";
319 case CLIENTTAG_REDALERT2_UINTcxx . . $ `src/common/tag.h:128:9`!:
320 return "Red Alert 2";
321 case CLIENTTAG_DUNE2000_UINTcxx . . $ `src/common/tag.h:130:9`!:
322 return "Dune 2000";
323 case CLIENTTAG_NOX_UINTcxx . . $ `src/common/tag.h:132:9`!:
324 return "Nox";
325 case CLIENTTAG_NOXQUEST_UINTcxx . . $ `src/common/tag.h:134:9`!:
326 return "Nox Quest";
327 case CLIENTTAG_RENEGADE_UINTcxx . . $ `src/common/tag.h:136:9`!:
328 return "Renegade";
329 case CLIENTTAG_RENGDFDS_UINTcxx . . $ `src/common/tag.h:138:9`!:
330 return "Renegade Free Dedicated Server";
331 case CLIENTTAG_YURISREV_UINTcxx . . $ `src/common/tag.h:140:9`!:
332 return "Yuri's Revenge";
333 case CLIENTTAG_EMPERORBD_UINTcxx . . $ `src/common/tag.h:142:9`!:
334 return "Emepror: Battle for Dune";
335 case CLIENTTAG_LOFLORE3_UINTcxx . . $ `src/common/tag.h:144:9`!:
336 return "Lands of Lore 3";
337 case CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!:
338 return "Westwood Online";
339 default:
340 return "Unknown";
341 }
342 }
343
344 extern int tag_check_in_listcxx . . $ pvpgn/tag_check_in_list(dbfc9165c1ea8dea).(t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, char const * list)
345 {
346 /* checks if a clienttag is in the list
347 * @clienttag : clienttag integer to check
348 * if it's allowed returns 0
349 * if it's not allowed returns -1
350 */
351 char *tmp, *p, *q;
352
353 /* by default allow all */
354 if (!list)
355 return 0;
356
357 /* this shortcut check should make server as fast as before if
358 * the configuration is left in default mode */
359 if (!strcasecmp(list, "all"))
360 return 0;
361
362 tmp = p = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(list);
363 do {
364 q = stdcxx . . $ std/::strchr(p, ',');
365 if (q)
366 *q = '\0';
367 if (!strcasecmp(p, "all"))
368 goto ok;
369 if (stdcxx . . $ std/::strlen(p) != 4)
370 continue;
371 if (clienttag == tag_case_str_to_uintcxx . . $ pvpgn/tag_case_str_to_uint(c61c63047ce273de).(p))
372 goto ok; /* client is in list */
373 if (q)
374 p = q + 1;
375 } while (q);
376 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)tmp);
377
378 return -1; /* client is NOT in list */
379
380 ok:
381 xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)tmp);
382 return 0;
383 }
384
385 extern t_clienttagcxx . . $ pvpgn/t_clienttag# tag_sku_to_uintcxx . . $ pvpgn/tag_sku_to_uint(46cc46841198e427).(int sku)
386 {
387 /**
388 * Here is table of Westwood Online SKUs and by this SKU returning CLIENTTAG
389 * SKUs are from Autoupdate FTP and from windows registry
390 */
391
392 if (!sku) {
393 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL sku");
394 return CLIENTTAG_UNKNOWN_UINTcxx . . $ `src/common/tag.h:152:9`!;
395 }
396
397 switch (sku) {
398 case 1000: /* Westwood Chat */
399 return CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!;
400 /* case 1002: Internet Registration */
401 case 1003: /* Command & Conquer */
402 return CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!;
403 // return CLIENTTAG_CNCONQUER_UINT;
404 case 1005: /* Red Alert 1 v2.00 (Westwood Chat Version) */
405 case 1006:
406 case 1007:
407 case 1008:
408 return CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!;
409 // return CLIENTTAG_REDALERT_UINT;
410 case 1040: /* C&C Sole Survivor */
411 return CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!;
412 // return CLIENTTAG_CNCSOLES_UINT;
413 case 3072: /* C&C Renegade */
414 case 3074:
415 case 3075:
416 case 3078:
417 case 3081:
418 case 3082:
419 // case 16780288: /* renegade ladder players */
420 return CLIENTTAG_RENEGADE_UINTcxx . . $ `src/common/tag.h:136:9`!;
421 case 3584: /* Dune 2000 */
422 case 3586:
423 case 3587:
424 case 3589:
425 case 3591:
426 return CLIENTTAG_DUNE2000_UINTcxx . . $ `src/common/tag.h:130:9`!;
427 case 4096: /* Nox */
428 case 4098:
429 case 4099:
430 case 4101:
431 case 4102:
432 case 4105:
433 return CLIENTTAG_NOX_UINTcxx . . $ `src/common/tag.h:132:9`!;
434 case 4608: /* Tiberian Sun */
435 case 4610:
436 case 4611:
437 case 4615:
438 return CLIENTTAG_TIBERNSUN_UINTcxx . . $ `src/common/tag.h:122:9`!;
439 case 5376: /* Red Alert 1 v3.03 (4 Players Internet Version) */
440 case 5378:
441 case 5379:
442 return CLIENTTAG_REDALERT_UINTcxx . . $ `src/common/tag.h:126:9`!;
443 case 6400: /* Lands of Lore 3 */
444 case 6401:
445 case 6402:
446 case 6403:
447 case 6405:
448 return CLIENTTAG_LOFLORE3_UINTcxx . . $ `src/common/tag.h:144:9`!;
449 case 7168: /* Tiberian Sun: Firestorm */
450 case 7170:
451 case 7171:
452 case 7175:
453 case 7424:
454 case 7426:
455 case 7427:
456 case 7431:
457 return CLIENTTAG_TIBSUNXP_UINTcxx . . $ `src/common/tag.h:124:9`!;
458 case 7936: /* Emperor: Battle for Dune */
459 case 7938:
460 case 7939:
461 case 7945:
462 case 7946:
463 return CLIENTTAG_EMPERORBD_UINTcxx . . $ `src/common/tag.h:142:9`!;
464 case 8448: /* Red Alert 2 */
465 case 8450:
466 case 8451:
467 case 8457:
468 case 8458:
469 case 8960:
470 case 8962:
471 case 8963:
472 case 8969:
473 case 8970:
474 return CLIENTTAG_REDALERT2_UINTcxx . . $ `src/common/tag.h:128:9`!;
475 case 9472: /* Nox Quest */
476 case 9474:
477 case 9475:
478 case 9477:
479 case 9478:
480 case 9481:
481 return CLIENTTAG_NOXQUEST_UINTcxx . . $ `src/common/tag.h:134:9`!;
482 case 10496: /* Yuri's Revenge */
483 case 10498:
484 case 10499:
485 case 10505:
486 case 10506:
487 return CLIENTTAG_YURISREV_UINTcxx . . $ `src/common/tag.h:140:9`!;
488 case 12288: /* C&C Renegade Free Dedicated Server */
489 return CLIENTTAG_RENGDFDS_UINTcxx . . $ `src/common/tag.h:138:9`!;
490 case 32512: /* Westwood Online API */
491 return CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!;
492 default: /* Unknown Westwood Online game -> is anyone SKU that we havent??? */
493 return CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!;
494 }
495 }
496
497 extern t_clienttagcxx . . $ pvpgn/t_clienttag# tag_channeltype_to_uintcxx . . $ pvpgn/tag_channeltype_to_uint(46cc46841198e427).(int channeltype)
498 {
499 /**
500 * This is used to convert WOL channel type to t_clienttag
501 */
502
503 if (!channeltype) {
504 ERROR0cxx . . $ `src/common/eventlog.h:73:9`!("got NULL channeltype");
505 return CLIENTTAG_UNKNOWN_UINTcxx . . $ `src/common/tag.h:152:9`!;
506 }
507
508 switch (channeltype) {
509 case 0: /* Westwood Chat channels */
510 case 1: /* Command & Conquer Win95 channels */
511 case 2: /* Red Alert Win95 channels */
512 case 3: /* Red Alert Win95 Counterstrike channels */
513 case 4: /* Red Alert Win95 The Aftermath channels */
514 case 5: /* Command & Conquer: Sole Survivor channels */
515 return CLIENTTAG_WCHAT_UINTcxx . . $ `src/common/tag.h:120:9`!;
516 case 12: /* Command & Conquer: Renegade channels */
517 return CLIENTTAG_RENEGADE_UINTcxx . . $ `src/common/tag.h:136:9`!;
518 case 14: /* Dune 2000 channels */
519 return CLIENTTAG_DUNE2000_UINTcxx . . $ `src/common/tag.h:130:9`!;
520 case 16: /* Nox channels */
521 return CLIENTTAG_NOX_UINTcxx . . $ `src/common/tag.h:132:9`!;
522 case 18: /* Tiberian Sun channels */
523 return CLIENTTAG_TIBERNSUN_UINTcxx . . $ `src/common/tag.h:122:9`!;
524 case 21: /* Red Alert 1 v 3.03 channels */
525 return CLIENTTAG_REDALERT_UINTcxx . . $ `src/common/tag.h:126:9`!;
526 case 31: /* Emperor: Battle for Dune channels */
527 return CLIENTTAG_EMPERORBD_UINTcxx . . $ `src/common/tag.h:142:9`!;
528 case 33: /* Red Alert 2 channels */
529 return CLIENTTAG_REDALERT2_UINTcxx . . $ `src/common/tag.h:128:9`!;
530 case 37: /* Nox Quest channels */
531 return CLIENTTAG_NOXQUEST_UINTcxx . . $ `src/common/tag.h:134:9`!;
532 case 38: /* QuickMatch channels */
533 case 39:
534 case 40:
535 return CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!;
536 case 41: /* Yuri's Revenge channels */
537 return CLIENTTAG_YURISREV_UINTcxx . . $ `src/common/tag.h:140:9`!;
538 default:
539 return CLIENTTAG_WWOL_UINTcxx . . $ `src/common/tag.h:146:9`!;
540 }
541 }
542
543 extern t_tagcxx . . $ pvpgn/t_tag# tag_wol_locale_to_uintcxx . . $ pvpgn/tag_wol_locale_to_uint(46cc46841198e427).(int locale)
544 {
545 switch (locale) {
546 case tag_wol_locale_unknowncxx . . $ tag_wol_locale_unknown.:
547 return GAMELANG_ENGLISH_UINTcxx . . $ `src/common/tag.h:164:9`!;
548 case tag_wol_locale_othercxx . . $ tag_wol_locale_other.:
549 return GAMELANG_ENGLISH_UINTcxx . . $ `src/common/tag.h:164:9`!;
550 case tag_wol_locale_usacxx . . $ tag_wol_locale_usa.:
551 return GAMELANG_ENGLISH_UINTcxx . . $ `src/common/tag.h:164:9`!;
552 /* case tag_wol_locale_canada:
553 return enCA
554 case tag_wol_locale_uk:
555 return enGB */
556 case tag_wol_locale_germanycxx . . $ tag_wol_locale_germany.:
557 return GAMELANG_GERMAN_UINTcxx . . $ `src/common/tag.h:165:9`!;
558 case tag_wol_locale_francecxx . . $ tag_wol_locale_france.:
559 return GAMELANG_FRENCH_UINTcxx . . $ `src/common/tag.h:168:9`!;
560 case tag_wol_locale_spaincxx . . $ tag_wol_locale_spain.:
561 return GAMELANG_SPANISH_UINTcxx . . $ `src/common/tag.h:167:9`!;
562 /* case tag_wol_locale_netherlands:
563 return nlNL
564 case tag_wol_locale_belgium:
565 return nlBE
566 case tag_wol_locale_austria:
567 return deAT
568 case tag_wol_locale_switzerland:
569 return deCH */
570 case tag_wol_locale_italycxx . . $ tag_wol_locale_italy.:
571 return GAMELANG_ITALIAN_UINTcxx . . $ `src/common/tag.h:169:9`!;
572 /* case tag_wol_locale_denmark:
573 return daDK
574 case tag_wol_locale_sweden:
575 return svSE
576 case tag_wol_locale_norway:
577 return noNO
578 case tag_wol_locale_finland:
579 return fiFI
580 case tag_wol_locale_israel:
581 return arIL
582 case tag_wol_locale_south_africa:
583 return enZA*/
584 case tag_wol_locale_japancxx . . $ tag_wol_locale_japan.:
585 return GAMELANG_JAPANESE_UINTcxx . . $ `src/common/tag.h:170:9`!;
586 case tag_wol_locale_south_koreacxx . . $ tag_wol_locale_south_korea.:
587 return GAMELANG_KOREAN_UINTcxx . . $ `src/common/tag.h:171:9`!;
588 case tag_wol_locale_chinacxx . . $ tag_wol_locale_china.:
589 return GAMELANG_CHINESE_S_UINTcxx . . $ `src/common/tag.h:174:9`!;
590 /* case tag_wol_locale_singapore:
591 return enSG
592 case tag_wol_locale_taiwan:
593 return zhTW
594 case tag_wol_locale_malaysia:
595 return msMY
596 case tag_wol_locale_australia:
597 return enAU
598 case tag_wol_locale_new_zealand:
599 return enNZ
600 case tag_wol_locale_brazil:
601 return ptBR
602 case tag_wol_locale_thailand:
603 return thTH
604 case tag_wol_locale_argentina:
605 return esAR
606 case tag_wol_locale_philippines:
607 return enPH
608 case tag_wol_locale_greece:
609 return elGR
610 case tag_wol_locale_ireland:
611 return enIE*/
612 case tag_wol_locale_polandcxx . . $ tag_wol_locale_poland.:
613 return GAMELANG_POLISH_UINTcxx . . $ `src/common/tag.h:172:9`!;
614 /* case tag_wol_locale_portugal:
615 return ptPT
616 case tag_wol_locale_mexico:
617 return esMX*/
618 case tag_wol_locale_russiacxx . . $ tag_wol_locale_russia.:
619 return GAMELANG_RUSSIAN_UINTcxx . . $ `src/common/tag.h:173:9`!;
620 /* case tag_wol_locale_turkey:
621 return trTR*/
622 default:
623 WARN1cxx . . $ `src/common/eventlog.h:79:9`!("{} is not defined", locale);
624 return GAMELANG_ENGLISH_UINTcxx . . $ `src/common/tag.h:164:9`!;
625 }
626 }
627
628 /* Convert clienttag to uppercase and check it in valid client list
629 * Return NULL of tag not found
630 */
631 extern t_clienttagcxx . . $ pvpgn/t_clienttag# tag_validate_clientcxx . . $ pvpgn/tag_validate_client(c61c63047ce273de).(char const * client)
632 {
633 t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag;
634 if (!client || strlen(client) != 4)
635 return 0;
636
637 // toupper
638 clienttag = tag_case_str_to_uintcxx . . $ pvpgn/tag_case_str_to_uint(c61c63047ce273de).(client);
639
640 if (!tag_check_clientcxx . . $ pvpgn/tag_check_client(4c679297bf94b9eb).(clienttag))
641 return 0;
642
643 return clienttag;
644 }
645
646 }