Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add requestPlayers option #624

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Fix: `Deus Ex` using the wrong protocol (#621)
* Fix: `Soldier ff Fortune` using the wrong protocol (#623)
* Feat: For the Quake2 protocol `version`'s field, also look for `version` in the raw object
* Feat: Add option `requestPlayers`, defaults to `true`.

## 5.1.2
* Added Vintage Story support via the master server (#606)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Confused on how this works, or you want to see more? Checkout the [examples](/ex
| **ipFamily** | number | 0 | IP family/version returned when looking up hostnames via DNS, can be 0 (IPv4 and IPv6), 4 (IPv4 only) or 6 (IPv6 only). |
| **debug** | boolean | false | Enables massive amounts of debug logging to stdout. |
| **requestRules** | boolean | false | Valve games only. Additional 'rules' may be fetched into the `raw` key. |
| **requestPlayers** | boolean | true | Valve games only. Disable this if you don't want to fetch players data. |
| **requestRulesRequired** | boolean | false | Valve games only. `requestRules` is always required to have a response or the query will timeout. |
| **requestPlayersRequired** | boolean | false | Valve games only. Querying players is always required to have a response or the query will timeout. Some [games](GAMES_LIST.md) may not provide a players response. |
| **stripColors** | boolean | true | Enables stripping colors for protocols: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron. |
Expand Down
5 changes: 3 additions & 2 deletions bin/gamedig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import Minimist from 'minimist'
import { GameDig } from './../lib/index.js'

const argv = Minimist(process.argv.slice(2), {
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'],
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestPlayers', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'],
string: ['guildId', 'serverId', 'listenUdpPort', 'ipFamily', 'token'],
default: {
stripColors: true,
portCache: true
portCache: true,
requestPlayers: true
}
})

Expand Down
3 changes: 2 additions & 1 deletion lib/QueryRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const defaultOptions = {
stripColors: true,
portCache: true,
noBreadthOrder: false,
ipFamily: 0
ipFamily: 0,
requestPlayers: true
}

export default class QueryRunner {
Expand Down
4 changes: 4 additions & 0 deletions protocols/valve.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export default class valve extends Core {
async queryPlayers (/** Results */ state) {
state.raw.players = []

if (!this.options.requestPlayers) {
return
}

this.logger.debug('Requesting player list ...')
const b = await this.sendPacket(
this.goldsrcInfo ? undefined : 0x55,
Expand Down
Loading