mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
Add a ton of reference
This commit is contained in:
parent
473d9544b1
commit
09d9b87ad6
22 changed files with 5115 additions and 4 deletions
109
reference/teeworlds/gameq2.txt
Normal file
109
reference/teeworlds/gameq2.txt
Normal file
|
|
@ -0,0 +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();
|
||||
}
|
||||
}
|
||||
144
reference/teeworlds/qstat.txt
Normal file
144
reference/teeworlds/qstat.txt
Normal file
|
|
@ -0,0 +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;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue