Bf2.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * This file is part of GameQ.
  4. *
  5. * GameQ is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GameQ is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. namespace GameQ\Protocols;
  19. /**
  20. * Class Battlefield 2
  21. *
  22. * @package GameQ\Protocols
  23. * @author Austin Bischoff <[email protected]>
  24. */
  25. class Bf2 extends Gamespy3
  26. {
  27. /**
  28. * String name of this protocol class
  29. *
  30. * @type string
  31. */
  32. protected $name = 'bf2';
  33. /**
  34. * Longer string name of this protocol class
  35. *
  36. * @type string
  37. */
  38. protected $name_long = "Battlefield 2";
  39. /**
  40. * query_port = client_port + 8433
  41. * 29900 = 16567 + 13333
  42. *
  43. * @type int
  44. */
  45. protected $port_diff = 13333;
  46. /**
  47. * The client join link
  48. *
  49. * @type string
  50. */
  51. protected $join_link = "bf2://%s:%d";
  52. /**
  53. * BF2 has a different query packet to send than "normal" Gamespy 3
  54. *
  55. * @var array
  56. */
  57. protected $packets = [
  58. self::PACKET_ALL => "\xFE\xFD\x00\x10\x20\x30\x40\xFF\xFF\xFF\x01",
  59. ];
  60. /**
  61. * Normalize settings for this protocol
  62. *
  63. * @type array
  64. */
  65. protected $normalize = [
  66. // General
  67. 'general' => [
  68. // target => source
  69. 'dedicated' => 'dedicated',
  70. 'gametype' => 'gametype',
  71. 'hostname' => 'hostname',
  72. 'mapname' => 'mapname',
  73. 'maxplayers' => 'maxplayers',
  74. 'numplayers' => 'numplayers',
  75. 'password' => 'password',
  76. ],
  77. // Individual
  78. 'player' => [
  79. 'name' => 'player',
  80. 'kills' => 'score',
  81. 'deaths' => 'deaths',
  82. 'ping' => 'ping',
  83. 'score' => 'score',
  84. ],
  85. 'team' => [
  86. 'name' => 'team',
  87. 'score' => 'score',
  88. ],
  89. ];
  90. }