| 1 | /* |
| 2 | * (C) 2004 Olaf Freyer ([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 | #define TEAM_INTERNAL_ACCESScxx . . $ `src/bnetd/team.cpp:19:9`! |
| 20 | #include "team.h"cxx . . $ `<file>/src/bnetd/team.h`/ |
| 21 | |
| 22 | #include <cstring> |
| 23 | #include <cassert> |
| 24 | |
| 25 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 26 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 27 | #include "common/bnet_protocol.h"cxx . . $ `<file>/src/common/bnet_protocol.h`/ |
| 28 | |
| 29 | #include "account.h"cxx . . $ `<file>/src/bnetd/account.h`/ |
| 30 | #include "account_wrap.h"cxx . . $ `<file>/src/bnetd/account_wrap.h`/ |
| 31 | #include "storage.h"cxx . . $ `<file>/src/bnetd/storage.h`/ |
| 32 | #include "ladder.h"cxx . . $ `<file>/src/bnetd/ladder.h`/ |
| 33 | #include "server.h"cxx . . $ `<file>/src/bnetd/server.h`/ |
| 34 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 35 | |
| 36 | namespace pvpgncxx . . $ pvpgn/ |
| 37 | { |
| 38 | |
| 39 | namespace bnetdcxx . . $ pvpgn/bnetd/ |
| 40 | { |
| 41 | |
| 42 | static t_listcxx . . $ pvpgn/t_list# *teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 43 | unsigned max_teamidcxx . . $ pvpgn/bnetd/max_teamid. = 0; |
| 44 | int teamlist_add_teamcxx . . $ pvpgn/bnetd/teamlist_add_team(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team); |
| 45 | |
| 46 | /* callback function for storage use */ |
| 47 | |
| 48 | static int _cb_load_teamscxx . . $ pvpgn/bnetd/_cb_load_teams(dedf1e9b1c614a07).(void *team) |
| 49 | { |
| 50 | if (teamlist_add_teamcxx . . $ pvpgn/bnetd/teamlist_add_team(bfd9c5af88c00d10).((t_teamcxx . . $ pvpgn/bnetd/t_team#*)team) < 0) |
| 51 | { |
| 52 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "failed to add team to teamlist"); |
| 53 | return -1; |
| 54 | } |
| 55 | |
| 56 | if (((t_teamcxx . . $ pvpgn/bnetd/t_team# *)team)->teamidcxx . . $ pvpgn/bnetd/team#teamid. > max_teamidcxx . . $ pvpgn/bnetd/max_teamid.) |
| 57 | max_teamidcxx . . $ pvpgn/bnetd/max_teamid. = ((t_teamcxx . . $ pvpgn/bnetd/t_team# *)team)->teamidcxx . . $ pvpgn/bnetd/team#teamid.; |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | |
| 62 | int teamlist_add_teamcxx . . $ pvpgn/bnetd/teamlist_add_team(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 63 | { |
| 64 | int i; |
| 65 | |
| 66 | if (!(team)) |
| 67 | { |
| 68 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL team"); |
| 69 | return -1; |
| 70 | } |
| 71 | |
| 72 | for (i = 0; i < team->sizecxx . . $ pvpgn/bnetd/team#size.; i++) |
| 73 | { |
| 74 | if (!(team->memberscxx . . $ pvpgn/bnetd/team#members.[i] = accountlist_find_account_by_uidcxx . . $ pvpgn/bnetd/accountlist_find_account_by_uid(c4505e327c9ccd36).(team->teammemberscxx . . $ pvpgn/bnetd/team#teammembers.[i]))) |
| 75 | { |
| 76 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "at least one non-existant member (id {}) in team {} - discarding team", team->teammemberscxx . . $ pvpgn/bnetd/team#teammembers.[i], team->teamidcxx . . $ pvpgn/bnetd/team#teamid.); |
| 77 | //FIXME: delete team file now??? |
| 78 | return team->teamidcxx . . $ pvpgn/bnetd/team#teamid.; //we return teamid even though we have an error, we don't want unintentional overwriting |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | for (i = 0; i < team->sizecxx . . $ pvpgn/bnetd/team#size.; i++) |
| 83 | account_add_teamcxx . . $ pvpgn/bnetd/account_add_team(7568b6ec01afeb15).(team->memberscxx . . $ pvpgn/bnetd/team#members.[i], team); |
| 84 | |
| 85 | if (!(team->teamidcxx . . $ pvpgn/bnetd/team#teamid.)) |
| 86 | team->teamidcxx . . $ pvpgn/bnetd/team#teamid. = ++max_teamidcxx . . $ pvpgn/bnetd/max_teamid.; |
| 87 | |
| 88 | list_append_data(teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head., team); |
| 89 | |
| 90 | return team->teamidcxx . . $ pvpgn/bnetd/team#teamid.; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | int teamlist_loadcxx . . $ pvpgn/bnetd/teamlist_load(b126dc7c1de90089).(void) |
| 95 | { |
| 96 | // make sure to unload previous teamlist before loading again |
| 97 | if (teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head.) |
| 98 | teamlist_unloadcxx . . $ pvpgn/bnetd/teamlist_unload(b126dc7c1de90089).(); |
| 99 | |
| 100 | teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head. = list_create(); |
| 101 | |
| 102 | storagecxx . . $ pvpgn/bnetd/storage.->load_teamscxx . . $ pvpgn/bnetd/$anonymous_type_c7c18ce0294b47dd_0#load_teams.(_cb_load_teamscxx . . $ pvpgn/bnetd/_cb_load_teams(dedf1e9b1c614a07).); |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | int teamlist_unloadcxx . . $ pvpgn/bnetd/teamlist_unload(b126dc7c1de90089).(void) |
| 109 | { |
| 110 | t_elemcxx . . $ pvpgn/t_elem# *curr; |
| 111 | t_teamcxx . . $ pvpgn/bnetd/t_team# *team; |
| 112 | |
| 113 | if ((teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head.)) |
| 114 | { |
| 115 | LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(teamlist_head, curr) |
| 116 | { |
| 117 | if (!(team = (t_teamcxx . . $ pvpgn/bnetd/t_team#*)elem_get_data(curr))) |
| 118 | { |
| 119 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list"); |
| 120 | continue; |
| 121 | } |
| 122 | xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)team); |
| 123 | list_remove_elem(teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head., &curr); |
| 124 | } |
| 125 | |
| 126 | if (list_destroy(teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head.) < 0) |
| 127 | return -1; |
| 128 | |
| 129 | teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 130 | } |
| 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | int teams_destroycxx . . $ pvpgn/bnetd/teams_destroy(20db0232078327de).(t_listcxx . . $ pvpgn/t_list# * teams) |
| 136 | { |
| 137 | t_elemcxx . . $ pvpgn/t_elem# *curr; |
| 138 | t_teamcxx . . $ pvpgn/bnetd/t_team# *team; |
| 139 | |
| 140 | if ((teams)) |
| 141 | { |
| 142 | LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(teams, curr) |
| 143 | { |
| 144 | if (!(team = (t_teamcxx . . $ pvpgn/bnetd/t_team#*)elem_get_data(curr))) |
| 145 | { |
| 146 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list"); |
| 147 | continue; |
| 148 | } |
| 149 | list_remove_elem(teams, &curr); |
| 150 | } |
| 151 | |
| 152 | if (list_destroy(teams) < 0) |
| 153 | return -1; |
| 154 | } |
| 155 | teams = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | t_teamcxx . . $ pvpgn/bnetd/t_team#* create_teamcxx . . $ pvpgn/bnetd/create_team(42f9c07c658dd58a).(t_accountcxx . . $ pvpgn/bnetd/t_account# **accounts, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 161 | { |
| 162 | t_teamcxx . . $ pvpgn/bnetd/t_team# * team; |
| 163 | int i; |
| 164 | unsigned char size; |
| 165 | |
| 166 | team = (t_teamcxx . . $ pvpgn/bnetd/t_team#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_team)); |
| 167 | stdcxx . . $ std/::memset(team, 0, sizeof(t_teamcxx . . $ pvpgn/bnetd/t_team#)); |
| 168 | size = 0; |
| 169 | |
| 170 | for (i = 0; i < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!; i++) |
| 171 | { |
| 172 | team->memberscxx . . $ pvpgn/bnetd/team#members.[i] = accounts[i]; |
| 173 | if ((accounts[i])) |
| 174 | { |
| 175 | team->teammemberscxx . . $ pvpgn/bnetd/team#teammembers.[i] = account_get_uidcxx . . $ `src/bnetd/account.h:91:9`!(accounts[i]); |
| 176 | size++; |
| 177 | } |
| 178 | } |
| 179 | team->sizecxx . . $ pvpgn/bnetd/team#size. = size; |
| 180 | team->clienttagcxx . . $ pvpgn/bnetd/team#clienttag. = clienttag; |
| 181 | |
| 182 | _cb_load_teamscxx . . $ pvpgn/bnetd/_cb_load_teams(dedf1e9b1c614a07).(team); |
| 183 | |
| 184 | storagecxx . . $ pvpgn/bnetd/storage.->write_teamcxx . . $ pvpgn/bnetd/$anonymous_type_c7c18ce0294b47dd_0#write_team.(team); |
| 185 | |
| 186 | return team; |
| 187 | } |
| 188 | |
| 189 | void dispose_teamcxx . . $ pvpgn/bnetd/dispose_team(5f5c25e2d1d679ca).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 190 | { |
| 191 | if ((team)) |
| 192 | xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)team); |
| 193 | team = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 194 | } |
| 195 | |
| 196 | t_teamcxx . . $ pvpgn/bnetd/t_team# * teamlist_find_team_by_accountscxx . . $ pvpgn/bnetd/teamlist_find_team_by_accounts(42f9c07c658dd58a).(t_accountcxx . . $ pvpgn/bnetd/t_account# **accounts, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 197 | { |
| 198 | return _list_find_team_by_accountscxx . . $ pvpgn/bnetd/_list_find_team_by_accounts(9996263dfee4e414).(accounts, clienttag, teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head.); |
| 199 | } |
| 200 | |
| 201 | t_teamcxx . . $ pvpgn/bnetd/t_team# * _list_find_team_by_accountscxx . . $ pvpgn/bnetd/_list_find_team_by_accounts(9996263dfee4e414).(t_accountcxx . . $ pvpgn/bnetd/t_account# **accounts, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, t_listcxx . . $ pvpgn/t_list# * teamlist) |
| 202 | { |
| 203 | t_elemcxx . . $ pvpgn/t_elem# *curr; |
| 204 | t_teamcxx . . $ pvpgn/bnetd/t_team# *cteam; |
| 205 | int i, j, found; |
| 206 | unsigned char size; |
| 207 | |
| 208 | assertcxx . . $ `/usr/include/assert.h:102:11`!(accounts); |
| 209 | |
| 210 | found = 0; |
| 211 | |
| 212 | if ((teamlist)) |
| 213 | { |
| 214 | LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(teamlist, curr) |
| 215 | { |
| 216 | if (!(cteam = (t_teamcxx . . $ pvpgn/bnetd/t_team#*)elem_get_data(curr))) |
| 217 | { |
| 218 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list"); |
| 219 | continue; |
| 220 | } |
| 221 | size = 0; |
| 222 | |
| 223 | for (i = 0; i < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!; i++) |
| 224 | { |
| 225 | if (!(accounts[i])) |
| 226 | break; |
| 227 | |
| 228 | size++; |
| 229 | found = 0; |
| 230 | for (j = 0; j < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!; j++) |
| 231 | { |
| 232 | if ((accounts[i] == cteam->memberscxx . . $ pvpgn/bnetd/team#members.[j])) |
| 233 | { |
| 234 | found = 1; |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | if (!(found)) break; |
| 239 | } |
| 240 | if ((found) && (clienttag == cteam->clienttagcxx . . $ pvpgn/bnetd/team#clienttag.) && (size == cteam->sizecxx . . $ pvpgn/bnetd/team#size.)) |
| 241 | return cteam; |
| 242 | } |
| 243 | |
| 244 | } |
| 245 | |
| 246 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 247 | } |
| 248 | |
| 249 | t_teamcxx . . $ pvpgn/bnetd/t_team# * teamlist_find_team_by_uidscxx . . $ pvpgn/bnetd/teamlist_find_team_by_uids(6fe6f0524b3a64d4).(unsigned int * uids, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 250 | { |
| 251 | return _list_find_team_by_uidscxx . . $ pvpgn/bnetd/_list_find_team_by_uids(8fb7560a318b2f55).(uids, clienttag, teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head.); |
| 252 | } |
| 253 | |
| 254 | t_teamcxx . . $ pvpgn/bnetd/t_team# * _list_find_team_by_uidscxx . . $ pvpgn/bnetd/_list_find_team_by_uids(8fb7560a318b2f55).(unsigned int * uids, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, t_listcxx . . $ pvpgn/t_list# * teamlist) |
| 255 | { |
| 256 | t_elemcxx . . $ pvpgn/t_elem# *curr; |
| 257 | t_teamcxx . . $ pvpgn/bnetd/t_team# *cteam; |
| 258 | int i, j, found; |
| 259 | unsigned char size; |
| 260 | |
| 261 | assertcxx . . $ `/usr/include/assert.h:102:11`!(uids); |
| 262 | |
| 263 | found = 0; |
| 264 | |
| 265 | if ((teamlist)) |
| 266 | { |
| 267 | LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(teamlist, curr) |
| 268 | { |
| 269 | if (!(cteam = (t_teamcxx . . $ pvpgn/bnetd/t_team#*)elem_get_data(curr))) |
| 270 | { |
| 271 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list"); |
| 272 | continue; |
| 273 | } |
| 274 | size = 0; |
| 275 | |
| 276 | for (i = 0; i < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!; i++) |
| 277 | { |
| 278 | if (!(uids[i])) |
| 279 | break; |
| 280 | |
| 281 | found = 0; |
| 282 | for (j = 0; j < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!; j++) |
| 283 | { |
| 284 | if ((uids[i] == cteam->teammemberscxx . . $ pvpgn/bnetd/team#teammembers.[j])) |
| 285 | { |
| 286 | found = 1; |
| 287 | break; |
| 288 | } |
| 289 | } |
| 290 | if (!(found)) break; |
| 291 | } |
| 292 | if ((found) && (clienttag == cteam->clienttagcxx . . $ pvpgn/bnetd/team#clienttag.) && (size == cteam->sizecxx . . $ pvpgn/bnetd/team#size.)) |
| 293 | return cteam; |
| 294 | } |
| 295 | |
| 296 | } |
| 297 | |
| 298 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 299 | } |
| 300 | |
| 301 | t_teamcxx . . $ pvpgn/bnetd/t_team# * teamlist_find_team_by_teamidcxx . . $ pvpgn/bnetd/teamlist_find_team_by_teamid(9f379b9caf96d76a).(unsigned int teamid) |
| 302 | { |
| 303 | return _list_find_team_by_teamidcxx . . $ pvpgn/bnetd/_list_find_team_by_teamid(924765dc6b5f1897).(teamid, teamlist_headcxx . . $ pvpgn/bnetd/teamlist_head.); |
| 304 | } |
| 305 | |
| 306 | t_teamcxx . . $ pvpgn/bnetd/t_team#* _list_find_team_by_teamidcxx . . $ pvpgn/bnetd/_list_find_team_by_teamid(924765dc6b5f1897).(unsigned int teamid, t_listcxx . . $ pvpgn/t_list# * teamlist) |
| 307 | { |
| 308 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 309 | t_teamcxx . . $ pvpgn/bnetd/t_team# * cteam; |
| 310 | |
| 311 | assertcxx . . $ `/usr/include/assert.h:102:11`!(teamid); |
| 312 | |
| 313 | if ((teamlist)) |
| 314 | { |
| 315 | LIST_TRAVERSEcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/list.h:94:9`!(teamlist, curr) |
| 316 | { |
| 317 | if (!(cteam = (t_teamcxx . . $ pvpgn/bnetd/t_team#*)elem_get_data(curr))) |
| 318 | { |
| 319 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "found NULL entry in list"); |
| 320 | continue; |
| 321 | } |
| 322 | |
| 323 | if ((cteam->teamidcxx . . $ pvpgn/bnetd/team#teamid. == teamid)) |
| 324 | return cteam; |
| 325 | |
| 326 | } |
| 327 | } |
| 328 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 329 | } |
| 330 | |
| 331 | unsigned int team_get_teamidcxx . . $ pvpgn/bnetd/team_get_teamid(3d0b4ed7d37a7d35).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 332 | { |
| 333 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 334 | |
| 335 | return team->teamidcxx . . $ pvpgn/bnetd/team#teamid.; |
| 336 | } |
| 337 | |
| 338 | t_accountcxx . . $ pvpgn/bnetd/t_account# * team_get_membercxx . . $ pvpgn/bnetd/team_get_member(98f1b445a9d30dd9).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team, int count) |
| 339 | { |
| 340 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 341 | assertcxx . . $ `/usr/include/assert.h:102:11`!(count >= 0); |
| 342 | assertcxx . . $ `/usr/include/assert.h:102:11`!(count < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!); |
| 343 | |
| 344 | return team->memberscxx . . $ pvpgn/bnetd/team#members.[count]; |
| 345 | } |
| 346 | |
| 347 | unsigned int team_get_memberuidcxx . . $ pvpgn/bnetd/team_get_memberuid(ddee88b4298fccdd).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team, int count) |
| 348 | { |
| 349 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 350 | assertcxx . . $ `/usr/include/assert.h:102:11`!(count >= 0); |
| 351 | assertcxx . . $ `/usr/include/assert.h:102:11`!(count < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!); |
| 352 | |
| 353 | return team->teammemberscxx . . $ pvpgn/bnetd/team#teammembers.[count]; |
| 354 | } |
| 355 | |
| 356 | |
| 357 | t_clienttagcxx . . $ pvpgn/t_clienttag# team_get_clienttagcxx . . $ pvpgn/bnetd/team_get_clienttag(3d0b4ed7d37a7d35).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 358 | { |
| 359 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 360 | |
| 361 | return team->clienttagcxx . . $ pvpgn/bnetd/team#clienttag.; |
| 362 | } |
| 363 | |
| 364 | unsigned char team_get_sizecxx . . $ pvpgn/bnetd/team_get_size(7a9350cb6bb6d81e).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 365 | { |
| 366 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 367 | |
| 368 | return team->sizecxx . . $ pvpgn/bnetd/team#size.; |
| 369 | } |
| 370 | |
| 371 | int team_get_winscxx . . $ pvpgn/bnetd/team_get_wins(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 372 | { |
| 373 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 374 | |
| 375 | return team->winscxx . . $ pvpgn/bnetd/team#wins.; |
| 376 | } |
| 377 | |
| 378 | int team_get_lossescxx . . $ pvpgn/bnetd/team_get_losses(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 379 | { |
| 380 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 381 | |
| 382 | return team->lossescxx . . $ pvpgn/bnetd/team#losses.; |
| 383 | } |
| 384 | |
| 385 | int team_get_xpcxx . . $ pvpgn/bnetd/team_get_xp(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 386 | { |
| 387 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 388 | |
| 389 | return team->xpcxx . . $ pvpgn/bnetd/team#xp.; |
| 390 | } |
| 391 | |
| 392 | int team_get_levelcxx . . $ pvpgn/bnetd/team_get_level(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 393 | { |
| 394 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 395 | |
| 396 | return team->levelcxx . . $ pvpgn/bnetd/team#level.; |
| 397 | } |
| 398 | |
| 399 | int team_set_rankcxx . . $ pvpgn/bnetd/team_set_rank(635b0a799ca96413).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team, unsigned int rank) |
| 400 | { |
| 401 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 402 | team->rankcxx . . $ pvpgn/bnetd/team#rank. = rank; |
| 403 | return 0; |
| 404 | } |
| 405 | |
| 406 | int team_get_rankcxx . . $ pvpgn/bnetd/team_get_rank(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 407 | { |
| 408 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 409 | |
| 410 | return team->rankcxx . . $ pvpgn/bnetd/team#rank.; |
| 411 | } |
| 412 | |
| 413 | time_tcxx . . $ time_t# team_get_lastgamecxx . . $ pvpgn/bnetd/team_get_lastgame(44a6e6e074cf5534).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 414 | { |
| 415 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 416 | |
| 417 | return team->lastgamecxx . . $ pvpgn/bnetd/team#lastgame.; |
| 418 | } |
| 419 | |
| 420 | int team_inc_winscxx . . $ pvpgn/bnetd/team_inc_wins(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 421 | { |
| 422 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 423 | |
| 424 | team->winscxx . . $ pvpgn/bnetd/team#wins.++; |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | int team_inc_lossescxx . . $ pvpgn/bnetd/team_inc_losses(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 429 | { |
| 430 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 431 | |
| 432 | team->lossescxx . . $ pvpgn/bnetd/team#losses.++; |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | int team_update_lastgamecxx . . $ pvpgn/bnetd/team_update_lastgame(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 437 | { |
| 438 | assertcxx . . $ `/usr/include/assert.h:102:11`!(team); |
| 439 | |
| 440 | team->lastgamecxx . . $ pvpgn/bnetd/team#lastgame. = nowcxx . . $ pvpgn/bnetd/now.; |
| 441 | return 0; |
| 442 | } |
| 443 | |
| 444 | extern int team_update_xpcxx . . $ pvpgn/bnetd/team_update_xp(18f40426c69d38c1).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team, int gameresult, unsigned int opponlevel, int * xp_diff) |
| 445 | { |
| 446 | int xp; |
| 447 | int mylevel; |
| 448 | int xpdiff = 0, placeholder; |
| 449 | |
| 450 | xp = team->xpcxx . . $ pvpgn/bnetd/team#xp.; //get current xp |
| 451 | if (xp < 0) { |
| 452 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got negative XP"); |
| 453 | return -1; |
| 454 | } |
| 455 | |
| 456 | mylevel = team->levelcxx . . $ pvpgn/bnetd/team#level.; //get teams level |
| 457 | if (mylevel > W3_XPCALC_MAXLEVELcxx . . $ `src/bnetd/ladder.h:30:9`!) { |
| 458 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got invalid level: {}", mylevel); |
| 459 | return -1; |
| 460 | } |
| 461 | |
| 462 | if (mylevel <= 0) //if level is 0 then set it to 1 |
| 463 | mylevel = 1; |
| 464 | |
| 465 | if (opponlevel < 1) opponlevel = 1; |
| 466 | |
| 467 | switch (gameresult) |
| 468 | { |
| 469 | case W3_GAMERESULT_WINcxx . . $ `src/common/bnet_protocol.h:227:9`!: |
| 470 | ladder_war3_xpdiffcxx . . $ pvpgn/bnetd/ladder_war3_xpdiff(61837cdd6f1cbbd0).(mylevel, opponlevel, &xpdiff, &placeholder); break; |
| 471 | case W3_GAMERESULT_LOSScxx . . $ `src/common/bnet_protocol.h:226:9`!: |
| 472 | ladder_war3_xpdiffcxx . . $ pvpgn/bnetd/ladder_war3_xpdiff(61837cdd6f1cbbd0).(opponlevel, mylevel, &placeholder, &xpdiff); break; |
| 473 | default: |
| 474 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got invalid game result: {}", gameresult); |
| 475 | return -1; |
| 476 | } |
| 477 | |
| 478 | *xp_diff = xpdiff; |
| 479 | xp += xpdiff; |
| 480 | if (xp < 0) xp = 0; |
| 481 | |
| 482 | team->xpcxx . . $ pvpgn/bnetd/team#xp. = xp; |
| 483 | |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | int team_update_levelcxx . . $ pvpgn/bnetd/team_update_level(bfd9c5af88c00d10).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team) |
| 488 | { |
| 489 | int xp, mylevel; |
| 490 | |
| 491 | xp = team->xpcxx . . $ pvpgn/bnetd/team#xp.; |
| 492 | if (xp < 0) xp = 0; |
| 493 | |
| 494 | mylevel = team->levelcxx . . $ pvpgn/bnetd/team#level.; |
| 495 | if (mylevel < 1) mylevel = 1; |
| 496 | |
| 497 | if (mylevel > W3_XPCALC_MAXLEVELcxx . . $ `src/bnetd/ladder.h:30:9`!) { |
| 498 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., "account_set_sololevel", "got invalid level: {}", mylevel); |
| 499 | return -1; |
| 500 | } |
| 501 | |
| 502 | mylevel = ladder_war3_updatelevelcxx . . $ pvpgn/bnetd/ladder_war3_updatelevel(1cb9ad283036edc7).(mylevel, xp); |
| 503 | |
| 504 | team->levelcxx . . $ pvpgn/bnetd/team#level. = mylevel; |
| 505 | |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | int team_set_saveladderstatscxx . . $ pvpgn/bnetd/team_set_saveladderstats(2629837aadad176e).(t_teamcxx . . $ pvpgn/bnetd/t_team# * team, unsigned int gametype, int result, unsigned int opponlevel, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 510 | { |
| 511 | unsigned int intrace; |
| 512 | int xpdiff; |
| 513 | int i; |
| 514 | t_accountcxx . . $ pvpgn/bnetd/t_account# * account; |
| 515 | |
| 516 | if (!team) |
| 517 | { |
| 518 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL team"); |
| 519 | return -1; |
| 520 | } |
| 521 | |
| 522 | //added for better tracking down of problems with gameresults |
| 523 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace., __FUNCTION__, "parsing game result for team: {} result: {}", team_get_teamidcxx . . $ pvpgn/bnetd/team_get_teamid(3d0b4ed7d37a7d35).(team), (result == W3_GAMERESULT_WINcxx . . $ `src/common/bnet_protocol.h:227:9`!) ? "WIN" : "LOSS"); |
| 524 | |
| 525 | |
| 526 | if (result == W3_GAMERESULT_WINcxx . . $ `src/common/bnet_protocol.h:227:9`!) |
| 527 | { |
| 528 | team_inc_winscxx . . $ pvpgn/bnetd/team_inc_wins(bfd9c5af88c00d10).(team); |
| 529 | } |
| 530 | if (result == W3_GAMERESULT_LOSScxx . . $ `src/common/bnet_protocol.h:226:9`!) |
| 531 | { |
| 532 | team_inc_lossescxx . . $ pvpgn/bnetd/team_inc_losses(bfd9c5af88c00d10).(team); |
| 533 | } |
| 534 | team_update_xpcxx . . $ pvpgn/bnetd/team_update_xp(18f40426c69d38c1).(team, result, opponlevel, &xpdiff); |
| 535 | team_update_levelcxx . . $ pvpgn/bnetd/team_update_level(bfd9c5af88c00d10).(team); |
| 536 | team_update_lastgamecxx . . $ pvpgn/bnetd/team_update_lastgame(bfd9c5af88c00d10).(team); |
| 537 | |
| 538 | LadderListcxx . . $ pvpgn/bnetd/LadderList#* ladderList = ladderscxx . . $ pvpgn/bnetd/ladders..getLadderListcxx . . $ pvpgn/bnetd/Ladders#getLadderList(2c0c64fbd1351270).(LadderKeycxx . . $ pvpgn/bnetd/LadderKey#LadderKey(f0da15e05d48c065).(ladder_id_ateamcxx . . $ pvpgn/bnetd/ladder_id_ateam., clienttag, ladder_sort_defaultcxx . . $ pvpgn/bnetd/ladder_sort_default., ladder_time_defaultcxx . . $ pvpgn/bnetd/ladder_time_default.)); |
| 539 | LadderReferencedObjectcxx . . $ pvpgn/bnetd/LadderReferencedObject# referencecxx . . $ pvpgn/bnetd/LadderReferencedObject#LadderReferencedObject(5f5c25e2d1d679ca).(team); |
| 540 | ladderList->updateEntrycxx . . $ pvpgn/bnetd/LadderList#updateEntry(f0ac5109e0f18056).(team->teamidcxx . . $ pvpgn/bnetd/team#teamid., team->levelcxx . . $ pvpgn/bnetd/team#level., team->xpcxx . . $ pvpgn/bnetd/team#xp., 0, reference); |
| 541 | |
| 542 | storagecxx . . $ pvpgn/bnetd/storage.->write_teamcxx . . $ pvpgn/bnetd/$anonymous_type_c7c18ce0294b47dd_0#write_team.(team); |
| 543 | |
| 544 | |
| 545 | // now set currentatteam to 0 so we only get one report for each team |
| 546 | for (i = 0; i < MAX_TEAMSIZEcxx . . $ `src/bnetd/team.h:36:9`!; i++) |
| 547 | { |
| 548 | if ((account = team->memberscxx . . $ pvpgn/bnetd/team#members.[i])) |
| 549 | { |
| 550 | intrace = account_get_w3pgracecxx . . $ pvpgn/bnetd/account_get_w3pgrace(43f7d0f5a7c4b307).(account, clienttag); |
| 551 | if (result == W3_GAMERESULT_WINcxx . . $ `src/common/bnet_protocol.h:227:9`!) |
| 552 | { |
| 553 | account_inc_racewinscxx . . $ pvpgn/bnetd/account_inc_racewins(d1a42c0f2badce10).(account, intrace, clienttag); |
| 554 | } |
| 555 | if (result == W3_GAMERESULT_LOSScxx . . $ `src/common/bnet_protocol.h:226:9`!) |
| 556 | { |
| 557 | account_inc_racelossescxx . . $ pvpgn/bnetd/account_inc_racelosses(d1a42c0f2badce10).(account, intrace, clienttag); |
| 558 | } |
| 559 | account_set_currentatteamcxx . . $ pvpgn/bnetd/account_set_currentatteam(43f7d0f5a7c4b307).(account, 0); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | return 0; |
| 564 | } |
| 565 | |
| 566 | } |
| 567 | |
| 568 | } |