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

View file

@ -0,0 +1,92 @@
<?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: silverback.php,v 1.1 2007/07/11 09:12:31 tombuskens Exp $
*/
[silverback]
status = "\x9e\x4c\x23\x00\x00\xcePiNG"
require_once GAMEQ_BASE . 'Protocol.php';
/**
* Silverback Engine Protocol
* (Savage)
*
* @author Tom Buskens <t.buskens@deviation.nl>
* @version $Revision: 1.1 $
*/
class GameQ_Protocol_silverback extends GameQ_Protocol
{
/*
* status packet
*/
public function status()
{
while ($this->p->getLength()) {
$var = $this->p->readString("\xFE");
if ($var == 'players') break;
$this->r->add($var, $this->p->readString("\xFF"));
}
$this->players();
}
/*
* player / team data
*/
public function players()
{
$team = '';
$players = 0;
while ($this->p->getLength()) {
if ($this->p->lookAhead() == "\x20") {
$this->p->skip();
$this->r->addPlayer('name', $this->p->readString("\x0a"));
$this->r->addPlayer('team', $team);
++$players;
}
else {
$team = $this->p->readString("\x0a");
if ($team != '--empty--') {
$this->r->addTeam('name', $team);
}
}
}
}
/*
* Merge packets
*/
public function preprocess($packets)
{
// Cut off headers and join packets
$return = '';
foreach ($packets as $packet) {
$return .= substr($packet, 12, strlen($packet) - 13);
}
return $return;
}
}
?>

66
reference/savage/lgsl.txt Normal file
View file

@ -0,0 +1,66 @@
/*----------------------------------------------------------------------------------------------------------\
| |
| [ 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_17(&$server, &$lgsl_need, &$lgsl_fp)
{
//---------------------------------------------------------+
// REFERENCE: http://masterserver.savage.s2games.com
fwrite($lgsl_fp, "\x9e\x4c\x23\x00\x00\xce\x21\x21\x21\x21");
$buffer = fread($lgsl_fp, 4096);
if (!$buffer) { return FALSE; }
//---------------------------------------------------------+
$buffer = substr($buffer, 12); // REMOVE HEADER
while ($key = strtolower(lgsl_cut_string($buffer, 0, "\xFE")))
{
if ($key == "players") { break; }
$value = lgsl_cut_string($buffer, 0, "\xFF");
$value = str_replace("\x00", "", $value);
$value = lgsl_parse_color($value, $server['b']['type']);
$server['e'][$key] = $value;
}
$server['s']['name'] = $server['e']['name']; unset($server['e']['name']);
$server['s']['map'] = $server['e']['world']; unset($server['e']['world']);
$server['s']['players'] = $server['e']['cnum']; unset($server['e']['cnum']);
$server['s']['playersmax'] = $server['e']['cmax']; unset($server['e']['cnum']);
$server['s']['password'] = $server['e']['pass']; unset($server['e']['cnum']);
//---------------------------------------------------------+
$server['t'][0]['name'] = $server['e']['race1'];
$server['t'][1]['name'] = $server['e']['race2'];
$server['t'][2]['name'] = "spectator";
$team_key = -1;
$player_key = 0;
while ($value = lgsl_cut_string($buffer, 0, "\x0a"))
{
if ($value[0] == "\x00") { break; }
if ($value[0] != "\x20") { $team_key++; continue; }
$server['p'][$player_key]['name'] = lgsl_parse_color(substr($value, 1), $server['b']['type']);
$server['p'][$player_key]['team'] = $server['t'][$team_key]['name'];
$player_key++;
}
//---------------------------------------------------------+
return TRUE;
}