// // SV_SendServerInfo // // Sends server info to a launcher // TODO: Clean up and reinvent. void SV_SendServerInfo() { size_t i; SZ_Clear(&ml_message); MSG_WriteLong(&ml_message, CHALLENGE); MSG_WriteLong(&ml_message, SV_NewToken()); // if master wants a key to be presented, present it we will if(MSG_BytesLeft() == 4) MSG_WriteLong(&ml_message, MSG_ReadLong()); MSG_WriteString(&ml_message, (char *)hostname.cstring()); byte playersingame = 0; for (i = 0; i < players.size(); ++i) { if (players[i].ingame()) playersingame++; } MSG_WriteByte(&ml_message, playersingame); MSG_WriteByte(&ml_message, maxclients); MSG_WriteString(&ml_message, level.mapname); size_t numwads = wadnames.size(); if(numwads > 0xff)numwads = 0xff; MSG_WriteByte(&ml_message, numwads - 1); for (i = 1; i < numwads; ++i) MSG_WriteString(&ml_message, wadnames[i].c_str()); MSG_WriteByte(&ml_message, (int)deathmatch); MSG_WriteByte(&ml_message, (int)skill); MSG_WriteByte(&ml_message, (int)teamplay); MSG_WriteByte(&ml_message, (int)ctfmode); for (i = 0; i < players.size(); ++i) { if (players[i].ingame()) { MSG_WriteString(&ml_message, players[i].userinfo.netname); MSG_WriteShort(&ml_message, players[i].fragcount); MSG_WriteLong(&ml_message, players[i].ping); if (teamplay || ctfmode) MSG_WriteByte(&ml_message, players[i].userinfo.team); else MSG_WriteByte(&ml_message, TEAM_NONE); } } for (i = 1; i < numwads; ++i) MSG_WriteString(&ml_message, wadhashes[i].c_str()); MSG_WriteString(&ml_message, website.cstring()); if (ctfmode || teamplay) { MSG_WriteLong(&ml_message, scorelimit); for(size_t i = 0; i < NUMTEAMS; i++) { MSG_WriteByte(&ml_message, TEAMenabled[i]); if (TEAMenabled[i]) MSG_WriteLong(&ml_message, TEAMpoints[i]); } } MSG_WriteShort(&ml_message, VERSION); //bond=========================== MSG_WriteString(&ml_message, (char *)email.cstring()); int timeleft = (int)(timelimit - level.time/(TICRATE*60)); if (timeleft<0) timeleft=0; MSG_WriteShort(&ml_message,(int)timelimit); MSG_WriteShort(&ml_message,timeleft); MSG_WriteShort(&ml_message,(int)fraglimit); MSG_WriteByte(&ml_message,(BOOL)itemsrespawn); MSG_WriteByte(&ml_message,(BOOL)weaponstay); MSG_WriteByte(&ml_message,(BOOL)friendlyfire); MSG_WriteByte(&ml_message,(BOOL)allowexit); MSG_WriteByte(&ml_message,(BOOL)infiniteammo); MSG_WriteByte(&ml_message,(BOOL)nomonsters); MSG_WriteByte(&ml_message,(BOOL)monstersrespawn); MSG_WriteByte(&ml_message,(BOOL)fastmonsters); MSG_WriteByte(&ml_message,(BOOL)allowjump); MSG_WriteByte(&ml_message,(BOOL)allowfreelook); MSG_WriteByte(&ml_message,(BOOL)waddownload); MSG_WriteByte(&ml_message,(BOOL)emptyreset); MSG_WriteByte(&ml_message,(BOOL)cleanmaps); MSG_WriteByte(&ml_message,(BOOL)fragexitswitch); for (i = 0; i < players.size(); ++i) { if (players[i].ingame()) { MSG_WriteShort(&ml_message, players[i].killcount); MSG_WriteShort(&ml_message, players[i].deathcount); int timeingame = (time(NULL) - players[i].JoinTime)/60; if (timeingame<0) timeingame=0; MSG_WriteShort(&ml_message, timeingame); } } //bond=========================== MSG_WriteLong(&ml_message, (DWORD)0x01020304); MSG_WriteShort(&ml_message, (WORD)maxplayers); for (i = 0; i < players.size(); ++i) { if (players[i].ingame()) { MSG_WriteByte(&ml_message, (players[i].spectator ? true : false)); } } MSG_WriteLong(&ml_message, (DWORD)0x01020305); MSG_WriteShort(&ml_message, strlen(password.cstring()) ? 1 : 0); NET_SendPacket(ml_message, net_from); }
// // SV_SendServerInfo // // Sends server info to a launcher // TODO: Clean up and reinvent. void SV_SendServerInfo() { size_t i; SZ_Clear(&ml_message); MSG_WriteLong(&ml_message, CHALLENGE); MSG_WriteLong(&ml_message, SV_NewToken()); // if master wants a key to be presented, present it we will if(MSG_BytesLeft() == 4) MSG_WriteLong(&ml_message, MSG_ReadLong()); MSG_WriteString(&ml_message, (char *)sv_hostname.cstring()); byte playersingame = 0; for (Players::iterator it = players.begin();it != players.end();++it) { if (it->ingame()) playersingame++; } MSG_WriteByte(&ml_message, playersingame); MSG_WriteByte(&ml_message, sv_maxclients.asInt()); MSG_WriteString(&ml_message, level.mapname); size_t numwads = wadfiles.size(); if(numwads > 0xff)numwads = 0xff; MSG_WriteByte(&ml_message, numwads - 1); for (i = 1; i < numwads; ++i) MSG_WriteString(&ml_message, D_CleanseFileName(wadfiles[i], "wad").c_str()); MSG_WriteBool(&ml_message, (sv_gametype == GM_DM || sv_gametype == GM_TEAMDM)); MSG_WriteByte(&ml_message, sv_skill.asInt()); MSG_WriteBool(&ml_message, (sv_gametype == GM_TEAMDM)); MSG_WriteBool(&ml_message, (sv_gametype == GM_CTF)); for (Players::iterator it = players.begin();it != players.end();++it) { if (it->ingame()) { MSG_WriteString(&ml_message, it->userinfo.netname.c_str()); MSG_WriteShort(&ml_message, it->fragcount); MSG_WriteLong(&ml_message, it->ping); if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) MSG_WriteByte(&ml_message, it->userinfo.team); else MSG_WriteByte(&ml_message, TEAM_NONE); } } for (i = 1; i < numwads; ++i) MSG_WriteString(&ml_message, wadhashes[i].c_str()); MSG_WriteString(&ml_message, sv_website.cstring()); if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { MSG_WriteLong(&ml_message, sv_scorelimit.asInt()); for(size_t i = 0; i < NUMTEAMS; i++) { if ((sv_gametype == GM_CTF && i < 2) || (sv_gametype != GM_CTF && i < sv_teamsinplay)) { MSG_WriteByte(&ml_message, 1); MSG_WriteLong(&ml_message, TEAMpoints[i]); } else { MSG_WriteByte(&ml_message, 0); } } } MSG_WriteShort(&ml_message, VERSION); //bond=========================== MSG_WriteString(&ml_message, (char *)sv_email.cstring()); int timeleft = (int)(sv_timelimit - level.time/(TICRATE*60)); if (timeleft<0) timeleft=0; MSG_WriteShort(&ml_message,sv_timelimit.asInt()); MSG_WriteShort(&ml_message,timeleft); MSG_WriteShort(&ml_message,sv_fraglimit.asInt()); MSG_WriteBool(&ml_message, (sv_itemsrespawn ? true : false)); MSG_WriteBool(&ml_message, (sv_weaponstay ? true : false)); MSG_WriteBool(&ml_message, (sv_friendlyfire ? true : false)); MSG_WriteBool(&ml_message, (sv_allowexit ? true : false)); MSG_WriteBool(&ml_message, (sv_infiniteammo ? true : false)); MSG_WriteBool(&ml_message, (sv_nomonsters ? true : false)); MSG_WriteBool(&ml_message, (sv_monstersrespawn ? true : false)); MSG_WriteBool(&ml_message, (sv_fastmonsters ? true : false)); MSG_WriteBool(&ml_message, (sv_allowjump ? true : false)); MSG_WriteBool(&ml_message, (sv_freelook ? true : false)); MSG_WriteBool(&ml_message, (sv_waddownload ? true : false)); MSG_WriteBool(&ml_message, (sv_emptyreset ? true : false)); MSG_WriteBool(&ml_message, false); // used to be sv_cleanmaps MSG_WriteBool(&ml_message, (sv_fragexitswitch ? true : false)); for (Players::iterator it = players.begin();it != players.end();++it) { if (it->ingame()) { MSG_WriteShort(&ml_message, it->killcount); MSG_WriteShort(&ml_message, it->deathcount); int timeingame = (time(NULL) - it->JoinTime)/60; if (timeingame<0) timeingame=0; MSG_WriteShort(&ml_message, timeingame); } } //bond=========================== MSG_WriteLong(&ml_message, (DWORD)0x01020304); MSG_WriteShort(&ml_message, sv_maxplayers.asInt()); for (Players::iterator it = players.begin();it != players.end();++it) { if (it->ingame()) { MSG_WriteBool(&ml_message, (it->spectator ? true : false)); } } MSG_WriteLong(&ml_message, (DWORD)0x01020305); MSG_WriteShort(&ml_message, strlen(join_password.cstring()) ? 1 : 0); // GhostlyDeath -- Send Game Version info MSG_WriteLong(&ml_message, GAMEVER); MSG_WriteByte(&ml_message, patchfiles.size()); for (size_t i = 0; i < patchfiles.size(); ++i) MSG_WriteString(&ml_message, D_CleanseFileName(patchfiles[i]).c_str()); NET_SendPacket(ml_message, net_from); }