node-gamedig/reference/openttd/lgsl.txt

65 lines
2.9 KiB
Text
Raw Normal View History

2014-10-29 08:02:03 +01:00
/*----------------------------------------------------------------------------------------------------------\
| |
| [ 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_22(&$server, &$lgsl_need, &$lgsl_fp)
{
//---------------------------------------------------------+
fwrite($lgsl_fp,"\x03\x00\x00");
$buffer = fread($lgsl_fp, 4096);
$buffer = substr($buffer, 3); // REMOVE HEADER
if (!$buffer) { return FALSE; }
$response_type = ord(lgsl_cut_byte($buffer, 1)); // TYPE SHOULD BE 4
//---------------------------------------------------------+
$grf_count = ord(lgsl_cut_byte($buffer, 1));
for ($a=0; $a<$grf_count; $a++)
{
$server['e']['grf_'.$a.'_id'] = strtoupper(dechex(lgsl_unpack(lgsl_cut_byte($buffer, 4), "N")));
for ($b=0; $b<16; $b++)
{
$server['e']['grf_'.$a.'_md5'] .= strtoupper(dechex(ord(lgsl_cut_byte($buffer, 1))));
}
}
//---------------------------------------------------------+
$server['e']['date_current'] = lgsl_unpack(lgsl_cut_byte($buffer, 4), "L");
$server['e']['date_start'] = lgsl_unpack(lgsl_cut_byte($buffer, 4), "L");
$server['e']['companies_max'] = ord(lgsl_cut_byte($buffer, 1));
$server['e']['companies'] = ord(lgsl_cut_byte($buffer, 1));
$server['e']['spectators_max'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['name'] = lgsl_cut_string($buffer);
$server['e']['version'] = lgsl_cut_string($buffer);
$server['e']['language'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['password'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['playersmax'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['players'] = ord(lgsl_cut_byte($buffer, 1));
$server['e']['spectators'] = ord(lgsl_cut_byte($buffer, 1));
$server['s']['map'] = lgsl_cut_string($buffer);
$server['e']['map_width'] = lgsl_unpack(lgsl_cut_byte($buffer, 2), "S");
$server['e']['map_height'] = lgsl_unpack(lgsl_cut_byte($buffer, 2), "S");
$server['e']['map_set'] = ord(lgsl_cut_byte($buffer, 1));
$server['e']['dedicated'] = ord(lgsl_cut_byte($buffer, 1));
// DOES NOT RETURN PLAYER INFORMATION
//---------------------------------------------------------+
return TRUE;
}