forked from gamedig/node-gamedig
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/gamedig/node-gamedig
- Loading branch information
Showing
18 changed files
with
165 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Core from './core.js' | ||
|
||
export default class ragemp extends Core { | ||
constructor () { | ||
super() | ||
this.usedTcp = true | ||
} | ||
|
||
async run (state) { | ||
const results = await this.request({ | ||
url: 'https://cdn.rage.mp/master/v2/', | ||
responseType: 'json' | ||
}) | ||
|
||
if (results == null) { | ||
throw new Error('Unable to retrieve master server list') | ||
} | ||
|
||
const targetID = `${this.options.host}:${this.options.port}` | ||
|
||
let serverResult = null | ||
let serverInfo = null | ||
|
||
for (const entry of results) { | ||
if (entry.id === targetID) { | ||
serverResult = entry | ||
serverInfo = entry.servers.at(0) | ||
break | ||
} | ||
|
||
for (const serverEntry of entry.servers) { | ||
if (serverEntry.id === targetID) { | ||
serverResult = entry | ||
serverInfo = serverEntry | ||
break | ||
} | ||
} | ||
} | ||
|
||
if (serverInfo == null) { | ||
throw new Error('Server not found in master server list.') | ||
} | ||
|
||
state.name = serverInfo.name | ||
state.numplayers = serverInfo.players.amount | ||
state.maxplayers = serverInfo.players.max | ||
state.raw = serverResult | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import quake3 from './quake3.js' | ||
|
||
export default class xonotic extends quake3 { | ||
async run (state) { | ||
await super.run(state) | ||
|
||
// Sometimes, the server returns a player's name as a number (which seems to be the team?) and the name in | ||
// an extra field called "address", we are not sure of this behaviour nor if this is a good enough solution | ||
for (const player of state.players) { | ||
if (!isNaN(player.name) && player.raw.address) { | ||
player.raw.team = player.name | ||
player.name = player.raw.address | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.