extern t_versioncheck * versioncheck_create(t_tag archtag, t_tag clienttag) { t_elem const * curr; t_versioninfo * vi; t_versioncheck * vc; char archtag_str[5]; char clienttag_str[5]; LIST_TRAVERSE_CONST(versioninfo_head,curr) { if (!(vi = (t_versioninfo*)elem_get_data(curr))) /* should not happen */ { eventlog(eventlog_level_error,__FUNCTION__,"version list contains NULL item"); continue; } eventlog(eventlog_level_debug,__FUNCTION__,"version check entry archtag=%s, clienttag=%s", tag_uint_to_str(archtag_str,vi->archtag), tag_uint_to_str(clienttag_str,vi->clienttag)); if (vi->archtag != archtag) continue; if (vi->clienttag != clienttag) continue; /* FIXME: randomize the selection if more than one match */ vc = (t_versioncheck*)xmalloc(sizeof(t_versioncheck)); vc->eqn = xstrdup(vi->eqn); vc->mpqfile = xstrdup(vi->mpqfile); vc->versiontag = xstrdup(tag_uint_to_str(clienttag_str,clienttag)); return vc; } /* * No entries in the file that match, return the dummy because we have to send * some equation and auth mpq to the client. The client is not going to pass the * validation later unless skip_versioncheck or allow_unknown_version is enabled. */ return &dummyvc; }
static int _glist_cb_simple(t_game *game, void *data) { static int number; char clienttag_str[5]; if (!data) { number = 1; return 0; } std::fprintf((std::FILE*)data, "game%d=%s,%u,%s\n", number, tag_uint_to_str(clienttag_str, game_get_clienttag(game)), game_get_id(game), game_get_name(game)); number++; return 0; }
extern char * autoupdate_check(t_tag archtag, t_tag clienttag, t_tag gamelang, char const * versiontag) { if (autoupdate_head) { t_elem const * curr; t_autoupdate * entry; char * temp; LIST_TRAVERSE_CONST(autoupdate_head,curr) { if (!(entry = (t_autoupdate*)elem_get_data(curr))) { eventlog(eventlog_level_error,__FUNCTION__,"found NULL entry in list"); continue; } if (entry->archtag != archtag) continue; if (entry->clienttag != clienttag) continue; if (strcmp(entry->versiontag, versiontag) != 0) continue; /* if we have a gamelang then add it to the mpq file name */ if ((gamelang) && // so far only WAR3 uses gamelang specific MPQs! ((clienttag == CLIENTTAG_WARCRAFT3_UINT) || (clienttag == CLIENTTAG_WAR3XP_UINT))){ char gltag[5]; char * tempmpq; char * extention; tag_uint_to_str(gltag,gamelang); tempmpq = xstrdup(entry->mpqfile); temp = (char*)xmalloc(strlen(tempmpq)+6); extention = strrchr(tempmpq,'.'); *extention = '\0'; extention++; sprintf(temp, "%s_%s.%s", tempmpq, gltag, extention); xfree((void *)tempmpq); return temp; } temp = xstrdup(entry->mpqfile); return temp; } } return NULL; }
int output_standard_writer(std::FILE * fp) { t_elem const *curr; t_connection *conn; t_channel const *channel; t_game *game; char const *channel_name; int number; char clienttag_str[5]; int uptime = server_get_uptime(); if (prefs_get_XML_status_output()) { int seconds; int minutes; int hours; int days; days = (uptime / (60 * 60 * 24)); hours = (uptime / (60 * 60)) % 24; minutes = (uptime / 60) % 60; seconds = uptime % 60; std::fprintf(fp, "<?xml version=\"1.0\"?>\n<status>\n"); std::fprintf(fp, "\t\t<Version>%s</Version>\n", PVPGN_VERSION); std::fprintf(fp, "\t\t<Uptime>\n"); std::fprintf(fp, "\t\t\t<Days>%d</Days>\n", days); std::fprintf(fp, "\t\t\t<Hours>%d</Hours>\n", hours); std::fprintf(fp, "\t\t\t<Minutes>%d</Minutes>\n", minutes); std::fprintf(fp, "\t\t\t<Seconds>%d</Seconds>\n", seconds); std::fprintf(fp, "\t\t</Uptime>\n"); std::fprintf(fp, "\t\t<Users>\n"); std::fprintf(fp, "\t\t<Number>%d</Number>\n", connlist_login_get_length()); LIST_TRAVERSE_CONST(connlist(), curr) { conn = (t_connection*)elem_get_data(curr); if (conn_get_account(conn)) std::fprintf(fp, "\t\t<user><name>%s</name><clienttag>%s</clienttag><version>%s</version>", conn_get_username(conn), tag_uint_to_str(clienttag_str, conn_get_clienttag(conn)), conn_get_clientver(conn)); if ((game = conn_get_game(conn))) std::fprintf(fp, "<gameid>%u</gameid>", game_get_id(game)); std::fprintf(fp, "</user>\n"); } std::fprintf(fp, "\t\t</Users>\n"); std::fprintf(fp, "\t\t<Games>\n"); std::fprintf(fp, "\t\t<Number>%d</Number>\n", gamelist_get_length()); gamelist_traverse(_glist_cb_xml, fp); std::fprintf(fp, "\t\t</Games>\n"); std::fprintf(fp, "\t\t<Channels>\n"); std::fprintf(fp, "\t\t<Number>%d</Number>\n", channellist_get_length()); LIST_TRAVERSE_CONST(channellist(), curr) { channel = (t_channel*)elem_get_data(curr); channel_name = channel_get_name(channel); std::fprintf(fp, "\t\t<channel>%s</channel>\n", channel_name); }
static void _maplists_add_map(t_clienttag clienttag, char * mapname, int queue) { /* this function does two things * 1. adds the mapname to maplist for MAPS section * maplist[mapnumber] = mapname * number_maps = total maps held in maplist[] * 2. adds the mapnumber to maplists for TYPE section * maplists[queue][0] = number of maps for queue * maplists[queue][1..32] = mapnumber * ie. maplist[maplists[queue][1..32]] = mapname */ int in_list = 0; int j; char clienttag_str[5]; if (clienttag==CLIENTTAG_WARCRAFT3_UINT) { for (j = 0; j < number_maps_war3; j++) { if (std::strcmp(maplist_war3[j], mapname) == 0) { /* already in list */ in_list = 1; break; } } if (!in_list) maplist_war3[number_maps_war3++] = xstrdup(mapname); if (maplists_war3[queue][0] < MAXMAPS_PER_QUEUE) { maplists_war3[queue][0]++; maplists_war3[queue][(int)maplists_war3[queue][0]] = j; } else { eventlog(eventlog_level_error,__FUNCTION__, "cannot add map \"%s\" for gametype: %s (maxmaps per qametype: %d)", mapname, _maplists_queue_get_type(queue), MAXMAPS_PER_QUEUE); } } else if (clienttag==CLIENTTAG_WAR3XP_UINT) { for (j = 0; j < number_maps_w3xp; j++) { if (std::strcmp(maplist_w3xp[j], mapname) == 0) { /* already in list */ in_list = 1; break; } } if (!in_list) maplist_w3xp[number_maps_w3xp++] = xstrdup(mapname); if (maplists_w3xp[queue][0] < MAXMAPS_PER_QUEUE) { maplists_w3xp[queue][0]++; maplists_w3xp[queue][(int)maplists_w3xp[queue][0]] = j; } else { eventlog(eventlog_level_error,__FUNCTION__, "cannot add map \"%s\" for gametype: %s (maxmaps per qametype: %d)", mapname, _maplists_queue_get_type(queue), MAXMAPS_PER_QUEUE); } } else if (clienttag==CLIENTTAG_REDALERT2_UINT) { for (j = 0; j < number_maps_ral2; j++) { if (std::strcmp(maplist_ral2[j], mapname) == 0) { /* already in list */ in_list = 1; break; } } if (!in_list) maplist_ral2[number_maps_ral2++] = xstrdup(mapname); if (maplists_ral2[queue][0] < MAXMAPS_PER_QUEUE) { maplists_ral2[queue][0]++; maplists_ral2[queue][(int)maplists_ral2[queue][0]] = j; } else { eventlog(eventlog_level_error,__FUNCTION__, "cannot add map \"%s\" for gametype: %s (maxmaps per qametype: %d)", mapname, _maplists_queue_get_type(queue), MAXMAPS_PER_QUEUE); } } else if (clienttag==CLIENTTAG_YURISREV_UINT) { for (j = 0; j < number_maps_yuri; j++) { if (std::strcmp(maplist_yuri[j], mapname) == 0) { /* already in list */ in_list = 1; break; } } if (!in_list) maplist_yuri[number_maps_yuri++] = xstrdup(mapname); if (maplists_yuri[queue][0] < MAXMAPS_PER_QUEUE) { maplists_yuri[queue][0]++; maplists_yuri[queue][(int)maplists_yuri[queue][0]] = j; } else { eventlog(eventlog_level_error,__FUNCTION__, "cannot add map \"%s\" for gametype: %s (maxmaps per qametype: %d)", mapname, _maplists_queue_get_type(queue), MAXMAPS_PER_QUEUE); } } else eventlog(eventlog_level_error,__FUNCTION__,"invalid clienttag: %s",tag_uint_to_str(clienttag_str,clienttag)); }
extern t_game_option bngoption_to_goption(t_clienttag clienttag, t_game_type gtype, unsigned short bngoption) { char clienttag_str[5]; if (!clienttag) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL clienttag"); return game_option_none; } if (clienttag==CLIENTTAG_WARCIIBNE_UINT) { switch (gtype) { case game_type_topvbot: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_TOPVBOT_1: return game_option_topvbot_1; case CLIENT_STARTGAME4_OPTION_TOPVBOT_2: return game_option_topvbot_2; case CLIENT_STARTGAME4_OPTION_TOPVBOT_3: return game_option_topvbot_3; case CLIENT_STARTGAME4_OPTION_TOPVBOT_4: return game_option_topvbot_4; case CLIENT_STARTGAME4_OPTION_TOPVBOT_5: return game_option_topvbot_5; case CLIENT_STARTGAME4_OPTION_TOPVBOT_6: return game_option_topvbot_6; case CLIENT_STARTGAME4_OPTION_TOPVBOT_7: return game_option_topvbot_7; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_melee: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_MELEE_NORMAL: return game_option_melee_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_ffa: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_FFA_NORMAL: return game_option_ffa_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_oneonone: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_ONEONONE_NORMAL: return game_option_oneonone_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_ladder: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_LADDER_COUNTASLOSS: return game_option_ladder_countasloss; case CLIENT_STARTGAME4_OPTION_LADDER_NOPENALTY: return game_option_ladder_nopenalty; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_ironman: switch (bngoption) { default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_mapset: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_MAPSET_NORMAL: return game_option_mapset_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Warcraft II game type \"%s\" %u",tag_uint_to_str(clienttag_str,clienttag),(unsigned int)gtype); return game_option_none; } } else if (clienttag==CLIENTTAG_DIABLO2DV_UINT || clienttag==CLIENTTAG_DIABLO2XP_UINT) { switch (gtype) { case game_type_diablo2open: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_NONE: /* FIXME: really? */ return game_option_none; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Diablo II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_diablo2closed: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_NONE: /* FIXME: really? */ return game_option_none; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Diablo II bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Diablo II game type \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),(unsigned int)gtype); return game_option_none; } } else if (clienttag==CLIENTTAG_DIABLORTL_UINT || clienttag==CLIENTTAG_DIABLOSHR_UINT) { switch (gtype) { case game_type_diablo: switch (bngoption) { default: /* diablo doesn't use any options */ return game_option_none; } default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Diablo game type \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),(unsigned int)gtype); return game_option_none; } } else if (clienttag==CLIENTTAG_STARCRAFT_UINT || clienttag==CLIENTTAG_BROODWARS_UINT || clienttag==CLIENTTAG_SHAREWARE_UINT) { switch (gtype) { case game_type_melee: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_MELEE_NORMAL: return game_option_melee_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_ffa: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_FFA_NORMAL: return game_option_ffa_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_oneonone: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_ONEONONE_NORMAL: return game_option_oneonone_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_ctf: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_CTF_NORMAL: return game_option_ctf_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_greed: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_GREED_10000: return game_option_greed_10000; case CLIENT_STARTGAME4_OPTION_GREED_7500: return game_option_greed_7500; case CLIENT_STARTGAME4_OPTION_GREED_5000: return game_option_greed_5000; case CLIENT_STARTGAME4_OPTION_GREED_2500: return game_option_greed_2500; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_slaughter: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_SLAUGHTER_60: return game_option_slaughter_60; case CLIENT_STARTGAME4_OPTION_SLAUGHTER_45: return game_option_slaughter_45; case CLIENT_STARTGAME4_OPTION_SLAUGHTER_30: return game_option_slaughter_30; case CLIENT_STARTGAME4_OPTION_SLAUGHTER_15: return game_option_slaughter_15; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_sdeath: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_SDEATH_NORMAL: return game_option_sdeath_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_ladder: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_LADDER_COUNTASLOSS: return game_option_ladder_countasloss; case CLIENT_STARTGAME4_OPTION_LADDER_NOPENALTY: return game_option_ladder_nopenalty; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_mapset: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_MAPSET_NORMAL: return game_option_mapset_normal; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_teammelee: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_TEAMMELEE_4: return game_option_teammelee_4; case CLIENT_STARTGAME4_OPTION_TEAMMELEE_3: return game_option_teammelee_3; case CLIENT_STARTGAME4_OPTION_TEAMMELEE_2: return game_option_teammelee_2; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_teamffa: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_TEAMFFA_4: return game_option_teamffa_4; case CLIENT_STARTGAME4_OPTION_TEAMFFA_3: return game_option_teamffa_3; case CLIENT_STARTGAME4_OPTION_TEAMFFA_2: return game_option_teamffa_2; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_teamctf: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_TEAMCTF_4: return game_option_teamctf_4; case CLIENT_STARTGAME4_OPTION_TEAMCTF_3: return game_option_teamctf_3; case CLIENT_STARTGAME4_OPTION_TEAMCTF_2: return game_option_teamctf_2; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_pgl: switch (bngoption) { default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_topvbot: switch (bngoption) { case CLIENT_STARTGAME4_OPTION_TOPVBOT_1: return game_option_topvbot_1; case CLIENT_STARTGAME4_OPTION_TOPVBOT_2: return game_option_topvbot_2; case CLIENT_STARTGAME4_OPTION_TOPVBOT_3: return game_option_topvbot_3; case CLIENT_STARTGAME4_OPTION_TOPVBOT_4: return game_option_topvbot_4; case CLIENT_STARTGAME4_OPTION_TOPVBOT_5: return game_option_topvbot_5; case CLIENT_STARTGAME4_OPTION_TOPVBOT_6: return game_option_topvbot_6; case CLIENT_STARTGAME4_OPTION_TOPVBOT_7: return game_option_topvbot_7; default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft bnet game option for \"%s\" game \"%s\" %hu",tag_uint_to_str(clienttag_str,clienttag),game_type_get_str(gtype),bngoption); return game_option_none; } case game_type_none: default: eventlog(eventlog_level_error,__FUNCTION__,"unknown Starcraft game type \"%s\" %u(%s)",tag_uint_to_str(clienttag_str,clienttag),(unsigned int)gtype,game_type_get_str(gtype)); return game_option_none; } } else if (clienttag==CLIENTTAG_WARCRAFT3_UINT || clienttag==CLIENTTAG_WAR3XP_UINT) { return game_option_none; } else { eventlog(eventlog_level_error,__FUNCTION__,"unknown game clienttag \"%s\" %u",tag_uint_to_str(clienttag_str,clienttag),(unsigned int)gtype); return game_option_none; } }