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 checking for older GIDs #496

Merged
merged 35 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e857ade
feat: add new games.extra.old_id
podrivo Jan 21, 2024
48022de
add extra.old_id; standard release_year
podrivo Jan 21, 2024
db6d84c
add option dontCheckOldIDs
podrivo Jan 21, 2024
7b5b0f0
update naming, README, CHANGELOG
podrivo Jan 21, 2024
f5635ae
Update CONTRIBUTING.md
podrivo Jan 21, 2024
4b49063
fix games.js
podrivo Jan 21, 2024
07969d7
add tool for checking duplicates
podrivo Jan 21, 2024
e3bdfdc
update GAMES_LIST
podrivo Jan 21, 2024
bade0b1
fix anchor links
podrivo Jan 21, 2024
26cb8ae
fix notes in generated game list
podrivo Jan 21, 2024
0bd15be
Update GAMES_LIST.md
podrivo Jan 21, 2024
9443737
Update GAMES_LIST.md
podrivo Jan 21, 2024
29eb072
add Game Object Example in CONTRIBUTING
podrivo Jan 21, 2024
fcbb76f
Update find_id_duplicates.js
podrivo Jan 21, 2024
31e0646
check skipOldIDs only once
podrivo Jan 21, 2024
485a630
remove old ids; tweaks GAMES_LIST
podrivo Jan 21, 2024
f6d636e
add MIGRATION document WIP
podrivo Jan 21, 2024
849d83e
Merge branch 'master' into feat/gid-new-old
podrivo Jan 21, 2024
1c52bbb
Update GAMES_LIST.md
podrivo Jan 21, 2024
2bfac17
update Halo Online name
podrivo Jan 21, 2024
a028ea7
revert changes tool/generate
podrivo Jan 21, 2024
24d8ced
remove extra line
podrivo Jan 21, 2024
c332804
Update GAMES_LIST.md
podrivo Jan 21, 2024
452e39d
roll back GAME_LIST
podrivo Jan 21, 2024
90a965b
Update GAMES_LIST.md
podrivo Jan 21, 2024
a1a987c
OMG
podrivo Jan 21, 2024
4d3bcc3
WAT
podrivo Jan 21, 2024
db26c0e
ok... hopefully the last change
podrivo Jan 21, 2024
84e3caa
Update GAMES_LIST.md
podrivo Jan 21, 2024
5bd2429
add MIGRATION ids
podrivo Jan 22, 2024
18bdb01
roll back CONTRIBUTING
podrivo Jan 22, 2024
c591341
Update CHANGELOG.md
podrivo Jan 22, 2024
54cf785
update skipOldIDs to checkOldIDs
podrivo Jan 22, 2024
9d94536
Update MIGRATION.md
podrivo Jan 22, 2024
60102ad
add migration note on README
podrivo Jan 22, 2024
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Modified exports, now the library exports `games` and `protocols` alongside the `GameDig` class.
* A game always has these fields: `name`, `release_year` and `options` (which always contains `port`/`port_query`/`port_query_offset` and `protocol`).
* `maxAttempts` has been renamed to `maxRetries`.
* Game Type IDs have been updated with new naming system, with new option field `game.options.extra.old_id` with the older ID

#### Games
* Almost all games ids have been changed to follow a standard, see [CONTRIBUTING.md#naming](https://github.com/gamedig/node-gamedig/blob/5ae12dd494c927abcbe43352609d9aa34a54753c/CONTRIBUTING.md?plain=1#L27C3-L27C3).
Expand Down Expand Up @@ -38,7 +39,8 @@
* `stripColors` (defaults to `true`) for protocols that strips colors: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron.
* `requestRulesRequired` (defaults to `false`) Valve games only. `requestRules` is always required to have a response or the query will timeout.
* `requestPlayersRequired` (defaults to `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.
* `noBreadthOrder` (defaults to `false`). If multiple attempts are to be made, disable doing one of each type until reaching the retry count.
* `noBreadthOrder` (defaults to `false`). If multiple attempts are to be made, disable doing one of each type until reaching the retry count.
* `skipOldIDs` (defaults to `false`). Query will skip checking for older game type IDs.
* Now documented: `address` (defaults to `undefined`) Override the IP address of the server skipping DNS resolution. When set, host will not be resolved, instead address will be connected to. However, some protocols still use host for other reasons e.g. as part of the query.

#### Games
Expand Down
27 changes: 23 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ so.

## Development
Note before contributing that everything done here is under the [MIT](https://opensource.org/license/mit/) license.

### Naming
Naming is an important matter, and it shouldn't be changed unless necessary.

Game **names** should be added as they appear on steam (or other storefront
if not listed there) with the release year appended in brackets (except when the
release year is already part of the name).
if not listed there) with also the release year included as `games.release_year`.
If there is a mod that needs to be added (or it adds the support for server
queries for the game), its name should be composed of the game name, a separating
**bracket**, the mod name and the release year as specified previously
(e.g. `Grand Theft Auto V - FiveM (2013)`).
(e.g. `Grand Theft Auto V - FiveM`).

A game's **identification** is a lowercase alphanumeric string will and be forged
A game's **identification** is a unique lowercase alphanumeric string will and be forged
following these rules:

1. Names composed of a maximum of two words (unless #4 applies) will result in an
id where the words are concatenated (`Dead Cells` -> `deadcells`), acronyms in
the name count as a single word (`S.T.A.L.K.E.R.` -> `stalker`).
Expand Down Expand Up @@ -72,6 +73,24 @@ following these rules:
8. If its actually about a mod that adds the ability for queries to be performed,
process only the mod name.

### Game Object Example

```js
terrariatshosck: {
name: 'Terraria - TShock',
release_year: 2011,
options: {
port: 7777,
port_query_offset: 101,
protocol: 'terraria'
},
extra: {
old_id: 'terraria',
doc_notes: 'terraria'
}
}
```

### Priorities
Game suggestions will be prioritized by maintainers based on whether the game
uses a protocol already implemented in the library (games that use already
Expand Down
680 changes: 343 additions & 337 deletions GAMES_LIST.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Migrating from v4 to v5

Older IDs exist because of a naming system update. Having them as an option, guarantees that other softwares will still function after a library update.

| v4 | | v5
|:---|:---|:---
| cs2 | → | counterstrike2
| had2 | → | hiddendangerous2
| left4dead2 | → | l4d2
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Confused on how this works, or you want to see more? Checkout the [examples](/ex
| **stripColors** | boolean | true | Enables stripping colors for protocols: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron. |
| **portCache** | boolean | true | After you queried a server, the second time you query that exact server (identified by specified ip and port), first add an attempt to query with the last successful port. |
| **noBreadthOrder** | boolean | false | Enable the behaviour of retrying an attempt X times followed by the next attempt X times, otherwise try attempt A, then B, then A, then B until reaching the X retry count of each. |
| **skipOldIDs** | boolean | false | Query will skip checking for older game type IDs. |

## Query Response

Expand Down
2 changes: 1 addition & 1 deletion bin/gamedig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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'],
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'skipOldIDs'],
string: ['guildId', 'listenUdpPort', 'ipFamily'],
default: {
stripColors: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/QueryRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class QueryRunner {
port_query: gameQueryPort,
port_query_offset: gameQueryPortOffset,
...gameOptions
} = lookup(userOptions.type)
} = lookup(userOptions)
const attempts = []

const optionsCollection = {
Expand Down
14 changes: 12 additions & 2 deletions lib/game-resolver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { games } from './games.js'

export const lookup = (type) => {
export const lookup = (options) => {
const type = options.type

if (!type) { throw Error('No game specified') }

if (type.startsWith('protocol-')) {
Expand All @@ -9,7 +11,15 @@ export const lookup = (type) => {
}
}

const game = games[type]
let game = games[type]

if (!options.skipOldIDs) {
Object.keys(games).forEach((id) => {
if (games[id]?.extra.old_id) {
game = games[id]
}
})
}

if (!game) { throw Error('Invalid game: ' + type) }

Expand Down
Loading