Skip to content

feat: add checking for older GIDs #496

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

Merged
merged 35 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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`.
* Updated `games` with new naming system, with new option field `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.
* `checkOldIDs` (defaults to `false`). Query will check for older game type IDs. See [migration](MIGRATION.md) document.
* 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
152 changes: 152 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Migrating from v4 to v5

## Game Type IDs

The naming system used to determine the Game Type IDs have been updated in GameDig v5 and some IDs have been changed. This means you should also update your queries.

Make sure you check if your game's ID is in the table below. If not, then nothing to worry about. If it is, make sure to update. You can still use the older ID for now, but we strongly recommend that you update your queries, as older IDs will eventually not be supported anymore.

## Optional Field

| Field | Type | Default | Description |
|:---------------------------|:--------|:----------|:------------------------------------------|
| **checkOldIDs** | boolean | false | Query will check for older game type IDs. |

### Old IDs Table

| v4 | | v5
|:---|:---|:---
| americasarmypg | → | aapg
| 7d2d | → | sdtd
| americasarmypg | → | aapg
| as | → | actionsource
| ageofchivalry | → | aoc
| arkse | → | ase
| arcasimracing | → | asr08
| arma | → | aaa
| arma2oa | → | a2oa
| armacwa | → | acwa
| armar | → | armaresistance
| armare | → | armareforger
| armagetron | → | armagetronadvanced
| bat1944 | → | battalion1944
| bf1942 | → | battlefield1942
| bfv | → | battlefieldvietnam
| bf2 | → | battlefield2
| bf2142 | → | battlefield2142
| bfbc2 | → | bbc2
| bf3 | → | battlefield3
| bf4 | → | battlefield4
| bfh | → | battlefieldhardline
| bd | → | basedefense
| bs | → | bladesymphony
| buildandshoot | → | bas
| cod4 | → | cod4mw
| callofjuarez | → | coj
| chivalry | → | cmw
| commandos3 | → | c3db
| cacrenegade | → | cacr
| contactjack | → | contractjack
| cs15 | → | counterstrike15
| cs16 | → | counterstrike16
| cs2 | → | counterstrike2
| crossracing | → | crce
| darkesthour | → | dhe4445
| daysofwar | → | dow
| deadlydozenpt | → | ddpt
| dh2005 | → | deerhunter2005
| dinodday | → | ddd
| dirttrackracing2 | → | dtr2
| dmc | → | deathmatchclassic
| dnl | → | dal
| drakan | → | dootf
| dys | → | dystopia
| em | → | empiresmod
| empyrion | → | egs
| f12002 | → | formulaone2002
| flashpointresistance | → | ofr
| fivem | → | gta5f
| forrest | → | theforrest
| graw | → | tcgraw
| graw2 | → | tcgraw2
| giantscitizenkabuto | → | gck
| ges | → | goldeneyesource
| gore | → | gus
| hldm | → | hld
| hldms | → | hlds
| hlopfor | → | hlof
| hl2dm | → | hl2d
| hidden | → | thehidden
| had2 | → | hiddendangerous2
| igi2 | → | i2cs
| il2 | → | il2sturmovik
| insurgencymic | → | imic
| isle | → | theisle
| jamesbondnightfire | → | jb007n
| jc2mp | → | jc2m
| jc3mp | → | jc3m
| kingpin | → | kloc
| kisspc | → | kpctnc
| kspdmp | → | kspd
| kzmod | → | kreedzclimbing
| left4dead | → | l4d
| left4dead2 | → | l4d2
| m2mp | → | m2m
| mohsh | → | mohaas
| mohbt | → | mohaab
| mohab | → | moha
| moh2010 | → | moh
| mohwf | → | mohw
| minecraftbe | → | mbe
| mtavc | → | gtavcmta
| mtasa | → | gtasamta
| ns | → | naturalselection
| ns2 | → | naturalselection2
| nwn | → | neverwinternights
| nwn2 | → | neverwinternights2
| nolf | → | tonolf
| nolf2 | → | nolf2asihw
| pvkii | → | pvak2
| ps | → | postscriptum
| primalcarnage | → | pce
| pc | → | projectcars
| pc2 | → | projectcars2
| prbf2 | → | prb2
| przomboid | → | projectzomboid
| quake1 | → | quake
| quake3 | → | q3a
| ragdollkungfu | → | rdkf
| r6 | → | rainbowsix
| r6roguespear | → | rs2rs
| r6ravenshield | → | rs3rs
| redorchestraost | → | roo4145
| redm | → | rdr2r
| riseofnations | → | ron
| rs2 | → | rs2v
| samp | → | gtasam
| saomp | → | gtasao
| savage2 | → | s2ats
| ss | → | serioussam
| ss2 | → | serioussam2
| ship | → | theship
| sinep | → | sinepisodes
| sonsoftheforest | → | sotf
| swbf | → | swb
| swbf2 | → | swb2
| swjk | → | swjkja
| swjk2 | → | swjk2jo
| takeonhelicopters | → | toh
| tf2 | → | teamfortress2
| terraria | → | terrariatshosck
| tribes1 | → | t1s
| ut | → | unrealtournament
| ut2003 | → | unrealtournament2003
| ut2004 | → | unrealtournament2004
| ut3 | → | unrealtournament3
| v8supercar | → | v8sc
| vcmp | → | vcm
| vs | → | vampireslayer
| wheeloftime | → | wot
| wolfenstein2009 | → | wolfenstein
| wolfensteinet | → | wet
| wurm | → | wurmunlimited
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ If a server makes its status publically available, GameDig can fetch it for you.

Support is available on the [Discord](https://discord.gg/NVCMn3tnxH) for questions, or [GitHub](https://github.com/gamedig/node-gamedig/issues) for bugs.

## Migration from v4 to v5
Game Type IDs have been updated in GameDig v5. Make sure to check if your game's ID is in the [migration document](MIGRATION.md).

## Games List
**node-GameDig** can query over 310 games + a few services!
See the [GAMES_LIST.md](GAMES_LIST.md) file for the currently supported titles, not yet supported titles and notes about some of them.
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', 'checkOldIDs'],
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.checkOldIDs) {
Object.keys(games).forEach((id) => {
if (games[id]?.extra.old_id) {
game = games[id]
}
})
}

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

Expand Down
Loading