Debian Codegraph @

src/d2cs/gamequeue.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 "gamequeue.h"cxx . . $ `<file>/src/d2cs/gamequeue.h`/
21
22 #include <cstring>
23
24 #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/
25 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
26 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
27 #include "connection.h"cxx . . $ `<file>/src/d2cs/connection.h`/
28 #include "handle_d2cs.h"cxx . . $ `<file>/src/d2cs/handle_d2cs.h`/
29 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
30
31 namespace pvpgncxx . . $ pvpgn/
32 {
33
34 namespace d2cscxx . . $ pvpgn/d2cs/
35 {
36
37 static t_listcxx . . $ pvpgn/t_list# * gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
38 static unsigned int gqlist_seqnocxx . . $ pvpgn/d2cs/gqlist_seqno. = 0;
39
40 extern t_listcxx . . $ pvpgn/t_list# * gqlistcxx . . $ pvpgn/d2cs/gqlist(7a6cb11de248e2c9).(void)
41 {
42 return gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head.;
43 }
44
45 extern int gqlist_createcxx . . $ pvpgn/d2cs/gqlist_create(b126dc7c1de90089).(void)
46 {
47 gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head. = list_createcxx . . $ pvpgn/list_create(7a6cb11de248e2c9).();
48 return 0;
49 }
50
51 extern int gqlist_destroycxx . . $ pvpgn/d2cs/gqlist_destroy(b126dc7c1de90089).(void)
52 {
53 t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq;
54
55 BEGIN_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:26:9`!(gqlist_head, gq, t_gq)
56 {
57 gq_destroycxx . . $ pvpgn/d2cs/gq_destroy(cf9f34ccc49a2ace).(gq, (t_elemcxx . . $ pvpgn/t_elem# **)curr_elem_);
58 }
59 END_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:32:9`!()
60
61 if (list_destroycxx . . $ pvpgn/list_destroy(20db0232078327de).(gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head.) < 0) {
62 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "error destroy game queue list");
63 return -1;
64 }
65 gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
66 return 0;
67 }
68
69 extern t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq_createcxx . . $ pvpgn/d2cs/gq_create(ef599294f3a56c4e).(unsigned int clientid, t_packetcxx . . $ pvpgn/t_packet# * packet, char const * gamename)
70 {
71 t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq;
72
73 gq = (t_gqcxx . . $ pvpgn/d2cs/t_gq#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_gq));
74 gq->seqnocxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#seqno. = ++gqlist_seqnocxx . . $ pvpgn/d2cs/gqlist_seqno.;
75 gq->clientidcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#clientid. = clientid;
76 gq->packetcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#packet. = packet;
77 stdcxx . . $ std/::strncpy(gq->gamenamecxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#gamename., gamename, MAX_GAMENAME_LENcxx . . $ MAX_GAMENAME_LEN.);
78 if (packet) packet_add_refcxx . . $ pvpgn/packet_add_ref(671b48e8886379c2).(packet);
79 list_append_datacxx . . $ pvpgn/list_append_data(4e1348bd294d996f).(gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head., gq);
80 return gq;
81 }
82
83 extern int gq_destroycxx . . $ pvpgn/d2cs/gq_destroy(cf9f34ccc49a2ace).(t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq, t_elemcxx . . $ pvpgn/t_elem# ** elem)
84 {
85 ASSERTcxx . . $ `src/d2cs/setup.h:67:9`!(gq, -1);
86 if (list_remove_datacxx . . $ pvpgn/list_remove_data(9d29d8ce7cabbadf).(gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head., gq, elem) < 0) {
87 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "error remove game queue from list");
88 return -1;
89 }
90 if (gq->packetcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#packet.) packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(gq->packetcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#packet.);
91 xfreecxx . . $ `src/common/xalloc.h:51:9`!(gq);
92 return 0;
93 }
94
95 extern unsigned int gq_get_clientidcxx . . $ pvpgn/d2cs/gq_get_clientid(c188010fd52a7d9e).(t_gqcxx . . $ pvpgn/d2cs/t_gq# const * gq)
96 {
97 ASSERTcxx . . $ `src/d2cs/setup.h:67:9`!(gq, 0);
98 return gq->clientidcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#clientid.;
99 }
100
101 extern int gqlist_check_creategamecxx . . $ pvpgn/d2cs/gqlist_check_creategame(7864480464b09eea).(int number)
102 {
103 t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c;
104 t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq;
105 int i = 0;
106
107 if (number <= 0) return -1;
108
109 BEGIN_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:26:9`!(gqlist_head, gq, t_gq)
110 {
111 c = d2cs_connlist_find_connection_by_sessionnumcxx . . $ pvpgn/d2cs/d2cs_connlist_find_connection_by_sessionnum(ffc4e98cf54e05f7).(gq->clientidcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#clientid.);
112 if (!c) {
113 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "client {} not found (gamename: {})", gq->clientidcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#clientid., gq->gamenamecxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#gamename.);
114 gq_destroycxx . . $ pvpgn/d2cs/gq_destroy(cf9f34ccc49a2ace).(gq, &curr_elem_);
115 continue;
116 }
117 else if (!conn_get_gamequeuecxx . . $ pvpgn/d2cs/conn_get_gamequeue(21f4c4cb9db64b4d).(c)) {
118 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL game queue for client {}", d2cs_conn_get_accountcxx . . $ pvpgn/d2cs/d2cs_conn_get_account(204e3869d17161f9).(c));
119 gq_destroycxx . . $ pvpgn/d2cs/gq_destroy(cf9f34ccc49a2ace).(gq, &curr_elem_);
120 continue;
121 }
122 else {
123 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "try create game {} for account {}", gq->gamenamecxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#gamename., d2cs_conn_get_accountcxx . . $ pvpgn/d2cs/d2cs_conn_get_account(204e3869d17161f9).(c));
124 d2cs_handle_client_creategamecxx . . $ pvpgn/d2cs/d2cs_handle_client_creategame(5937b18ec8c7bf53).(c, gq->packetcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#packet.);
125 conn_set_gamequeuecxx . . $ pvpgn/d2cs/conn_set_gamequeue(bd9afd294a72d45a).(c, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
126 gq_destroycxx . . $ pvpgn/d2cs/gq_destroy(cf9f34ccc49a2ace).(gq, &curr_elem_);
127 i++;
128 if (i >= number) break;
129 }
130 }
131 END_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:32:9`!()
132 return 0;
133 }
134
135 extern int gqlist_update_all_clientscxx . . $ pvpgn/d2cs/gqlist_update_all_clients(b126dc7c1de90089).(void)
136 {
137 t_connectioncxx . . $ pvpgn/d2cs/t_connection# * c;
138 t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq;
139 unsigned int n;
140
141 n = 0;
142 BEGIN_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:26:9`!(gqlist_head, gq, t_gq)
143 {
144 c = d2cs_connlist_find_connection_by_sessionnumcxx . . $ pvpgn/d2cs/d2cs_connlist_find_connection_by_sessionnum(ffc4e98cf54e05f7).(gq->clientidcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#clientid.);
145 if (!c) {
146 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "client {} not found (gamename: {})", gq->clientidcxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#clientid., gq->gamenamecxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#gamename.);
147 gq_destroycxx . . $ pvpgn/d2cs/gq_destroy(cf9f34ccc49a2ace).(gq, &curr_elem_);
148 continue;
149 }
150 else {
151 n++;
152 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "update client {} position to {}", d2cs_conn_get_accountcxx . . $ pvpgn/d2cs/d2cs_conn_get_account(204e3869d17161f9).(c), n);
153 d2cs_send_client_creategamewaitcxx . . $ pvpgn/d2cs/d2cs_send_client_creategamewait(2fb9731f9a7a8931).(c, n);
154 }
155 }
156 END_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:32:9`!()
157 if (n) eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "total {} game queues", n);
158 return 0;
159 }
160
161 extern unsigned int gqlist_get_gq_positioncxx . . $ pvpgn/d2cs/gqlist_get_gq_position(4f7e797736adbb74).(t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq)
162 {
163 t_gqcxx . . $ pvpgn/d2cs/t_gq# * tmp;
164 unsigned int pos;
165
166 pos = 0;
167 BEGIN_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:26:9`!(gqlist_head, tmp, t_gq)
168 {
169 pos++;
170 if (tmp == gq) return pos;
171 }
172 END_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:32:9`!()
173 return 0;
174 }
175
176 extern unsigned int gqlist_get_lengthcxx . . $ pvpgn/d2cs/gqlist_get_length(db52760e79bf9054).(void)
177 {
178 return list_get_lengthcxx . . $ pvpgn/list_get_length(ff288adc7992d0f0).(gqlist_headcxx . . $ pvpgn/d2cs/gqlist_head.);
179 }
180
181 extern t_gqcxx . . $ pvpgn/d2cs/t_gq# * gqlist_find_gamecxx . . $ pvpgn/d2cs/gqlist_find_game(cb98c57ab88fe94e).(char const * gamename)
182 {
183 t_gqcxx . . $ pvpgn/d2cs/t_gq# * gq;
184
185 BEGIN_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:26:9`!(gqlist_head, gq, t_gq)
186 {
187 if (!strcasecmp(gq->gamenamecxx . . $ pvpgn/d2cs/$anonymous_type_3c029f150a21829a_0#gamename., gamename)) return gq;
188 }
189 END_LIST_TRAVERSE_DATAcxx . . $ `src/d2cs/setup.h:32:9`!()
190 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
191 }
192
193 }
194
195 }