mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
crlf -> ln conversion
This commit is contained in:
parent
50d3ef20a0
commit
f1467c5a04
94 changed files with 11388 additions and 11388 deletions
|
|
@ -1,65 +1,65 @@
|
|||
<?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: teeworlds.php,v 1.2 2009/03/09 13:36:32 tombuskens Exp $
|
||||
*/
|
||||
|
||||
[teeworlds]
|
||||
status = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFFgief"
|
||||
|
||||
|
||||
require_once GAMEQ_BASE . 'Protocol.php';
|
||||
|
||||
|
||||
/**
|
||||
* Teeworlds protocol
|
||||
*
|
||||
* @author Tom Buskens <t.buskens@deviation.nl>
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class GameQ_Protocol_teeworlds extends GameQ_Protocol
|
||||
{
|
||||
/*
|
||||
* status packet
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$this->p->skip(14);
|
||||
|
||||
$this->r->add('version', $this->p->readString());
|
||||
$this->r->add('hostname', $this->p->readString());
|
||||
$this->r->add('map', $this->p->readString());
|
||||
$this->r->add('gametype', $this->p->readString());
|
||||
|
||||
|
||||
$this->r->add('password', $this->p->readString());
|
||||
$this->r->add('ping', $this->p->readString());
|
||||
$this->r->add('num_players', $this->p->readString());
|
||||
$this->r->add('max_players', $this->p->readString());
|
||||
|
||||
$this->players();
|
||||
}
|
||||
|
||||
private function players()
|
||||
{
|
||||
while ($name = $this->p->readString()) {
|
||||
$this->r->addPlayer('name', $name);
|
||||
$this->r->addPlayer('score', $this->p->readString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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: teeworlds.php,v 1.2 2009/03/09 13:36:32 tombuskens Exp $
|
||||
*/
|
||||
|
||||
[teeworlds]
|
||||
status = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFFgief"
|
||||
|
||||
|
||||
require_once GAMEQ_BASE . 'Protocol.php';
|
||||
|
||||
|
||||
/**
|
||||
* Teeworlds protocol
|
||||
*
|
||||
* @author Tom Buskens <t.buskens@deviation.nl>
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class GameQ_Protocol_teeworlds extends GameQ_Protocol
|
||||
{
|
||||
/*
|
||||
* status packet
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$this->p->skip(14);
|
||||
|
||||
$this->r->add('version', $this->p->readString());
|
||||
$this->r->add('hostname', $this->p->readString());
|
||||
$this->r->add('map', $this->p->readString());
|
||||
$this->r->add('gametype', $this->p->readString());
|
||||
|
||||
|
||||
$this->r->add('password', $this->p->readString());
|
||||
$this->r->add('ping', $this->p->readString());
|
||||
$this->r->add('num_players', $this->p->readString());
|
||||
$this->r->add('max_players', $this->p->readString());
|
||||
|
||||
$this->players();
|
||||
}
|
||||
|
||||
private function players()
|
||||
{
|
||||
while ($name = $this->p->readString()) {
|
||||
$this->r->addPlayer('name', $name);
|
||||
$this->r->addPlayer('score', $this->p->readString());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,109 +1,109 @@
|
|||
<?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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Teeworlds Protocol
|
||||
*
|
||||
* @author Marcel Bößendörfer <m.boessendoerfer@marbis.net>
|
||||
*/
|
||||
class GameQ_Protocols_Teeworlds extends GameQ_Protocols {
|
||||
|
||||
/**
|
||||
* Array of packets we want to look up.
|
||||
* Each key should correspond to a defined method in this or a parent class
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $packets = array(
|
||||
self::PACKET_ALL => "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x67\x69\x65\x33\x05",
|
||||
// 0.5 Packet (not compatible, maybe some wants to implement "Teeworldsold")
|
||||
//self::PACKET_STATUS => "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFFgief",
|
||||
);
|
||||
|
||||
/**
|
||||
* Methods to be run when processing the response(s)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $process_methods = array(
|
||||
"process_all"
|
||||
);
|
||||
|
||||
/**
|
||||
* Default port for this server type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $port = 8303; // Default port, used if not set when instanced
|
||||
|
||||
/**
|
||||
* The protocol being used
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $protocol = 'teeworlds';
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'teeworlds';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name_long = "Teeworlds";
|
||||
|
||||
/*
|
||||
* Internal methods
|
||||
*/
|
||||
|
||||
protected function process_all() {
|
||||
if(!$this->hasValidResponse(self::PACKET_ALL))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
$data = $this->packets_response[self::PACKET_ALL][0];
|
||||
$buf = new GameQ_Buffer($data);
|
||||
$result = new GameQ_Result();
|
||||
$buf->readString();
|
||||
$result->add('version', $buf->readString());
|
||||
$result->add('hostname', $buf->readString());
|
||||
$result->add('map', $buf->readString());
|
||||
$result->add('game_descr', $buf->readString());
|
||||
$result->add('flags', $buf->readString()); // not use about that
|
||||
$result->add('num_players', $buf->readString());
|
||||
$result->add('maxplayers', $buf->readString());
|
||||
$result->add('num_players_total', $buf->readString());
|
||||
$result->add('maxplayers_total', $buf->readString());
|
||||
|
||||
// Players
|
||||
while ($buf->getLength()) {
|
||||
$result->addPlayer('name', $buf->readString());
|
||||
$result->addPlayer('clan', $buf->readString());
|
||||
$result->addPlayer('flag', $buf->readString());
|
||||
$result->addPlayer('score', $buf->readString());
|
||||
$result->addPlayer('team', $buf->readString());
|
||||
}
|
||||
return $result->fetch();
|
||||
}
|
||||
<?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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Teeworlds Protocol
|
||||
*
|
||||
* @author Marcel Bößendörfer <m.boessendoerfer@marbis.net>
|
||||
*/
|
||||
class GameQ_Protocols_Teeworlds extends GameQ_Protocols {
|
||||
|
||||
/**
|
||||
* Array of packets we want to look up.
|
||||
* Each key should correspond to a defined method in this or a parent class
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $packets = array(
|
||||
self::PACKET_ALL => "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x67\x69\x65\x33\x05",
|
||||
// 0.5 Packet (not compatible, maybe some wants to implement "Teeworldsold")
|
||||
//self::PACKET_STATUS => "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFFgief",
|
||||
);
|
||||
|
||||
/**
|
||||
* Methods to be run when processing the response(s)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $process_methods = array(
|
||||
"process_all"
|
||||
);
|
||||
|
||||
/**
|
||||
* Default port for this server type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $port = 8303; // Default port, used if not set when instanced
|
||||
|
||||
/**
|
||||
* The protocol being used
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $protocol = 'teeworlds';
|
||||
|
||||
/**
|
||||
* String name of this protocol class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'teeworlds';
|
||||
|
||||
/**
|
||||
* Longer string name of this protocol class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name_long = "Teeworlds";
|
||||
|
||||
/*
|
||||
* Internal methods
|
||||
*/
|
||||
|
||||
protected function process_all() {
|
||||
if(!$this->hasValidResponse(self::PACKET_ALL))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
$data = $this->packets_response[self::PACKET_ALL][0];
|
||||
$buf = new GameQ_Buffer($data);
|
||||
$result = new GameQ_Result();
|
||||
$buf->readString();
|
||||
$result->add('version', $buf->readString());
|
||||
$result->add('hostname', $buf->readString());
|
||||
$result->add('map', $buf->readString());
|
||||
$result->add('game_descr', $buf->readString());
|
||||
$result->add('flags', $buf->readString()); // not use about that
|
||||
$result->add('num_players', $buf->readString());
|
||||
$result->add('maxplayers', $buf->readString());
|
||||
$result->add('num_players_total', $buf->readString());
|
||||
$result->add('maxplayers_total', $buf->readString());
|
||||
|
||||
// Players
|
||||
while ($buf->getLength()) {
|
||||
$result->addPlayer('name', $buf->readString());
|
||||
$result->addPlayer('clan', $buf->readString());
|
||||
$result->addPlayer('flag', $buf->readString());
|
||||
$result->addPlayer('score', $buf->readString());
|
||||
$result->addPlayer('team', $buf->readString());
|
||||
}
|
||||
return $result->fetch();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +1,54 @@
|
|||
|
||||
/*----------------------------------------------------------------------------------------------------------\
|
||||
| |
|
||||
| [ 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_21(&$server, &$lgsl_need, &$lgsl_fp)
|
||||
{
|
||||
//---------------------------------------------------------+
|
||||
|
||||
fwrite($lgsl_fp,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffgief");
|
||||
|
||||
$buffer = fread($lgsl_fp, 4096);
|
||||
$buffer = substr($buffer, 20); // REMOVE HEADER
|
||||
|
||||
if (!$buffer) { return FALSE; }
|
||||
|
||||
//---------------------------------------------------------+
|
||||
|
||||
$server['s']['name'] = lgsl_cut_string($buffer);
|
||||
$server['s']['map'] = lgsl_cut_string($buffer);
|
||||
$server['e']['gamemode'] = lgsl_cut_string($buffer);
|
||||
$server['s']['password'] = lgsl_cut_string($buffer);
|
||||
$server['e']['progress'] = lgsl_cut_string($buffer)."%";
|
||||
$server['s']['players'] = lgsl_cut_string($buffer);
|
||||
$server['s']['playersmax'] = lgsl_cut_string($buffer);
|
||||
|
||||
switch ($server['e']['gamemode'])
|
||||
{
|
||||
case 0: $server['e']['gamemode'] = "Deathmatch"; break;
|
||||
case 1: $server['e']['gamemode'] = "Team Deathmatch"; break;
|
||||
case 2: $server['e']['gamemode'] = "Capture The Flag"; break;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------+
|
||||
|
||||
$player_key = 0;
|
||||
|
||||
while ($buffer)
|
||||
{
|
||||
$server['p'][$player_key]['name'] = lgsl_cut_string($buffer);
|
||||
$server['p'][$player_key]['score'] = lgsl_cut_string($buffer);
|
||||
|
||||
$player_key ++;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------+
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------\
|
||||
| |
|
||||
| [ 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_21(&$server, &$lgsl_need, &$lgsl_fp)
|
||||
{
|
||||
//---------------------------------------------------------+
|
||||
|
||||
fwrite($lgsl_fp,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffgief");
|
||||
|
||||
$buffer = fread($lgsl_fp, 4096);
|
||||
$buffer = substr($buffer, 20); // REMOVE HEADER
|
||||
|
||||
if (!$buffer) { return FALSE; }
|
||||
|
||||
//---------------------------------------------------------+
|
||||
|
||||
$server['s']['name'] = lgsl_cut_string($buffer);
|
||||
$server['s']['map'] = lgsl_cut_string($buffer);
|
||||
$server['e']['gamemode'] = lgsl_cut_string($buffer);
|
||||
$server['s']['password'] = lgsl_cut_string($buffer);
|
||||
$server['e']['progress'] = lgsl_cut_string($buffer)."%";
|
||||
$server['s']['players'] = lgsl_cut_string($buffer);
|
||||
$server['s']['playersmax'] = lgsl_cut_string($buffer);
|
||||
|
||||
switch ($server['e']['gamemode'])
|
||||
{
|
||||
case 0: $server['e']['gamemode'] = "Deathmatch"; break;
|
||||
case 1: $server['e']['gamemode'] = "Team Deathmatch"; break;
|
||||
case 2: $server['e']['gamemode'] = "Capture The Flag"; break;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------+
|
||||
|
||||
$player_key = 0;
|
||||
|
||||
while ($buffer)
|
||||
{
|
||||
$server['p'][$player_key]['name'] = lgsl_cut_string($buffer);
|
||||
$server['p'][$player_key]['score'] = lgsl_cut_string($buffer);
|
||||
|
||||
$player_key ++;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------+
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,144 +1,144 @@
|
|||
LICENSE: The Artistic License 2.0
|
||||
|
||||
/*
|
||||
* qstat.h
|
||||
* by Steve Jankowski
|
||||
* steve@qstat.org
|
||||
* http://www.qstat.org
|
||||
*
|
||||
* Copyright 1996,1997,1998,1999,2000,2001,2002 by Steve Jankowski
|
||||
*/
|
||||
|
||||
char tee_serverstatus[14] = { '\x20', '\0', '\0', '\0', '\0', '\0', '\xFF', '\xFF', '\xFF', '\xFF', 'g', 'i', 'e', 'f' };
|
||||
|
||||
|
||||
{
|
||||
/* Teeworlds */
|
||||
TEE_SERVER, /* id */
|
||||
"TEE", /* type_prefix */
|
||||
"tee", /* type_string */
|
||||
"-tee", /* type_option */
|
||||
"Teeworlds", /* game_name */
|
||||
0, /* master */
|
||||
35515, /* default_port */
|
||||
0, /* port_offset */
|
||||
0, /* flags */
|
||||
"gametype", /* game_rule */
|
||||
"TEE", /* template_var */
|
||||
tee_serverstatus, /* status_packet */
|
||||
sizeof(tee_serverstatus), /* status_len */
|
||||
NULL, /* player_packet */
|
||||
0, /* player_len */
|
||||
NULL, /* rule_packet */
|
||||
0, /* rule_len */
|
||||
NULL, /* master_packet */
|
||||
0, /* master_len */
|
||||
NULL, /* master_protocol */
|
||||
NULL, /* master_query */
|
||||
display_tee_player_info, /* display_player_func */
|
||||
display_server_rules, /* display_rule_func */
|
||||
raw_display_tee_player_info, /* display_raw_player_func */
|
||||
raw_display_server_rules, /* display_raw_rule_func */
|
||||
xml_display_tee_player_info, /* display_xml_player_func */
|
||||
xml_display_server_rules, /* display_xml_rule_func */
|
||||
send_tee_request_packet, /* status_query_func */
|
||||
NULL, /* rule_query_func */
|
||||
NULL, /* player_query_func */
|
||||
deal_with_tee_packet, /* packet_func */
|
||||
},
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* qstat 2.11
|
||||
* by Steve Jankowski
|
||||
*
|
||||
* Teeworlds protocol
|
||||
* Copyright 2008 ? Emiliano Leporati
|
||||
*
|
||||
* Licensed under the Artistic License, see LICENSE.txt for license terms
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "qstat.h"
|
||||
#include "packet_manip.h"
|
||||
|
||||
char tee_serverinfo[8] = { '\xFF', '\xFF', '\xFF', '\xFF', 'i', 'n', 'f', 'o' };
|
||||
|
||||
query_status_t send_tee_request_packet( struct qserver *server )
|
||||
{
|
||||
return send_packet( server, server->type->status_packet, server->type->status_len );
|
||||
}
|
||||
|
||||
query_status_t deal_with_tee_packet( struct qserver *server, char *rawpkt, int pktlen )
|
||||
{
|
||||
// skip unimplemented ack, crc, etc
|
||||
char *pkt = rawpkt + 6;
|
||||
char *tok = NULL, *version = NULL;
|
||||
int i;
|
||||
struct player* player;
|
||||
|
||||
server->ping_total += time_delta(&packet_recv_time, &server->packet_time1);
|
||||
|
||||
if (0 == memcmp( pkt, tee_serverinfo, 8))
|
||||
{
|
||||
pkt += 8;
|
||||
// version
|
||||
version = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
// server name
|
||||
server->server_name = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
// map name
|
||||
server->map_name = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
// game type
|
||||
switch(atoi(pkt)) {
|
||||
case 0:
|
||||
add_rule( server, server->type->game_rule, "dm", NO_FLAGS);
|
||||
break;
|
||||
case 1:
|
||||
add_rule( server, server->type->game_rule, "tdm", NO_FLAGS);
|
||||
break;
|
||||
case 2:
|
||||
add_rule( server, server->type->game_rule, "ctf", NO_FLAGS);
|
||||
break;
|
||||
default:
|
||||
add_rule( server, server->type->game_rule, "unknown", NO_FLAGS);
|
||||
break;
|
||||
}
|
||||
pkt += strlen(pkt) + 1;
|
||||
pkt += strlen(pkt) + 1;
|
||||
pkt += strlen(pkt) + 1;
|
||||
// num players
|
||||
server->num_players = atoi(pkt); pkt += strlen(pkt) + 1;
|
||||
// max players
|
||||
server->max_players = atoi(pkt); pkt += strlen(pkt) + 1;
|
||||
// players
|
||||
for(i = 0; i < server->num_players; i++)
|
||||
{
|
||||
player = add_player( server, i );
|
||||
player->name = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
player->score = atoi(pkt); pkt += strlen(pkt) + 1;
|
||||
}
|
||||
// version reprise
|
||||
server->protocol_version = 0;
|
||||
|
||||
if (NULL == (tok = strtok(version, "."))) return -1;
|
||||
server->protocol_version |= (atoi(tok) & 0x000F) << 12;
|
||||
if (NULL == (tok = strtok(NULL, "."))) return -1;
|
||||
server->protocol_version |= (atoi(tok) & 0x000F) << 8;
|
||||
if (NULL == (tok = strtok(NULL, "."))) return -1;
|
||||
server->protocol_version |= (atoi(tok) & 0x00FF);
|
||||
|
||||
free(version);
|
||||
|
||||
return DONE_FORCE;
|
||||
}
|
||||
|
||||
// unknown packet type
|
||||
return PKT_ERROR;
|
||||
}
|
||||
|
||||
LICENSE: The Artistic License 2.0
|
||||
|
||||
/*
|
||||
* qstat.h
|
||||
* by Steve Jankowski
|
||||
* steve@qstat.org
|
||||
* http://www.qstat.org
|
||||
*
|
||||
* Copyright 1996,1997,1998,1999,2000,2001,2002 by Steve Jankowski
|
||||
*/
|
||||
|
||||
char tee_serverstatus[14] = { '\x20', '\0', '\0', '\0', '\0', '\0', '\xFF', '\xFF', '\xFF', '\xFF', 'g', 'i', 'e', 'f' };
|
||||
|
||||
|
||||
{
|
||||
/* Teeworlds */
|
||||
TEE_SERVER, /* id */
|
||||
"TEE", /* type_prefix */
|
||||
"tee", /* type_string */
|
||||
"-tee", /* type_option */
|
||||
"Teeworlds", /* game_name */
|
||||
0, /* master */
|
||||
35515, /* default_port */
|
||||
0, /* port_offset */
|
||||
0, /* flags */
|
||||
"gametype", /* game_rule */
|
||||
"TEE", /* template_var */
|
||||
tee_serverstatus, /* status_packet */
|
||||
sizeof(tee_serverstatus), /* status_len */
|
||||
NULL, /* player_packet */
|
||||
0, /* player_len */
|
||||
NULL, /* rule_packet */
|
||||
0, /* rule_len */
|
||||
NULL, /* master_packet */
|
||||
0, /* master_len */
|
||||
NULL, /* master_protocol */
|
||||
NULL, /* master_query */
|
||||
display_tee_player_info, /* display_player_func */
|
||||
display_server_rules, /* display_rule_func */
|
||||
raw_display_tee_player_info, /* display_raw_player_func */
|
||||
raw_display_server_rules, /* display_raw_rule_func */
|
||||
xml_display_tee_player_info, /* display_xml_player_func */
|
||||
xml_display_server_rules, /* display_xml_rule_func */
|
||||
send_tee_request_packet, /* status_query_func */
|
||||
NULL, /* rule_query_func */
|
||||
NULL, /* player_query_func */
|
||||
deal_with_tee_packet, /* packet_func */
|
||||
},
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* qstat 2.11
|
||||
* by Steve Jankowski
|
||||
*
|
||||
* Teeworlds protocol
|
||||
* Copyright 2008 ? Emiliano Leporati
|
||||
*
|
||||
* Licensed under the Artistic License, see LICENSE.txt for license terms
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "qstat.h"
|
||||
#include "packet_manip.h"
|
||||
|
||||
char tee_serverinfo[8] = { '\xFF', '\xFF', '\xFF', '\xFF', 'i', 'n', 'f', 'o' };
|
||||
|
||||
query_status_t send_tee_request_packet( struct qserver *server )
|
||||
{
|
||||
return send_packet( server, server->type->status_packet, server->type->status_len );
|
||||
}
|
||||
|
||||
query_status_t deal_with_tee_packet( struct qserver *server, char *rawpkt, int pktlen )
|
||||
{
|
||||
// skip unimplemented ack, crc, etc
|
||||
char *pkt = rawpkt + 6;
|
||||
char *tok = NULL, *version = NULL;
|
||||
int i;
|
||||
struct player* player;
|
||||
|
||||
server->ping_total += time_delta(&packet_recv_time, &server->packet_time1);
|
||||
|
||||
if (0 == memcmp( pkt, tee_serverinfo, 8))
|
||||
{
|
||||
pkt += 8;
|
||||
// version
|
||||
version = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
// server name
|
||||
server->server_name = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
// map name
|
||||
server->map_name = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
// game type
|
||||
switch(atoi(pkt)) {
|
||||
case 0:
|
||||
add_rule( server, server->type->game_rule, "dm", NO_FLAGS);
|
||||
break;
|
||||
case 1:
|
||||
add_rule( server, server->type->game_rule, "tdm", NO_FLAGS);
|
||||
break;
|
||||
case 2:
|
||||
add_rule( server, server->type->game_rule, "ctf", NO_FLAGS);
|
||||
break;
|
||||
default:
|
||||
add_rule( server, server->type->game_rule, "unknown", NO_FLAGS);
|
||||
break;
|
||||
}
|
||||
pkt += strlen(pkt) + 1;
|
||||
pkt += strlen(pkt) + 1;
|
||||
pkt += strlen(pkt) + 1;
|
||||
// num players
|
||||
server->num_players = atoi(pkt); pkt += strlen(pkt) + 1;
|
||||
// max players
|
||||
server->max_players = atoi(pkt); pkt += strlen(pkt) + 1;
|
||||
// players
|
||||
for(i = 0; i < server->num_players; i++)
|
||||
{
|
||||
player = add_player( server, i );
|
||||
player->name = strdup(pkt); pkt += strlen(pkt) + 1;
|
||||
player->score = atoi(pkt); pkt += strlen(pkt) + 1;
|
||||
}
|
||||
// version reprise
|
||||
server->protocol_version = 0;
|
||||
|
||||
if (NULL == (tok = strtok(version, "."))) return -1;
|
||||
server->protocol_version |= (atoi(tok) & 0x000F) << 12;
|
||||
if (NULL == (tok = strtok(NULL, "."))) return -1;
|
||||
server->protocol_version |= (atoi(tok) & 0x000F) << 8;
|
||||
if (NULL == (tok = strtok(NULL, "."))) return -1;
|
||||
server->protocol_version |= (atoi(tok) & 0x00FF);
|
||||
|
||||
free(version);
|
||||
|
||||
return DONE_FORCE;
|
||||
}
|
||||
|
||||
// unknown packet type
|
||||
return PKT_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue