| 1 | /* |
| 2 | * Copyright (C) 2014 HarpyWar ([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 | |
| 20 | #include <algorithm> |
| 21 | #include <cctype> |
| 22 | #include <cstdio> |
| 23 | #include <cerrno> |
| 24 | #include <cstring> |
| 25 | #include <ctime> |
| 26 | #include <cstdlib> |
| 27 | #include <sstream> |
| 28 | #include <vector> |
| 29 | #include <string.h> |
| 30 | |
| 31 | #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/ |
| 32 | |
| 33 | #include "common/token.h"cxx . . $ `<file>/src/common/token.h`/ |
| 34 | |
| 35 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 36 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 37 | #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/ |
| 38 | #include "common/xstring.h"cxx . . $ `<file>/src/common/xstring.h`/ |
| 39 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 40 | #include "common/tag.h"cxx . . $ `<file>/src/common/tag.h`/ |
| 41 | |
| 42 | #include "account.h"cxx . . $ `<file>/src/bnetd/account.h`/ |
| 43 | #include "connection.h"cxx . . $ `<file>/src/bnetd/connection.h`/ |
| 44 | #include "icons.h"cxx . . $ `<file>/src/bnetd/icons.h`/ |
| 45 | #include "account_wrap.h"cxx . . $ `<file>/src/bnetd/account_wrap.h`/ |
| 46 | |
| 47 | #include "message.h"cxx . . $ `<file>/src/bnetd/message.h`/ |
| 48 | #include "helpfile.h"cxx . . $ `<file>/src/bnetd/helpfile.h`/ |
| 49 | #include "channel.h"cxx . . $ `<file>/src/bnetd/channel.h`/ |
| 50 | #include "command.h"cxx . . $ `<file>/src/bnetd/command.h`/ |
| 51 | #include "i18n.h"cxx . . $ `<file>/src/bnetd/i18n.h`/ |
| 52 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 53 | |
| 54 | namespace pvpgncxx . . $ pvpgn/ |
| 55 | { |
| 56 | |
| 57 | namespace bnetdcxx . . $ pvpgn/bnetd/ |
| 58 | { |
| 59 | |
| 60 | static t_listcxx . . $ pvpgn/t_list# * icon_headcxx . . $ pvpgn/bnetd/icon_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 61 | /* use prefs_get_custom_icons() for this option */ |
| 62 | static int enable_custom_iconscxx . . $ pvpgn/bnetd/enable_custom_icons. = 0; |
| 63 | /* command groups for master users */ |
| 64 | static int master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. = 0; |
| 65 | #define MASTER_COMMANDGROUPS_DEFAULTcxx . . $ `src/bnetd/icons.cpp:65:11`! 8; /* default group flags if master_commandgroups is undefined */ |
| 66 | |
| 67 | static int skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(char *buff); |
| 68 | static t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * _read_optioncxx . . $ pvpgn/bnetd/_read_option(e61207b9f1e42b20).(char *str, unsigned lineno); |
| 69 | static char * _find_attr_keycxx . . $ pvpgn/bnetd/_find_attr_key(7a9722d75b371431).(char * clienttag); |
| 70 | |
| 71 | |
| 72 | |
| 73 | /* Set usericon (command) */ |
| 74 | extern int handle_icon_commandcxx . . $ pvpgn/bnetd/handle_icon_command(2e9022cda97b266d).(t_connection * c, char const *text) |
| 75 | { |
| 76 | t_accountcxx . . $ pvpgn/bnetd/t_account# * account; |
| 77 | t_connection * user_c; |
| 78 | char const * channel_name; |
| 79 | char const * subcommand, *username, *iconname; |
| 80 | char const *usericon, *iconalias, *iconcode; |
| 81 | t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag; |
| 82 | stdcxx . . $ std/::stringcxx . . $ std/string# output_icons = ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 83 | int count = 1; // 1 icon in stash ("default" icon) |
| 84 | bool is_selected = false; |
| 85 | |
| 86 | stdcxx . . $ std/::stringcxx . . $ std/string# msgtempcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 87 | |
| 88 | if (!(conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c))) { |
| 89 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "This command can only be used inside a channel.")); |
| 90 | return -1; |
| 91 | } |
| 92 | else { |
| 93 | channel_name = channel_get_namecxx . . $ pvpgn/bnetd/channel_get_name(7800017c14723985).(conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c)); |
| 94 | } |
| 95 | |
| 96 | // get current clienttag |
| 97 | clienttag = conn_get_clienttagcxx . . $ pvpgn/bnetd/conn_get_clienttag(8bd2285a65940781).(c); |
| 98 | if (!clienttag || clienttag == CLIENTTAG_BNCHATBOT_UINTcxx . . $ `src/common/tag.h:85:9`!) |
| 99 | { |
| 100 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "This command can only be used from the game.")); |
| 101 | return -1; |
| 102 | } |
| 103 | |
| 104 | |
| 105 | // split command args |
| 106 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> args = split_commandcxx . . $ pvpgn/bnetd/split_command(36641c1b5e9c088b).(text, 3); |
| 107 | |
| 108 | if (!((master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. & account_get_command_groupscxx . . $ pvpgn/bnetd/account_get_command_groups(c7ab9369555c44b8).(conn_get_accountcxx . . $ pvpgn/bnetd/conn_get_account(8df8b24b7c17a7f3).(c))))) |
| 109 | { |
| 110 | /* A) Simple command syntax for users */ |
| 111 | |
| 112 | iconname = args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // icon code |
| 113 | |
| 114 | account = conn_get_accountcxx . . $ pvpgn/bnetd/conn_get_account(8df8b24b7c17a7f3).(c); |
| 115 | |
| 116 | // get current user icon |
| 117 | if (usericon = account_get_user_iconcxx . . $ pvpgn/bnetd/account_get_user_icon(771ec84f6146e718).(account, clienttag)) |
| 118 | usericon = strreversecxx . . $ pvpgn/strreverse(7a9722d75b371431).(xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(usericon)); |
| 119 | |
| 120 | bool is_found = false; |
| 121 | // get user stash |
| 122 | if (char const * iconstash = account_get_user_iconstashcxx . . $ pvpgn/bnetd/account_get_user_iconstash(771ec84f6146e718).(account, clienttag)) |
| 123 | { |
| 124 | stdcxx . . $ std/::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(iconstash); |
| 125 | stdcxx . . $ std/::istringstreamcxx . . $ std/istringstream# isscxx . . $ std/__cxx11/basic_istringstream#basic_istringstream(d3c8ea0e6521074c).(s); |
| 126 | do |
| 127 | { |
| 128 | stdcxx . . $ std/::stringcxx . . $ std/string# _iconcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 129 | iss >>cxx . . $ std/`operator>>`(567ac654e2f44b5d). _icon; |
| 130 | if (_icon.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) continue; |
| 131 | |
| 132 | // output icon_alias instead of icon_code |
| 133 | if (iconalias = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), true)) |
| 134 | _icon =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). stdcxx . . $ std/::stringcxx . . $ std/string#(iconalias); |
| 135 | |
| 136 | if (!(iconcode = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()))) |
| 137 | iconcode = iconalias = _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // icon was added earlier to user and then removed from server stash |
| 138 | |
| 139 | |
| 140 | // set selected icon in brackets |
| 141 | if (usericon && strcasecmp(usericon, iconcode) == 0) |
| 142 | { |
| 143 | _icon =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). "[" +cxx . . $ std/operator+(42c652dfebe55ad7). _icon +cxx . . $ std/operator+(900ec9581c410ad9). "]"; |
| 144 | is_selected = true; |
| 145 | } |
| 146 | |
| 147 | if (!output_icons.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 148 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ", "; |
| 149 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). _icon; |
| 150 | |
| 151 | // if iconname parameter passed then find it in user stash |
| 152 | if (iconname[0] != '\0') |
| 153 | { |
| 154 | if (strcasecmp(iconname, iconalias) == 0 || strcasecmp(iconname, iconcode) == 0) |
| 155 | is_found = true; |
| 156 | } |
| 157 | |
| 158 | count++; |
| 159 | } while (iss); |
| 160 | } |
| 161 | |
| 162 | if (iconname[0] != '\0') |
| 163 | { |
| 164 | // unset value |
| 165 | if (strcasecmp(iconname, "default") == 0) |
| 166 | { |
| 167 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Set default icon."); |
| 168 | usericon = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 169 | } |
| 170 | // set usericon (reversed) |
| 171 | else |
| 172 | { |
| 173 | // if icon not found in server stash |
| 174 | if (!(iconcode = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, iconname))) |
| 175 | { |
| 176 | // set icon code from args |
| 177 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].begincxx . . $ std/__cxx11/basic_string#begin(417acd00ce8503f4).(), args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].endcxx . . $ std/__cxx11/basic_string#end(417acd00ce8503f4).(), args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].begincxx . . $ std/__cxx11/basic_string#begin(417acd00ce8503f4).(), ::toupper); // to upper |
| 178 | iconcode = args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); |
| 179 | } |
| 180 | if (!is_found || strlen(iconcode) != 4) |
| 181 | { |
| 182 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Bad icon.")); |
| 183 | return -1; |
| 184 | } |
| 185 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Set new icon is succeed."); |
| 186 | usericon = strreversecxx . . $ pvpgn/strreverse(7a9722d75b371431).((char*)iconcode); |
| 187 | } |
| 188 | account_set_user_iconcxx . . $ pvpgn/bnetd/account_set_user_icon(571eb5b9fcb96c29).(account, clienttag, usericon); |
| 189 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 190 | |
| 191 | // if user online then force him to rejoin channel |
| 192 | if (c) |
| 193 | { |
| 194 | conn_update_w3_playerinfocxx . . $ pvpgn/bnetd/conn_update_w3_playerinfo(c4dfbc2386fe4fc3).(c); |
| 195 | channel_rejoincxx . . $ pvpgn/bnetd/channel_rejoin(c4dfbc2386fe4fc3).(c); |
| 196 | } |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | // display icon list in user stash |
| 201 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "You have {} icons in stash:", count); |
| 202 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 203 | |
| 204 | output_icons =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). ((is_selected || usericon) ? "default" : "[default]") +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::stringcxx . . $ std/string#((count > 1) ? ", " : "") +cxx . . $ std/operator+(db5dc2ea912c6495). output_icons; |
| 205 | |
| 206 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). " " +cxx . . $ std/operator+(42c652dfebe55ad7). output_icons; |
| 207 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* B) Complex command syntax for operator and admins */ |
| 213 | |
| 214 | if (args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 215 | { |
| 216 | describe_commandcxx . . $ pvpgn/bnetd/describe_command(2e9022cda97b266d).(c, args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 217 | return -1; |
| 218 | } |
| 219 | subcommand = args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // sub command |
| 220 | username = args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).2].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // username |
| 221 | iconname = args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).3].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // icon alias or code |
| 222 | |
| 223 | // display icons from the server stash |
| 224 | // subcommand = list |
| 225 | if (subcommand[0] == 'l' && username[0] == '\0') |
| 226 | { |
| 227 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Available icons in server stash:")); |
| 228 | stdcxx . . $ std/::stringcxx . . $ std/string# output_icons = customicons_stash_get_listcxx . . $ pvpgn/bnetd/customicons_stash_get_list(84506afe9362c9ca).(clienttag, true); |
| 229 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). " " +cxx . . $ std/operator+(42c652dfebe55ad7). output_icons; |
| 230 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | // find user account |
| 236 | if (!(account = accountlist_find_accountcxx . . $ pvpgn/bnetd/accountlist_find_account(db6f5ebdea1fa12b).(username))) |
| 237 | { |
| 238 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Invalid user.")); |
| 239 | return -1; |
| 240 | } |
| 241 | user_c = account_get_conncxx . . $ pvpgn/bnetd/account_get_conn(831fe2ed2f0bd703).(account); |
| 242 | |
| 243 | |
| 244 | switch (safe_tolowercxx . . $ `src/common/xstring.h:41:10`!(subcommand[0])) |
| 245 | { |
| 246 | // set |
| 247 | case 's': |
| 248 | if (iconname[0] == '\0') |
| 249 | { |
| 250 | describe_commandcxx . . $ pvpgn/bnetd/describe_command(2e9022cda97b266d).(c, args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 251 | return -1; |
| 252 | } |
| 253 | |
| 254 | // unset value |
| 255 | if (strcasecmp(iconname, "default") == 0) |
| 256 | { |
| 257 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Set default icon for {}", account_get_namecxx . . $ `src/bnetd/account.h:115:10`!(account)); |
| 258 | usericon = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 259 | } |
| 260 | // set usericon (reversed) |
| 261 | else |
| 262 | { |
| 263 | // find icon in server stash |
| 264 | if (!(iconcode = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, iconname))) |
| 265 | { |
| 266 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "That icon doesn't exist in server stash.")); |
| 267 | return -1; |
| 268 | } |
| 269 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Set new icon is succeed for {}", account_get_namecxx . . $ `src/bnetd/account.h:115:10`!(account)); |
| 270 | usericon = strreversecxx . . $ pvpgn/strreverse(7a9722d75b371431).((char*)iconcode); |
| 271 | } |
| 272 | account_set_user_iconcxx . . $ pvpgn/bnetd/account_set_user_icon(571eb5b9fcb96c29).(account, clienttag, usericon); |
| 273 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 274 | |
| 275 | // if user online then force him to rejoin channel |
| 276 | if (user_c) |
| 277 | { |
| 278 | conn_update_w3_playerinfocxx . . $ pvpgn/bnetd/conn_update_w3_playerinfo(c4dfbc2386fe4fc3).(user_c); |
| 279 | channel_rejoincxx . . $ pvpgn/bnetd/channel_rejoin(c4dfbc2386fe4fc3).(user_c); |
| 280 | } |
| 281 | |
| 282 | return 0; |
| 283 | break; |
| 284 | |
| 285 | // list |
| 286 | case 'l': |
| 287 | // get current user icon |
| 288 | if (usericon = account_get_user_iconcxx . . $ pvpgn/bnetd/account_get_user_icon(771ec84f6146e718).(account, clienttag)) |
| 289 | usericon = strreversecxx . . $ pvpgn/strreverse(7a9722d75b371431).(xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(usericon)); |
| 290 | |
| 291 | // get user stash |
| 292 | if (char const * iconstash = account_get_user_iconstashcxx . . $ pvpgn/bnetd/account_get_user_iconstash(771ec84f6146e718).(account, clienttag)) |
| 293 | { |
| 294 | stdcxx . . $ std/::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(iconstash); |
| 295 | stdcxx . . $ std/::istringstreamcxx . . $ std/istringstream# isscxx . . $ std/__cxx11/basic_istringstream#basic_istringstream(d3c8ea0e6521074c).(s); |
| 296 | do |
| 297 | { |
| 298 | stdcxx . . $ std/::stringcxx . . $ std/string# _iconcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 299 | iss >>cxx . . $ std/`operator>>`(567ac654e2f44b5d). _icon; |
| 300 | if (_icon.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) continue; |
| 301 | |
| 302 | if (!(iconcode = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()))) |
| 303 | iconcode = _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // icon was added earlier to user and then removed from server stash |
| 304 | |
| 305 | // output icon_alias instead of icon_code |
| 306 | if (iconalias = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), true)) |
| 307 | _icon =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). stdcxx . . $ std/::stringcxx . . $ std/string#(iconalias); // output key instead of code |
| 308 | |
| 309 | // set selected icon in brackets |
| 310 | if (usericon && strcasecmp(usericon, iconcode) == 0) |
| 311 | { |
| 312 | _icon =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). "[" +cxx . . $ std/operator+(42c652dfebe55ad7). _icon +cxx . . $ std/operator+(900ec9581c410ad9). "]"; |
| 313 | is_selected = true; |
| 314 | } |
| 315 | |
| 316 | if (!output_icons.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 317 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ", "; |
| 318 | |
| 319 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). _icon; |
| 320 | |
| 321 | count++; |
| 322 | } while (iss); |
| 323 | } |
| 324 | |
| 325 | // display icon list in user stash |
| 326 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "{} has {} icons in stash : ", account_get_namecxx . . $ `src/bnetd/account.h:115:10`!(account), count); |
| 327 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 328 | |
| 329 | output_icons =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). ((is_selected || usericon) ? "default" : "[default]") +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::stringcxx . . $ std/string#((count > 1) ? ", " : "") +cxx . . $ std/operator+(db5dc2ea912c6495). output_icons; |
| 330 | |
| 331 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). " " +cxx . . $ std/operator+(42c652dfebe55ad7). output_icons; |
| 332 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 333 | |
| 334 | |
| 335 | return 0; |
| 336 | break; |
| 337 | |
| 338 | // add |
| 339 | case 'a': |
| 340 | if (iconname[0] == '\0') |
| 341 | { |
| 342 | describe_commandcxx . . $ pvpgn/bnetd/describe_command(2e9022cda97b266d).(c, args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 343 | return -1; |
| 344 | } |
| 345 | // find icon in server stash |
| 346 | if (!(iconcode = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, iconname))) |
| 347 | { |
| 348 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "That icon doesn't exist in server stash.")); |
| 349 | return -1; |
| 350 | } |
| 351 | |
| 352 | // find icon in user stash |
| 353 | if (char const * iconstash = account_get_user_iconstashcxx . . $ pvpgn/bnetd/account_get_user_iconstash(771ec84f6146e718).(account, clienttag)) |
| 354 | { |
| 355 | stdcxx . . $ std/::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(iconstash); |
| 356 | stdcxx . . $ std/::istringstreamcxx . . $ std/istringstream# isscxx . . $ std/__cxx11/basic_istringstream#basic_istringstream(d3c8ea0e6521074c).(s); |
| 357 | do |
| 358 | { |
| 359 | stdcxx . . $ std/::stringcxx . . $ std/string# _iconcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 360 | iss >>cxx . . $ std/`operator>>`(567ac654e2f44b5d). _icon; |
| 361 | if (_icon.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) continue; |
| 362 | |
| 363 | if (!output_icons.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 364 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 365 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). _icon; |
| 366 | |
| 367 | if (strcasecmp(_icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), iconcode) == 0) |
| 368 | { |
| 369 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "User already has that icon in stash.")); |
| 370 | return -1; |
| 371 | } |
| 372 | } while (iss); |
| 373 | } |
| 374 | // append new icon |
| 375 | if (!output_icons.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 376 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 377 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). stdcxx . . $ std/::stringcxx . . $ std/string#(iconcode); |
| 378 | |
| 379 | // save stash |
| 380 | account_set_user_iconstashcxx . . $ pvpgn/bnetd/account_set_user_iconstash(571eb5b9fcb96c29).(account, clienttag, output_icons.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 381 | |
| 382 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Add new icon to {}'s stash.", account_get_namecxx . . $ `src/bnetd/account.h:115:10`!(account)); |
| 383 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 384 | |
| 385 | return 0; |
| 386 | break; |
| 387 | |
| 388 | // del |
| 389 | case 'd': |
| 390 | if (iconname[0] == '\0') |
| 391 | { |
| 392 | describe_commandcxx . . $ pvpgn/bnetd/describe_command(2e9022cda97b266d).(c, args[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 393 | return -1; |
| 394 | } |
| 395 | bool is_found = false; |
| 396 | if (char const * iconstash = account_get_user_iconstashcxx . . $ pvpgn/bnetd/account_get_user_iconstash(771ec84f6146e718).(account, clienttag)) |
| 397 | { |
| 398 | // get current user icon |
| 399 | if (usericon = account_get_user_iconcxx . . $ pvpgn/bnetd/account_get_user_icon(771ec84f6146e718).(account, clienttag)) |
| 400 | usericon = strreversecxx . . $ pvpgn/strreverse(7a9722d75b371431).(xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(usericon)); |
| 401 | |
| 402 | stdcxx . . $ std/::stringcxx . . $ std/string# scxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(iconstash); |
| 403 | stdcxx . . $ std/::istringstreamcxx . . $ std/istringstream# isscxx . . $ std/__cxx11/basic_istringstream#basic_istringstream(d3c8ea0e6521074c).(s); |
| 404 | do |
| 405 | { |
| 406 | stdcxx . . $ std/::stringcxx . . $ std/string# _iconcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 407 | iss >>cxx . . $ std/`operator>>`(567ac654e2f44b5d). _icon; |
| 408 | if (_icon.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) continue; |
| 409 | |
| 410 | iconalias = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), true); |
| 411 | if (!(iconcode = customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(clienttag, _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()))) |
| 412 | iconcode = iconalias = _icon.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); // icon was added earlier to user and then removed from server stash |
| 413 | |
| 414 | // exclude deleted icon (allow to delete icon by code or alias) |
| 415 | if (strcasecmp(iconname, iconalias) == 0 || strcasecmp(iconname, iconcode) == 0) |
| 416 | { |
| 417 | // also unset current user icon if it equals with given |
| 418 | if (usericon && strcasecmp(usericon, iconcode) == 0) |
| 419 | account_set_user_iconcxx . . $ pvpgn/bnetd/account_set_user_icon(571eb5b9fcb96c29).(account, clienttag, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 420 | |
| 421 | is_found = true; |
| 422 | continue; |
| 423 | } |
| 424 | |
| 425 | if (!output_icons.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 426 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " "; |
| 427 | output_icons +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). _icon; |
| 428 | } while (iss); |
| 429 | } |
| 430 | if (!is_found) |
| 431 | { |
| 432 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_error, c, localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "That icon doesn't exist in user stash.")); |
| 433 | return -1; |
| 434 | } |
| 435 | // save stash |
| 436 | account_set_user_iconstashcxx . . $ pvpgn/bnetd/account_set_user_iconstash(571eb5b9fcb96c29).(account, clienttag, output_icons.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 437 | |
| 438 | msgtemp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). localizecxx . . $ `src/bnetd/i18n.h:73:11`!(c, "Delete icon from {}'s stash.", account_get_namecxx . . $ `src/bnetd/account.h:115:10`!(account)); |
| 439 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(6288036871507e5c).(c, message_type_info, c, msgtempcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).); |
| 440 | |
| 441 | return 0; |
| 442 | break; |
| 443 | } |
| 444 | |
| 445 | return -1; |
| 446 | } |
| 447 | |
| 448 | |
| 449 | |
| 450 | /* Search usericon in available list by icon code or alias, for given clienttag |
| 451 | * return icon code if found, and NULL if not found |
| 452 | * if (return_alias == true) then aias is returned |
| 453 | */ |
| 454 | extern char const * customicons_stash_findcxx . . $ pvpgn/bnetd/customicons_stash_find(308ee6425accf20f).(t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, char const * code, bool return_alias) |
| 455 | { |
| 456 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 457 | t_elemcxx . . $ pvpgn/t_elem# * curr_var; |
| 458 | t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * var; |
| 459 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * iconset; |
| 460 | |
| 461 | if (!code || !clienttag) |
| 462 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 463 | |
| 464 | char clienttag_str[5]; |
| 465 | tag_uint_to_strcxx . . $ pvpgn/tag_uint_to_str(d172961b102a89a5).(clienttag_str, clienttag); |
| 466 | |
| 467 | if (icon_headcxx . . $ pvpgn/bnetd/icon_head.) { |
| 468 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(icon_head, curr) |
| 469 | { |
| 470 | if (!(iconset = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr))) { |
| 471 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 472 | continue; |
| 473 | } |
| 474 | |
| 475 | // find a needed tag |
| 476 | if (stdcxx . . $ std/::strcmp(iconset->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag., clienttag_str) != 0) |
| 477 | continue; |
| 478 | |
| 479 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(iconset->iconstash, curr_var) |
| 480 | { |
| 481 | if (!(var = (t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr_var))) |
| 482 | { |
| 483 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "vars list contains NULL item"); |
| 484 | continue; |
| 485 | } |
| 486 | |
| 487 | if (strcasecmp(var->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key., code) == 0 || strcasecmp(var->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value., code) == 0) |
| 488 | { |
| 489 | char const * val = (return_alias) |
| 490 | ? xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(var->key) |
| 491 | : xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(var->value); |
| 492 | return val; |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | } |
| 497 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 498 | } |
| 499 | |
| 500 | |
| 501 | /* Return comma delimeted icons from stash |
| 502 | */ |
| 503 | extern stdcxx . . $ std/::stringcxx . . $ std/string# customicons_stash_get_listcxx . . $ pvpgn/bnetd/customicons_stash_get_list(84506afe9362c9ca).(t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag, bool return_alias) |
| 504 | { |
| 505 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 506 | t_elemcxx . . $ pvpgn/t_elem# * curr_var; |
| 507 | t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * var; |
| 508 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * iconset; |
| 509 | |
| 510 | stdcxx . . $ std/::stringcxx . . $ std/string# output = ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 511 | |
| 512 | if (!clienttag) |
| 513 | return outputcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 514 | |
| 515 | char clienttag_str[5]; |
| 516 | tag_uint_to_strcxx . . $ pvpgn/tag_uint_to_str(d172961b102a89a5).(clienttag_str, clienttag); |
| 517 | |
| 518 | if (icon_headcxx . . $ pvpgn/bnetd/icon_head.) { |
| 519 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(icon_head, curr) |
| 520 | { |
| 521 | if (!(iconset = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr))) { |
| 522 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 523 | continue; |
| 524 | } |
| 525 | |
| 526 | // find a needed tag |
| 527 | if (stdcxx . . $ std/::strcmp(iconset->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag., clienttag_str) != 0) |
| 528 | continue; |
| 529 | |
| 530 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(iconset->iconstash, curr_var) |
| 531 | { |
| 532 | if (!(var = (t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr_var))) |
| 533 | { |
| 534 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "vars list contains NULL item"); |
| 535 | continue; |
| 536 | } |
| 537 | |
| 538 | |
| 539 | stdcxx . . $ std/::stringcxx . . $ std/string# val = (cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).return_alias) ? var->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key.: var->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.; |
| 540 | |
| 541 | if (!output.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) |
| 542 | output +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). ", "; |
| 543 | output +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). val; |
| 544 | } |
| 545 | break; |
| 546 | } |
| 547 | } |
| 548 | return outputcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).; |
| 549 | } |
| 550 | |
| 551 | |
| 552 | extern int prefs_get_custom_iconscxx . . $ pvpgn/bnetd/prefs_get_custom_icons(b126dc7c1de90089).() |
| 553 | { |
| 554 | return enable_custom_iconscxx . . $ pvpgn/bnetd/enable_custom_icons.; |
| 555 | } |
| 556 | |
| 557 | |
| 558 | extern bool customicons_allowed_by_clientcxx . . $ pvpgn/bnetd/customicons_allowed_by_client(dfa6e707f7696010).(t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 559 | { |
| 560 | switch (clienttag) |
| 561 | { |
| 562 | // Starcraft variations |
| 563 | case CLIENTTAG_STARCRAFT_UINTcxx . . $ `src/common/tag.h:87:9`!: |
| 564 | case CLIENTTAG_BROODWARS_UINTcxx . . $ `src/common/tag.h:89:9`!: |
| 565 | case CLIENTTAG_SHAREWARE_UINTcxx . . $ `src/common/tag.h:91:9`!: |
| 566 | case CLIENTTAG_STARJAPAN_UINTcxx . . $ `src/common/tag.h:101:9`!: |
| 567 | // Diablo |
| 568 | case CLIENTTAG_DIABLORTL_UINTcxx . . $ `src/common/tag.h:93:9`!: |
| 569 | case CLIENTTAG_DIABLOSHR_UINTcxx . . $ `src/common/tag.h:95:9`!: |
| 570 | // Warcraft 2 |
| 571 | case CLIENTTAG_WARCIIBNE_UINTcxx . . $ `src/common/tag.h:97:9`!: |
| 572 | // Warcraft 3 |
| 573 | case CLIENTTAG_WARCRAFT3_UINTcxx . . $ `src/common/tag.h:111:9`!: |
| 574 | case CLIENTTAG_WAR3XP_UINTcxx . . $ `src/common/tag.h:113:9`!: |
| 575 | return true; |
| 576 | default: |
| 577 | break; |
| 578 | } |
| 579 | |
| 580 | return false; |
| 581 | } |
| 582 | |
| 583 | |
| 584 | /* Format stats text, with attributes from a storage, and output text to a user */ |
| 585 | extern const char * customicons_get_stats_textcxx . . $ pvpgn/bnetd/customicons_get_stats_text(771ec84f6146e718).(t_accountcxx . . $ pvpgn/bnetd/t_account# * account, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 586 | { |
| 587 | const char *value; |
| 588 | const char *text; |
| 589 | char clienttag_str[5], tmp[64]; |
| 590 | t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info# * icon; |
| 591 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * iconset; |
| 592 | t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * var; |
| 593 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 594 | t_elemcxx . . $ pvpgn/t_elem# * curr_var; |
| 595 | |
| 596 | tag_uint_to_strcxx . . $ pvpgn/tag_uint_to_str(d172961b102a89a5).(clienttag_str, clienttag); |
| 597 | |
| 598 | text = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 599 | |
| 600 | if (icon_headcxx . . $ pvpgn/bnetd/icon_head.) { |
| 601 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(icon_head, curr) |
| 602 | { |
| 603 | if (!(iconset = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr))) |
| 604 | { |
| 605 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 606 | continue; |
| 607 | } |
| 608 | |
| 609 | // find a needed tag |
| 610 | if (stdcxx . . $ std/::strcmp(iconset->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag., clienttag_str) != 0) |
| 611 | continue; |
| 612 | |
| 613 | if (!iconset->statscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#stats.) |
| 614 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 615 | |
| 616 | text = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(iconset->stats); |
| 617 | |
| 618 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(iconset->vars, curr_var) |
| 619 | { |
| 620 | if (!(var = (t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr_var))) |
| 621 | { |
| 622 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "vars list contains NULL item"); |
| 623 | continue; |
| 624 | } |
| 625 | |
| 626 | // replace NULL attributes to "0" |
| 627 | if (!(value = account_get_strattrcxx . . $ `src/bnetd/account.h:96:9`!(account, var->value))) |
| 628 | value = "0"; |
| 629 | |
| 630 | // replace in a text |
| 631 | stdcxx . . $ std/::snprintfcxx . . $ std/snprintf(416d90c494a2998e).(tmp, sizeof(tmp), "{{%s}}", var->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key.); |
| 632 | text = str_replacecxx . . $ pvpgn/str_replace(a1df38fec57fccd9).((char*)text, tmp, (char*)value); |
| 633 | |
| 634 | // also replace {var}->rank |
| 635 | if (icon = customicons_get_icon_by_ratingcxx . . $ pvpgn/bnetd/customicons_get_icon_by_rating(2c42b6e02b3f2820).(atoi(value), clienttag_str)) |
| 636 | { |
| 637 | stdcxx . . $ std/::snprintfcxx . . $ std/snprintf(416d90c494a2998e).(tmp, sizeof(tmp), "{{%s->rank}}", var->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key.); |
| 638 | text = str_replacecxx . . $ pvpgn/str_replace(a1df38fec57fccd9).((char*)text, tmp, icon->rankcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_0#rank.); |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | return text; |
| 645 | } |
| 646 | |
| 647 | |
| 648 | /* find icon code by rating for the clienttag */ |
| 649 | extern t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info# * customicons_get_icon_by_accountcxx . . $ pvpgn/bnetd/customicons_get_icon_by_account(6aa4f522a41892c1).(t_accountcxx . . $ pvpgn/bnetd/t_account# * account, t_clienttagcxx . . $ pvpgn/t_clienttag# clienttag) |
| 650 | { |
| 651 | char * attr_key; |
| 652 | int rating; |
| 653 | char clienttag_str[5]; |
| 654 | t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info# * icon; |
| 655 | |
| 656 | tag_uint_to_strcxx . . $ pvpgn/tag_uint_to_str(d172961b102a89a5).(clienttag_str, clienttag); |
| 657 | |
| 658 | // get attribute field name from a storage |
| 659 | if (!(attr_key = _find_attr_keycxx . . $ pvpgn/bnetd/_find_attr_key(7a9722d75b371431).((char*)clienttag_str))) |
| 660 | { |
| 661 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace., __FUNCTION__, "no custom iconset defined for client tag {}", clienttag_str); |
| 662 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 663 | } |
| 664 | |
| 665 | rating = account_get_numattrcxx . . $ `src/bnetd/account_wrap.h:45:9`!(account, attr_key); |
| 666 | |
| 667 | icon = customicons_get_icon_by_ratingcxx . . $ pvpgn/bnetd/customicons_get_icon_by_rating(2c42b6e02b3f2820).(rating, clienttag_str); |
| 668 | return icon; |
| 669 | } |
| 670 | |
| 671 | |
| 672 | extern int customicons_unloadcxx . . $ pvpgn/bnetd/customicons_unload(b126dc7c1de90089).(void) |
| 673 | { |
| 674 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 675 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * iconset; |
| 676 | |
| 677 | if (icon_headcxx . . $ pvpgn/bnetd/icon_head.) { |
| 678 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(icon_head, curr) |
| 679 | { |
| 680 | if (!(iconset = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr))) { |
| 681 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 682 | continue; |
| 683 | } |
| 684 | |
| 685 | if (list_remove_elemcxx . . $ pvpgn/list_remove_elem(17f7246ce0d3563b).(icon_headcxx . . $ pvpgn/bnetd/icon_head., &curr) < 0) |
| 686 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not remove item from list"); |
| 687 | |
| 688 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(iconset->clienttag); |
| 689 | if (iconset->attr_keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#attr_key.) |
| 690 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(iconset->attr_key); |
| 691 | if (iconset->statscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#stats.) |
| 692 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void*)iconset->stats); |
| 693 | if (iconset->icon_infocxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#icon_info.) |
| 694 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(iconset->icon_info);//need to free ->rank and ->icon_code too somehow |
| 695 | if (iconset->iconstashcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#iconstash.) |
| 696 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(iconset->iconstash);//need to free ->key and ->value too somehow |
| 697 | if (iconset->varscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#vars.) |
| 698 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(iconset->vars);//need to free ->key and ->value too somehow |
| 699 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(iconset); |
| 700 | } |
| 701 | |
| 702 | if (list_destroycxx . . $ pvpgn/list_destroy(20db0232078327de).(icon_headcxx . . $ pvpgn/bnetd/icon_head.) < 0) |
| 703 | return -1; |
| 704 | icon_headcxx . . $ pvpgn/bnetd/icon_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 705 | } |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | /*****/ |
| 711 | extern int customicons_loadcxx . . $ pvpgn/bnetd/customicons_load(5c4306d8553b3696).(char const * filename) |
| 712 | { |
| 713 | stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fp; |
| 714 | unsigned int line, pos, counter = 0; |
| 715 | bool end_of_iconset = false; |
| 716 | char *buff, *value; |
| 717 | char *rating, *rank, *icon; |
| 718 | t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * option; |
| 719 | |
| 720 | icon_headcxx . . $ pvpgn/bnetd/icon_head. = list_createcxx . . $ pvpgn/list_create(7a6cb11de248e2c9).(); |
| 721 | unsigned int fpos = 0; |
| 722 | |
| 723 | if (!filename) { |
| 724 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL filename"); |
| 725 | return -1; |
| 726 | } |
| 727 | |
| 728 | if (!(fp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(filename, "r"))) { |
| 729 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not open file \"{}\" for reading (std::fopen: {})", filename, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 730 | return -1; |
| 731 | } |
| 732 | |
| 733 | /* 1) parse root config options */ |
| 734 | for (line = 1; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(fp)); line++) |
| 735 | { |
| 736 | if (skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(buff) > 0) |
| 737 | { |
| 738 | continue; |
| 739 | } |
| 740 | // read root options |
| 741 | if (option = _read_optioncxx . . $ pvpgn/bnetd/_read_option(e61207b9f1e42b20).(buff, line)) |
| 742 | { |
| 743 | if (stdcxx . . $ std/::strcmp(option->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key., "custom_icons") == 0) |
| 744 | if (stdcxx . . $ std/::strcmp(option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value., "true") == 0) |
| 745 | enable_custom_iconscxx . . $ pvpgn/bnetd/enable_custom_icons. = 1; |
| 746 | else |
| 747 | enable_custom_iconscxx . . $ pvpgn/bnetd/enable_custom_icons. = 0; |
| 748 | |
| 749 | if (stdcxx . . $ std/::strcmp(option->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key., "master_commandgroups") == 0) |
| 750 | { |
| 751 | size_t option_valuelen = stdcxx . . $ std/::strlen(option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.); |
| 752 | // convert string groups from config to integer |
| 753 | for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# i = 0; i < option_valuelen; i++) |
| 754 | { |
| 755 | if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '1') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 1; |
| 756 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '2') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 2; |
| 757 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '3') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 4; |
| 758 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '4') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 8; |
| 759 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '5') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 16; |
| 760 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '6') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 32; |
| 761 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '7') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 64; |
| 762 | else if (option->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value.[i] == '8') master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. |= 128; |
| 763 | } |
| 764 | } |
| 765 | // set default value if not defined |
| 766 | if (master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. == 0) |
| 767 | master_commandgroupscxx . . $ pvpgn/bnetd/master_commandgroups. = MASTER_COMMANDGROUPS_DEFAULTcxx . . $ `src/bnetd/icons.cpp:65:11`!; |
| 768 | |
| 769 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(option->key); |
| 770 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(option->value); |
| 771 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!(option); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | /* 2) parse clienttags */ |
| 776 | if (stdcxx . . $ std/::strcmp(buff, "[W3XP]") == 0 || stdcxx . . $ std/::strcmp(buff, "[WAR3]") == 0 || stdcxx . . $ std/::strcmp(buff, "[STAR]") == 0 || |
| 777 | stdcxx . . $ std/::strcmp(buff, "[SEXP]") == 0 || stdcxx . . $ std/::strcmp(buff, "[JSTR]") == 0 || stdcxx . . $ std/::strcmp(buff, "[SSHR]") == 0 || |
| 778 | stdcxx . . $ std/::strcmp(buff, "[W2BN]") == 0 || stdcxx . . $ std/::strcmp(buff, "[DRTL]") == 0 || stdcxx . . $ std/::strcmp(buff, "[DSHR]") == 0) |
| 779 | { |
| 780 | if (skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(buff) > 0) |
| 781 | { |
| 782 | continue; |
| 783 | } |
| 784 | value = stdcxx . . $ std/::strtok(buff, " []"); // extract clienttag |
| 785 | |
| 786 | // new iconset for a clienttag |
| 787 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * icon_set = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_iconset_info)); |
| 788 | icon_set->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(value); |
| 789 | icon_set->attr_keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#attr_key. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 790 | icon_set->icon_infocxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#icon_info. = list_createcxx . . $ pvpgn/list_create(7a6cb11de248e2c9).(); |
| 791 | icon_set->iconstashcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#iconstash. = list_createcxx . . $ pvpgn/list_create(7a6cb11de248e2c9).(); |
| 792 | icon_set->varscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#vars. = list_createcxx . . $ pvpgn/list_create(7a6cb11de248e2c9).(); |
| 793 | icon_set->statscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#stats. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 794 | |
| 795 | |
| 796 | /* 3) parse inner options under a clienttag */ |
| 797 | for (; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(fp)); line++) |
| 798 | { |
| 799 | if (stdcxx . . $ std/::strcmp(buff, "[W3XP]") == 0 || stdcxx . . $ std/::strcmp(buff, "[WAR3]") == 0 || stdcxx . . $ std/::strcmp(buff, "[STAR]") == 0 || |
| 800 | stdcxx . . $ std/::strcmp(buff, "[SEXP]") == 0 || stdcxx . . $ std/::strcmp(buff, "[JSTR]") == 0 || stdcxx . . $ std/::strcmp(buff, "[SSHR]") == 0 || |
| 801 | stdcxx . . $ std/::strcmp(buff, "[W2BN]") == 0 || stdcxx . . $ std/::strcmp(buff, "[DRTL]") == 0 || stdcxx . . $ std/::strcmp(buff, "[DSHR]") == 0) |
| 802 | { |
| 803 | // return position in stream |
| 804 | fseek(fp, fpos, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!); |
| 805 | break; |
| 806 | } |
| 807 | if (skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(buff) > 0) |
| 808 | { |
| 809 | continue; |
| 810 | } |
| 811 | // fill variables list |
| 812 | if (option = _read_optioncxx . . $ pvpgn/bnetd/_read_option(e61207b9f1e42b20).(buff, line)) |
| 813 | { |
| 814 | // set attr_key with a first variable |
| 815 | if (!icon_set->attr_keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#attr_key.) |
| 816 | icon_set->attr_keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#attr_key. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(option->value); |
| 817 | |
| 818 | // add to variables |
| 819 | list_append_datacxx . . $ pvpgn/list_append_data(4e1348bd294d996f).(icon_set->varscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#vars., option); |
| 820 | |
| 821 | continue; |
| 822 | } |
| 823 | |
| 824 | /* 3) parse icons section */ |
| 825 | if (stdcxx . . $ std/::strcmp(buff, "[icons]") == 0) |
| 826 | { |
| 827 | counter = 0; |
| 828 | for (; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(fp)); line++) |
| 829 | { |
| 830 | if (skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(buff) > 0) |
| 831 | { |
| 832 | continue; |
| 833 | } |
| 834 | // end if icons |
| 835 | if (stdcxx . . $ std/::strcmp(buff, "[/icons]") == 0) { |
| 836 | break; |
| 837 | } |
| 838 | |
| 839 | pos = 0; |
| 840 | if (!(rating = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos))) |
| 841 | { |
| 842 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing value in line {} in file \"{}\"", line, filename); |
| 843 | continue; |
| 844 | } |
| 845 | if (!(rank = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos))) |
| 846 | { |
| 847 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing rank in line {} in file \"{}\"", line, filename); |
| 848 | continue; |
| 849 | } |
| 850 | if (!(icon = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos))) |
| 851 | { |
| 852 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing icon in line {} in file \"{}\"", line, filename); |
| 853 | continue; |
| 854 | } |
| 855 | counter++; |
| 856 | |
| 857 | t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info# * icon_info = (t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_icon_info)); |
| 858 | icon_info->ratingcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_0#rating. = atoi(rating); |
| 859 | icon_info->rankcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_0#rank. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(rank); |
| 860 | icon_info->icon_codecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_0#icon_code. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(strreverse(icon)); // save reversed icon code |
| 861 | list_prepend_datacxx . . $ pvpgn/list_prepend_data(4e1348bd294d996f).(icon_set->icon_infocxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#icon_info., icon_info); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | /* 3) parse stats section */ |
| 866 | if (stdcxx . . $ std/::strcmp(buff, "[stats]") == 0) |
| 867 | { |
| 868 | stdcxx . . $ std/::stringcxx . . $ std/string# tmpcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 869 | for (; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(fp)); line++) |
| 870 | { |
| 871 | // end of stats |
| 872 | if (stdcxx . . $ std/::strcmp(buff, "[/stats]") == 0) { |
| 873 | // put whole text of stats after read |
| 874 | icon_set->statscxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#stats. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(tmp.c_str()); |
| 875 | break; |
| 876 | } |
| 877 | tmp =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). tmp +cxx . . $ std/operator+(40fc1db9226233c6). buff +cxx . . $ std/operator+(900ec9581c410ad9). "\n"; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | |
| 882 | /* 4) parse usericons section */ |
| 883 | if (stdcxx . . $ std/::strcmp(buff, "[iconstash]") == 0) |
| 884 | { |
| 885 | char *key, *value; |
| 886 | counter = 0; |
| 887 | for (; (buff = file_get_linecxx . . $ pvpgn/file_get_line(e31226b218f63160).(fp)); line++) |
| 888 | { |
| 889 | if (skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(buff) > 0) |
| 890 | { |
| 891 | continue; |
| 892 | } |
| 893 | // end if usericons |
| 894 | if (stdcxx . . $ std/::strcmp(buff, "[/iconstash]") == 0) { |
| 895 | break; |
| 896 | } |
| 897 | |
| 898 | pos = 0; |
| 899 | if (!(key = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos))) |
| 900 | continue; |
| 901 | if (!(value = next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(buff, &pos))) |
| 902 | value = key; |
| 903 | counter++; |
| 904 | |
| 905 | t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * icon_item = (t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_icon_var_info)); |
| 906 | icon_item->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(key); |
| 907 | icon_item->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(value); |
| 908 | list_append_datacxx . . $ pvpgn/list_append_data(4e1348bd294d996f).(icon_set->iconstashcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#iconstash., icon_item); |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | // remember file position |
| 913 | fpos = ftell(fp); |
| 914 | } |
| 915 | |
| 916 | if (!icon_set->attr_keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#attr_key.) |
| 917 | { |
| 918 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "attr_key is null for iconset {}", icon_set->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag.); |
| 919 | continue; |
| 920 | } |
| 921 | list_append_datacxx . . $ pvpgn/list_append_data(4e1348bd294d996f).(icon_headcxx . . $ pvpgn/bnetd/icon_head., icon_set); |
| 922 | |
| 923 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace., __FUNCTION__, "loaded {} custom icons for {}", counter, icon_set->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag.); |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp); |
| 928 | |
| 929 | return 0; |
| 930 | } |
| 931 | |
| 932 | static int skip_commentscxx . . $ pvpgn/bnetd/skip_comments(1ef8e6ec083aabb9).(char *buff) |
| 933 | { |
| 934 | char *temp; |
| 935 | int pos; |
| 936 | |
| 937 | for (pos = 0; buff[pos] == '\t' || buff[pos] == ' '; pos++); |
| 938 | if (buff[pos] == '\0' || buff[pos] == '#') { |
| 939 | return 1; |
| 940 | } |
| 941 | if ((temp = stdcxx . . $ std/::strrchr(buff, '#'))) { |
| 942 | unsigned int len; |
| 943 | unsigned int endpos; |
| 944 | |
| 945 | *temp = '\0'; |
| 946 | len = stdcxx . . $ std/::strlen(buff) + 1; |
| 947 | for (endpos = len - 1; buff[endpos] == '\t' || buff[endpos] == ' '; endpos--); |
| 948 | buff[endpos + 1] = '\0'; |
| 949 | } |
| 950 | return 0; |
| 951 | } |
| 952 | |
| 953 | /* Read an option like "key = value" from a str line, and split in into a pair: key, value */ |
| 954 | static t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * _read_optioncxx . . $ pvpgn/bnetd/_read_option(e61207b9f1e42b20).(char *str, unsigned lineno) |
| 955 | { |
| 956 | char *cp, prev, *directive; |
| 957 | t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info# * icon_var = (t_icon_var_infocxx . . $ pvpgn/bnetd/t_icon_var_info#*)xmalloccxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:43:9`!(sizeof(t_icon_var_info)); |
| 958 | |
| 959 | directive = str; |
| 960 | str = str_skip_wordcxx . . $ pvpgn/str_skip_word(7a9722d75b371431).(str + 1); |
| 961 | if (*str) *(str++) = '\0'; |
| 962 | |
| 963 | str = str_skip_spacecxx . . $ pvpgn/str_skip_space(7a9722d75b371431).(str); |
| 964 | if (*str != '=') { |
| 965 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void*)icon_var); |
| 966 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 967 | } |
| 968 | |
| 969 | str = str_skip_spacecxx . . $ pvpgn/str_skip_space(7a9722d75b371431).(str + 1); |
| 970 | if (!*str) { |
| 971 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing value at line {}", lineno); |
| 972 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void*)icon_var); |
| 973 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 974 | } |
| 975 | |
| 976 | if (*str == '"') { |
| 977 | for (cp = ++str, prev = '\0'; *cp; cp++) { |
| 978 | switch (*cp) { |
| 979 | case '"': |
| 980 | if (prev != '\\') break; |
| 981 | prev = '"'; |
| 982 | continue; |
| 983 | case '\\': |
| 984 | if (prev == '\\') prev = '\0'; |
| 985 | else prev = '\\'; |
| 986 | continue; |
| 987 | default: |
| 988 | prev = *cp; |
| 989 | continue; |
| 990 | } |
| 991 | break; |
| 992 | } |
| 993 | |
| 994 | if (*cp != '"') { |
| 995 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "missing end quota at line {}", lineno); |
| 996 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void*)icon_var); |
| 997 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 998 | } |
| 999 | |
| 1000 | *cp = '\0'; |
| 1001 | cp = str_skip_spacecxx . . $ pvpgn/str_skip_space(7a9722d75b371431).(cp + 1); |
| 1002 | if (*cp) { |
| 1003 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "extra characters in value after ending quote at line {}", lineno); |
| 1004 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void*)icon_var); |
| 1005 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1006 | } |
| 1007 | } |
| 1008 | else { |
| 1009 | cp = str_skip_wordcxx . . $ pvpgn/str_skip_word(7a9722d75b371431).(str); |
| 1010 | if (*cp) { |
| 1011 | *cp = '\0'; |
| 1012 | cp = str_skip_spacecxx . . $ pvpgn/str_skip_space(7a9722d75b371431).(cp + 1); |
| 1013 | if (*cp) { |
| 1014 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "extra characters after the value at line {}", lineno); |
| 1015 | xfreecxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:51:9`!((void*)icon_var); |
| 1016 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1017 | } |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | //if (!find && std::strcmp(find, directive) == 0) |
| 1022 | // return str_skip_space(str); |
| 1023 | //else |
| 1024 | // return NULL; |
| 1025 | |
| 1026 | icon_var->keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#key. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(directive); |
| 1027 | icon_var->valuecxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_2#value. = xstrdupcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/xalloc.h:49:9`!(str_skip_space(str)); |
| 1028 | |
| 1029 | return icon_var; |
| 1030 | } |
| 1031 | |
| 1032 | |
| 1033 | |
| 1034 | |
| 1035 | /* Get custom icon by rating for clienttag */ |
| 1036 | extern t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info# * customicons_get_icon_by_ratingcxx . . $ pvpgn/bnetd/customicons_get_icon_by_rating(2c42b6e02b3f2820).(int rating, char * clienttag) |
| 1037 | { |
| 1038 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 1039 | t_elemcxx . . $ pvpgn/t_elem# * curr_icon; |
| 1040 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * iconset; |
| 1041 | t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info# * icon = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1042 | |
| 1043 | if (!clienttag) |
| 1044 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1045 | |
| 1046 | if (icon_headcxx . . $ pvpgn/bnetd/icon_head.) { |
| 1047 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(icon_head, curr) |
| 1048 | { |
| 1049 | if (!(iconset = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr))) |
| 1050 | { |
| 1051 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 1052 | continue; |
| 1053 | } |
| 1054 | |
| 1055 | // find a needed tag |
| 1056 | if (stdcxx . . $ std/::strcmp(iconset->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag., clienttag) != 0) |
| 1057 | continue; |
| 1058 | |
| 1059 | // iterate all icons for the tag |
| 1060 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(iconset->icon_info, curr_icon) |
| 1061 | { |
| 1062 | if (!(icon = (t_icon_infocxx . . $ pvpgn/bnetd/t_icon_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr_icon))) |
| 1063 | { |
| 1064 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 1065 | continue; |
| 1066 | } |
| 1067 | |
| 1068 | if (rating >= icon->ratingcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_0#rating.) |
| 1069 | return icon; |
| 1070 | } |
| 1071 | // if nothing found then return last icon |
| 1072 | return icon; |
| 1073 | } |
| 1074 | } |
| 1075 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | /* Get attr_key for clienttag */ |
| 1080 | static char * _find_attr_keycxx . . $ pvpgn/bnetd/_find_attr_key(7a9722d75b371431).(char * clienttag) |
| 1081 | { |
| 1082 | t_elemcxx . . $ pvpgn/t_elem# * curr; |
| 1083 | t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info# * iconset; |
| 1084 | |
| 1085 | if (icon_headcxx . . $ pvpgn/bnetd/icon_head.) { |
| 1086 | LIST_TRAVERSEcxx . . $ `src/common/list.h:94:9`!(icon_head, curr) |
| 1087 | { |
| 1088 | if (!(iconset = (t_iconset_infocxx . . $ pvpgn/bnetd/t_iconset_info#*)elem_get_datacxx . . $ pvpgn/elem_get_data(317ff0e7f02bf2b).(curr))) |
| 1089 | { |
| 1090 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "icon list contains NULL item"); |
| 1091 | continue; |
| 1092 | } |
| 1093 | |
| 1094 | // find a needed tag |
| 1095 | if (stdcxx . . $ std/::strcmp(iconset->clienttagcxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#clienttag., clienttag) == 0) |
| 1096 | return iconset->attr_keycxx . . $ pvpgn/bnetd/$anonymous_type_e36c06d23f785114_1#attr_key.; |
| 1097 | } |
| 1098 | } |
| 1099 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1100 | } |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | } |
| 1106 | } |