| 1 |
sysadm |
1.1 |
/*
|
| 2 |
|
|
* Copyright (C) 2004 CreepLord (creeplord@pvpgn.org)
|
| 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"
|
| 19 |
|
|
#ifdef HAVE_STRING_H
|
| 20 |
|
|
# include <string.h>
|
| 21 |
|
|
#else
|
| 22 |
|
|
# ifdef HAVE_STRINGS_H
|
| 23 |
|
|
# include <strings.h>
|
| 24 |
|
|
# endif
|
| 25 |
|
|
#endif
|
| 26 |
|
|
#include <errno.h>
|
| 27 |
|
|
#ifdef STDC_HEADERS
|
| 28 |
|
|
# include <stdlib.h>
|
| 29 |
|
|
#else
|
| 30 |
|
|
# ifdef HAVE_MALLOC_H
|
| 31 |
|
|
# include <malloc.h>
|
| 32 |
|
|
# endif
|
| 33 |
|
|
#endif
|
| 34 |
|
|
|
| 35 |
|
|
#ifdef WIN32_GUI
|
| 36 |
|
|
# include <win32/winmain.h>
|
| 37 |
|
|
#endif
|
| 38 |
|
|
|
| 39 |
|
|
#include "common/bn_type.h"
|
| 40 |
|
|
#include "common/eventlog.h"
|
| 41 |
|
|
#include "common/packet.h"
|
| 42 |
|
|
#include "common/queue.h"
|
| 43 |
|
|
#include "common/tag.h"
|
| 44 |
|
|
#include "common/list.h"
|
| 45 |
|
|
#include "common/util.h"
|
| 46 |
|
|
#include "common/xalloc.h"
|
| 47 |
|
|
#include "common/bnettime.h"
|
| 48 |
|
|
#include "connection.h"
|
| 49 |
|
|
#include "team.h"
|
| 50 |
|
|
#include "account.h"
|
| 51 |
|
|
#include "account_wrap.h"
|
| 52 |
|
|
#include "channel.h"
|
| 53 |
|
|
#include "anongame.h"
|
| 54 |
|
|
#include "anongame_infos.h"
|
| 55 |
|
|
#include "anongame_maplists.h"
|
| 56 |
|
|
#include "handle_anongame.h"
|
| 57 |
|
|
#include "tournament.h"
|
| 58 |
|
|
#include "server.h"
|
| 59 |
|
|
#include "clan.h"
|
| 60 |
|
|
#include "common/setup_after.h"
|
| 61 |
|
|
|
| 62 |
|
|
/* option - handling function */
|
| 63 |
|
|
|
| 64 |
|
|
/* 0x00 */ /* PG style search - handle_anongame_search() in anongame.c */
|
| 65 |
|
|
/* 0x01 */ /* server side packet sent from handle_anongame_search() in anongame.c */
|
| 66 |
|
|
/* 0x02 */ static int _client_anongame_infos(t_connection * c, t_packet const * const packet);
|
| 67 |
|
|
/* 0x03 */ static int _client_anongame_cancel(t_connection * c);
|
| 68 |
|
|
/* 0x04 */ static int _client_anongame_profile(t_connection * c, t_packet const * const packet);
|
| 69 |
|
|
/* 0x05 */ /* AT style search - handle_anongame_search() in anongame.c */
|
| 70 |
|
|
/* 0x06 */ /* AT style search (Inviter) handle_anongame_search() in anongame.c */
|
| 71 |
|
|
/* 0x07 */ static int _client_anongame_tournament(t_connection * c, t_packet const * const packet);
|
| 72 |
|
|
/* 0x08 */ static int _client_anongame_profile_clan(t_connection * c, t_packet const * const packet);
|
| 73 |
|
|
/* 0x09 */ static int _client_anongame_get_icon(t_connection * c, t_packet const * const packet);
|
| 74 |
|
|
/* 0x0A */ static int _client_anongame_set_icon(t_connection * c, t_packet const * const packet);
|
| 75 |
|
|
|
| 76 |
|
|
/* misc functions used by _client_anongame_tournament() */
|
| 77 |
|
|
static unsigned int _tournament_time_convert(unsigned int time);
|
| 78 |
|
|
|
| 79 |
|
|
/* and now the functions */
|
| 80 |
|
|
|
| 81 |
|
|
static int _client_anongame_profile_clan(t_connection * c, t_packet const * const packet)
|
| 82 |
|
|
{
|
| 83 |
|
|
t_packet * rpacket;
|
| 84 |
|
|
int clantag;
|
| 85 |
|
|
int clienttag;
|
| 86 |
|
|
int count;
|
| 87 |
|
|
int temp;
|
| 88 |
|
|
t_clan * clan;
|
| 89 |
|
|
unsigned char rescount;
|
| 90 |
|
|
|
| 91 |
|
|
if (packet_get_size(packet)<sizeof(t_client_findanongame_profile_clan))
|
| 92 |
|
|
{
|
| 93 |
|
|
eventlog(eventlog_level_error,__FUNCTION__,"[%d] got bad ANONGAME_PROFILE_CLAN packet (expected %u bytes, got %u)",conn_get_socket(c), sizeof(t_client_findanongame_profile_clan), packet_get_size(packet));
|
| 94 |
|
|
return -1;
|
| 95 |
|
|
}
|
| 96 |
|
|
|
| 97 |
|
|
clantag = bn_int_get(packet->u.client_findanongame_profile_clan.clantag);
|
| 98 |
|
|
clienttag = bn_int_get(packet->u.client_findanongame_profile_clan.clienttag);
|
| 99 |
|
|
count = bn_int_get(packet->u.server_findanongame_profile_clan.count);
|
| 100 |
|
|
clan = clanlist_find_clan_by_clantag(clantag);
|
| 101 |
|
|
|
| 102 |
|
|
if ((rpacket = packet_create(packet_class_bnet)))
|
| 103 |
|
|
{
|
| 104 |
|
|
packet_set_size(rpacket,sizeof(t_server_findanongame_profile_clan));
|
| 105 |
|
|
packet_set_type(rpacket,SERVER_FINDANONGAME_PROFILE_CLAN);
|
| 106 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_profile_clan.option,CLIENT_FINDANONGAME_PROFILE_CLAN);
|
| 107 |
|
|
bn_int_set(&rpacket->u.server_findanongame_profile_clan.count,count);
|
| 108 |
|
|
rescount = 0;
|
| 109 |
|
|
|
| 110 |
|
|
if (!(clan))
|
| 111 |
|
|
{
|
| 112 |
|
|
temp = 0;
|
| 113 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 114 |
|
|
}
|
| 115 |
|
|
else
|
| 116 |
|
|
{
|
| 117 |
|
|
temp = 0;
|
| 118 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 119 |
|
|
|
| 120 |
|
|
/* need to add clan stuff here:
|
| 121 |
|
|
format:
|
| 122 |
|
|
bn_int ladder_tag (SNLC, 2NLC, 3NLC, 4NLC)
|
| 123 |
|
|
bn_int wins
|
| 124 |
|
|
bn_int losses
|
| 125 |
|
|
bn_byte rank
|
| 126 |
|
|
bn_byte progess bar
|
| 127 |
|
|
bn_int xp
|
| 128 |
|
|
bn_int rank
|
| 129 |
|
|
bn_byte 0x06 <-- random + 5 races
|
| 130 |
|
|
6 times:
|
| 131 |
|
|
bn_int wins
|
| 132 |
|
|
bn_int losses
|
| 133 |
|
|
*/
|
| 134 |
|
|
}
|
| 135 |
|
|
|
| 136 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_profile_clan.rescount,rescount);
|
| 137 |
|
|
|
| 138 |
|
|
|
| 139 |
|
|
conn_push_outqueue(c,rpacket);
|
| 140 |
|
|
packet_del_ref(rpacket);
|
| 141 |
|
|
}
|
| 142 |
|
|
|
| 143 |
|
|
return 0;
|
| 144 |
|
|
}
|
| 145 |
|
|
|
| 146 |
|
|
static int _client_anongame_profile(t_connection * c, t_packet const * const packet)
|
| 147 |
|
|
{
|
| 148 |
|
|
t_packet * rpacket;
|
| 149 |
|
|
char const * username;
|
| 150 |
|
|
int Count, i;
|
| 151 |
|
|
int temp;
|
| 152 |
|
|
t_account * account;
|
| 153 |
|
|
t_connection * dest_c;
|
| 154 |
|
|
t_clienttag ctag;
|
| 155 |
|
|
char clienttag_str[5];
|
| 156 |
|
|
t_list * teamlist;
|
| 157 |
|
|
unsigned char teamcount;
|
| 158 |
|
|
unsigned char *atcountp;
|
| 159 |
|
|
t_elem * curr;
|
| 160 |
|
|
t_team * team;
|
| 161 |
|
|
t_bnettime bn_time;
|
| 162 |
|
|
bn_long ltime;
|
| 163 |
|
|
|
| 164 |
|
|
|
| 165 |
|
|
Count = bn_int_get(packet->u.client_findanongame.count);
|
| 166 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"[%d] got a FINDANONGAME PROFILE packet",conn_get_socket(c));
|
| 167 |
|
|
|
| 168 |
|
|
if (!(username = packet_get_str_const(packet,sizeof(t_client_findanongame_profile),USER_NAME_MAX)))
|
| 169 |
|
|
{
|
| 170 |
|
|
eventlog(eventlog_level_error,__FUNCTION__,"[%d] got bad FINDANONGAME_PROFILE (missing or too long username)",conn_get_socket(c));
|
| 171 |
|
|
return -1;
|
| 172 |
|
|
}
|
| 173 |
|
|
|
| 174 |
|
|
//If no account is found then break
|
| 175 |
|
|
if (!(account = accountlist_find_account(username)))
|
| 176 |
|
|
{
|
| 177 |
|
|
eventlog(eventlog_level_error, __FUNCTION__, "Could not get account - PROFILE");
|
| 178 |
|
|
return -1;
|
| 179 |
|
|
}
|
| 180 |
|
|
|
| 181 |
|
|
if (!(dest_c = connlist_find_connection_by_accountname(username))) {
|
| 182 |
|
|
eventlog(eventlog_level_debug, __FUNCTION__, "account is offline - try ll_clienttag");
|
| 183 |
|
|
if (!(ctag = account_get_ll_clienttag(account))) return -1;
|
| 184 |
|
|
}
|
| 185 |
|
|
else
|
| 186 |
|
|
ctag = conn_get_clienttag(dest_c);
|
| 187 |
|
|
|
| 188 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"Looking up %s's %s Stats.",username,tag_uint_to_str(clienttag_str,ctag));
|
| 189 |
|
|
|
| 190 |
|
|
if (account_get_ladder_level(account,ctag,ladder_id_solo)<=0 &&
|
| 191 |
|
|
account_get_ladder_level(account,ctag,ladder_id_team)<=0 &&
|
| 192 |
|
|
account_get_ladder_level(account,ctag,ladder_id_ffa)<=0 &&
|
| 193 |
|
|
account_get_teams(account)==NULL)
|
| 194 |
|
|
{
|
| 195 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"%s does not have WAR3 Stats.",username);
|
| 196 |
|
|
if (!(rpacket = packet_create(packet_class_bnet)))
|
| 197 |
|
|
return -1;
|
| 198 |
|
|
packet_set_size(rpacket,sizeof(t_server_findanongame_profile2));
|
| 199 |
|
|
packet_set_type(rpacket,SERVER_FINDANONGAME_PROFILE);
|
| 200 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_profile2.option,CLIENT_FINDANONGAME_PROFILE);
|
| 201 |
|
|
bn_int_set(&rpacket->u.server_findanongame_profile2.count,Count);
|
| 202 |
|
|
bn_int_set(&rpacket->u.server_findanongame_profile2.icon,account_icon_to_profile_icon(account_get_user_icon(account,ctag),account,ctag));
|
| 203 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_profile2.rescount,0);
|
| 204 |
|
|
temp=0;
|
| 205 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 206 |
|
|
conn_push_outqueue(c,rpacket);
|
| 207 |
|
|
packet_del_ref(rpacket);
|
| 208 |
|
|
}
|
| 209 |
|
|
else // If they do have a profile then:
|
| 210 |
|
|
{
|
| 211 |
|
|
int solowins=account_get_ladder_wins(account,ctag,ladder_id_solo);
|
| 212 |
|
|
int sololoss=account_get_ladder_losses(account,ctag,ladder_id_solo);
|
| 213 |
|
|
int soloxp=account_get_ladder_xp(account,ctag,ladder_id_solo);
|
| 214 |
|
|
int sololevel=account_get_ladder_level(account,ctag,ladder_id_solo);
|
| 215 |
|
|
int solorank=account_get_ladder_rank(account,ctag,ladder_id_solo);
|
| 216 |
|
|
|
| 217 |
|
|
int teamwins=account_get_ladder_wins(account,ctag,ladder_id_team);
|
| 218 |
|
|
int teamloss=account_get_ladder_losses(account,ctag,ladder_id_team);
|
| 219 |
|
|
int teamxp=account_get_ladder_xp(account,ctag,ladder_id_team);
|
| 220 |
|
|
int teamlevel=account_get_ladder_level(account,ctag,ladder_id_team);
|
| 221 |
|
|
int teamrank=account_get_ladder_rank(account,ctag,ladder_id_team);
|
| 222 |
|
|
|
| 223 |
|
|
int ffawins=account_get_ladder_wins(account,ctag,ladder_id_ffa);
|
| 224 |
|
|
int ffaloss=account_get_ladder_losses(account,ctag,ladder_id_ffa);
|
| 225 |
|
|
int ffaxp=account_get_ladder_xp(account,ctag,ladder_id_ffa);
|
| 226 |
|
|
int ffalevel=account_get_ladder_level(account,ctag,ladder_id_ffa);
|
| 227 |
|
|
int ffarank=account_get_ladder_rank(account,ctag,ladder_id_ffa);
|
| 228 |
|
|
|
| 229 |
|
|
int humanwins=account_get_racewins(account,1,ctag);
|
| 230 |
|
|
int humanlosses=account_get_racelosses(account,1,ctag);
|
| 231 |
|
|
int orcwins=account_get_racewins(account,2,ctag);
|
| 232 |
|
|
int orclosses=account_get_racelosses(account,2,ctag);
|
| 233 |
|
|
int undeadwins=account_get_racewins(account,8,ctag);
|
| 234 |
|
|
int undeadlosses=account_get_racelosses(account,8,ctag);
|
| 235 |
|
|
int nightelfwins=account_get_racewins(account,4,ctag);
|
| 236 |
|
|
int nightelflosses=account_get_racelosses(account,4,ctag);
|
| 237 |
|
|
int randomwins=account_get_racewins(account,0,ctag);
|
| 238 |
|
|
int randomlosses=account_get_racelosses(account,0,ctag);
|
| 239 |
|
|
|
| 240 |
|
|
unsigned char rescount;
|
| 241 |
|
|
|
| 242 |
|
|
if (!(rpacket = packet_create(packet_class_bnet)))
|
| 243 |
|
|
return -1;
|
| 244 |
|
|
packet_set_size(rpacket,sizeof(t_server_findanongame_profile2));
|
| 245 |
|
|
packet_set_type(rpacket,SERVER_FINDANONGAME_PROFILE);
|
| 246 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_profile2.option,CLIENT_FINDANONGAME_PROFILE);
|
| 247 |
|
|
bn_int_set(&rpacket->u.server_findanongame_profile2.count,Count); //job count
|
| 248 |
|
|
bn_int_set(&rpacket->u.server_findanongame_profile2.icon,account_icon_to_profile_icon(account_get_user_icon(account,ctag),account,ctag));
|
| 249 |
|
|
|
| 250 |
|
|
rescount = 0;
|
| 251 |
|
|
if (sololevel > 0) {
|
| 252 |
|
|
bn_int_set((bn_int*)&temp,0x534F4C4F); // SOLO backwards
|
| 253 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 254 |
|
|
temp=0;
|
| 255 |
|
|
bn_int_set((bn_int*)&temp,solowins);
|
| 256 |
|
|
packet_append_data(rpacket,&temp,2); //SOLO WINS
|
| 257 |
|
|
bn_int_set((bn_int*)&temp,sololoss);
|
| 258 |
|
|
packet_append_data(rpacket,&temp,2); // SOLO LOSSES
|
| 259 |
|
|
bn_int_set((bn_int*)&temp,sololevel);
|
| 260 |
|
|
packet_append_data(rpacket,&temp,1); // SOLO LEVEL
|
| 261 |
|
|
bn_int_set((bn_int*)&temp,account_get_profile_calcs(account,soloxp,sololevel));
|
| 262 |
|
|
packet_append_data(rpacket,&temp,1); // SOLO PROFILE CALC
|
| 263 |
|
|
bn_int_set((bn_int *)&temp,soloxp);
|
| 264 |
|
|
packet_append_data(rpacket,&temp,2); // SOLO XP
|
| 265 |
|
|
bn_int_set((bn_int *)&temp,solorank);
|
| 266 |
|
|
packet_append_data(rpacket,&temp,4); // SOLO LADDER RANK
|
| 267 |
|
|
rescount++;
|
| 268 |
|
|
}
|
| 269 |
|
|
|
| 270 |
|
|
if (teamlevel > 0) {
|
| 271 |
|
|
//below is for team records. Add this after 2v2,3v3,4v4 are done
|
| 272 |
|
|
bn_int_set((bn_int*)&temp,0x5445414D);
|
| 273 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 274 |
|
|
bn_int_set((bn_int*)&temp,teamwins);
|
| 275 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 276 |
|
|
bn_int_set((bn_int*)&temp,teamloss);
|
| 277 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 278 |
|
|
bn_int_set((bn_int*)&temp,teamlevel);
|
| 279 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 280 |
|
|
bn_int_set((bn_int*)&temp,account_get_profile_calcs(account,teamxp,teamlevel));
|
| 281 |
|
|
|
| 282 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 283 |
|
|
bn_int_set((bn_int*)&temp,teamxp);
|
| 284 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 285 |
|
|
bn_int_set((bn_int*)&temp,teamrank);
|
| 286 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 287 |
|
|
//done of team game stats
|
| 288 |
|
|
rescount++;
|
| 289 |
|
|
}
|
| 290 |
|
|
|
| 291 |
|
|
if (ffalevel > 0) {
|
| 292 |
|
|
bn_int_set((bn_int*)&temp,0x46464120);
|
| 293 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 294 |
|
|
bn_int_set((bn_int*)&temp,ffawins);
|
| 295 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 296 |
|
|
bn_int_set((bn_int*)&temp,ffaloss);
|
| 297 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 298 |
|
|
bn_int_set((bn_int*)&temp,ffalevel);
|
| 299 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 300 |
|
|
bn_int_set((bn_int*)&temp,account_get_profile_calcs(account,ffaxp,ffalevel));
|
| 301 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 302 |
|
|
bn_int_set((bn_int*)&temp,ffaxp);
|
| 303 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 304 |
|
|
bn_int_set((bn_int*)&temp,ffarank);
|
| 305 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 306 |
|
|
//End of FFA Stats
|
| 307 |
|
|
rescount++;
|
| 308 |
|
|
}
|
| 309 |
|
|
/* set result count */
|
| 310 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_profile2.rescount,rescount);
|
| 311 |
|
|
|
| 312 |
|
|
bn_int_set((bn_int*)&temp,0x06); //start of race stats
|
| 313 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 314 |
|
|
bn_int_set((bn_int*)&temp,randomwins);
|
| 315 |
|
|
packet_append_data(rpacket,&temp,2); //random wins
|
| 316 |
|
|
bn_int_set((bn_int*)&temp,randomlosses);
|
| 317 |
|
|
packet_append_data(rpacket,&temp,2); //random losses
|
| 318 |
|
|
bn_int_set((bn_int*)&temp,humanwins);
|
| 319 |
|
|
packet_append_data(rpacket,&temp,2); //human wins
|
| 320 |
|
|
bn_int_set((bn_int*)&temp,humanlosses);
|
| 321 |
|
|
packet_append_data(rpacket,&temp,2); //human losses
|
| 322 |
|
|
bn_int_set((bn_int*)&temp,orcwins);
|
| 323 |
|
|
packet_append_data(rpacket,&temp,2); //orc wins
|
| 324 |
|
|
bn_int_set((bn_int*)&temp,orclosses);
|
| 325 |
|
|
packet_append_data(rpacket,&temp,2); //orc losses
|
| 326 |
|
|
bn_int_set((bn_int*)&temp,undeadwins);
|
| 327 |
|
|
packet_append_data(rpacket,&temp,2); //undead wins
|
| 328 |
|
|
bn_int_set((bn_int*)&temp,undeadlosses);
|
| 329 |
|
|
packet_append_data(rpacket,&temp,2); //undead losses
|
| 330 |
|
|
bn_int_set((bn_int*)&temp,nightelfwins);
|
| 331 |
|
|
packet_append_data(rpacket,&temp,2); //elf wins
|
| 332 |
|
|
bn_int_set((bn_int*)&temp,nightelflosses);
|
| 333 |
|
|
packet_append_data(rpacket,&temp,2); //elf losses
|
| 334 |
|
|
temp=0;
|
| 335 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 336 |
|
|
//end of normal stats - Start of AT stats
|
| 337 |
|
|
|
| 338 |
|
|
/* 1 byte team count place holder, set later */
|
| 339 |
|
|
packet_append_data(rpacket, &temp, 1);
|
| 340 |
|
|
|
| 341 |
|
|
/* we need to store the AT team count but we dont know yet the no
|
| 342 |
|
|
* of stored teams so we cache the pointer for later use
|
| 343 |
|
|
*/
|
| 344 |
|
|
atcountp = (unsigned char *)packet_get_raw_data(rpacket, packet_get_size(rpacket) - 1);
|
| 345 |
|
|
|
| 346 |
|
|
teamlist = account_get_teams(account);
|
| 347 |
|
|
teamcount = 0;
|
| 348 |
|
|
if (teamlist)
|
| 349 |
|
|
{
|
| 350 |
|
|
int teamtype[] = {0, 0x32565332, 0x33565333, 0x34565334, 0x35565335, 0x36565336};
|
| 351 |
|
|
|
| 352 |
|
|
LIST_TRAVERSE(teamlist,curr)
|
| 353 |
|
|
{
|
| 354 |
|
|
if (!(team = elem_get_data(curr)))
|
| 355 |
|
|
{
|
| 356 |
|
|
eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list");
|
| 357 |
|
|
continue;
|
| 358 |
|
|
}
|
| 359 |
|
|
|
| 360 |
|
|
if (team_get_clienttag(team) != ctag)
|
| 361 |
|
|
continue;
|
| 362 |
|
|
|
| 363 |
|
|
bn_int_set((bn_int*)&temp,teamtype[team_get_size(team)-1]);
|
| 364 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 365 |
|
|
|
| 366 |
|
|
bn_int_set((bn_int*)&temp,team_get_wins(team)); //at team wins
|
| 367 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 368 |
|
|
bn_int_set((bn_int*)&temp,team_get_losses(team)); //at team losses
|
| 369 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 370 |
|
|
bn_int_set((bn_int*)&temp,team_get_level(team));
|
| 371 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 372 |
|
|
bn_int_set((bn_int*)&temp,account_get_profile_calcs(account,team_get_xp(team),team_get_level(team))); // xp bar calc
|
| 373 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 374 |
|
|
bn_int_set((bn_int*)&temp,team_get_xp(team));
|
| 375 |
|
|
packet_append_data(rpacket,&temp,2);
|
| 376 |
|
|
bn_int_set((bn_int*)&temp,team_get_rank(team)); //rank on AT ladder
|
| 377 |
|
|
packet_append_data(rpacket,&temp,4);
|
| 378 |
|
|
|
| 379 |
|
|
bn_time = time_to_bnettime(temp,team_get_lastgame(team));
|
| 380 |
|
|
bnettime_to_bn_long(bn_time,<ime);
|
| 381 |
|
|
packet_append_data(rpacket,<ime,8);
|
| 382 |
|
|
|
| 383 |
|
|
bn_int_set((bn_int*)&temp,team_get_size(team)-1);
|
| 384 |
|
|
packet_append_data(rpacket,&temp,1);
|
| 385 |
|
|
|
| 386 |
|
|
for (i=0; i<team_get_size(team);i++)
|
| 387 |
|
|
{
|
| 388 |
|
|
if ((team_get_memberuid(team,i)!=account_get_uid(account)))
|
| 389 |
|
|
packet_append_string(rpacket,account_get_name(team_get_member(team,i)));
|
| 390 |
|
|
//now attach the names to the packet - not including yourself
|
| 391 |
|
|
// [quetzal] 20020826
|
| 392 |
|
|
|
| 393 |
|
|
}
|
| 394 |
|
|
teamcount++;
|
| 395 |
|
|
|
| 396 |
|
|
if ((teamcount>=16)) break;
|
| 397 |
|
|
}
|
| 398 |
|
|
}
|
| 399 |
|
|
|
| 400 |
|
|
*atcountp = (unsigned char)teamcount;
|
| 401 |
|
|
|
| 402 |
|
|
conn_push_outqueue(c,rpacket);
|
| 403 |
|
|
packet_del_ref(rpacket);
|
| 404 |
|
|
|
| 405 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"Sent %s's WAR3 Stats (including %d teams) to requestor.",username,teamcount);
|
| 406 |
|
|
}
|
| 407 |
|
|
return 0;
|
| 408 |
|
|
}
|
| 409 |
|
|
|
| 410 |
|
|
static int _client_anongame_cancel(t_connection * c)
|
| 411 |
|
|
{
|
| 412 |
|
|
t_packet * rpacket;
|
| 413 |
|
|
t_connection * tc[ANONGAME_MAX_GAMECOUNT/2];
|
| 414 |
|
|
|
| 415 |
|
|
// [quetzal] 20020809 - added a_count, so we dont refer to already destroyed anongame
|
| 416 |
|
|
t_anongame *a = conn_get_anongame(c);
|
| 417 |
|
|
int a_count, i;
|
| 418 |
|
|
|
| 419 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"[%d] got FINDANONGAME CANCEL packet", conn_get_socket(c));
|
| 420 |
|
|
|
| 421 |
|
|
if(!a)
|
| 422 |
|
|
return -1;
|
| 423 |
|
|
|
| 424 |
|
|
a_count = anongame_get_count(a);
|
| 425 |
|
|
|
| 426 |
|
|
// anongame_unqueue(c, anongame_get_queue(a));
|
| 427 |
|
|
// -- already doing unqueue in conn_destroy_anongame
|
| 428 |
|
|
for (i=0; i < ANONGAME_MAX_GAMECOUNT/2; i++)
|
| 429 |
|
|
tc[i] = anongame_get_tc(a, i);
|
| 430 |
|
|
|
| 431 |
|
|
for (i=0; i < ANONGAME_MAX_GAMECOUNT/2; i++) {
|
| 432 |
|
|
if (tc[i] == NULL)
|
| 433 |
|
|
continue;
|
| 434 |
|
|
|
| 435 |
|
|
conn_set_routeconn(tc[i], NULL);
|
| 436 |
|
|
conn_destroy_anongame(tc[i]);
|
| 437 |
|
|
}
|
| 438 |
|
|
|
| 439 |
|
|
if (!(rpacket = packet_create(packet_class_bnet)))
|
| 440 |
|
|
return -1;
|
| 441 |
|
|
|
| 442 |
|
|
packet_set_size(rpacket,sizeof(t_server_findanongame_playgame_cancel));
|
| 443 |
|
|
packet_set_type(rpacket,SERVER_FINDANONGAME_PLAYGAME_CANCEL);
|
| 444 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_playgame_cancel.cancel,SERVER_FINDANONGAME_CANCEL);
|
| 445 |
|
|
bn_int_set(&rpacket->u.server_findanongame_playgame_cancel.count, a_count);
|
| 446 |
|
|
conn_push_outqueue(c,rpacket);
|
| 447 |
|
|
packet_del_ref(rpacket);
|
| 448 |
|
|
return 0;
|
| 449 |
|
|
}
|
| 450 |
|
|
|
| 451 |
|
|
static int _client_anongame_get_icon(t_connection * c, t_packet const * const packet)
|
| 452 |
|
|
{
|
| 453 |
|
|
t_packet * rpacket;
|
| 454 |
|
|
|
| 455 |
|
|
//BlacKDicK 04/20/2003 Need some huge re-work on this.
|
| 456 |
|
|
{
|
| 457 |
|
|
struct
|
| 458 |
|
|
{
|
| 459 |
|
|
char icon_code[4];
|
| 460 |
|
|
unsigned int portrait_code;
|
| 461 |
|
|
char race;
|
| 462 |
|
|
bn_short required_wins;
|
| 463 |
|
|
char client_enabled;
|
| 464 |
|
|
} tempicon;
|
| 465 |
|
|
|
| 466 |
|
|
//FIXME: Add those to the prefs and also merge them on accoun_wrap;
|
| 467 |
|
|
// FIXED BY DJP 07/16/2003 FOR 110 CHANGE ( TOURNEY & RACE WINS ) + Table_witdh
|
| 468 |
|
|
short icon_req_race_wins;
|
| 469 |
|
|
short icon_req_tourney_wins;
|
| 470 |
|
|
int race[]={W3_RACE_RANDOM,W3_RACE_HUMANS,W3_RACE_ORCS,W3_RACE_UNDEAD,W3_RACE_NIGHTELVES,W3_ICON_DEMONS};
|
| 471 |
|
|
char race_char[6] ={'R','H','O','U','N','D'};
|
| 472 |
|
|
char icon_pos[5] ={'2','3','4','5','6',};
|
| 473 |
|
|
char table_width = 6;
|
| 474 |
|
|
char table_height= 5;
|
| 475 |
|
|
int i,j;
|
| 476 |
|
|
char rico;
|
| 477 |
|
|
unsigned int rlvl,rwins;
|
| 478 |
|
|
t_clienttag clienttag;
|
| 479 |
|
|
t_account * acc;
|
| 480 |
|
|
|
| 481 |
|
|
char user_icon[5];
|
| 482 |
|
|
char const * uicon;
|
| 483 |
|
|
|
| 484 |
|
|
clienttag = conn_get_clienttag(c);
|
| 485 |
|
|
acc = conn_get_account(c);
|
| 486 |
|
|
/* WAR3 uses a different table size, might change if blizzard add tournament support to RoC */
|
| 487 |
|
|
if (clienttag==CLIENTTAG_WARCRAFT3_UINT) {
|
| 488 |
|
|
table_width = 5;
|
| 489 |
|
|
table_height= 4;
|
| 490 |
|
|
}
|
| 491 |
|
|
|
| 492 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"[%d] got FINDANONGAME Get Icons packet",conn_get_socket(c));
|
| 493 |
|
|
|
| 494 |
|
|
if ((rpacket = packet_create(packet_class_bnet)) == NULL) {
|
| 495 |
|
|
eventlog(eventlog_level_error, __FUNCTION__, "could not create new packet");
|
| 496 |
|
|
return -1;
|
| 497 |
|
|
}
|
| 498 |
|
|
|
| 499 |
|
|
packet_set_size(rpacket, sizeof(t_server_findanongame_iconreply));
|
| 500 |
|
|
packet_set_type(rpacket, SERVER_FINDANONGAME_ICONREPLY);
|
| 501 |
|
|
bn_int_set(&rpacket->u.server_findanongame_iconreply.count, bn_int_get(packet->u.client_findanongame_inforeq.count));
|
| 502 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_iconreply.option, CLIENT_FINDANONGAME_GET_ICON);
|
| 503 |
|
|
if ((uicon = account_get_user_icon(acc,clienttag)))
|
| 504 |
|
|
{
|
| 505 |
|
|
memcpy(&rpacket->u.server_findanongame_iconreply.curricon, uicon,4);
|
| 506 |
|
|
}
|
| 507 |
|
|
else
|
| 508 |
|
|
{
|
| 509 |
|
|
account_get_raceicon(acc,&rico,&rlvl,&rwins,clienttag);
|
| 510 |
|
|
sprintf(user_icon,"%1d%c3W",rlvl,rico);
|
| 511 |
|
|
memcpy(&rpacket->u.server_findanongame_iconreply.curricon,user_icon,4);
|
| 512 |
|
|
}
|
| 513 |
|
|
|
| 514 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_iconreply.table_width, table_width);
|
| 515 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_iconreply.table_size, table_width*table_height);
|
| 516 |
|
|
for (j=0;j<table_height;j++){
|
| 517 |
|
|
if (clienttag==CLIENTTAG_WARCRAFT3_UINT)
|
| 518 |
|
|
icon_req_race_wins = anongame_infos_get_ICON_REQ_WAR3(j+1);
|
| 519 |
|
|
else
|
| 520 |
|
|
icon_req_race_wins = anongame_infos_get_ICON_REQ_W3XP(j+1);
|
| 521 |
|
|
for (i=0;i<table_width;i++){
|
| 522 |
|
|
tempicon.race=i;
|
| 523 |
|
|
tempicon.icon_code[0] = icon_pos[j];
|
| 524 |
|
|
tempicon.icon_code[1] = race_char[i];
|
| 525 |
|
|
tempicon.icon_code[2] = '3';
|
| 526 |
|
|
tempicon.icon_code[3] = 'W';
|
| 527 |
|
|
tempicon.portrait_code = (account_icon_to_profile_icon(tempicon.icon_code,acc,clienttag));
|
| 528 |
|
|
if (i<=4){
|
| 529 |
|
|
//Building the icon for the races
|
| 530 |
|
|
bn_short_set(&tempicon.required_wins,icon_req_race_wins);
|
| 531 |
|
|
if (account_get_racewins(acc,race[i],clienttag)>=icon_req_race_wins) {
|
| 532 |
|
|
tempicon.client_enabled=1;
|
| 533 |
|
|
}else{
|
| 534 |
|
|
tempicon.client_enabled=0;
|
| 535 |
|
|
}
|
| 536 |
|
|
}else{
|
| 537 |
|
|
//Building the icon for the tourney
|
| 538 |
|
|
icon_req_tourney_wins = anongame_infos_get_ICON_REQ_TOURNEY(j+1);
|
| 539 |
|
|
bn_short_set(&tempicon.required_wins,icon_req_tourney_wins);
|
| 540 |
|
|
if (account_get_racewins(acc,race[i],clienttag)>=icon_req_tourney_wins) {
|
| 541 |
|
|
tempicon.client_enabled=1;
|
| 542 |
|
|
}else{
|
| 543 |
|
|
tempicon.client_enabled=0;}
|
| 544 |
|
|
}
|
| 545 |
|
|
packet_append_data(rpacket, &tempicon, sizeof(tempicon));
|
| 546 |
|
|
}
|
| 547 |
|
|
}
|
| 548 |
|
|
//Go,go,go
|
| 549 |
|
|
conn_push_outqueue(c,rpacket);
|
| 550 |
|
|
packet_del_ref(rpacket);
|
| 551 |
|
|
}
|
| 552 |
|
|
return 0;
|
| 553 |
|
|
}
|
| 554 |
|
|
|
| 555 |
|
|
static int _client_anongame_set_icon(t_connection * c, t_packet const * const packet)
|
| 556 |
|
|
{
|
| 557 |
|
|
//BlacKDicK 04/20/2003
|
| 558 |
|
|
unsigned int desired_icon;
|
| 559 |
|
|
char user_icon[5];
|
| 560 |
|
|
|
| 561 |
|
|
/*FIXME: In this case we do not get a 'count' but insted of it we get the icon
|
| 562 |
|
|
that the client wants to set.'W3H2' for an example. For now it is ok, since they share
|
| 563 |
|
|
the same position on the packet*/
|
| 564 |
|
|
desired_icon=bn_int_get(packet->u.client_findanongame.count);
|
| 565 |
|
|
user_icon[4]=0;
|
| 566 |
|
|
if (desired_icon==0){
|
| 567 |
|
|
strcpy(user_icon,"NULL");
|
| 568 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"[%d] Set icon packet to DEFAULT ICON [%4.4s]",conn_get_socket(c),user_icon);
|
| 569 |
|
|
}else{
|
| 570 |
|
|
memcpy(user_icon,&desired_icon,4);
|
| 571 |
|
|
eventlog(eventlog_level_info,__FUNCTION__,"[%d] Set icon packet to ICON [%s]",conn_get_socket(c),user_icon);
|
| 572 |
|
|
}
|
| 573 |
|
|
|
| 574 |
|
|
account_set_user_icon(conn_get_account(c),conn_get_clienttag(c),user_icon);
|
| 575 |
|
|
//FIXME: Still need a way to 'refresh the user/channel'
|
| 576 |
|
|
//_handle_rejoin_command(conn_get_account(c),"");
|
| 577 |
|
|
/* ??? channel_update_userflags() */
|
| 578 |
|
|
conn_update_w3_playerinfo(c);
|
| 579 |
|
|
|
| 580 |
|
|
channel_rejoin(c);
|
| 581 |
|
|
return 0;
|
| 582 |
|
|
}
|
| 583 |
|
|
|
| 584 |
|
|
static int _client_anongame_infos(t_connection * c, t_packet const * const packet)
|
| 585 |
|
|
{
|
| 586 |
|
|
t_packet * rpacket;
|
| 587 |
|
|
|
| 588 |
|
|
if (bn_int_get(packet->u.client_findanongame_inforeq.count) > 1) {
|
| 589 |
|
|
/* reply with 0 entries found */
|
| 590 |
|
|
int temp = 0;
|
| 591 |
|
|
|
| 592 |
|
|
if ((rpacket = packet_create(packet_class_bnet)) == NULL) {
|
| 593 |
|
|
eventlog(eventlog_level_error, __FUNCTION__, "could not create new packet");
|
| 594 |
|
|
return -1;
|
| 595 |
|
|
}
|
| 596 |
|
|
|
| 597 |
|
|
packet_set_size(rpacket, sizeof(t_server_findanongame_inforeply));
|
| 598 |
|
|
packet_set_type(rpacket, SERVER_FINDANONGAME_INFOREPLY);
|
| 599 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_inforeply.option, CLIENT_FINDANONGAME_INFOS);
|
| 600 |
|
|
bn_int_set(&rpacket->u.server_findanongame_inforeply.count, bn_int_get(packet->u.client_findanongame_inforeq.count));
|
| 601 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_inforeply.noitems, 0);
|
| 602 |
|
|
packet_append_data(rpacket, &temp, 1);
|
| 603 |
|
|
|
| 604 |
|
|
conn_push_outqueue(c,rpacket);
|
| 605 |
|
|
packet_del_ref(rpacket);
|
| 606 |
|
|
} else {
|
| 607 |
|
|
int i;
|
| 608 |
|
|
int client_tag;
|
| 609 |
|
|
int server_tag_count = 0;
|
| 610 |
|
|
int client_tag_unk;
|
| 611 |
|
|
int server_tag_unk;
|
| 612 |
|
|
bn_int temp;
|
| 613 |
|
|
char noitems;
|
| 614 |
|
|
char * tmpdata;
|
| 615 |
|
|
int tmplen;
|
| 616 |
|
|
t_clienttag clienttag = conn_get_clienttag(c);
|
| 617 |
|
|
char last_packet = 0x00;
|
| 618 |
|
|
char other_packet = 0x01;
|
| 619 |
|
|
char langstr[5];
|
| 620 |
|
|
t_gamelang gamelang = conn_get_gamelang(c);
|
| 621 |
|
|
bn_int_tag_get((bn_int const *)&gamelang, langstr, 5);
|
| 622 |
|
|
|
| 623 |
|
|
/* Send seperate packet for each item requested
|
| 624 |
|
|
* sending all at once overloaded w3xp
|
| 625 |
|
|
* [Omega] */
|
| 626 |
|
|
for (i=0;i<bn_byte_get(packet->u.client_findanongame_inforeq.noitems);i++){
|
| 627 |
|
|
noitems = 0;
|
| 628 |
|
|
|
| 629 |
|
|
if ((rpacket = packet_create(packet_class_bnet)) == NULL) {
|
| 630 |
|
|
eventlog(eventlog_level_error, __FUNCTION__, "could not create new packet");
|
| 631 |
|
|
return -1;
|
| 632 |
|
|
}
|
| 633 |
|
|
|
| 634 |
|
|
/* Starting the packet stuff */
|
| 635 |
|
|
packet_set_size(rpacket, sizeof(t_server_findanongame_inforeply));
|
| 636 |
|
|
packet_set_type(rpacket, SERVER_FINDANONGAME_INFOREPLY);
|
| 637 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_inforeply.option, CLIENT_FINDANONGAME_INFOS);
|
| 638 |
|
|
bn_int_set(&rpacket->u.server_findanongame_inforeply.count, 1);
|
| 639 |
|
|
|
| 640 |
|
|
memcpy(&temp,(packet_get_data_const(packet,10+(i*8),4)),sizeof(int));
|
| 641 |
|
|
client_tag=bn_int_get(temp);
|
| 642 |
|
|
memcpy(&temp,packet_get_data_const(packet,14+(i*8),4),sizeof(int));
|
| 643 |
|
|
client_tag_unk=bn_int_get(temp);
|
| 644 |
|
|
|
| 645 |
|
|
switch (client_tag){
|
| 646 |
|
|
case CLIENT_FINDANONGAME_INFOTAG_URL:
|
| 647 |
|
|
bn_int_set((bn_int*)&server_tag_unk,0xBF1F1047);
|
| 648 |
|
|
packet_append_data(rpacket, "LRU\0" , 4);
|
| 649 |
|
|
packet_append_data(rpacket, &server_tag_unk , 4);
|
| 650 |
|
|
// FIXME: Maybe need do do some checks to avoid prefs empty strings.
|
| 651 |
|
|
tmpdata = anongame_infos_data_get_url(clienttag, conn_get_versionid(c), &tmplen);
|
| 652 |
|
|
packet_append_data(rpacket, tmpdata, tmplen);
|
| 653 |
|
|
noitems++;
|
| 654 |
|
|
server_tag_count++;
|
| 655 |
|
|
eventlog(eventlog_level_debug,__FUNCTION__,"client_tag version=(0x%01x) request tagid=(0x%01x) tag=(%s) tag_unk=(0x%04x)",conn_get_versionid(c),i,"CLIENT_FINDANONGAME_INFOTAG_URL",client_tag_unk);
|
| 656 |
|
|
break;
|
| 657 |
|
|
case CLIENT_FINDANONGAME_INFOTAG_MAP:
|
| 658 |
|
|
bn_int_set((bn_int*)&server_tag_unk,0x70E2E0D5);
|
| 659 |
|
|
packet_append_data(rpacket, "PAM\0" , 4);
|
| 660 |
|
|
packet_append_data(rpacket, &server_tag_unk , 4);
|
| 661 |
|
|
tmpdata = anongame_infos_data_get_map(clienttag, conn_get_versionid(c), &tmplen);
|
| 662 |
|
|
packet_append_data(rpacket, tmpdata, tmplen);
|
| 663 |
|
|
noitems++;
|
| 664 |
|
|
server_tag_count++;
|
| 665 |
|
|
eventlog(eventlog_level_debug,__FUNCTION__,"client_tag request tagid=(0x%01x) tag=(%s) tag_unk=(0x%04x)",i,"CLIENT_FINDANONGAME_INFOTAG_MAP",client_tag_unk);
|
| 666 |
|
|
break;
|
| 667 |
|
|
case CLIENT_FINDANONGAME_INFOTAG_TYPE:
|
| 668 |
|
|
bn_int_set((bn_int*)&server_tag_unk,0x7C87DEEE);
|
| 669 |
|
|
packet_append_data(rpacket, "EPYT" , 4);
|
| 670 |
|
|
packet_append_data(rpacket, &server_tag_unk , 4);
|
| 671 |
|
|
tmpdata = anongame_infos_data_get_type(clienttag, conn_get_versionid(c), &tmplen);
|
| 672 |
|
|
packet_append_data(rpacket, tmpdata, tmplen);
|
| 673 |
|
|
noitems++;
|
| 674 |
|
|
server_tag_count++;
|
| 675 |
|
|
eventlog(eventlog_level_debug,__FUNCTION__,"client_tag request tagid=(0x%01x) tag=(%s) tag_unk=(0x%04x)",i,"CLIENT_FINDANONGAME_INFOTAG_TYPE",client_tag_unk);
|
| 676 |
|
|
break;
|
| 677 |
|
|
case CLIENT_FINDANONGAME_INFOTAG_DESC:
|
| 678 |
|
|
bn_int_set((bn_int*)&server_tag_unk,0xA4F0A22F);
|
| 679 |
|
|
packet_append_data(rpacket, "CSED" , 4);
|
| 680 |
|
|
packet_append_data(rpacket,&server_tag_unk,4);
|
| 681 |
|
|
tmpdata = anongame_infos_data_get_desc(langstr, clienttag, conn_get_versionid(c), &tmplen);
|
| 682 |
|
|
packet_append_data(rpacket, tmpdata, tmplen);
|
| 683 |
|
|
eventlog(eventlog_level_debug,__FUNCTION__,"client_tag request tagid=(0x%01x) tag=(%s) tag_unk=(0x%04x)",i,"CLIENT_FINDANONGAME_INFOTAG_DESC",client_tag_unk);
|
| 684 |
|
|
noitems++;
|
| 685 |
|
|
server_tag_count++;
|
| 686 |
|
|
break;
|
| 687 |
|
|
case CLIENT_FINDANONGAME_INFOTAG_LADR:
|
| 688 |
|
|
bn_int_set((bn_int*)&server_tag_unk,0x3BADE25A);
|
| 689 |
|
|
packet_append_data(rpacket, "RDAL" , 4);
|
| 690 |
|
|
packet_append_data(rpacket, &server_tag_unk , 4);
|
| 691 |
|
|
tmpdata = anongame_infos_data_get_ladr(langstr, clienttag, conn_get_versionid(c), &tmplen);
|
| 692 |
|
|
packet_append_data(rpacket, tmpdata, tmplen);
|
| 693 |
|
|
noitems++;
|
| 694 |
|
|
server_tag_count++;
|
| 695 |
|
|
eventlog(eventlog_level_debug,__FUNCTION__,"client_tag request tagid=(0x%01x) tag=(%s) tag_unk=(0x%04x)",i,"CLIENT_FINDANONGAME_INFOTAG_LADR",client_tag_unk);
|
| 696 |
|
|
break;
|
| 697 |
|
|
default:
|
| 698 |
|
|
eventlog(eventlog_level_debug,__FUNCTION__,"unrec client_tag request tagid=(0x%01x) tag=(0x%04x)",i,client_tag);
|
| 699 |
|
|
|
| 700 |
|
|
}
|
| 701 |
|
|
//Adding a last padding null-byte
|
| 702 |
|
|
if (server_tag_count == bn_byte_get(packet->u.client_findanongame_inforeq.noitems))
|
| 703 |
|
|
packet_append_data(rpacket, &last_packet, 1); /* only last packet in group gets 0x00 */
|
| 704 |
|
|
else
|
| 705 |
|
|
packet_append_data(rpacket, &other_packet, 1); /* the rest get 0x01 */
|
| 706 |
|
|
|
| 707 |
|
|
//Go,go,go
|
| 708 |
|
|
bn_byte_set(&rpacket->u.server_findanongame_inforeply.noitems, noitems);
|
| 709 |
|
|
conn_push_outqueue(c,rpacket);
|
| 710 |
|
|
packet_del_ref(rpacket);
|
| 711 |
|
|
}
|
| 712 |
|
|
}
|
| 713 |
|
|
return 0;
|
| 714 |
|
|
}
|
| 715 |
|
|
|
| 716 |
|
|
/* tournament notice disabled at this time, but responce is sent to cleint */
|
| 717 |
|
|
static int _client_anongame_tournament(t_connection * c, t_packet const * const packet)
|
| 718 |
|
|
{
|
| 719 |
|
|
t_packet * rpacket;
|
| 720 |
|
|
|
| 721 |
|
|
t_account * account = conn_get_account(c);
|
| 722 |
|
|
t_clienttag clienttag = conn_get_clienttag(c);
|
| 723 |
|
|
|
| 724 |
|
|
unsigned int start_prelim = tournament_get_start_preliminary();
|
| 725 |
|
|
unsigned int end_signup = tournament_get_end_signup();
|
| 726 |
|
|
unsigned int end_prelim = tournament_get_end_preliminary();
|
| 727 |
|
|
unsigned int start_r1 = tournament_get_start_round_1();
|
| 728 |
|
|
|
| 729 |
|
|
if ((rpacket = packet_create(packet_class_bnet)) == NULL) {
|
| 730 |
|
|
eventlog(eventlog_level_error, __FUNCTION__, "could not create new packet");
|
| 731 |
|
|
return -1;
|
| 732 |
|
|
}
|
| 733 |
|
|
|
| 734 |
|
|
packet_set_size(rpacket, sizeof(t_server_anongame_tournament_reply));
|
| 735 |
|
|
packet_set_type(rpacket, SERVER_FINDANONGAME_TOURNAMENT_REPLY);
|
| 736 |
|
|
bn_byte_set(&rpacket->u.server_anongame_tournament_reply.option, 7);
|
| 737 |
|
|
bn_int_set(&rpacket->u.server_anongame_tournament_reply.count,
|
| 738 |
|
|
bn_int_get(packet->u.client_anongame_tournament_request.count));
|
| 739 |
|
|
|
| 740 |
|
|
if ( !start_prelim || (end_signup <= now && tournament_user_signed_up(account) < 0) ||
|
| 741 |
|
|
tournament_check_client(clienttag) < 0) { /* No Tournament Notice */
|
| 742 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 0);
|
| 743 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 744 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0);
|
| 745 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, 0);
|
| 746 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0);
|
| 747 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, 0);
|
| 748 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0);
|
| 749 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, 0);
|
| 750 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, 0);
|
| 751 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, 0);
|
| 752 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0);
|
| 753 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 0);
|
| 754 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 755 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 756 |
|
|
}
|
| 757 |
|
|
else if (start_prelim>=now) { /* Tournament Notice */
|
| 758 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 1);
|
| 759 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 760 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0x0000); /* random */
|
| 761 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, _tournament_time_convert(start_prelim));
|
| 762 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0x01);
|
| 763 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, start_prelim-now);
|
| 764 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0);
|
| 765 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, 0);
|
| 766 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, 0);
|
| 767 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, 0);
|
| 768 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x00);
|
| 769 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 770 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 771 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 772 |
|
|
}
|
| 773 |
|
|
else if (end_signup>=now) { /* Tournament Signup Notice - Play Game Active */
|
| 774 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 2);
|
| 775 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 776 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0x0828); /* random */
|
| 777 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, _tournament_time_convert(end_signup));
|
| 778 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0x01);
|
| 779 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, end_signup-now);
|
| 780 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0);
|
| 781 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, tournament_get_stat(account, 1));
|
| 782 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, tournament_get_stat(account, 2));
|
| 783 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, tournament_get_stat(account, 3));
|
| 784 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x08);
|
| 785 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 786 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 787 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 788 |
|
|
}
|
| 789 |
|
|
else if (end_prelim>=now) { /* Tournament Prelim Period - Play Game Active */
|
| 790 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 3);
|
| 791 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 792 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0x0828); /* random */
|
| 793 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, _tournament_time_convert(end_prelim));
|
| 794 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0x01);
|
| 795 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, end_prelim-now);
|
| 796 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0);
|
| 797 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, tournament_get_stat(account, 1));
|
| 798 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, tournament_get_stat(account, 2));
|
| 799 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, tournament_get_stat(account, 3));
|
| 800 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x08);
|
| 801 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 802 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 803 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 804 |
|
|
}
|
| 805 |
|
|
else if (start_r1>=now && (tournament_get_game_in_progress()) ) { /* Prelim Period Over - Shows user stats (not all prelim games finished) */
|
| 806 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 4);
|
| 807 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 808 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0x0000); /* random */
|
| 809 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, _tournament_time_convert(start_r1));
|
| 810 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0x01);
|
| 811 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, start_r1-now);
|
| 812 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0); /* 00 00 */
|
| 813 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, tournament_get_stat(account, 1));
|
| 814 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, tournament_get_stat(account, 2));
|
| 815 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, tournament_get_stat(account, 3));
|
| 816 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x08);
|
| 817 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 818 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 819 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 820 |
|
|
}
|
| 821 |
|
|
else if (!(tournament_get_in_finals_status(account))) { /* Prelim Period Over - user did not make finals - Shows user stats */
|
| 822 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 5);
|
| 823 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 824 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0);
|
| 825 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, 0);
|
| 826 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0);
|
| 827 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, 0);
|
| 828 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0);
|
| 829 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, tournament_get_stat(account, 1));
|
| 830 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, tournament_get_stat(account, 2));
|
| 831 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, tournament_get_stat(account, 3));
|
| 832 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x04);
|
| 833 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 834 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 835 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 836 |
|
|
}
|
| 837 |
|
|
/* cycle through [type-6] & [type-7] packets
|
| 838 |
|
|
*
|
| 839 |
|
|
* use [type-6] to show client "eliminated" or "continue"
|
| 840 |
|
|
* timestamp , countdown & round number (of next round) must be set if clinet continues
|
| 841 |
|
|
*
|
| 842 |
|
|
* use [type-7] to make cleint wait for 44FF packet option 1 to start game (A guess, not tested)
|
| 843 |
|
|
*
|
| 844 |
|
|
* not sure if there is overall winner packet sent at end of last final round
|
| 845 |
|
|
*/
|
| 846 |
|
|
|
| 847 |
|
|
else if ( (0) ) { /* User in finals - Shows user stats and start of next round*/
|
| 848 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 6);
|
| 849 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 850 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0x0000);
|
| 851 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, _tournament_time_convert(start_r1));
|
| 852 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0x01);
|
| 853 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, start_r1-now);
|
| 854 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0x0000); /* 00 00 */
|
| 855 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, 4); /* round number */
|
| 856 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, 0); /* 0 = continue , 1= eliminated */
|
| 857 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, 0);
|
| 858 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x04); /* number of rounds in finals */
|
| 859 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 860 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 861 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 862 |
|
|
}
|
| 863 |
|
|
else if ( (0) ) { /* user waiting for match to be made */
|
| 864 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.type, 7);
|
| 865 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown, 0);
|
| 866 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown4, 0);
|
| 867 |
|
|
bn_int_set( &rpacket->u.server_anongame_tournament_reply.timestamp, 0);
|
| 868 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown5, 0);
|
| 869 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.countdown, 0);
|
| 870 |
|
|
bn_short_set( &rpacket->u.server_anongame_tournament_reply.unknown2, 0);
|
| 871 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.wins, 1); /* round number */
|
| 872 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.losses, 0);
|
| 873 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.ties, 0);
|
| 874 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.unknown3, 0x04); /* number of finals */
|
| 875 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.selection, 2);
|
| 876 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.descnum, 0);
|
| 877 |
|
|
bn_byte_set( &rpacket->u.server_anongame_tournament_reply.nulltag, 0);
|
| 878 |
|
|
}
|
| 879 |
|
|
|
| 880 |
|
|
conn_push_outqueue(c,rpacket);
|
| 881 |
|
|
packet_del_ref(rpacket);
|
| 882 |
|
|
return 0;
|
| 883 |
|
|
}
|
| 884 |
|
|
|
| 885 |
|
|
static unsigned int _tournament_time_convert(unsigned int time)
|
| 886 |
|
|
{
|
| 887 |
|
|
/* it works, don't ask me how */ /* some time drift reportd by testers */
|
| 888 |
|
|
unsigned int tmp1, tmp2, tmp3;
|
| 889 |
|
|
|
| 890 |
|
|
tmp1 = time-1059179400; /* 0x3F21CB88 */
|
| 891 |
|
|
tmp2 = tmp1*0.59604645;
|
| 892 |
|
|
tmp3 = tmp2+3276999960U;
|
| 893 |
|
|
/*eventlog(eventlog_level_trace,__FUNCTION__,"time: 0x%08x, tmp1: 0x%08x, tmp2 0x%08x, tmp3 0x%08x",time,tmp1,tmp2,tmp3);*/
|
| 894 |
|
|
|
| 895 |
|
|
return tmp3;
|
| 896 |
|
|
}
|
| 897 |
|
|
|
| 898 |
|
|
extern int handle_anongame_packet(t_connection * c, t_packet const * const packet)
|
| 899 |
|
|
{
|
| 900 |
|
|
switch (bn_byte_get(packet->u.client_anongame.option))
|
| 901 |
|
|
{
|
| 902 |
|
|
case CLIENT_FINDANONGAME_PROFILE:
|
| 903 |
|
|
return _client_anongame_profile(c, packet);
|
| 904 |
|
|
|
| 905 |
|
|
case CLIENT_FINDANONGAME_CANCEL:
|
| 906 |
|
|
return _client_anongame_cancel(c);
|
| 907 |
|
|
|
| 908 |
|
|
case CLIENT_FINDANONGAME_SEARCH:
|
| 909 |
|
|
case CLIENT_FINDANONGAME_AT_INVITER_SEARCH:
|
| 910 |
|
|
case CLIENT_FINDANONGAME_AT_SEARCH:
|
| 911 |
|
|
return handle_anongame_search(c, packet); /* located in anongame.c */
|
| 912 |
|
|
|
| 913 |
|
|
case CLIENT_FINDANONGAME_GET_ICON:
|
| 914 |
|
|
return _client_anongame_get_icon(c, packet);
|
| 915 |
|
|
|
| 916 |
|
|
case CLIENT_FINDANONGAME_SET_ICON:
|
| 917 |
|
|
return _client_anongame_set_icon(c, packet);
|
| 918 |
|
|
|
| 919 |
|
|
case CLIENT_FINDANONGAME_INFOS:
|
| 920 |
|
|
return _client_anongame_infos(c, packet);
|
| 921 |
|
|
|
| 922 |
|
|
case CLIENT_ANONGAME_TOURNAMENT:
|
| 923 |
|
|
return _client_anongame_tournament(c, packet);
|
| 924 |
|
|
|
| 925 |
|
|
case CLIENT_FINDANONGAME_PROFILE_CLAN:
|
| 926 |
|
|
return _client_anongame_profile_clan(c, packet);
|
| 927 |
|
|
|
| 928 |
|
|
default:
|
| 929 |
|
|
eventlog(eventlog_level_error,__FUNCTION__,"got unhandled option %d",bn_byte_get(packet->u.client_findanongame.option));
|
| 930 |
|
|
return -1;
|
| 931 |
|
|
}
|
| 932 |
|
|
}
|