| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | namespace Clansuite\ServerQuery\ServerProtocols; |
| 14: | |
| 15: | use Clansuite\Capture\Protocol\ProtocolInterface; |
| 16: | use Clansuite\Capture\ServerAddress; |
| 17: | use Clansuite\Capture\ServerInfo; |
| 18: | use Override; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | class Dayz extends Steam implements ProtocolInterface |
| 27: | { |
| 28: | |
| 29: | |
| 30: | |
| 31: | public string $name = 'DayZ'; |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | public array $supportedGames = ['DayZ']; |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | public string $protocol = 'dayz'; |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | #[Override] |
| 51: | public function query_server(bool $getPlayers = true, bool $getRules = true): bool |
| 52: | { |
| 53: | $result = parent::query_server($getPlayers, $getRules); |
| 54: | |
| 55: | if ($result) { |
| 56: | |
| 57: | |
| 58: | $this->hostport = ($this->queryport ?? 0) - 2714; |
| 59: | } |
| 60: | |
| 61: | return $result; |
| 62: | } |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | #[Override] |
| 68: | public function query(ServerAddress $addr): ServerInfo |
| 69: | { |
| 70: | $this->address = $addr->ip; |
| 71: | $this->queryport = $addr->port; |
| 72: | $this->query_server(true, true); |
| 73: | |
| 74: | return new ServerInfo( |
| 75: | address: $this->address, |
| 76: | queryport: $this->queryport, |
| 77: | online: $this->online, |
| 78: | gamename: $this->gamename, |
| 79: | gameversion: $this->gameversion, |
| 80: | servertitle: $this->servertitle, |
| 81: | mapname: $this->mapname, |
| 82: | gametype: $this->gametype, |
| 83: | numplayers: $this->numplayers, |
| 84: | maxplayers: $this->maxplayers, |
| 85: | rules: $this->rules ?? [], |
| 86: | players: $this->players ?? [], |
| 87: | errstr: $this->errstr, |
| 88: | ); |
| 89: | } |
| 90: | |
| 91: | |
| 92: | |
| 93: | |
| 94: | #[Override] |
| 95: | public function getProtocolName(): string |
| 96: | { |
| 97: | return $this->protocol; |
| 98: | } |
| 99: | |
| 100: | |
| 101: | |
| 102: | |
| 103: | #[Override] |
| 104: | public function getVersion(ServerInfo $info): string |
| 105: | { |
| 106: | return $info->gameversion ?? 'unknown'; |
| 107: | } |
| 108: | } |
| 109: | |