feat: Add Factorio support (#527)

* Update eco protocol to include player names and fixed problems when using eco webinterface behind a proxy

* changelog + readability

* Typo

* Typo

* Added Factorio

* wrong comment

* CHANGELOG
This commit is contained in:
Vito0912 2024-01-31 22:38:17 +01:00 committed by GitHub
parent 3416e8c21a
commit 2338b82307
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 1 deletions

View File

@ -3,6 +3,7 @@
## 5.0.0-beta.3
* Euro Truck Simulator 2 (2012) - Added support (By @podrivo #523)
* Eco - Fixed querying servers using reverse queries and player names (By @Vito0912 #526)
* Factorio (2016) - Added support (By @Vito0912 #527)
## 5.0.0-beta.2
* Fixed support for projects using `require`.

View File

@ -119,6 +119,7 @@
| etqw | Enemy Territory: Quake Wars | |
| ets2 | Euro Truck Simulator 2 | [Valve Protocol](#valve) |
| f1c9902 | F1 Challenge '99-'02 | |
| factorio | Factorio | |
| farcry | Far Cry | |
| farcry2 | Far Cry 2 | |
| fear | F.E.A.R. | |

View File

@ -1161,6 +1161,14 @@ export const games = {
protocol: 'gamespy1'
}
},
factorio: {
name: 'Factorio',
release_year: 2016,
options: {
port_query: 34197,
protocol: 'factorio'
}
},
farcry: {
name: 'Far Cry',
release_year: 2004,

25
protocols/factorio.js Normal file
View File

@ -0,0 +1,25 @@
import Core from './core.js'
export default class factorio extends Core {
async run (state) {
if (!this.options.port) this.options.port = 34197
// Don't use the tcp ping probing
this.usedTcp = true
const request = await this.request({
url: `https://multiplayer.factorio.com/get-game-details/${this.options.address}:${this.options.port}`,
responseType: 'json'
})
const serverInfo = request
state.name = serverInfo.name
state.password = serverInfo.has_password
state.numplayers = serverInfo.players?.length || 0 // players is undefined if there are no players
state.maxplayers = serverInfo.max_players
state.players = serverInfo.players?.map(player => ({ name: player, raw: {} })) || []
state.raw = serverInfo
}
}

View File

@ -10,6 +10,7 @@ import doom3 from './doom3.js'
import eco from './eco.js'
import eldewrito from './eldewrito.js'
import epic from './epic.js'
import factorio from './factorio.js'
import ffow from './ffow.js'
import fivem from './fivem.js'
import gamespy1 from './gamespy1.js'
@ -55,7 +56,7 @@ import dayz from './dayz.js'
import theisleevrima from './theisleevrima.js'
export {
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, ffow, fivem, gamespy1,
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, ffow, fivem, gamespy1,
gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft,
minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, rfactor, samp,
savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,