Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added Satisfactory Protocol and Support #645

Merged
merged 9 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 5.X.Y
* Feat: Replaced `punycode` package usage with `url.domainToASCII` (#630).
* Feat: World of Padman (2007) - Added support (#636)
* Feat: Satisfactory - Added support (#645) (By @Smidy13)
Smidy13 marked this conversation as resolved.
Show resolved Hide resolved

## 5.1.3
* Fix: `Deus Ex` using the wrong protocol (#621)
Expand Down
1 change: 1 addition & 0 deletions GAMES_LIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
| rune | Rune | |
| rust | Rust | [Valve Protocol](#valve) |
| s2ats | Savage 2: A Tortured Soul | |
| satisfactory | Satisfactory | |
| sdtd | 7 Days to Die | [Valve Protocol](#valve) |
| serioussam | Serious Sam | |
| serioussam2 | Serious Sam 2 | |
Expand Down
8 changes: 8 additions & 0 deletions lib/games.js
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,14 @@ export const games = {
old_id: '7d2d'
}
},
satisfactory: {
name: 'Satisfactory',
release_year: 2019,
options: {
port: 7777,
protocol: 'satisfactory'
},
},
spaceengineers: {
name: 'Space Engineers',
release_year: 2019,
Expand Down
3 changes: 2 additions & 1 deletion protocols/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import quake2 from './quake2.js'
import quake3 from './quake3.js'
import rfactor from './rfactor.js'
import samp from './samp.js'
import satisfactory from './satisfactory.js'
import savage2 from './savage2.js'
import starmade from './starmade.js'
import starsiege from './starsiege.js'
Expand Down Expand Up @@ -67,7 +68,7 @@ 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,
satisfactory, savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,
vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima, xonotic, altvmp, vintagestorymaster,
vintagestory
}
75 changes: 75 additions & 0 deletions protocols/satisfactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Core from './core.js'

export default class satisfactory extends Core {
constructor () {
super()

// Don't use the tcp ping probing
this.usedTcp = true

}

async run (state) {

/**
* To get information about the Satisfactory game server, you need to first obtain a client authenticationToken.
* https://satisfactory.wiki.gg/wiki/Dedicated_servers/HTTPS_API
*/

const tokenRequestJson = {
function: 'PasswordlessLogin',
data: {
MinimumPrivilegeLevel: 'Client'
}
}

const queryJson = {
function: 'QueryServerState'
}

let headers = {
'Content-Type': 'application/json'
}

let tokenRequestResponse = await this.queryInfo(tokenRequestJson, headers)

headers.Authorization = `Bearer ${tokenRequestResponse.data.authenticationToken}`

let queryResponse = await this.queryInfo(queryJson, headers)

/**
* Satisfactory API cannot pull Server Name at the moment, see QA and vote for fix here
* https://questions.satisfactorygame.com/post/66ebebad772a987f4a8b9ef8
*/

state.numplayers = queryResponse.data.serverGameState.numConnectedPlayers
state.maxplayers = queryResponse.data.serverGameState.playerLimit
state.raw = queryResponse

}

async queryInfo (json, headers) {

Smidy13 marked this conversation as resolved.
Show resolved Hide resolved
const url = `https://${this.options.host}:${this.options.port}/api/v1/`

this.logger.debug(`POST: ${url}`)

const response = await this.request({
url,
json,
headers,
method: 'POST',
responseType: 'json',
https: {
minVersion: 'TLSv1.2',
rejectUnauthorized: false
}
})

if (response.data == null) {
throw new Error('Unable to retrieve data from server')
} else {
return response
}
}
}