From 328d518d5b9cd0c4a1a90f97633b896220bedd7a Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 17 Sep 2023 13:01:39 +0300 Subject: [PATCH] Add `Eco` (2018) support. (#363) * Add initial working eco query * Add default port and add the game to games.txt * Add to changelog * Fix request Info object and add to raw the object * Rearrange some code to be more readable --- CHANGELOG.md | 1 + GAMES_LIST.md | 1 + games.txt | 1 + protocols/eco.js | 19 +++++++++++++++++++ protocols/index.js | 3 ++- 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 protocols/eco.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a54edbd..f437445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Moved the library a `module`. * CLI: Resolved incorrect error message when querying with a non-existent protocol name. * Replaced deprecated internal `punycode` with the [punycode](https://www.npmjs.com/package/punycode) package. +* Eco (2018) - Added support (requested by @dgibbs64). ### 4.1.0 * Replace `compressjs` dependency by `seek-bzip` to solve some possible import issues. diff --git a/GAMES_LIST.md b/GAMES_LIST.md index 26ce82f..65b9589 100644 --- a/GAMES_LIST.md +++ b/GAMES_LIST.md @@ -96,6 +96,7 @@ | `doom3` | Doom 3 (2004) | | | `dota2` | Dota 2 (2013) | [Valve Protocol](#valve) | | `drakan` | Drakan: Order of the Flame (1999) | | +| `eco` | Eco (2018) | | | `empyrion` | Empyrion - Galactic Survival (2015) | [Valve Protocol](#valve) | | `etqw` | Enemy Territory: Quake Wars (2007) | | | `fear` | F.E.A.R. (2005) | | diff --git a/games.txt b/games.txt index 8e2eb84..c9c95d4 100644 --- a/games.txt +++ b/games.txt @@ -108,6 +108,7 @@ doom3|Doom 3 (2004)|doom3|port=27666 dota2|Dota 2 (2013)|valve|port=27015 drakan|Drakan: Order of the Flame (1999)|gamespy1|port=27045,port_query_offset=1 dst|Don't Starve Together (2016)|valve|port=10999,port_query=27016 +eco|Eco (2018)|eco|port=3000,port_query_offset=1 empyrion|Empyrion - Galactic Survival (2015)|valve|port=30000,port_query_offset=1 etqw|Enemy Territory: Quake Wars (2007)|doom3|port=3074,port_query=27733 fear|F.E.A.R. (2005)|gamespy2|port_query=27888 diff --git a/protocols/eco.js b/protocols/eco.js new file mode 100644 index 0000000..aef0b9c --- /dev/null +++ b/protocols/eco.js @@ -0,0 +1,19 @@ +import Core from './core.js'; + +export default class eco extends Core { + async run(state) { + if (!this.options.port) this.options.port = 3001; + + const request = await this.request({ + url: `http://${this.options.address}:${this.options.port}/frontpage`, + responseType: 'json' + }); + const serverInfo = request.Info; + + state.name = serverInfo.Description; + state.maxplayers = serverInfo.TotalPlayers; + state.password = serverInfo.HasPassword; + state.gamePort = serverInfo.GamePort; + state.raw = serverInfo; + } +} diff --git a/protocols/index.js b/protocols/index.js index 134f677..35f200d 100644 --- a/protocols/index.js +++ b/protocols/index.js @@ -6,6 +6,7 @@ import buildandshoot from "./buildandshoot.js"; import cs2d from "./cs2d.js"; import discord from "./discord.js"; import doom3 from "./doom3.js"; +import eco from "./eco.js"; import ffow from "./ffow.js"; import fivem from "./fivem.js"; import gamespy1 from "./gamespy1.js"; @@ -45,7 +46,7 @@ import vcmp from "./vcmp.js"; import ventrilo from "./ventrilo.js"; import warsow from "./warsow.js"; -export { armagetron, ase, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, ffow, fivem, gamespy1, +export { armagetron, ase, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, ffow, fivem, gamespy1, gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft, minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, quake1, quake2, quake3, rfactor, samp, savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,