📄 handle_anongame.c
字号:
packet_append_data(rpacket,&temp,2); //random wins bn_int_set((bn_int*)&temp,randomlosses); packet_append_data(rpacket,&temp,2); //random losses bn_int_set((bn_int*)&temp,humanwins); packet_append_data(rpacket,&temp,2); //human wins bn_int_set((bn_int*)&temp,humanlosses); packet_append_data(rpacket,&temp,2); //human losses bn_int_set((bn_int*)&temp,orcwins); packet_append_data(rpacket,&temp,2); //orc wins bn_int_set((bn_int*)&temp,orclosses); packet_append_data(rpacket,&temp,2); //orc losses bn_int_set((bn_int*)&temp,undeadwins); packet_append_data(rpacket,&temp,2); //undead wins bn_int_set((bn_int*)&temp,undeadlosses); packet_append_data(rpacket,&temp,2); //undead losses bn_int_set((bn_int*)&temp,nightelfwins); packet_append_data(rpacket,&temp,2); //elf wins bn_int_set((bn_int*)&temp,nightelflosses); packet_append_data(rpacket,&temp,2); //elf losses temp=0; packet_append_data(rpacket,&temp,4); //end of normal stats - Start of AT stats /* 1 byte team count place holder, set later */ packet_append_data(rpacket, &temp, 1); /* we need to store the AT team count but we dont know yet the no * of stored teams so we cache the pointer for later use */ atcountp = (unsigned char *)packet_get_raw_data(rpacket, packet_get_size(rpacket) - 1); teamlist = account_get_teams(account); teamcount = 0; if (teamlist) { int teamtype[] = {0, 0x32565332, 0x33565333, 0x34565334, 0x35565335, 0x36565336}; LIST_TRAVERSE(teamlist,curr) { if (!(team = elem_get_data(curr))) { eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list"); continue; } if (team_get_clienttag(team) != ctag) continue; bn_int_set((bn_int*)&temp,teamtype[team_get_size(team)-1]); packet_append_data(rpacket,&temp,4); bn_int_set((bn_int*)&temp,team_get_wins(team)); //at team wins packet_append_data(rpacket,&temp,2); bn_int_set((bn_int*)&temp,team_get_losses(team)); //at team losses packet_append_data(rpacket,&temp,2); bn_int_set((bn_int*)&temp,team_get_level(team)); packet_append_data(rpacket,&temp,1); bn_int_set((bn_int*)&temp,account_get_profile_calcs(account,team_get_xp(team),team_get_level(team))); // xp bar calc packet_append_data(rpacket,&temp,1); bn_int_set((bn_int*)&temp,team_get_xp(team)); packet_append_data(rpacket,&temp,2); bn_int_set((bn_int*)&temp,team_get_rank(team)); //rank on AT ladder packet_append_data(rpacket,&temp,4); bn_time = time_to_bnettime(temp,team_get_lastgame(team)); bnettime_to_bn_long(bn_time,<ime); packet_append_data(rpacket,<ime,8); bn_int_set((bn_int*)&temp,team_get_size(team)-1); packet_append_data(rpacket,&temp,1); for (i=0; i<team_get_size(team);i++) { if ((team_get_memberuid(team,i)!=account_get_uid(account))) packet_append_string(rpacket,account_get_name(team_get_member(team,i))); //now attach the names to the packet - not including yourself // [quetzal] 20020826 } teamcount++; if ((teamcount>=16)) break; } } *atcountp = (unsigned char)teamcount; conn_push_outqueue(c,rpacket); packet_del_ref(rpacket); eventlog(eventlog_level_info,__FUNCTION__,"Sent %s's WAR3 Stats (including %d teams) to requestor.",username,teamcount); } return 0;} static int _client_anongame_cancel(t_connection * c){ t_packet * rpacket; t_connection * tc[ANONGAME_MAX_GAMECOUNT/2]; // [quetzal] 20020809 - added a_count, so we dont refer to already destroyed anongame t_anongame *a = conn_get_anongame(c); int a_count, i; eventlog(eventlog_level_info,__FUNCTION__,"[%d] got FINDANONGAME CANCEL packet", conn_get_socket(c)); if(!a) return -1; a_count = anongame_get_count(a); // anongame_unqueue(c, anongame_get_queue(a)); // -- already doing unqueue in conn_destroy_anongame for (i=0; i < ANONGAME_MAX_GAMECOUNT/2; i++) tc[i] = anongame_get_tc(a, i); for (i=0; i < ANONGAME_MAX_GAMECOUNT/2; i++) { if (tc[i] == NULL) continue; conn_set_routeconn(tc[i], NULL); conn_destroy_anongame(tc[i]); } if (!(rpacket = packet_create(packet_class_bnet))) return -1; packet_set_size(rpacket,sizeof(t_server_findanongame_playgame_cancel)); packet_set_type(rpacket,SERVER_FINDANONGAME_PLAYGAME_CANCEL); bn_byte_set(&rpacket->u.server_findanongame_playgame_cancel.cancel,SERVER_FINDANONGAME_CANCEL); bn_int_set(&rpacket->u.server_findanongame_playgame_cancel.count, a_count); conn_push_outqueue(c,rpacket); packet_del_ref(rpacket); return 0;}static int _client_anongame_get_icon(t_connection * c, t_packet const * const packet){ t_packet * rpacket; //BlacKDicK 04/20/2003 Need some huge re-work on this. { struct { char icon_code[4]; unsigned int portrait_code; char race; bn_short required_wins; char client_enabled; } tempicon; //FIXME: Add those to the prefs and also merge them on accoun_wrap; // FIXED BY DJP 07/16/2003 FOR 110 CHANGE ( TOURNEY & RACE WINS ) + Table_witdh short icon_req_race_wins; short icon_req_tourney_wins; int race[]={W3_RACE_RANDOM,W3_RACE_HUMANS,W3_RACE_ORCS,W3_RACE_UNDEAD,W3_RACE_NIGHTELVES,W3_ICON_DEMONS}; char race_char[6] ={'R','H','O','U','N','D'}; char icon_pos[5] ={'2','3','4','5','6',}; char table_width = 6; char table_height= 5; int i,j; char rico; unsigned int rlvl,rwins; t_clienttag clienttag; t_account * acc; char user_icon[5]; char const * uicon; clienttag = conn_get_clienttag(c); acc = conn_get_account(c); /* WAR3 uses a different table size, might change if blizzard add tournament support to RoC */ if (clienttag==CLIENTTAG_WARCRAFT3_UINT) { table_width = 5; table_height= 4; } eventlog(eventlog_level_info,__FUNCTION__,"[%d] got FINDANONGAME Get Icons packet",conn_get_socket(c)); if ((rpacket = packet_create(packet_class_bnet)) == NULL) { eventlog(eventlog_level_error, __FUNCTION__, "could not create new packet"); return -1; } packet_set_size(rpacket, sizeof(t_server_findanongame_iconreply)); packet_set_type(rpacket, SERVER_FINDANONGAME_ICONREPLY); bn_int_set(&rpacket->u.server_findanongame_iconreply.count, bn_int_get(packet->u.client_findanongame_inforeq.count)); bn_byte_set(&rpacket->u.server_findanongame_iconreply.option, CLIENT_FINDANONGAME_GET_ICON); if ((uicon = account_get_user_icon(acc,clienttag))) { memcpy(&rpacket->u.server_findanongame_iconreply.curricon, uicon,4); } else { account_get_raceicon(acc,&rico,&rlvl,&rwins,clienttag); sprintf(user_icon,"%1d%c3W",rlvl,rico); memcpy(&rpacket->u.server_findanongame_iconreply.curricon,user_icon,4); } bn_byte_set(&rpacket->u.server_findanongame_iconreply.table_width, table_width); bn_byte_set(&rpacket->u.server_findanongame_iconreply.table_size, table_width*table_height); for (j=0;j<table_height;j++){ icon_req_race_wins = anongame_infos_get_ICON_REQ(j+1,clienttag); for (i=0;i<table_width;i++){ tempicon.race=i; tempicon.icon_code[0] = icon_pos[j]; tempicon.icon_code[1] = race_char[i]; tempicon.icon_code[2] = '3'; tempicon.icon_code[3] = 'W'; tempicon.portrait_code = (account_icon_to_profile_icon(tempicon.icon_code,acc,clienttag)); if (i<=4){ //Building the icon for the races bn_short_set(&tempicon.required_wins,icon_req_race_wins); if (account_get_racewins(acc,race[i],clienttag)>=icon_req_race_wins) { tempicon.client_enabled=1; }else{ tempicon.client_enabled=0; } }else{ //Building the icon for the tourney icon_req_tourney_wins = anongame_infos_get_ICON_REQ_TOURNEY(j+1); bn_short_set(&tempicon.required_wins,icon_req_tourney_wins); if (account_get_racewins(acc,race[i],clienttag)>=icon_req_tourney_wins) { tempicon.client_enabled=1; }else{ tempicon.client_enabled=0;} } packet_append_data(rpacket, &tempicon, sizeof(tempicon)); } } //Go,go,go conn_push_outqueue(c,rpacket); packet_del_ref(rpacket); } return 0;}static int _client_anongame_set_icon(t_connection * c, t_packet const * const packet){ //BlacKDicK 04/20/2003 unsigned int desired_icon; char user_icon[5]; /*FIXME: In this case we do not get a 'count' but insted of it we get the icon that the client wants to set.'W3H2' for an example. For now it is ok, since they share the same position on the packet*/ desired_icon=bn_int_get(packet->u.client_findanongame.count); user_icon[4]=0; if (desired_icon==0){ strcpy(user_icon,"NULL"); eventlog(eventlog_level_info,__FUNCTION__,"[%d] Set icon packet to DEFAULT ICON [%4.4s]",conn_get_socket(c),user_icon); }else{ memcpy(user_icon,&desired_icon,4); eventlog(eventlog_level_info,__FUNCTION__,"[%d] Set icon packet to ICON [%s]",conn_get_socket(c),user_icon); } account_set_user_icon(conn_get_account(c),conn_get_clienttag(c),user_icon); //FIXME: Still need a way to 'refresh the user/channel' //_handle_rejoin_command(conn_get_account(c),""); /* ??? channel_update_userflags() */ conn_update_w3_playerinfo(c); channel_rejoin(c); return 0;}static int _client_anongame_infos(t_connection * c, t_packet const * const packet){ t_packet * rpacket; if (bn_int_get(packet->u.client_findanongame_inforeq.count) > 1) { /* reply with 0 entries found */ int temp = 0; if ((rpacket = packet_create(packet_class_bnet)) == NULL) { eventlog(eventlog_level_error, __FUNCTION__, "could not create new packet"); return -1; } packet_set_size(rpacket, sizeof(t_server_findanongame_inforeply)); packet_set_type(rpacket, SERVER_FINDANONGAME_INFOREPLY); bn_byte_set(&rpacket->u.server_findanongame_inforeply.option, CLIENT_FINDANONGAME_INFOS); bn_int_set(&rpacket->u.server_findanongame_inforeply.count, bn_int_get(packet->u.client_findanongame_inforeq.count)); bn_byte_set(&rpacket->u.server_findanongame_inforeply.noitems, 0); packet_append_data(rpacket, &temp, 1); conn_push_outqueue(c,rpacket); packet_del_ref(rpacket); } else { int i; int client_tag; int server_tag_count = 0; int client_tag_unk; int server_tag_unk; bn_int temp; char noitems; char * tmpdata; int tmplen; t_clienttag clienttag = conn_get_clienttag(c); char last_packet = 0x00; char other_packet = 0x01; char langstr[5]; t_gamelang gamelang = conn_get_gamelang(c); bn_int_tag_get((bn_int const *)&gamelang, langstr, 5); /* Send seperate packet for each item requested * sending all at once overloaded w3xp * [Omega] */ for (i=0;i<bn_byte_get(packet->u.client_findanongame_inforeq.noitems);i++){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -