mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Add a bunch of reference docs
This commit is contained in:
parent
bc6b5c9225
commit
473d9544b1
32 changed files with 1282 additions and 0 deletions
77
reference/openttd/gameq.txt
Normal file
77
reference/openttd/gameq.txt
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of GameQ.
|
||||
*
|
||||
* GameQ is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GameQ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $Id: openttd.php,v 1.1 2009/10/24 18:45:16 evilpie Exp $
|
||||
*/
|
||||
|
||||
[openttd]
|
||||
status = "\x03\x00\x00"
|
||||
|
||||
|
||||
require_once GAMEQ_BASE . 'Protocol.php';
|
||||
|
||||
/**
|
||||
* OpenTTD Protocol, direct port from udp.cpp source from the game
|
||||
*
|
||||
* @author Tom Schuster <evilpie@users.sf.net>
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
class GameQ_Protocol_openttd extends GameQ_Protocol
|
||||
{
|
||||
public function status ()
|
||||
{
|
||||
$this->p->readInt16(); # packet size
|
||||
$this->p->readInt8(); # packet type
|
||||
|
||||
$protocol_version = $this->p->readInt8();
|
||||
$this->r->add('protocol_version', $protocol_version);
|
||||
switch ($protocol_version)
|
||||
{
|
||||
case 4:
|
||||
$num_grfs = $this->p->readInt8(); #number of grfs
|
||||
$this->r->add('num_grfs', $num_grfs);
|
||||
$this->p->skip ($num_grfs * 20); #skip id and md5 hash
|
||||
case 3:
|
||||
$this->r->add('game_date', $this->p->readInt32());
|
||||
$this->r->add('start_date', $this->p->readInt32());
|
||||
case 2:
|
||||
$this->r->add('companies_max', $this->p->readInt8());
|
||||
$this->r->add('companies_on', $this->p->readInt8());
|
||||
$this->r->add('spectators_max', $this->p->readInt8());
|
||||
case 1:
|
||||
$this->r->add('hostname', $this->p->readString());
|
||||
$this->r->add('version', $this->p->readString());
|
||||
$this->r->add('language', $this->p->readInt8());
|
||||
$this->r->add('password', $this->p->readInt8());
|
||||
$this->r->add('max_clients', $this->p->readInt8());
|
||||
$this->r->add('clients', $this->p->readInt8());
|
||||
$this->r->add('spectators', $this->p->readInt8());
|
||||
if ($protocol_version < 3)
|
||||
{
|
||||
$days = ( 365 * 1920 + 1920 / 4 - 1920 / 100 + 1920 / 400 );
|
||||
$this->r->add('game_date', $this->p->readInt16() + $days);
|
||||
$this->r->add('start_date', $this->p->readInt16() + $days);
|
||||
}
|
||||
$this->r->add('map', $this->p->readString());
|
||||
$this->r->add('map_width', $this->p->readInt16());
|
||||
$this->r->add('map_height', $this->p->readInt16());
|
||||
$this->r->add('map_type', $this->p->readInt8());
|
||||
$this->r->add('dedicated', $this->p->readInt8());
|
||||
}
|
||||
}
|
||||
}
|
||||
64
reference/openttd/lgsl.txt
Normal file
64
reference/openttd/lgsl.txt
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
/*----------------------------------------------------------------------------------------------------------\
|
||||
| |
|
||||
| [ LIVE GAME SERVER LIST ] [ © 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue