Debian Codegraph @

src/d2cs/handle_d2gs.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2000,2001 Onlyer ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
19 #include "setup.h"cxx . . $ `<file>/src/d2cs/setup.h`/
20 #include "handle_d2gs.h"cxx . . $ `<file>/src/d2cs/handle_d2gs.h`/
21
22 #include <ctime>
23
24 #ifdef HAVE_SYS_TYPES_Hcxx . . $ `build/config.h:16:9`!
25 # include <sys/types.h>
26 #endif
27 #ifdef HAVE_SYS_STAT_Hcxx . . $ `build/config.h:21:9`!
28 # include <sys/stat.h>
29 #endif
30 #ifdef HAVE_UNISTD_Hcxx . . $ `build/config.h:7:9`!
31 # include <unistd.h>
32 #endif
33
34 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
35 #include "common/addr.h"cxx . . $ `<file>/src/common/addr.h`/
36 #include "common/trans.h"cxx . . $ `<file>/src/common/trans.h`/
37 #include "d2gs.h"cxx . . $ `<file>/src/d2cs/d2gs.h`/
38 #include "serverqueue.h"cxx . . $ `<file>/src/d2cs/serverqueue.h`/
39 #include "game.h"cxx . . $ `<file>/src/d2cs/game.h`/
40 #include "prefs.h"cxx . . $ `<file>/src/d2cs/prefs.h`/
41 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
42
43 namespace pvpgncxx . . $ pvpgn/
44 {
45
46 namespace d2cscxx . . $ pvpgn/d2cs/
47 {
48
49 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_authreply)
50 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_setgsinfo)
51 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_echoreply)
52 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_creategamereply)
53 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_joingamereply)
54 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_updategameinfo)
55 DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_d2gs_closegame)
56
57 static t_packet_handle_tablecxx . . $ pvpgn/d2cs/t_packet_handle_table# d2gs_packet_handle_tablecxx . . $ pvpgn/d2cs/d2gs_packet_handle_table.[]={
58 /* 0x00 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
59 /* 0x01 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
60 /* 0x02 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
61 /* 0x03 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
62 /* 0x04 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
63 /* 0x05 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
64 /* 0x06 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
65 /* 0x07 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
66 /* 0x08 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
67 /* 0x09 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
68 /* 0x0a */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
69 /* 0x0b */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
70 /* 0x0c */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
71 /* 0x0d */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
72 /* 0x0e */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
73 /* 0x0f */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
74 /* 0x10 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
75 /* FIXME: shouldn't these three be at 0x10-0x12? (But I'm pretty sure I preserved the padding) */
76 /* 0x11 */ { sizeof(t_d2gs_d2cs_authreplycxx . . $ pvpgn/t_d2gs_d2cs_authreply#), conn_state_connectedcxx . . $ pvpgn/d2cs/conn_state_connected., on_d2gs_authreplycxx . . $ pvpgn/d2cs/on_d2gs_authreply(5937b18ec8c7bf53). },
77 /* 0x12 */ { sizeof(t_d2gs_d2cs_setgsinfocxx . . $ pvpgn/t_d2gs_d2cs_setgsinfo#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_d2gs_setgsinfocxx . . $ pvpgn/d2cs/on_d2gs_setgsinfo(5937b18ec8c7bf53). },
78 /* 0x13 */ { sizeof(t_d2gs_d2cs_echoreplycxx . . $ pvpgn/t_d2gs_d2cs_echoreply#), conn_state_anycxx . . $ pvpgn/d2cs/conn_state_any., on_d2gs_echoreplycxx . . $ pvpgn/d2cs/on_d2gs_echoreply(5937b18ec8c7bf53). },
79 /* 0x14 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
80 /* 0x15 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
81 /* 0x16 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
82 /* 0x17 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
83 /* 0x18 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
84 /* 0x19 */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
85 /* 0x1a */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
86 /* 0x1b */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
87 /* 0x1c */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
88 /* 0x1d */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
89 /* 0x1e */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
90 /* 0x1f */ { 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! },
91 /* 0x20 */ { sizeof(t_d2gs_d2cs_creategamereplycxx . . $ pvpgn/t_d2gs_d2cs_creategamereply#),conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_d2gs_creategamereplycxx . . $ pvpgn/d2cs/on_d2gs_creategamereply(5937b18ec8c7bf53). },
92 /* 0x21 */ { sizeof(t_d2gs_d2cs_joingamereplycxx . . $ pvpgn/t_d2gs_d2cs_joingamereply#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_d2gs_joingamereplycxx . . $ pvpgn/d2cs/on_d2gs_joingamereply(5937b18ec8c7bf53). },
93 /* 0x22 */ { sizeof(t_d2gs_d2cs_updategameinfocxx . . $ pvpgn/t_d2gs_d2cs_updategameinfo#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_d2gs_updategameinfocxx . . $ pvpgn/d2cs/on_d2gs_updategameinfo(5937b18ec8c7bf53). },
94 /* 0x23 */ { sizeof(t_d2gs_d2cs_closegamecxx . . $ pvpgn/t_d2gs_d2cs_closegame#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_d2gs_closegamecxx . . $ pvpgn/d2cs/on_d2gs_closegame(5937b18ec8c7bf53). },
95 };
96
97 static void d2gs_send_init_infocxx . . $ pvpgn/d2cs/d2gs_send_init_info(d952f78e288dcd17).(t_d2gscxx . . $ pvpgn/d2cs/t_d2gs# * gs, t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c)
98 {
99 t_packetcxx . . $ pvpgn/t_packet# * rpacket;
100
101 if ((rpacket=packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2gscxx . . $ pvpgn/packet_class_d2gs.))) {
102 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket,sizeof(t_d2cs_d2gs_setinitinfocxx . . $ pvpgn/t_d2cs_d2gs_setinitinfo#));
103 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket,D2CS_D2GS_SETINITINFOcxx . . $ `src/common/d2cs_d2gs_protocol.h:119:9`!);
104 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setinitinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setinitinfo..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_10#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.,0);
105 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setinitinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setinitinfo..timecxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_10#time., stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!));
106 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setinitinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setinitinfo..gs_idcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_10#gs_id., d2gs_get_idcxx . . $ pvpgn/d2cs/d2gs_get_id(986de4a3f93bb0c3).(gs));
107 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setinitinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setinitinfo..ac_versioncxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_10#ac_version., 0);
108 // packet_append_string(rpacket,prefs_get_d2gs_ac_checksum());
109 packet_append_stringcxx . . $ pvpgn/packet_append_string(41801851180b7cbb).(rpacket,"bogus_ac_checksum");
110 // packet_append_string(rpacket,prefs_get_d2gs_ac_string());
111 packet_append_stringcxx . . $ pvpgn/packet_append_string(41801851180b7cbb).(rpacket,"bogus_ac_string");
112 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c,rpacket);
113 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
114 }
115 return;
116 }
117
118 static void d2gs_send_server_conffilecxx . . $ pvpgn/d2cs/d2gs_send_server_conffile(d952f78e288dcd17).(t_d2gscxx . . $ pvpgn/d2cs/t_d2gs# *gs, t_connectioncxx . . $ pvpgn/d2cs/t_connection# *c)
119 {
120 t_packetcxx . . $ pvpgn/t_packet# *rpacket;
121 stdcxx . . $ std/::FILEcxx . . $ std/FILE# *fp;
122 char buff[256];
123 int rno;
124 struct stat sfile;
125
126 /* open d2gs server config file */
127 fp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(prefs_get_d2gsconffilecxx . . $ pvpgn/d2cs/prefs_get_d2gsconffile(33a1f659e94feb42).(), "rb");
128 if (!fp) goto err;
129
130 /* get file size */
131 if (fstat(fileno(fp),&sfile)) {
132 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug.,__FUNCTION__,"failed fstat()");
133 goto err_fp;
134 }
135
136 rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cscxx . . $ pvpgn/packet_class_d2cs.);
137 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket,sizeof(t_d2cs_d2gs_setconffilecxx . . $ pvpgn/t_d2cs_d2gs_setconffile#));
138 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket,D2CS_D2GS_SETCONFFILEcxx . . $ `src/common/d2cs_d2gs_protocol.h:129:9`!);
139 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setconffilecxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setconffile..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_11#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.,0);
140 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setconffilecxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setconffile..sizecxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_11#size., sfile.st_size);
141 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setconffilecxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setconffile..reserved1cxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_11#reserved1., stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!));
142
143 while((rno = stdcxx . . $ std/::freadcxx . . $ std/fread(738fc8ac1d711e58).(buff,1,sizeof(buff),fp)) > 0) {
144 if (packet_append_datacxx . . $ pvpgn/packet_append_data(d82347a7305550af).(rpacket,buff,rno) < 0) { /* file too big */
145 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug.,__FUNCTION__,"conffile too big for a single packet");
146 goto err_packet;
147 }
148 }
149
150 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c,rpacket);
151 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
152 stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp);
153
154 return;
155
156 err_packet:
157 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
158
159 err_fp:
160 stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp);
161
162 err:
163 return;
164 }
165
166 static int on_d2gs_authreplycxx . . $ pvpgn/d2cs/on_d2gs_authreply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
167 {
168 t_d2gscxx . . $ pvpgn/d2cs/t_d2gs# * gs;
169 t_packetcxx . . $ pvpgn/t_packet# * rpacket;
170 unsigned int reply;
171 unsigned int try_checksum, checksum;
172 unsigned int version, conf_version;
173 unsigned int randnum, signlen;
174 unsigned char *sign;
175
176 if (!(gs=d2gslist_find_gscxx . . $ pvpgn/d2cs/d2gslist_find_gs(a5ff5b022d63132f).(conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c)))) {
177 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game server {} not found",conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
178 return -1;
179 }
180
181 version=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_authreply..versioncxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_3#version.);
182 try_checksum=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_authreply..checksumcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_3#checksum.);
183 checksum=d2gs_calc_checksumcxx . . $ pvpgn/d2cs/d2gs_calc_checksum(b75ab30b7b10ab34).(c);
184
185 conf_version = prefs_get_d2gs_versioncxx . . $ pvpgn/d2cs/prefs_get_d2gs_version(db52760e79bf9054).();
186 randnum = bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_authreply..randnumcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_3#randnum.);
187 signlen = bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_authreply..signlencxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_3#signlen.);
188 sign = packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_authreply..signcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_3#sign.;
189 if (conf_version && conf_version != version) {
190 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn.,__FUNCTION__,"game server {} version mismatch 0x{:X} - 0x{:X}",conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c),
191 version,conf_version);
192 }
193 if (conf_version && !MAJOR_VERSION_EQUALcxx . . $ `src/d2cs/setup.h:88:9`!(version, conf_version, D2GS_MAJOR_VERSION_MASKcxx . . $ `src/d2cs/d2gs.h:83:9`!)) {
194 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game server {} major version mismatch 0x{:X} - 0x{:X}",conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c),
195 version,conf_version);
196 reply=D2CS_D2GS_AUTHREPLY_BAD_VERSIONcxx . . $ `src/common/d2cs_d2gs_protocol.h:77:9`!;
197 } else if (prefs_get_d2gs_checksumcxx . . $ pvpgn/d2cs/prefs_get_d2gs_checksum(db52760e79bf9054).() && try_checksum != checksum) {
198 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game server {} checksum mismach 0x{:X} - 0x{:X}",conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c),try_checksum,checksum);
199 reply=D2CS_D2GS_AUTHREPLY_BAD_CHECKSUMcxx . . $ `src/common/d2cs_d2gs_protocol.h:78:9`!;
200 // } else if (license_verify_reply(c, randnum, sign, signlen)) {
201 // eventlog(eventlog_level_error,__FUNCTION__,"game server {} std::signal mismach", conn_get_d2gs_id(c));
202 // reply=D2CS_D2GS_AUTHREPLY_BAD_CHECKSUM;
203 } else {
204 reply=D2CS_D2GS_AUTHREPLY_SUCCEEDcxx . . $ `src/common/d2cs_d2gs_protocol.h:76:9`!;
205 }
206
207 if (reply==D2CS_D2GS_AUTHREPLY_SUCCEEDcxx . . $ `src/common/d2cs_d2gs_protocol.h:76:9`!) {
208 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"game server {} authed",addr_num_to_ip_strcxx . . $ pvpgn/addr_num_to_ip_str(81a3ae90da26a711).(d2cs_conn_get_addrcxx . . $ pvpgn/d2cs/d2cs_conn_get_addr(efed4e5eb0be6497).(c)));
209 d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(c,conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed.);
210 d2gs_send_server_conffilecxx . . $ pvpgn/d2cs/d2gs_send_server_conffile(d952f78e288dcd17).(gs, c);
211 d2gs_send_init_infocxx . . $ pvpgn/d2cs/d2gs_send_init_info(d952f78e288dcd17).(gs, c);
212 d2gs_activecxx . . $ pvpgn/d2cs/d2gs_active(9b01a82329d01ede).(gs,c);
213 } else {
214 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game server {} failed to auth",addr_num_to_ip_strcxx . . $ pvpgn/addr_num_to_ip_str(81a3ae90da26a711).(d2cs_conn_get_addrcxx . . $ pvpgn/d2cs/d2cs_conn_get_addr(efed4e5eb0be6497).(c)));
215 /*
216 d2cs_conn_set_state(c,conn_state_destroy);
217 */
218 }
219 if ((rpacket=packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2gscxx . . $ pvpgn/packet_class_d2gs.))) {
220 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket,sizeof(t_d2cs_d2gs_authreplycxx . . $ pvpgn/t_d2cs_d2gs_authreply#));
221 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket,D2CS_D2GS_AUTHREPLYcxx . . $ `src/common/d2cs_d2gs_protocol.h:70:9`!);
222 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_authreply..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_4#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.,0);
223 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_authreply..replycxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_4#reply.,reply);
224 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c,rpacket);
225 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
226 }
227
228 return 0;
229 }
230
231 static int on_d2gs_setgsinfocxx . . $ pvpgn/d2cs/on_d2gs_setgsinfo(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
232 {
233 t_d2gscxx . . $ pvpgn/d2cs/t_d2gs# * gs;
234 t_packetcxx . . $ pvpgn/t_packet# * rpacket;
235 unsigned int maxgame, prev_maxgame;
236 unsigned int currgame, gameflag;
237
238 if (!(gs=d2gslist_find_gscxx . . $ pvpgn/d2cs/d2gslist_find_gs(a5ff5b022d63132f).(conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c)))) {
239 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game server {} not found",conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
240 return -1;
241 }
242 maxgame=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_setgsinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_setgsinfo..maxgamecxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_5#maxgame.);
243 gameflag=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_setgsinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_setgsinfo..gameflagcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_5#gameflag.);
244 prev_maxgame=d2gs_get_maxgamecxx . . $ pvpgn/d2cs/d2gs_get_maxgame(986de4a3f93bb0c3).(gs);
245 currgame = d2gs_get_gamenumcxx . . $ pvpgn/d2cs/d2gs_get_gamenum(986de4a3f93bb0c3).(gs);
246 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "change game server {} max game from {} to {} ({} current)",addr_num_to_ip_strcxx . . $ pvpgn/addr_num_to_ip_str(81a3ae90da26a711).(d2cs_conn_get_addrcxx . . $ pvpgn/d2cs/d2cs_conn_get_addr(efed4e5eb0be6497).(c)),prev_maxgame, maxgame, currgame);
247 d2gs_set_maxgamecxx . . $ pvpgn/d2cs/d2gs_set_maxgame(f014ce79ab04150b).(gs,maxgame);
248
249 if ((rpacket=packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2gscxx . . $ pvpgn/packet_class_d2gs.))) {
250 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket,sizeof(t_d2cs_d2gs_setgsinfocxx . . $ pvpgn/t_d2cs_d2gs_setgsinfo#));
251 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket,D2CS_D2GS_SETGSINFOcxx . . $ `src/common/d2cs_d2gs_protocol.h:88:9`!);
252 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setgsinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setgsinfo..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_6#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.,0);
253 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setgsinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setgsinfo..maxgamecxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_6#maxgame.,maxgame);
254 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_setgsinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_setgsinfo..gameflagcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_6#gameflag.,gameflag);
255 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c,rpacket);
256 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
257 }
258
259 gqlist_check_creategamecxx . . $ pvpgn/d2cs/gqlist_check_creategame(7864480464b09eea).(maxgame - currgame);
260 return 0;
261 }
262
263 static int on_d2gs_echoreplycxx . . $ pvpgn/d2cs/on_d2gs_echoreply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
264 {
265 if (!c || !packet)
266 return 0;
267 return 0;
268 }
269
270 static int on_d2gs_creategamereplycxx . . $ pvpgn/d2cs/on_d2gs_creategamereply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
271 {
272 t_packetcxx . . $ pvpgn/t_packet# * opacket, * rpacket;
273 t_sqcxx . . $ pvpgn/d2cs/t_sq# * sq;
274 t_connectioncxx . . $ pvpgn/d2cs/t_connection# * client;
275 t_gamecxx . . $ pvpgn/d2cs/t_game# * game;
276 int result;
277 int reply;
278 int seqno;
279 t_elem * curr;
280
281 seqno=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gscxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_1#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.);
282 if (!(sq=sqlist_find_sqcxx . . $ pvpgn/d2cs/sqlist_find_sq(e493466095b7404b).(seqno))) {
283 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"seqno {} not found",seqno);
284 return 0;
285 }
286 if (!(client=d2cs_connlist_find_connection_by_sessionnumcxx . . $ pvpgn/d2cs/d2cs_connlist_find_connection_by_sessionnum(ffc4e98cf54e05f7).(sq_get_clientidcxx . . $ pvpgn/d2cs/sq_get_clientid(b4250823e36b6ab).(sq)))) {
287 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"client {} not found",sq_get_clientidcxx . . $ pvpgn/d2cs/sq_get_clientid(b4250823e36b6ab).(sq));
288 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
289 return 0;
290 }
291 if (!(game=gamelist_find_game_by_idcxx . . $ pvpgn/d2cs/gamelist_find_game_by_id(f476a3e7e1ba51cb).(sq_get_gameidcxx . . $ pvpgn/d2cs/sq_get_gameid(b4250823e36b6ab).(sq)))) {
292 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game {} not found",sq_get_gameidcxx . . $ pvpgn/d2cs/sq_get_gameid(b4250823e36b6ab).(sq));
293 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
294 return 0;
295 }
296 if (!(opacket=sq_get_packetcxx . . $ pvpgn/d2cs/sq_get_packet(cc7363a0c7bb9fd0).(sq))) {
297 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"previous packet not found (seqno: {})",seqno);
298 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
299 return 0;
300 }
301
302 result=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_creategamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_creategamereply..resultcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_13#result.);
303 if (result==D2GS_D2CS_CREATEGAME_SUCCEEDcxx . . $ `src/common/d2cs_d2gs_protocol.h:164:9`!) {
304 game_set_d2gs_gameidcxx . . $ pvpgn/d2cs/game_set_d2gs_gameid(b1b6f5a91b93abc1).(game,bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_creategamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_creategamereply..gameidcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_13#gameid.));
305 game_set_createdcxx . . $ pvpgn/d2cs/game_set_created(b1b6f5a91b93abc1).(game,1);
306 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"game {} created on gs {}",d2cs_game_get_namecxx . . $ pvpgn/d2cs/d2cs_game_get_name(d16e89b4cf68b40f).(game),conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
307 reply=D2CS_CLIENT_CREATEGAMEREPLY_SUCCEEDcxx . . $ `src/common/d2cs_protocol.h:110:9`!;
308 } else {
309 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn.,__FUNCTION__,"failed to create game {} on gs {}",d2cs_game_get_namecxx . . $ pvpgn/d2cs/d2cs_game_get_name(d16e89b4cf68b40f).(game),conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
310 game_destroycxx . . $ pvpgn/d2cs/game_destroy(35433708d3d50b5a).(game,&curr);
311 reply=D2CS_CLIENT_CREATEGAMEREPLY_FAILEDcxx . . $ `src/common/d2cs_protocol.h:111:9`!;
312 }
313
314 if ((rpacket=packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cscxx . . $ pvpgn/packet_class_d2cs.))) {
315 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket,sizeof(t_d2cs_client_creategamereplycxx . . $ pvpgn/t_d2cs_client_creategamereply#));
316 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket,D2CS_CLIENT_CREATEGAMEREPLYcxx . . $ `src/common/d2cs_protocol.h:101:9`!);
317 bn_short_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_creategamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_creategamereply..seqnocxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_7#seqno.,
318 bn_short_get(opacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..client_d2cs_creategamereqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#client_d2cs_creategamereq..seqnocxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_6#seqno.));
319 bn_short_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_creategamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_creategamereply..gameidcxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_7#gameid.,1);
320 bn_short_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_creategamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_creategamereply..u1cxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_7#u1.,1);
321 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_creategamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_creategamereply..replycxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_7#reply.,reply);
322 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(client,rpacket);
323 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
324 }
325 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
326 return 0;
327 }
328
329 static int on_d2gs_joingamereplycxx . . $ pvpgn/d2cs/on_d2gs_joingamereply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
330 {
331 t_sqcxx . . $ pvpgn/d2cs/t_sq# * sq;
332 t_d2gscxx . . $ pvpgn/d2cs/t_d2gs# * gs;
333 t_connectioncxx . . $ pvpgn/d2cs/t_connection# * client;
334 t_gamecxx . . $ pvpgn/d2cs/t_game# * game;
335 t_packetcxx . . $ pvpgn/t_packet# * opacket, * rpacket;
336 int result;
337 int reply;
338 int seqno;
339 unsigned int gsaddr;
340 t_elem * curr;
341 unsigned short gsport;
342
343
344 seqno=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gscxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_1#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.);
345 if (!(sq=sqlist_find_sqcxx . . $ pvpgn/d2cs/sqlist_find_sq(e493466095b7404b).(seqno))) {
346 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"seqno {} not found",seqno);
347 return 0;
348 }
349 if (!(client=d2cs_connlist_find_connection_by_sessionnumcxx . . $ pvpgn/d2cs/d2cs_connlist_find_connection_by_sessionnum(ffc4e98cf54e05f7).(sq_get_clientidcxx . . $ pvpgn/d2cs/sq_get_clientid(b4250823e36b6ab).(sq)))) {
350 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"client {} not found",sq_get_clientidcxx . . $ pvpgn/d2cs/sq_get_clientid(b4250823e36b6ab).(sq));
351 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
352 return 0;
353 }
354 if (!(game=gamelist_find_game_by_idcxx . . $ pvpgn/d2cs/gamelist_find_game_by_id(f476a3e7e1ba51cb).(sq_get_gameidcxx . . $ pvpgn/d2cs/sq_get_gameid(b4250823e36b6ab).(sq)))) {
355 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game {} not found",sq_get_gameidcxx . . $ pvpgn/d2cs/sq_get_gameid(b4250823e36b6ab).(sq));
356 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
357 return 0;
358 }
359 if (!(gs=game_get_d2gscxx . . $ pvpgn/d2cs/game_get_d2gs(d8ef2cc2a93b457).(game))) {
360 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"try join game without game server set");
361 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
362 return 0;
363 }
364 if (!(opacket=sq_get_packetcxx . . $ pvpgn/d2cs/sq_get_packet(cc7363a0c7bb9fd0).(sq))) {
365 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"previous packet not found (seqno: {})",seqno);
366 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
367 return 0;
368 }
369
370 result=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_joingamereply..resultcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_15#result.);
371 switch (result) {
372 case D2GS_D2CS_JOINGAME_SUCCEEDcxx . . $ `src/common/d2cs_d2gs_protocol.h:186:9`!:
373 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"added {} to game {} on gs {}",d2cs_conn_get_charnamecxx . . $ pvpgn/d2cs/d2cs_conn_get_charname(204e3869d17161f9).(client),
374 d2cs_game_get_namecxx . . $ pvpgn/d2cs/d2cs_game_get_name(d16e89b4cf68b40f).(game),conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
375 reply=D2CS_CLIENT_JOINGAMEREPLY_SUCCEEDcxx . . $ `src/common/d2cs_protocol.h:138:9`!;
376 break;
377
378 case D2GS_D2CS_JOINGAME_GAME_FULLcxx . . $ `src/common/d2cs_d2gs_protocol.h:188:9`!:
379 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"failed to add {} to game {} on gs {} (game full)",d2cs_conn_get_charnamecxx . . $ pvpgn/d2cs/d2cs_conn_get_charname(204e3869d17161f9).(client),
380 d2cs_game_get_namecxx . . $ pvpgn/d2cs/d2cs_game_get_name(d16e89b4cf68b40f).(game),conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
381 reply=D2CS_CLIENT_JOINGAMEREPLY_GAME_FULLcxx . . $ `src/common/d2cs_protocol.h:141:9`!;
382 break;
383 default:
384 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"failed to add {} to game {} on gs {}",d2cs_conn_get_charnamecxx . . $ pvpgn/d2cs/d2cs_conn_get_charname(204e3869d17161f9).(client),
385 d2cs_game_get_namecxx . . $ pvpgn/d2cs/d2cs_game_get_name(d16e89b4cf68b40f).(game),conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c));
386 reply=D2CS_CLIENT_JOINGAMEREPLY_FAILEDcxx . . $ `src/common/d2cs_protocol.h:149:9`!;
387 }
388
389 if ((rpacket=packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cscxx . . $ pvpgn/packet_class_d2cs.))) {
390 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket,sizeof(t_d2cs_client_joingamereplycxx . . $ pvpgn/t_d2cs_client_joingamereply#));
391 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket,D2CS_CLIENT_JOINGAMEREPLYcxx . . $ `src/common/d2cs_protocol.h:127:9`!);
392 bn_short_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..seqnocxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#seqno.,
393 bn_short_get(opacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..client_d2cs_joingamereqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#client_d2cs_joingamereq..seqnocxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_8#seqno.));
394 /* specific flag for anti-cheating support */
395 /*
396 bn_short_set(&rpacket->u.d2cs_client_joingamereply.gameid,(unsigned short)game_get_d2gs_gameid(game)|0x8000);
397 */
398 bn_short_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..gameidcxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#gameid.,(unsigned short)game_get_d2gs_gameidcxx . . $ pvpgn/d2cs/game_get_d2gs_gameid(33681cfe92f0a311).(game));
399
400 bn_short_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..u1cxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#u1.,0);
401 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..replycxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#reply.,reply);
402 // if (reply == SERVER_JOINGAMEREPLY2_REPLY_OK) {
403 if (reply == D2CS_CLIENT_JOINGAMEREPLY_SUCCEEDcxx . . $ `src/common/d2cs_protocol.h:138:9`!) {
404 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..tokencxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#token.,sq_get_gametokencxx . . $ pvpgn/d2cs/sq_get_gametoken(b4250823e36b6ab).(sq));
405
406 gsaddr = d2gs_get_ipcxx . . $ pvpgn/d2cs/d2gs_get_ip(986de4a3f93bb0c3).(gs);
407 gsport = 4000;
408 trans_netcxx . . $ pvpgn/trans_net(cf0ba8ec647fd542).(d2cs_conn_get_addrcxx . . $ pvpgn/d2cs/d2cs_conn_get_addr(efed4e5eb0be6497).(client), &gsaddr, &gsport);
409
410 if(d2gs_get_ipcxx . . $ pvpgn/d2cs/d2gs_get_ip(986de4a3f93bb0c3).(gs)!=gsaddr)
411 {
412 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"translated gameserver {} -> {}",addr_num_to_ip_strcxx . . $ pvpgn/addr_num_to_ip_str(81a3ae90da26a711).(d2gs_get_ipcxx . . $ pvpgn/d2cs/d2gs_get_ip(986de4a3f93bb0c3).(gs)),addr_num_to_ip_strcxx . . $ pvpgn/addr_num_to_ip_str(81a3ae90da26a711).(gsaddr));
413 } else {
414 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"no translation required for gamserver {}",addr_num_to_ip_strcxx . . $ pvpgn/addr_num_to_ip_str(81a3ae90da26a711).(gsaddr));
415 }
416
417 bn_int_nset(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..addrcxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#addr.,gsaddr);
418
419 } else {
420 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..tokencxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#token.,0);
421 bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_joingamereplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_joingamereply..addrcxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_9#addr.,0);
422 }
423 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(client,rpacket);
424 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket);
425 }
426 sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq,&curr);
427 return 0;
428 }
429
430 static int on_d2gs_updategameinfocxx . . $ pvpgn/d2cs/on_d2gs_updategameinfo(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
431 {
432 unsigned int flag;
433 char const * charname;
434 t_gamecxx . . $ pvpgn/d2cs/t_game# * game;
435 unsigned int charclass;
436 unsigned int charlevel;
437 unsigned int d2gs_gameid;
438 unsigned int d2gs_id;
439
440 if (!(charname=packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(packet,sizeof(t_d2gs_d2cs_updategameinfocxx . . $ pvpgn/t_d2gs_d2cs_updategameinfo#),MAX_CHARNAME_LENcxx . . $ MAX_CHARNAME_LEN.))) {
441 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"got bad charname");
442 return 0;
443 }
444 d2gs_id=conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c);
445 d2gs_gameid=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_updategameinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_updategameinfo..gameidcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_16#gameid.);
446 charclass=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_updategameinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_updategameinfo..charclasscxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_16#charclass.);
447 charlevel=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_updategameinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_updategameinfo..charlevelcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_16#charlevel.);
448 flag=bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_updategameinfocxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_updategameinfo..flagcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_16#flag.);
449 if (!(game=gamelist_find_game_by_d2gs_and_idcxx . . $ pvpgn/d2cs/gamelist_find_game_by_d2gs_and_id(8574b6076fa391a1).(d2gs_id,d2gs_gameid))) {
450 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"game {} not found on gs {}",d2gs_gameid,d2gs_id);
451 return -1;
452 }
453 if (flag==D2GS_D2CS_UPDATEGAMEINFO_FLAG_ENTERcxx . . $ `src/common/d2cs_d2gs_protocol.h:201:9`!) {
454 game_add_charactercxx . . $ pvpgn/d2cs/game_add_character(c3db1e962ac9bee0).(game,charname,charclass,charlevel);
455 } else if (flag==D2GS_D2CS_UPDATEGAMEINFO_FLAG_LEAVEcxx . . $ `src/common/d2cs_d2gs_protocol.h:202:9`!) {
456 game_del_charactercxx . . $ pvpgn/d2cs/game_del_character(e30eb5f745b12d84).(game,charname);
457 } else if (flag==D2GS_D2CS_UPDATEGAMEINFO_FLAG_UPDATEcxx . . $ `src/common/d2cs_d2gs_protocol.h:200:9`!) {
458 game_add_charactercxx . . $ pvpgn/d2cs/game_add_character(c3db1e962ac9bee0).(game,charname,charclass,charlevel);
459 } else {
460 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.,__FUNCTION__,"got bad updategameinfo flag {}",flag);
461 }
462 return 0;
463 }
464
465 static int on_d2gs_closegamecxx . . $ pvpgn/d2cs/on_d2gs_closegame(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
466 {
467 t_gamecxx . . $ pvpgn/d2cs/t_game# * game;
468 t_elem * curr;
469
470 if (!(game=gamelist_find_game_by_d2gs_and_idcxx . . $ pvpgn/d2cs/gamelist_find_game_by_d2gs_and_id(8574b6076fa391a1).(conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c),
471 bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2gs_d2cs_closegamecxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2gs_d2cs_closegame..gameidcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_17#gameid.)))) {
472 return 0;
473 }
474 game_destroycxx . . $ pvpgn/d2cs/game_destroy(35433708d3d50b5a).(game, &curr);
475 return 0;
476 }
477
478 extern int handle_d2gs_packetcxx . . $ pvpgn/d2cs/handle_d2gs_packet(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet)
479 {
480 conn_process_packetcxx . . $ pvpgn/d2cs/conn_process_packet(2bc178548fb00cfb).(c,packet,d2gs_packet_handle_tablecxx . . $ pvpgn/d2cs/d2gs_packet_handle_table.,NELEMScxx . . $ `src/d2cs/setup.h:69:9`!(d2gs_packet_handle_table));
481 return 0;
482 }
483
484 extern int handle_d2gs_initcxx . . $ pvpgn/d2cs/handle_d2gs_init(2043ce9004c1cbc1).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c)
485 {
486 t_packetcxx . . $ pvpgn/t_packet# * packet;
487
488 if ((packet=packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2gscxx . . $ pvpgn/packet_class_d2gs.))) {
489 packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(packet,sizeof(t_d2cs_d2gs_authreqcxx . . $ pvpgn/t_d2cs_d2gs_authreq#));
490 packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(packet,D2CS_D2GS_AUTHREQcxx . . $ `src/common/d2cs_d2gs_protocol.h:49:9`!);
491 bn_int_set(&packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_authreqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_authreq..hcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_2#h..seqnocxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_0#seqno.,0);
492 bn_int_set(&packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_authreqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_authreq..sessionnumcxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_2#sessionnum.,d2cs_conn_get_sessionnumcxx . . $ pvpgn/d2cs/d2cs_conn_get_sessionnum(efed4e5eb0be6497).(c));
493 bn_int_set(&packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_d2gs_authreqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_d2gs_authreq..signlencxx . . $ pvpgn/$anonymous_type_dfcfbe7283f3304a_2#signlen., 0);
494 packet_append_stringcxx . . $ pvpgn/packet_append_string(41801851180b7cbb).(packet,prefs_get_realmnamecxx . . $ pvpgn/d2cs/prefs_get_realmname(33a1f659e94feb42).());
495 // packet_append_data(packet, sign, signlen);
496 conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c,packet);
497 packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(packet);
498 }
499 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.,__FUNCTION__,"sent init packet to d2gs {} (sessionnum={})",conn_get_d2gs_idcxx . . $ pvpgn/d2cs/conn_get_d2gs_id(efed4e5eb0be6497).(c),d2cs_conn_get_sessionnumcxx . . $ pvpgn/d2cs/d2cs_conn_get_sessionnum(efed4e5eb0be6497).(c));
500 return 0;
501 }
502
503 }
504
505 }