Add a bunch of reference docs

This commit is contained in:
Michael Morrison 2014-02-03 15:09:00 -06:00
parent bc6b5c9225
commit 473d9544b1
32 changed files with 1282 additions and 0 deletions

104
reference/tribes2/gameq.txt Normal file
View file

@ -0,0 +1,104 @@
<?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: tribes2.php,v 1.1 2007/07/07 14:52:01 tombuskens Exp $
*/
[tribes2]
info = "\x0E\x02\x01\x02\x03\x04"
status = "\x12\x02\x01\x02\x03\x04"
require_once GAMEQ_BASE . 'Protocol.php';
/**
* Tribes 2 protocol
*
* @author Tom Buskens <t.buskens@deviation.nl>
* @version $Revision: 1.1 $
*/
class GameQ_Protocol_tribes2 extends GameQ_Protocol
{
public function info()
{
// Header
$this->p->skip(6);
$this->r->add('version', $this->p->readPascalString());
// TODO: Protocol and build numbers
$this->p->skip(12);
$this->r->add('hostname', $this->p->readPascalString());
}
public function status()
{
// Header
$this->p->skip(6);
// Vars
$this->r->add('mod', $this->p->readPascalString());
$this->r->add('gametype', $this->p->readPascalString());
$this->r->add('map', $this->p->readPascalString());
$this->readBitflag($this->p->read());
$this->r->add('num_players', $this->p->readInt8());
$this->r->add('max_players', $this->p->readInt8());
$this->r->add('num_bots', $this->p->readInt8());
$this->r->add('cpu', $this->p->readInt16());
$this->r->add('info', $this->p->readPascalString());
$this->p->skip(2);
$this->teams();
$this->players();
}
private function teams()
{
$num_teams = $this->p->read();
$this->r->add('num_teams', $num_teams);
$this->p->skip();
for ($i = 0; $i < $num_teams; $i++) {
$this->r->addTeam('name', $this->p->readString("\x09"));
$this->r->addTeam('score', $this->p->readString("\x0a"));
}
}
private function players()
{
// TODO
}
private function readBitflag($flag)
{
$vars = array('dedicated', 'password', 'linux',
'tournament', 'no_alias');
$bit = 1;
foreach ($vars as $var) {
$value = ($flag & $bit) ? 1 : 0;
$this->r->add($var, $value);
$bit *= 2;
}
}
}
?>

View file

@ -0,0 +1,72 @@
/*----------------------------------------------------------------------------------------------------------\
| |
| [ 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_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;
}