| 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 function is_int; |
| 16: | use function is_string; |
| 17: | use Clansuite\Capture\Protocol\ProtocolInterface; |
| 18: | use Clansuite\Capture\ServerAddress; |
| 19: | use Clansuite\Capture\ServerInfo; |
| 20: | use Override; |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | class DayOfDefeatSource extends Steam implements ProtocolInterface |
| 31: | { |
| 32: | |
| 33: | |
| 34: | |
| 35: | public string $name = 'Day of Defeat: Source'; |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | public array $supportedGames = ['Day of Defeat: Source']; |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | public string $protocol = 'dods'; |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public array $game_series_list = ['Day of Defeat']; |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | protected int $port_diff = 0; |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | public function __construct(mixed $address = null, mixed $queryport = null) |
| 65: | { |
| 66: | parent::__construct((is_string($address) ? $address : null), (is_int($queryport) ? $queryport : null)); |
| 67: | } |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | #[Override] |
| 73: | public function getNativeJoinURI(): string |
| 74: | { |
| 75: | return 'steam://connect/' . $this->address . ':' . $this->hostport; |
| 76: | } |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | #[Override] |
| 82: | public function query(ServerAddress $addr): ServerInfo |
| 83: | { |
| 84: | $this->address = $addr->ip; |
| 85: | $this->queryport = $addr->port; |
| 86: | $this->query_server(true, true); |
| 87: | |
| 88: | return new ServerInfo( |
| 89: | address: $this->address, |
| 90: | queryport: $this->queryport, |
| 91: | online: $this->online, |
| 92: | gamename: $this->gamename, |
| 93: | gameversion: $this->gameversion, |
| 94: | servertitle: $this->servertitle, |
| 95: | mapname: $this->mapname, |
| 96: | gametype: $this->gametype, |
| 97: | numplayers: $this->numplayers, |
| 98: | maxplayers: $this->maxplayers, |
| 99: | rules: $this->rules, |
| 100: | players: $this->players, |
| 101: | errstr: $this->errstr, |
| 102: | ); |
| 103: | } |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: | #[Override] |
| 109: | public function getProtocolName(): string |
| 110: | { |
| 111: | return $this->protocol; |
| 112: | } |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | #[Override] |
| 118: | public function getVersion(ServerInfo $info): string |
| 119: | { |
| 120: | return $info->gameversion ?? 'unknown'; |
| 121: | } |
| 122: | } |
| 123: | |