Rust.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /**
  21. * Class Rust
  22. *
  23. * @package GameQ\Protocols
  24. * @author Austin Bischoff <[email protected]>
  25. */
  26. class Rust extends Source
  27. {
  28. /**
  29. * String name of this protocol class
  30. *
  31. * @type string
  32. */
  33. protected $name = 'rust';
  34. /**
  35. * Longer string name of this protocol class
  36. *
  37. * @type string
  38. */
  39. protected $name_long = "Rust";
  40. /**
  41. * Overload so we can get max players from mp of keywords and num players from cp keyword
  42. *
  43. * @param Buffer $buffer
  44. */
  45. protected function processDetails(Buffer $buffer)
  46. {
  47. $results = parent::processDetails($buffer);
  48. if ($results['keywords']) {
  49. //get max players from mp of keywords and num players from cp keyword
  50. preg_match_all('/(mp|cp)([\d]+)/', $results['keywords'], $matches);
  51. $results['max_players'] = intval($matches[2][0]);
  52. $results['num_players'] = intval($matches[2][1]);
  53. }
  54. return $results;
  55. }
  56. }