node-gamedig/reference/tribes2/lgsl.txt

73 lines
3.3 KiB
Text
Raw Normal View History

/*----------------------------------------------------------------------------------------------------------\
| |
| [ LIVE GAME SERVER LIST ] [ <20> RICHARD PERRY FROM GREYCUBE.COM ] |
| |
| Released under the terms and conditions of the GNU General Public License Version 3 (http://gnu.org) |
| |
\-----------------------------------------------------------------------------------------------------------*/
function lgsl_query_25(&$server, &$lgsl_need, &$lgsl_fp)
{
//---------------------------------------------------------+
// REFERENCE: http://www.tribesnext.com
fwrite($lgsl_fp,"\x12\x02\x21\x21\x21\x21");
$buffer = fread($lgsl_fp, 4096);
if (!$buffer) { return FALSE; }
$buffer = substr($buffer, 6); // REMOVE HEADER
//---------------------------------------------------------+
$server['s']['game'] = lgsl_cut_pascal($buffer);
$server['e']['gamemode'] = lgsl_cut_pascal($buffer);
$server['s']['map'] = lgsl_cut_pascal($buffer);
$server['e']['bit_flags'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['players'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['playersmax'] = ord(lgsl_cut_byte($buffer, 1));
$server['e']['bots'] = ord(lgsl_cut_byte($buffer, 1));
$server['e']['cpu'] = lgsl_unpack(lgsl_cut_byte($buffer, 2), "S");
$server['e']['motd'] = lgsl_cut_pascal($buffer);
$server['e']['unknown'] = lgsl_unpack(lgsl_cut_byte($buffer, 2), "S");
$server['e']['dedicated'] = ($server['e']['bit_flags'] & 1) ? "1" : "0";
$server['s']['password'] = ($server['e']['bit_flags'] & 2) ? "1" : "0";
$server['e']['os'] = ($server['e']['bit_flags'] & 4) ? "L" : "W";
$server['e']['tournament'] = ($server['e']['bit_flags'] & 8) ? "1" : "0";
$server['e']['no_alias'] = ($server['e']['bit_flags'] & 16) ? "1" : "0";
unset($server['e']['bit_flags']);
//---------------------------------------------------------+
$team_total = lgsl_cut_string($buffer, 0, "\x0A");
for ($i=0; $i<$team_total; $i++)
{
$server['t'][$i]['name'] = lgsl_cut_string($buffer, 0, "\x09");
$server['t'][$i]['score'] = lgsl_cut_string($buffer, 0, "\x0A");
}
$player_total = lgsl_cut_string($buffer, 0, "\x0A");
for ($i=0; $i<$player_total; $i++)
{
lgsl_cut_byte($buffer, 1); // ? 16
lgsl_cut_byte($buffer, 1); // ? 8 or 14 = BOT / 12 = ALIAS / 11 = NORMAL
if (ord($buffer[0]) < 32) { lgsl_cut_byte($buffer, 1); } // ? 8 PREFIXES SOME NAMES
$server['p'][$i]['name'] = lgsl_cut_string($buffer, 0, "\x11");
lgsl_cut_string($buffer, 0, "\x09"); // ALWAYS BLANK
$server['p'][$i]['team'] = lgsl_cut_string($buffer, 0, "\x09");
$server['p'][$i]['score'] = lgsl_cut_string($buffer, 0, "\x0A");
}
//---------------------------------------------------------+
return TRUE;
}