feat: port_query_offset can now handle arrays of numbers

This commit is contained in:
Pedro Ivo Hudson 2024-01-16 15:46:01 -03:00
parent 107024e5d1
commit bf42ddaeff
2 changed files with 20 additions and 6 deletions

View File

@ -28,7 +28,6 @@ export default class QueryRunner {
const {
port_query: gameQueryPort,
port_query_offset: gameQueryPortOffset,
port_query_offset_alt: gameQueryPortOffsetAlt,
...gameOptions
} = lookup(userOptions.type)
const attempts = []
@ -48,18 +47,34 @@ export default class QueryRunner {
if (userOptions.port) {
if (!userOptions.givenPortOnly) {
if (gameQueryPortOffset) {addAttemptWithPort(userOptions.port + gameQueryPortOffset) }
if (gameQueryPortOffsetAlt) { addAttemptWithPort(userOptions.port + gameQueryPortOffsetAlt) }
if (gameQueryPortOffset) {
if (Array.isArray(gameQueryPortOffset)) {
gameQueryPortOffset.forEach((portOffset) => addAttemptWithPort(userOptions.port + portOffset))
} else {
addAttemptWithPort(userOptions.port + gameQueryPortOffset)
}
}
if (userOptions.port === gameOptions.port && gameQueryPort) { addAttemptWithPort(gameQueryPort) }
}
attempts.push(optionsCollection)
} else if (gameQueryPort) {
addAttemptWithPort(gameQueryPort)
} else if (gameOptions.port) {
addAttemptWithPort(gameOptions.port + (gameQueryPortOffset || 0))
if (gameQueryPortOffset) {
if (Array.isArray(gameQueryPortOffset)) {
gameQueryPortOffset.forEach((portOffset) => addAttemptWithPort(userOptions.port + portOffset))
} else {
addAttemptWithPort(userOptions.port + gameQueryPortOffset)
}
} else {
addAttemptWithPort(userOptions.port)
}
} else {
// Hopefully the request doesn't need a port. If it does, it'll fail when making the request.
attempts.push(optionsCollection)

View File

@ -2656,8 +2656,7 @@ export const games = {
name: 'V Rising',
options: {
port: 27015,
port_query_offset: 1,
port_query_offset_alt: 15,
port_query_offset: [1, 15],
protocol: 'valve'
},
release_year: 2022