feat: add checking for older GIDs (#496)

* feat: add new games.extra.old_id

* add extra.old_id; standard release_year

* add option dontCheckOldIDs

* update naming, README, CHANGELOG

* Update CONTRIBUTING.md

* fix games.js

* add tool for checking duplicates

* update GAMES_LIST

* fix anchor links

* fix notes in generated game list

* Update GAMES_LIST.md

* Update GAMES_LIST.md

* add Game Object Example in CONTRIBUTING

* Update find_id_duplicates.js

* check skipOldIDs only once

* remove old ids; tweaks GAMES_LIST

* add MIGRATION document WIP

* Update GAMES_LIST.md

* update Halo Online name

* revert changes tool/generate

* remove extra line

* Update GAMES_LIST.md

* roll back GAME_LIST

* Update GAMES_LIST.md

* OMG

* WAT

* ok... hopefully the last change

* Update GAMES_LIST.md

* add MIGRATION ids

* roll back CONTRIBUTING

* Update CHANGELOG.md

* update skipOldIDs to checkOldIDs

* Update MIGRATION.md

* add migration note on README
This commit is contained in:
Pedro Ivo Hudson 2024-01-22 17:16:58 -03:00 committed by GitHub
parent 67e0cd8809
commit 1f10ad0608
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 943 additions and 349 deletions

View File

@ -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).
@ -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

152
MIGRATION.md Normal file
View File

@ -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

View File

@ -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.

View File

@ -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,

View File

@ -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 = {

View File

@ -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-')) {
@ -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) }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
import { games } from '../lib/games.js'
const ids = Object.keys(games)
Object.keys(games).forEach((key) => {
if (games[key].extra && games[key].extra.old_id) {
const idOld = games[key].extra.old_id
ids.push(idOld)
}
})
function hasDuplicates(obj) {
const uniqueSet = new Set()
for (const item of obj) {
if (uniqueSet.has(item)) {
console.log('Duplicate:', item)
return true
}
uniqueSet.add(item)
}
return false
}
if (hasDuplicates(ids)) {
console.log('Duplicates found.')
} else {
console.log('No duplicates found.')
}