From dcd12d0360f566fc7f69574cac7e03e825e11249 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Tue, 13 Aug 2024 11:56:28 +0300 Subject: [PATCH] feat: add vintage story support (#606) * feat: add vintage story support * remove debug console.log --- CHANGELOG.md | 1 + GAMES_LIST.md | 11 ++++++----- lib/games.js | 8 ++++++++ protocols/index.js | 5 ++++- protocols/vintagestory.js | 24 ++++++++++++++++++++++++ protocols/vintagestorymaster.js | 17 +++++++++++++++++ 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 protocols/vintagestory.js create mode 100644 protocols/vintagestorymaster.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 3daba92..85b247d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## To Be Released... ## 5.X.Y +* Added Vintage Story support via the master server (#606) ## 4.3.2 * Locked dependencies versions diff --git a/GAMES_LIST.md b/GAMES_LIST.md index d73ec7d..e44ddc2 100644 --- a/GAMES_LIST.md +++ b/GAMES_LIST.md @@ -137,9 +137,9 @@ | globaloperations | Global Operations | | | goldeneyesource | GoldenEye: Source | [Valve Protocol](#valve) | | groundbreach | Ground Breach | [Valve Protocol](#valve) | +| gta5am | Grand Theft Auto V - alt:V Multiplayer | [Notes](#gta5am) | | gta5f | Grand Theft Auto V - FiveM | | -| gta5r | Grand Theft Auto V - RAGE MP | [Notes](#gta5r) | -| gta5am | Grand Theft Auto V - alt:V Multiplayer | [Notes](#gta5am) | +| gta5r | Grand Theft Auto V - RageMP | [Notes](#gta5r) | | gtasam | Grand Theft Auto: San Andreas Multiplayer | | | gtasamta | Grand Theft Auto: San Andreas - Multi Theft Auto | | | gtasao | Grand Theft Auto: San Andreas OpenMP | | @@ -258,7 +258,7 @@ | serioussam2 | Serious Sam 2 | | | shatteredhorizon | Shattered Horizon | [Valve Protocol](#valve) | | shogo | Shogo | | -| shootmania | Shootmania | [Notes](#nadeo-shootmania--trackmania--etc) | +| shootmania | Shootmania | [Notes](#nadeo) | | sin | SiN | | | sinepisodes | SiN Episodes | [Valve Protocol](#valve) | | sof | Soldier of Fortune | | @@ -309,8 +309,8 @@ | toh | Take On Helicopters | | | tonolf | The Operative: No One Lives Forever | | | towerunite | Tower Unite | [Valve Protocol](#valve) | -| trackmania2 | Trackmania 2 | [Notes](#nadeo-shootmania--trackmania--etc) | -| trackmaniaforever | Trackmania Forever | [Notes](#nadeo-shootmania--trackmania--etc) | +| trackmania2 | Trackmania 2 | [Notes](#nadeo) | +| trackmaniaforever | Trackmania Forever | [Notes](#nadeo) | | tremulous | Tremulous | | | tribesvengeance | Tribes: Vengeance | | | tron20 | Tron 2.0 | | @@ -331,6 +331,7 @@ | ventrilo | Ventrilo | | | vietcong | Vietcong | | | vietcong2 | Vietcong 2 | | +| vintagestory | Vintage Story | | | vrising | V Rising | [Valve Protocol](#valve) | | warfork | Warfork | | | warsow | Warsow | | diff --git a/lib/games.js b/lib/games.js index 0008ec8..fe08f4a 100644 --- a/lib/games.js +++ b/lib/games.js @@ -3214,6 +3214,14 @@ export const games = { old_id: 'vs' } }, + vintagestory: { + name: 'Vintage Story', + release_year: 2016, + options: { + port: 42420, + protocol: 'vintagestory' + } + }, warsow: { name: 'Warsow', release_year: 2012, diff --git a/protocols/index.js b/protocols/index.js index 4740fee..fa91dc5 100644 --- a/protocols/index.js +++ b/protocols/index.js @@ -60,11 +60,14 @@ import theisleevrima from './theisleevrima.js' import ragemp from './ragemp.js' import xonotic from './xonotic.js' import altvmp from './altvmp.js' +import vintagestorymaster from './vintagestorymaster.js' +import vintagestory from './vintagestory.js' export { armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, farmingsimulator, ffow, fivem, gamespy1, gamespy2, gamespy3, geneshift, goldsrc, gtasao, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft, minecraftbedrock, minecraftvanilla, minetest, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, rfactor, ragemp, samp, savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve, - vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima, xonotic, altvmp + vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima, xonotic, altvmp, vintagestorymaster, + vintagestory } diff --git a/protocols/vintagestory.js b/protocols/vintagestory.js new file mode 100644 index 0000000..bf9dc32 --- /dev/null +++ b/protocols/vintagestory.js @@ -0,0 +1,24 @@ +import Core from './core.js' +import vintagestorymaster from './vintagestorymaster.js' + +export default class vintagestory extends Core { + async run (state) { + const master = new vintagestorymaster() + master.options = this.options + const masterState = await master.runOnceSafe() + const servers = masterState.raw.servers + const server = servers.find(s => s.serverIP === `${this.options.address}:${this.options.port}`) + + if (!server) { + throw new Error('Server not found in the master list') + } + + state.name = server.serverName + state.password = server.hasPassword + state.numplayers = parseInt(server.players) + state.maxplayers = parseInt(server.maxPlayers) + state.version = server.gameVersion + + state.raw = server + } +} diff --git a/protocols/vintagestorymaster.js b/protocols/vintagestorymaster.js new file mode 100644 index 0000000..b0b52e2 --- /dev/null +++ b/protocols/vintagestorymaster.js @@ -0,0 +1,17 @@ +import Core from './core.js' + +export default class vintagestorymaster extends Core { + constructor () { + super() + this.usedTcp = true + } + + async run (state) { + const response = await this.request({ + url: 'https://masterserver.vintagestory.at/api/v1/servers/list', + responseType: 'json' + }) + + state.raw.servers = response?.data || [] + } +}