Skip to content

Commit 780cb31

Browse files
committed
fix query offset handling
1 parent a98ed62 commit 780cb31

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

player-counter/src/Models/GameQuery.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,23 @@ public function eggs(): BelongsToMany
4444
/** @return array<string, mixed> */
4545
public function runQuery(Allocation $allocation): array
4646
{
47-
$ip = is_ipv6($allocation->ip) ? '[' . $allocation->ip . ']' : $allocation->ip;
48-
$port = $allocation->port + ($this->query_port_offset ?? 0);
49-
$host = $ip . ':' . $port;
47+
$host = (is_ipv6($allocation->ip) ? '[' . $allocation->ip . ']' : $allocation->ip) . ':' . $allocation->port;
5048

5149
try {
52-
$gameQ = new GameQ();
53-
54-
$gameQ->addServer([
50+
$data = [
5551
'type' => $this->query_type->value,
5652
'host' => $host,
57-
]);
53+
];
54+
55+
if ($this->query_port_offset) {
56+
$data['options'] = [
57+
'query_port' => $allocation->port + $this->query_port_offset,
58+
];
59+
}
60+
61+
$gameQ = new GameQ();
62+
63+
$gameQ->addServer($data);
5864

5965
$gameQ->setOption('debug', config('app.debug'));
6066

0 commit comments

Comments
 (0)