From b0ca4df6870f55e7736edceb0f3bfbe90a5aae52 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Mon, 22 Jan 2024 23:05:52 +0200 Subject: [PATCH] fix: rewrite migration document and fix check old ids (#504) * docs: rewrite migration document * fix: old games check --- CHANGELOG.md | 4 +- MIGRATE_IDS.md | 149 ++++++++++++++++++++++++++++++++++++++++++ MIGRATION.md | 152 ------------------------------------------- README.md | 4 +- lib/game-resolver.js | 4 +- 5 files changed, 155 insertions(+), 158 deletions(-) create mode 100644 MIGRATE_IDS.md delete mode 100644 MIGRATION.md diff --git a/CHANGELOG.md b/CHANGELOG.md index bb965c1..a8a57eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,9 @@ * Made the library a `module`. * Removed `GameResolver`, moved the `GameDig` class in a separate file. * 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`). + * Many game ids have changed, see the [migrate ids](MIGRATE_IDS.md) file for more info regarding this. + * A game always has these fields: `name`, `release_year` and `options` (which always contains `port`/`port_query`/`port_query_offset` and `protocol`) and could contain `extra.old_id`. * `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). diff --git a/MIGRATE_IDS.md b/MIGRATE_IDS.md new file mode 100644 index 0000000..dd1f489 --- /dev/null +++ b/MIGRATE_IDS.md @@ -0,0 +1,149 @@ +# Migrating game ids from v4 to v5 + +**Tip**: Checkout the [changelog](CHANGELOG.md) file to see all changes. + +## Game IDs +The naming system used to determine the Game IDs have been updated in `v5` and some IDs have been changed. +This means some ids will not work as they could have been changed to something else, see the table below to check which one is which. +(*Don't see your id here? That means it stayed the same.*) + +**Note**: If you are heavily using the old ids, just pass the `checkOldIDs` as true in options (or `--checkOldIDs` via the CLI) to also use them. +**Warning**: We strongly recommend that you update your game id, as these older IDs will eventually not be supported anymore and will be removed. + +### 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 | diff --git a/MIGRATION.md b/MIGRATION.md deleted file mode 100644 index d49bd01..0000000 --- a/MIGRATION.md +++ /dev/null @@ -1,152 +0,0 @@ -# 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 \ No newline at end of file diff --git a/README.md b/README.md index 2f60dc7..21e4fe6 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ 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). +**Are you updating from v4 to v5?** Many game ids have changed. +Make sure to check if your game's ID is in the [id migration document](MIGRATE_IDS.md) and don't forget to check the [changelog](CHANGELOG.md) file. ## Games List **node-GameDig** can query over 310 games + a few services! diff --git a/lib/game-resolver.js b/lib/game-resolver.js index d875c99..f04ba52 100644 --- a/lib/game-resolver.js +++ b/lib/game-resolver.js @@ -12,10 +12,10 @@ export const lookup = (options) => { } let game = games[type] - + if (options.checkOldIDs) { Object.keys(games).forEach((id) => { - if (games[id]?.extra.old_id) { + if (games[id]?.extra?.old_id === type) { game = games[id] } })