Killingfloor.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. use GameQ\Buffer;
  20. use GameQ\Result;
  21. /**
  22. * Class Killing floor
  23. *
  24. * @package GameQ\Protocols
  25. * @author Austin Bischoff <[email protected]>
  26. */
  27. class Killingfloor extends Unreal2
  28. {
  29. /**
  30. * String name of this protocol class
  31. *
  32. * @type string
  33. */
  34. protected $name = 'killing floor';
  35. /**
  36. * Longer string name of this protocol class
  37. *
  38. * @type string
  39. */
  40. protected $name_long = "Killing Floor";
  41. /**
  42. * query_port = client_port + 1
  43. *
  44. * @type int
  45. */
  46. protected $port_diff = 1;
  47. /**
  48. * The client join link
  49. *
  50. * @type string
  51. */
  52. protected $join_link = "steam://connect/%s:%d/";
  53. /**
  54. * Overload the default detail process since this version is different
  55. *
  56. * @param \GameQ\Buffer $buffer
  57. *
  58. * @return array
  59. */
  60. protected function processDetails(Buffer $buffer)
  61. {
  62. // Set the result to a new result instance
  63. $result = new Result();
  64. $result->add('serverid', $buffer->readInt32()); // 0
  65. $result->add('serverip', $buffer->readPascalString(1)); // empty
  66. $result->add('gameport', $buffer->readInt32());
  67. $result->add('queryport', $buffer->readInt32()); // 0
  68. // We burn the first char since it is not always correct with the hostname
  69. $buffer->skip(1);
  70. // Read as a regular string since the length is incorrect (what we skipped earlier)
  71. $result->add('servername', utf8_encode($buffer->readString()));
  72. // The rest is read as normal
  73. $result->add('mapname', utf8_encode($buffer->readPascalString(1)));
  74. $result->add('gametype', $buffer->readPascalString(1));
  75. $result->add('numplayers', $buffer->readInt32());
  76. $result->add('maxplayers', $buffer->readInt32());
  77. $result->add('currentwave', $buffer->readInt32());
  78. unset($buffer);
  79. return $result->fetch();
  80. }
  81. }