| 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_bnetd.h"cxx . . $ `<file>/src/d2cs/handle_bnetd.h`/ |
| 21 | |
| 22 | #include "common/init_protocol.h"cxx . . $ `<file>/src/common/init_protocol.h`/ |
| 23 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 24 | /* |
| 25 | #include "common/d2cs_bnetd_protocol.h" |
| 26 | #include "common/d2cs_protocol.h" |
| 27 | #include "common/packet.h" |
| 28 | #include "connection.h" |
| 29 | */ |
| 30 | #include "version.h"cxx . . $ `<file>/src/d2cs/version.h`/ |
| 31 | #include "prefs.h"cxx . . $ `<file>/src/d2cs/prefs.h`/ |
| 32 | #include "serverqueue.h"cxx . . $ `<file>/src/d2cs/serverqueue.h`/ |
| 33 | #include "game.h"cxx . . $ `<file>/src/d2cs/game.h`/ |
| 34 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 35 | |
| 36 | namespace pvpgncxx . . $ pvpgn/ |
| 37 | { |
| 38 | |
| 39 | namespace d2cscxx . . $ pvpgn/d2cs/ |
| 40 | { |
| 41 | |
| 42 | DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_bnetd_accountloginreply) |
| 43 | DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_bnetd_charloginreply) |
| 44 | DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_bnetd_authreq) |
| 45 | DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_bnetd_authreply) |
| 46 | DECLARE_PACKET_HANDLERcxx . . $ `src/d2cs/setup.h:68:9`!(on_bnetd_gameinforeq) |
| 47 | |
| 48 | static t_packet_handle_tablecxx . . $ pvpgn/d2cs/t_packet_handle_table# bnetd_packet_handle_tablecxx . . $ pvpgn/d2cs/bnetd_packet_handle_table.[] = { |
| 49 | /* 0x00 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 50 | /* 0x01 */{ sizeof(t_bnetd_d2cs_authreqcxx . . $ pvpgn/t_bnetd_d2cs_authreq#), conn_state_connectedcxx . . $ pvpgn/d2cs/conn_state_connected., on_bnetd_authreqcxx . . $ pvpgn/d2cs/on_bnetd_authreq(5937b18ec8c7bf53). }, |
| 51 | /* 0x02 */{ sizeof(t_bnetd_d2cs_authreplycxx . . $ pvpgn/t_bnetd_d2cs_authreply#), conn_state_connectedcxx . . $ pvpgn/d2cs/conn_state_connected., on_bnetd_authreplycxx . . $ pvpgn/d2cs/on_bnetd_authreply(5937b18ec8c7bf53). }, |
| 52 | /* 0x03 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 53 | /* 0x04 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 54 | /* 0x05 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 55 | /* 0x06 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 56 | /* 0x07 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 57 | /* 0x08 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 58 | /* 0x09 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 59 | /* 0x0a */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 60 | /* 0x0b */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 61 | /* 0x0c */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 62 | /* 0x0d */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 63 | /* 0x03 */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 64 | /* 0x0f */{ 0, conn_state_nonecxx . . $ pvpgn/d2cs/conn_state_none., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 65 | /* 0x10 */{ sizeof(t_bnetd_d2cs_accountloginreplycxx . . $ pvpgn/t_bnetd_d2cs_accountloginreply#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_bnetd_accountloginreplycxx . . $ pvpgn/d2cs/on_bnetd_accountloginreply(5937b18ec8c7bf53). }, |
| 66 | /* 0x11 */{ sizeof(t_bnetd_d2cs_charloginreplycxx . . $ pvpgn/t_bnetd_d2cs_charloginreply#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_bnetd_charloginreplycxx . . $ pvpgn/d2cs/on_bnetd_charloginreply(5937b18ec8c7bf53). }, |
| 67 | /* 0x12 */{ sizeof(t_bnetd_d2cs_gameinforeqcxx . . $ pvpgn/t_bnetd_d2cs_gameinforeq#), conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed., on_bnetd_gameinforeqcxx . . $ pvpgn/d2cs/on_bnetd_gameinforeq(5937b18ec8c7bf53). } |
| 68 | }; |
| 69 | |
| 70 | extern int handle_bnetd_packetcxx . . $ pvpgn/d2cs/handle_bnetd_packet(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet) |
| 71 | { |
| 72 | conn_process_packetcxx . . $ pvpgn/d2cs/conn_process_packet(2bc178548fb00cfb).(c, packet, bnetd_packet_handle_tablecxx . . $ pvpgn/d2cs/bnetd_packet_handle_table., NELEMScxx . . $ `src/d2cs/setup.h:69:9`!(bnetd_packet_handle_table)); |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | extern int handle_bnetd_initcxx . . $ pvpgn/d2cs/handle_bnetd_init(2043ce9004c1cbc1).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c) |
| 77 | { |
| 78 | t_packetcxx . . $ pvpgn/t_packet# * packet; |
| 79 | |
| 80 | packet = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_initcxx . . $ pvpgn/packet_class_init.); |
| 81 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(packet, sizeof(t_client_initconncxx . . $ pvpgn/t_client_initconn#)); |
| 82 | bn_byte_setcxx . . $ pvpgn/bn_byte_set(9656657e14223459).(&packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..client_initconncxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#client_initconn..cclasscxx . . $ pvpgn/$anonymous_type_7cca3803bac3bad7_0#cclass., CLIENT_INITCONN_CLASS_D2CS_BNETDcxx . . $ `src/common/init_protocol.h:66:9`!); |
| 83 | conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c, packet); |
| 84 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(packet); |
| 85 | d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(c, conn_state_connectedcxx . . $ pvpgn/d2cs/conn_state_connected.); |
| 86 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "sent init class packet to bnetd"); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | static int on_bnetd_authreqcxx . . $ pvpgn/d2cs/on_bnetd_authreq(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet) |
| 91 | { |
| 92 | t_packetcxx . . $ pvpgn/t_packet# * rpacket; |
| 93 | unsigned int sessionnum; |
| 94 | |
| 95 | sessionnum = bn_int_getcxx . . $ pvpgn/bn_int_get(ca1608e2c87725e2).(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..bnetd_d2cs_authreqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#bnetd_d2cs_authreq..sessionnumcxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_2#sessionnum.); |
| 96 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "received bnetd sessionnum {}", sessionnum); |
| 97 | if ((rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cs_bnetdcxx . . $ pvpgn/packet_class_d2cs_bnetd.))) { |
| 98 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket, sizeof(t_d2cs_bnetd_authreplycxx . . $ pvpgn/t_d2cs_bnetd_authreply#)); |
| 99 | packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket, D2CS_BNETD_AUTHREPLYcxx . . $ `src/common/d2cs_bnetd_protocol.h:45:9`!); |
| 100 | bn_int_setcxx . . $ pvpgn/bn_int_set(e97e500db3ec3c79).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_bnetd_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_bnetd_authreply..hcxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_3#h..seqnocxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_0#seqno., 1); |
| 101 | bn_int_setcxx . . $ pvpgn/bn_int_set(e97e500db3ec3c79).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_bnetd_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_bnetd_authreply..versioncxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_3#version., D2CS_VERSION_NUMBERcxx . . $ `src/d2cs/version.h:21:9`!); |
| 102 | packet_append_stringcxx . . $ pvpgn/packet_append_string(41801851180b7cbb).(rpacket, prefs_get_realmnamecxx . . $ pvpgn/d2cs/prefs_get_realmname(33a1f659e94feb42).()); |
| 103 | conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c, rpacket); |
| 104 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 105 | } |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | static int on_bnetd_authreplycxx . . $ pvpgn/d2cs/on_bnetd_authreply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet) |
| 110 | { |
| 111 | unsigned int reply; |
| 112 | |
| 113 | reply = bn_int_getcxx . . $ pvpgn/bn_int_get(ca1608e2c87725e2).(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..bnetd_d2cs_authreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#bnetd_d2cs_authreply..replycxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_4#reply.); |
| 114 | if (reply == BNETD_D2CS_AUTHREPLY_SUCCEEDcxx . . $ `src/common/d2cs_bnetd_protocol.h:59:9`!) { |
| 115 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "authed by bnetd"); |
| 116 | d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(c, conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed.); |
| 117 | } |
| 118 | else { |
| 119 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "failed to auth by bnetd (error={})", reply); |
| 120 | d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(c, conn_state_destroycxx . . $ pvpgn/d2cs/conn_state_destroy.); |
| 121 | } |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | static int on_bnetd_accountloginreplycxx . . $ pvpgn/d2cs/on_bnetd_accountloginreply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet) |
| 126 | { |
| 127 | unsigned int seqno; |
| 128 | t_sqcxx . . $ pvpgn/d2cs/t_sq# * sq; |
| 129 | t_packetcxx . . $ pvpgn/t_packet# * opacket, *rpacket; |
| 130 | t_connectioncxx . . $ pvpgn/d2cs/t_connection# * client; |
| 131 | int result, reply; |
| 132 | char const * account; |
| 133 | t_elemcxx . . $ pvpgn/t_elem# * elem; |
| 134 | |
| 135 | if (!packet || !c) |
| 136 | return -1; |
| 137 | |
| 138 | seqno = bn_int_getcxx . . $ pvpgn/bn_int_get(ca1608e2c87725e2).(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_bnetdcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_bnetd..hcxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_1#h..seqnocxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_0#seqno.); |
| 139 | if (!(sq = sqlist_find_sqcxx . . $ pvpgn/d2cs/sqlist_find_sq(e493466095b7404b).(seqno))) { |
| 140 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "seqno {} not found", seqno); |
| 141 | return -1; |
| 142 | } |
| 143 | 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)))) { |
| 144 | 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)); |
| 145 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 146 | return -1; |
| 147 | } |
| 148 | if (!(opacket = sq_get_packetcxx . . $ pvpgn/d2cs/sq_get_packet(cc7363a0c7bb9fd0).(sq))) { |
| 149 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "previous packet missing (seqno: {})", seqno); |
| 150 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 151 | return -1; |
| 152 | } |
| 153 | result = bn_int_getcxx . . $ pvpgn/bn_int_get(ca1608e2c87725e2).(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..bnetd_d2cs_accountloginreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#bnetd_d2cs_accountloginreply..replycxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_6#reply.); |
| 154 | if (result == BNETD_D2CS_CHARLOGINREPLY_SUCCEEDcxx . . $ `src/common/d2cs_bnetd_protocol.h:97:9`!) { |
| 155 | reply = D2CS_CLIENT_LOGINREPLY_SUCCEEDcxx . . $ `src/common/d2cs_protocol.h:62:9`!; |
| 156 | account = packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(opacket, sizeof(t_client_d2cs_loginreqcxx . . $ pvpgn/t_client_d2cs_loginreq#), MAX_CHARNAME_LENcxx . . $ MAX_CHARNAME_LEN.); |
| 157 | d2cs_conn_set_accountcxx . . $ pvpgn/d2cs/d2cs_conn_set_account(127e6fcf538cb408).(client, account); |
| 158 | d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(client, conn_state_authedcxx . . $ pvpgn/d2cs/conn_state_authed.); |
| 159 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "account {} authed", account); |
| 160 | } |
| 161 | else { |
| 162 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn., __FUNCTION__, "client {} login request was rejected by bnetd", sq_get_clientidcxx . . $ pvpgn/d2cs/sq_get_clientid(b4250823e36b6ab).(sq)); |
| 163 | reply = D2CS_CLIENT_LOGINREPLY_BADPASScxx . . $ `src/common/d2cs_protocol.h:63:9`!; |
| 164 | } |
| 165 | if ((rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cscxx . . $ pvpgn/packet_class_d2cs.))) { |
| 166 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket, sizeof(t_d2cs_client_loginreplycxx . . $ pvpgn/t_d2cs_client_loginreply#)); |
| 167 | packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket, D2CS_CLIENT_LOGINREPLYcxx . . $ `src/common/d2cs_protocol.h:56:9`!); |
| 168 | bn_int_setcxx . . $ pvpgn/bn_int_set(e97e500db3ec3c79).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_loginreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_loginreply..replycxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_3#reply., reply); |
| 169 | conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(client, rpacket); |
| 170 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 171 | } |
| 172 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static int on_bnetd_charloginreplycxx . . $ pvpgn/d2cs/on_bnetd_charloginreply(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet) |
| 177 | { |
| 178 | unsigned int seqno; |
| 179 | t_sqcxx . . $ pvpgn/d2cs/t_sq# * sq; |
| 180 | t_connectioncxx . . $ pvpgn/d2cs/t_connection# * client; |
| 181 | t_packetcxx . . $ pvpgn/t_packet# * opacket, *rpacket; |
| 182 | int result, reply, type; |
| 183 | char const * charname; |
| 184 | t_elemcxx . . $ pvpgn/t_elem# * elem; |
| 185 | |
| 186 | if (!packet || !c) |
| 187 | return -1; |
| 188 | |
| 189 | seqno = bn_int_getcxx . . $ pvpgn/bn_int_get(ca1608e2c87725e2).(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_bnetdcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_bnetd..hcxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_1#h..seqnocxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_0#seqno.); |
| 190 | if (!(sq = sqlist_find_sqcxx . . $ pvpgn/d2cs/sqlist_find_sq(e493466095b7404b).(seqno))) { |
| 191 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "seqno {} not found", seqno); |
| 192 | return -1; |
| 193 | } |
| 194 | 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)))) { |
| 195 | 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)); |
| 196 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 197 | return -1; |
| 198 | } |
| 199 | if (!(opacket = sq_get_packetcxx . . $ pvpgn/d2cs/sq_get_packet(cc7363a0c7bb9fd0).(sq))) { |
| 200 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "previous packet missing (seqno: {})", seqno); |
| 201 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 202 | return -1; |
| 203 | } |
| 204 | type = packet_get_typecxx . . $ pvpgn/packet_get_type(e4ac9e2b4744cb4b).(opacket); |
| 205 | result = bn_int_getcxx . . $ pvpgn/bn_int_get(ca1608e2c87725e2).(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..bnetd_d2cs_charloginreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#bnetd_d2cs_charloginreply..replycxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_8#reply.); |
| 206 | if (type == CLIENT_D2CS_CREATECHARREQcxx . . $ `src/common/d2cs_protocol.h:65:9`!) { |
| 207 | charname = packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(opacket, sizeof(t_client_d2cs_createcharreqcxx . . $ pvpgn/t_client_d2cs_createcharreq#), MAX_CHARNAME_LENcxx . . $ MAX_CHARNAME_LEN.); |
| 208 | if (result == BNETD_D2CS_CHARLOGINREPLY_SUCCEEDcxx . . $ `src/common/d2cs_bnetd_protocol.h:97:9`!) { |
| 209 | if (conn_check_multilogincxx . . $ pvpgn/d2cs/conn_check_multilogin(636e7872f5a2b03c).(client, charname) < 0) { |
| 210 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "character {} is already logged in", charname); |
| 211 | reply = D2CS_CLIENT_CHARLOGINREPLY_FAILEDcxx . . $ `src/common/d2cs_protocol.h:211:9`!; |
| 212 | } |
| 213 | else { |
| 214 | reply = D2CS_CLIENT_CREATECHARREPLY_SUCCEEDcxx . . $ `src/common/d2cs_protocol.h:81:9`!; |
| 215 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "character {} authed", charname); |
| 216 | d2cs_conn_set_charnamecxx . . $ pvpgn/d2cs/d2cs_conn_set_charname(127e6fcf538cb408).(client, charname); |
| 217 | d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(client, conn_state_char_authedcxx . . $ pvpgn/d2cs/conn_state_char_authed.); |
| 218 | } |
| 219 | } |
| 220 | else { |
| 221 | reply = D2CS_CLIENT_CREATECHARREPLY_FAILEDcxx . . $ `src/common/d2cs_protocol.h:82:9`!; |
| 222 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "failed to auth character {}", charname); |
| 223 | } |
| 224 | if ((rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cscxx . . $ pvpgn/packet_class_d2cs.))) { |
| 225 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket, sizeof(t_d2cs_client_createcharreplycxx . . $ pvpgn/t_d2cs_client_createcharreply#)); |
| 226 | packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket, D2CS_CLIENT_CREATECHARREPLYcxx . . $ `src/common/d2cs_protocol.h:75:9`!); |
| 227 | bn_int_setcxx . . $ pvpgn/bn_int_set(e97e500db3ec3c79).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_createcharreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_createcharreply..replycxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_5#reply., reply); |
| 228 | conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(client, rpacket); |
| 229 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 230 | } |
| 231 | } |
| 232 | else if (type == CLIENT_D2CS_CHARLOGINREQcxx . . $ `src/common/d2cs_protocol.h:197:9`!) { |
| 233 | charname = packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(opacket, sizeof(t_client_d2cs_charloginreqcxx . . $ pvpgn/t_client_d2cs_charloginreq#), MAX_CHARNAME_LENcxx . . $ MAX_CHARNAME_LEN.); |
| 234 | if (result == BNETD_D2CS_CHARLOGINREPLY_SUCCEEDcxx . . $ `src/common/d2cs_bnetd_protocol.h:97:9`!) { |
| 235 | if (conn_check_multilogincxx . . $ pvpgn/d2cs/conn_check_multilogin(636e7872f5a2b03c).(client, charname) < 0) { |
| 236 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "character {} is already logged in", charname); |
| 237 | reply = D2CS_CLIENT_CHARLOGINREPLY_FAILEDcxx . . $ `src/common/d2cs_protocol.h:211:9`!; |
| 238 | } |
| 239 | else { |
| 240 | reply = D2CS_CLIENT_CHARLOGINREPLY_SUCCEEDcxx . . $ `src/common/d2cs_protocol.h:210:9`!; |
| 241 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "character {} authed", charname); |
| 242 | d2cs_conn_set_charnamecxx . . $ pvpgn/d2cs/d2cs_conn_set_charname(127e6fcf538cb408).(client, charname); |
| 243 | d2cs_conn_set_statecxx . . $ pvpgn/d2cs/d2cs_conn_set_state(1e8a554d8269318).(client, conn_state_char_authedcxx . . $ pvpgn/d2cs/conn_state_char_authed.); |
| 244 | } |
| 245 | } |
| 246 | else { |
| 247 | reply = D2CS_CLIENT_CHARLOGINREPLY_FAILEDcxx . . $ `src/common/d2cs_protocol.h:211:9`!; |
| 248 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "failed to auth character {}", charname); |
| 249 | } |
| 250 | if ((rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cscxx . . $ pvpgn/packet_class_d2cs.))) { |
| 251 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket, sizeof(t_d2cs_client_charloginreplycxx . . $ pvpgn/t_d2cs_client_charloginreply#)); |
| 252 | packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket, D2CS_CLIENT_CHARLOGINREPLYcxx . . $ `src/common/d2cs_protocol.h:204:9`!); |
| 253 | bn_int_setcxx . . $ pvpgn/bn_int_set(e97e500db3ec3c79).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_client_charloginreplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_client_charloginreply..replycxx . . $ pvpgn/$anonymous_type_b07e82e2fff2dccd_15#reply., reply); |
| 254 | conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(client, rpacket); |
| 255 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 256 | } |
| 257 | } |
| 258 | else { |
| 259 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got bad packet type {}", type); |
| 260 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 261 | return -1; |
| 262 | } |
| 263 | sq_destroycxx . . $ pvpgn/d2cs/sq_destroy(211ea308ebfa0f0e).(sq, &elem); |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | int on_bnetd_gameinforeqcxx . . $ pvpgn/d2cs/on_bnetd_gameinforeq(5937b18ec8c7bf53).(t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c, t_packetcxx . . $ pvpgn/t_packet# * packet) |
| 268 | { |
| 269 | t_packetcxx . . $ pvpgn/t_packet# * rpacket; |
| 270 | t_gamecxx . . $ pvpgn/d2cs/t_game# * game; |
| 271 | |
| 272 | char const * gamename; |
| 273 | |
| 274 | if (!(c)) { |
| 275 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL connection"); |
| 276 | return -1; |
| 277 | } |
| 278 | |
| 279 | if (!(gamename = packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(packet, sizeof(t_bnetd_d2cs_gameinforeqcxx . . $ pvpgn/t_bnetd_d2cs_gameinforeq#), MAX_GAMENAME_LENcxx . . $ MAX_GAMENAME_LEN.))) |
| 280 | { |
| 281 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing or too long gamename"); |
| 282 | return -1; |
| 283 | } |
| 284 | |
| 285 | if (!(game = d2cs_gamelist_find_gamecxx . . $ pvpgn/d2cs/d2cs_gamelist_find_game(6da516f6176bdca0).(gamename))) |
| 286 | { |
| 287 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "request for unknown game \"{}\"", gamename); |
| 288 | return -1; |
| 289 | } |
| 290 | |
| 291 | if ((rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_d2cs_bnetdcxx . . $ pvpgn/packet_class_d2cs_bnetd.))) { |
| 292 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket, sizeof(t_d2cs_bnetd_gameinforeplycxx . . $ pvpgn/t_d2cs_bnetd_gameinforeply#)); |
| 293 | packet_set_typecxx . . $ pvpgn/packet_set_type(a12d8724e4c46208).(rpacket, D2CS_BNETD_GAMEINFOREPLYcxx . . $ `src/common/d2cs_bnetd_protocol.h:107:9`!); |
| 294 | bn_int_setcxx . . $ pvpgn/bn_int_set(e97e500db3ec3c79).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_bnetd_gameinforeplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_bnetd_gameinforeply..hcxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_10#h..seqnocxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_0#seqno., 0); |
| 295 | packet_append_stringcxx . . $ pvpgn/packet_append_string(41801851180b7cbb).(rpacket, gamename); |
| 296 | |
| 297 | bn_byte_setcxx . . $ pvpgn/bn_byte_set(9656657e14223459).(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..d2cs_bnetd_gameinforeplycxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#d2cs_bnetd_gameinforeply..difficultycxx . . $ pvpgn/$anonymous_type_b0a976df95fb5a1_10#difficulty., game_get_gameflag_difficultycxx . . $ pvpgn/d2cs/game_get_gameflag_difficulty(33681cfe92f0a311).(game)); |
| 298 | |
| 299 | conn_push_outqueuecxx . . $ pvpgn/d2cs/conn_push_outqueue(5937b18ec8c7bf53).(c, rpacket); |
| 300 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 301 | } |
| 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | } |
| 306 | |
| 307 | } |