-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Battlefield 2 support. Fixes #317
- Loading branch information
Showing
8 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?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 Lesser 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 Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace GameQ\Protocols; | ||
|
||
/** | ||
* Class Battlefield 2 | ||
* | ||
* @package GameQ\Protocols | ||
* @author Austin Bischoff <austin@codebeard.com> | ||
*/ | ||
class Bf2 extends Gamespy3 | ||
{ | ||
|
||
/** | ||
* String name of this protocol class | ||
* | ||
* @type string | ||
*/ | ||
protected $name = 'bf2'; | ||
|
||
/** | ||
* Longer string name of this protocol class | ||
* | ||
* @type string | ||
*/ | ||
protected $name_long = "Battlefield 2"; | ||
|
||
/** | ||
* query_port = client_port + 8433 | ||
* 29900 = 16567 + 13333 | ||
* | ||
* @type int | ||
*/ | ||
protected $port_diff = 13333; | ||
|
||
/** | ||
* The client join link | ||
* | ||
* @type string | ||
*/ | ||
protected $join_link = "bf2://%s:%d"; | ||
|
||
/** | ||
* BF2 has a different query packet to send than "normal" Gamespy 3 | ||
* | ||
* @var array | ||
*/ | ||
protected $packets = [ | ||
self::PACKET_ALL => "\xFE\xFD\x00\x10\x20\x30\x40\xFF\xFF\xFF\x01", | ||
]; | ||
|
||
/** | ||
* Normalize settings for this protocol | ||
* | ||
* @type array | ||
*/ | ||
protected $normalize = [ | ||
// General | ||
'general' => [ | ||
// target => source | ||
'dedicated' => 'dedicated', | ||
'gametype' => 'gametype', | ||
'hostname' => 'hostname', | ||
'mapname' => 'mapname', | ||
'maxplayers' => 'maxplayers', | ||
'numplayers' => 'numplayers', | ||
'password' => 'password', | ||
], | ||
// Individual | ||
'player' => [ | ||
'name' => 'player', | ||
'kills' => 'score', | ||
'deaths' => 'deaths', | ||
'ping' => 'ping', | ||
'score' => 'score', | ||
], | ||
'team' => [ | ||
'name' => 'team', | ||
'score' => 'score', | ||
], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?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 Lesser 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 Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace GameQ\Tests\Protocols; | ||
|
||
class Bf2 extends Base | ||
{ | ||
|
||
/** | ||
* Test responses for Battlefield 2 | ||
* | ||
* @dataProvider loadData | ||
* | ||
* @param $responses | ||
* @param $result | ||
*/ | ||
public function testResponses($responses, $result) | ||
{ | ||
|
||
// Pull the first key off the array this is the server ip:port | ||
$server = key($result); | ||
|
||
$testResult = $this->queryTest( | ||
$server, | ||
'bf2', | ||
$responses | ||
); | ||
|
||
$this->assertEquals($result[$server], $testResult); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"31.186.250.205:16567":{"bf2_anticheat":"1","bf2_autobalanced":"1","bf2_autorec":"1","bf2_bots":"0","bf2_communitylogo_url":"http:\/\/www.superinfantryclan.com\/bf2\/109338097-superbf2.jpg","bf2_coopbotcount":"","bf2_coopbotdiff":"","bf2_coopbotratio":"","bf2_d_dl":"http:\/\/pb.superinfantryclan.com\/servers\/bf2-s1dm\/","bf2_d_idx":"http:\/\/pb.superinfantryclan.com\/servers\/bf2-s1dm\/","bf2_dedicated":"1","bf2_fps":"36.000000","bf2_friendlyfire":"0","bf2_globalunlocks":"1","bf2_mapsize":"64","bf2_novehicles":"1","bf2_os":"linux-64","bf2_plasma":"0","bf2_pure":"1","bf2_ranked":"1","bf2_reservedslots":"0","bf2_scorelimit":"0","bf2_spawntime":"15.000000","bf2_sponsorlogo_url":"http:\/\/www.superinfantryclan.com\/bf2\/109338097-superbf2.jpg","bf2_sponsortext":"www.superinfantryclan.com","bf2_startdelay":"15","bf2_team1":"MEC","bf2_team2":"US","bf2_teamratio":"100.000000","bf2_ticketratio":"100","bf2_tkmode":"No Punish","bf2_voip":"1","gamemode":"openplaying","gamename":"battlefield2","gametype":"gpm_cq","gamevariant":"bf2","gamever":"1.5.3153-802.0","gq_address":"31.186.250.205","gq_joinlink":"bf2:\/\/31.186.250.205:16567","gq_name":"Battlefield 2","gq_online":true,"gq_port_client":16567,"gq_port_query":29900,"gq_protocol":"gamespy3","gq_transport":"udp","gq_type":"bf2","hostname":"SUPER@ - S1 Strike at Karkand Infantry Only","hostport":"16567","mapname":"Strike At Karkand","maxplayers":"64","numplayers":"54","password":"0","players":[{"player":"Deniko_pirliko_BiH","score":"90","ping":"26","team":"2","deaths":"5","pid":"1164362","skill":"21","AIBot":"0"},{"player":"Mr.Untraceable","score":"70","ping":"38","team":"1","deaths":"5","pid":"1162172","skill":"23","AIBot":"0"},{"player":"Rememberme?","score":"68","ping":"42","team":"1","deaths":"4","pid":"500088692","skill":"20","AIBot":"0"},{"player":"[LRRP]Snipersonic","score":"65","ping":"30","team":"2","deaths":"13","pid":"1114130","skill":"22","AIBot":"0"},{"player":"snake4u","score":"59","ping":"53","team":"2","deaths":"11","pid":"1070430","skill":"19","AIBot":"0"},{"player":"canptainx","score":"57","ping":"26","team":"1","deaths":"6","pid":"1053398","skill":"14","AIBot":"0"},{"player":"beyonD|willibalD","score":"53","ping":"27","team":"1","deaths":"7","pid":"447339954","skill":"26","AIBot":"0"},{"player":"Tomcrafd","score":"50","ping":"42","team":"2","deaths":"10","pid":"482738578","skill":"11","AIBot":"0"},{"player":"Sniper14","score":"49","ping":"151","team":"2","deaths":"13","pid":"1229457","skill":"12","AIBot":"0"},{"player":"#Inf Hyvaeae_paeivaeae","score":"48","ping":"40","team":"2","deaths":"6","pid":"1164781","skill":"11","AIBot":"0"},{"player":"maximus1111","score":"44","ping":"59","team":"1","deaths":"9","pid":"1143006","skill":"6","AIBot":"0"},{"player":"givemeyourbest1","score":"43","ping":"86","team":"1","deaths":"7","pid":"1305448","skill":"18","AIBot":"0"},{"player":"Pegas_55rus","score":"40","ping":"86","team":"2","deaths":"12","pid":"1270274","skill":"11","AIBot":"0"},{"player":"ullly_Dobpa.~","score":"38","ping":"87","team":"1","deaths":"4","pid":"1007608","skill":"4","AIBot":"0"},{"player":"100% Lexilium_bih","score":"38","ping":"55","team":"2","deaths":"0","pid":"1067266","skill":"0","AIBot":"0"},{"player":"Tonald_Drump_2k16","score":"36","ping":"77","team":"1","deaths":"8","pid":"1233964","skill":"14","AIBot":"0"},{"player":"=SG= FUQhax","score":"34","ping":"122","team":"1","deaths":"12","pid":"1272903","skill":"13","AIBot":"0"},{"player":"Bi0nic(GhostKid)","score":"33","ping":"62","team":"2","deaths":"2","pid":"441168429","skill":"16","AIBot":"0"},{"player":"N3x","score":"33","ping":"14","team":"1","deaths":"8","pid":"1317778","skill":"5","AIBot":"0"},{"player":"BeLaRUS-1988","score":"32","ping":"62","team":"2","deaths":"8","pid":"1048174","skill":"5","AIBot":"0"},{"player":"corn_syrup","score":"31","ping":"111","team":"2","deaths":"3","pid":"1021430","skill":"11","AIBot":"0"},{"player":"aahnz","score":"30","ping":"22","team":"1","deaths":"7","pid":"1317660","skill":"2","AIBot":"0"},{"player":"sam0ht","score":"29","ping":"7","team":"2","deaths":"2","pid":"1131805","skill":"15","AIBot":"0"},{"player":"BlackBull33","score":"27","ping":"27","team":"1","deaths":"4","pid":"1289858","skill":"8","AIBot":"0"},{"player":"hekutooo","score":"27","ping":"52","team":"2","deaths":"8","pid":"1269541","skill":"7","AIBot":"0"},{"player":"Bl4ck^Sun","score":"25","ping":"51","team":"2","deaths":"9","pid":"1261912","skill":"11","AIBot":"0"},{"player":"LICZER COMAN07","score":"25","ping":"468","team":"2","deaths":"14","pid":"1273269","skill":"8","AIBot":"0"},{"player":"KarniksCCCP","score":"24","ping":"53","team":"2","deaths":"8","pid":"1172761","skill":"6","AIBot":"0"},{"player":"BRKOLOL","score":"21","ping":"35","team":"1","deaths":"13","pid":"1178284","skill":"6","AIBot":"0"},{"player":"spoofer27","score":"19","ping":"115","team":"2","deaths":"7","pid":"1259397","skill":"5","AIBot":"0"},{"player":"zmaj111ss","score":"18","ping":"43","team":"2","deaths":"8","pid":"1318624","skill":"9","AIBot":"0"},{"player":"PempekPalembang","score":"18","ping":"214","team":"1","deaths":"15","pid":"1316864","skill":"6","AIBot":"0"},{"player":"Gamers.Anonymous","score":"17","ping":"53","team":"1","deaths":"6","pid":"1318165","skill":"5","AIBot":"0"},{"player":"BL@cK boky1122","score":"16","ping":"54","team":"1","deaths":"8","pid":"1288033","skill":"4","AIBot":"0"},{"player":"KOFF94","score":"14","ping":"55","team":"1","deaths":"5","pid":"1295618","skill":"5","AIBot":"0"},{"player":"slakic slakicar","score":"14","ping":"50","team":"2","deaths":"8","pid":"1312593","skill":"5","AIBot":"0"},{"player":"Arca","score":"8","ping":"57","team":"1","deaths":"10","pid":"1267400","skill":"4","AIBot":"0"},{"player":"Raptor25","score":"7","ping":"178","team":"2","deaths":"2","pid":"1310891","skill":"3","AIBot":"0"},{"player":"#Inf Revive|Mawr","score":"7","ping":"33","team":"1","deaths":"0","pid":"500088450","skill":"1","AIBot":"0"},{"player":"II_Bratishka_II","score":"6","ping":"37","team":"1","deaths":"0","pid":"1252416","skill":"3","AIBot":"0"},{"player":"tenik","score":"6","ping":"22","team":"2","deaths":"3","pid":"1289493","skill":"3","AIBot":"0"},{"player":"chrissel123","score":"6","ping":"39","team":"2","deaths":"2","pid":"1291452","skill":"2","AIBot":"0"},{"player":"kvk8550","score":"6","ping":"49","team":"2","deaths":"2","pid":"1304925","skill":"2","AIBot":"0"},{"player":"SekerEnes","score":"4","ping":"36","team":"1","deaths":"4","pid":"1271080","skill":"2","AIBot":"0"},{"player":"ardvw","score":"4","ping":"33","team":"1","deaths":"7","pid":"1270304","skill":"2","AIBot":"0"},{"player":"Kecske16","score":"4","ping":"28","team":"1","deaths":"8","pid":"1280227","skill":"1","AIBot":"0"},{"player":"antlolq","score":"1","ping":"26","team":"1","deaths":"1","pid":"1144670","skill":"0","AIBot":"0"},{"player":"RomanBN","score":"0","ping":"86","team":"1","deaths":"0","pid":"1263065","skill":"0","AIBot":"0"},{"player":"nikhomes","score":"0","ping":"27","team":"2","deaths":"0","pid":"1176651","skill":"0","AIBot":"0"},{"player":"Tamtam13","score":"0","ping":"42","team":"2","deaths":"0","pid":"1272249","skill":"0","AIBot":"0"},{"player":"Satido","score":"0","ping":"53","team":"1","deaths":"0","pid":"63902872","skill":"0","AIBot":"0"},{"player":"KyOkUsHiN.OBi","score":"0","ping":"139","team":"2","deaths":"0","pid":"1247612","skill":"0","AIBot":"0"},{"player":"SUPER@ GerEliteSteff_2.","score":"0","ping":"24","team":"2","deaths":"0","pid":"479665451","skill":"0","AIBot":"0"},{"player":"michasio","score":"0","ping":"38","team":"1","deaths":"0","pid":"1293319","skill":"0","AIBot":"0"}],"roundtime":"99","teams":[{"team":"MEC","score":"0"},{"team":"US","score":"0"}],"timelimit":"0"}} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"108.61.88.95:16567":{"bf2_anticheat":"0","bf2_autobalanced":"0","bf2_autorec":"1","bf2_bots":"0","bf2_communitylogo_url":"http:\/\/www.hardcoregaming.org\/","bf2_coopbotcount":"","bf2_coopbotdiff":"","bf2_coopbotratio":"","bf2_d_dl":"http:\/\/108.61.88.96\/demos\/.index.php","bf2_d_idx":"http:\/\/108.61.88.96\/demos\/.index.php","bf2_dedicated":"1","bf2_fps":"34.000000","bf2_friendlyfire":"1","bf2_globalunlocks":"1","bf2_mapsize":"64","bf2_novehicles":"0","bf2_os":"linux-64","bf2_plasma":"0","bf2_pure":"0","bf2_ranked":"0","bf2_reservedslots":"0","bf2_scorelimit":"1000","bf2_spawntime":"300.000000","bf2_sponsorlogo_url":"http:\/\/i.imgur.com\/uLm15H6.jpg","bf2_sponsortext":"=]H[= HARDCORE GAMING| |Website: www.hardcoregaming.org|TS3: ts.hardcoregaming.org:8990|Rules: www.hardcoregaming.org\/serverrules||- Al Basrah Insurgency Alt","bf2_startdelay":"210","bf2_team1":"MEInsurgent","bf2_team2":"US","bf2_teamratio":"100.000000","bf2_ticketratio":"100","bf2_tkmode":"No Punish","bf2_voip":"0","gamemode":"openplaying","gamename":"battlefield2","gametype":"gpm_insurgency","gamevariant":"pr","gamever":"1.5.3153-802.0","gq_address":"108.61.88.95","gq_joinlink":"bf2:\/\/108.61.88.95:16567","gq_name":"Battlefield 2","gq_online":true,"gq_port_client":16567,"gq_port_query":29900,"gq_protocol":"gamespy3","gq_transport":"udp","gq_type":"bf2","hostname":"[PR v1.3.9.0] =]H[= HARDCORE GAMING - 2INS\/2AAS - NA","hostport":"16567","mapname":"Fallujah West","maxplayers":"100","numplayers":"1","password":"0","players":[{"player":"=]H[= Eskil_swe","score":"99","ping":"106","team":"2","deaths":"0","pid":"100000205","skill":"0","AIBot":"0"}],"roundtime":"1","teams":[{"team":"MEInsurgent","score":"0"},{"team":"US","score":"0"}],"timelimit":"14400"}} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"178.63.57.115:16567":{"bf2_anticheat":"0","bf2_autobalanced":"1","bf2_autorec":"1","bf2_bots":"0","bf2_communitylogo_url":"http:\/\/merkpr.co.uk","bf2_coopbotcount":"","bf2_coopbotdiff":"","bf2_coopbotratio":"","bf2_d_dl":"ftp:\/\/prftp:merk@178.63.57.115\/battlerecorder\/","bf2_d_idx":"ftp:\/\/prftp:merk@178.63.57.115\/battlerecorder\/","bf2_dedicated":"1","bf2_fps":"36.000000","bf2_friendlyfire":"1","bf2_globalunlocks":"1","bf2_mapsize":"16","bf2_novehicles":"0","bf2_os":"linux-64","bf2_plasma":"0","bf2_pure":"0","bf2_ranked":"0","bf2_reservedslots":"10","bf2_scorelimit":"1000","bf2_spawntime":"300.000000","bf2_sponsorlogo_url":"http:\/\/files.enjin.com\/39200\/module_header\/39273557\/background\/header-300x50.jpg","bf2_sponsortext":"Welcome to MeRk Servers!|Full list of rules on our website www.merkpr.co.uk|2 Pounds Per Month Reserve Slots|SL's MUST communicate and collaborate with others!|Free MeRk Public Teamspeak 178.63.57.115:9988|Free To All Public\/Clan's To Use|http:\/\/www.teamspeak.com\/invite\/178.63.57.115\/?port=9988","bf2_startdelay":"240","bf2_team1":"MEInsurgent","bf2_team2":"GB","bf2_teamratio":"100.000000","bf2_ticketratio":"100","bf2_tkmode":"Punish","bf2_voip":"0","gamemode":"openplaying","gamename":"battlefield2","gametype":"gpm_skirmish","gamevariant":"pr","gamever":"1.5.3153-802.0","gq_address":"178.63.57.115","gq_joinlink":"bf2:\/\/178.63.57.115:16567","gq_name":"Battlefield 2","gq_online":true,"gq_port_client":16567,"gq_port_query":29900,"gq_protocol":"gamespy3","gq_transport":"udp","gq_type":"bf2","hostname":"[PR v1.3.9.0] *** =MeRk= REALITY TEAMWORK -EU- ***","hostport":"16567","mapname":"Al Basrah","maxplayers":"100","numplayers":"0","password":"0","roundtime":"1","teams":[{"team":"MEInsurgent","score":"0"},{"team":"GB","score":"0"}],"timelimit":"14400"}} |