Add Assetto Corsa support

This commit is contained in:
cwbr 2019-12-27 19:53:38 +01:00
parent 211c2d1635
commit 9db659b86b
3 changed files with 43 additions and 0 deletions

View file

@ -100,6 +100,7 @@ Games List
| `armacwa` | ARMA: Cold War Assault (2011) | `armacwa` | ARMA: Cold War Assault (2011)
| `armar` | ARMA: Resistance (2011) | `armar` | ARMA: Resistance (2011)
| `armagetron` | Armagetron Advanced (2001) | `armagetron` | Armagetron Advanced (2001)
| `assettocorsa` | Assetto Corsa (2014)
| `atlas` | Atlas (2018) | `atlas` | Atlas (2018)
| `baldursgate` | Baldur's Gate (1998) | `baldursgate` | Baldur's Gate (1998)
| `bat1944` | Battalion 1944 (2018) | `bat1944` | Battalion 1944 (2018)

View file

@ -6,6 +6,7 @@ aoe2|Age of Empires 2 (1999)|ase|port_query=27224
alienarena|Alien Arena (2004)|quake2|port_query=27910 alienarena|Alien Arena (2004)|quake2|port_query=27910
alienswarm|Alien Swarm (2010)|valve|port=27015 alienswarm|Alien Swarm (2010)|valve|port=27015
arkse|Ark: Survival Evolved (2017)|valve|port=7777,port_query=27015 arkse|Ark: Survival Evolved (2017)|valve|port=7777,port_query=27015
assettocorsa|Assetto Corsa (2014)|assettocorsa|port=9610
atlas|Atlas (2018)|valve|port=5761,port_query_offset=51800 atlas|Atlas (2018)|valve|port=5761,port_query_offset=51800
avp2|Aliens versus Predator 2 (2001)|gamespy1|port=27888 avp2|Aliens versus Predator 2 (2001)|gamespy1|port=27888
avp2010|Aliens vs. Predator (2010)|valve|port=27015 avp2010|Aliens vs. Predator (2010)|valve|port=27015

41
protocols/assettocorsa.js Normal file
View file

@ -0,0 +1,41 @@
const Core = require('./core');
class AssettoCorsa extends Core {
async run(state) {
const serverInfo = await this.request({
json: true,
uri: `http://${this.options.address}:${this.options.port}/INFO`
});
const carInfo = await this.request({
json: true,
uri: `http://${this.options.address}:${this.options.port}/JSON|${parseInt(Math.random() * 999999999999999, 10)}`
});
if (!serverInfo || !carInfo || !carInfo.Cars) {
throw new Error('Query not successful');
}
state.maxplayers = serverInfo.maxclients;
state.name = serverInfo.name;
state.map = serverInfo.track;
state.password = serverInfo.pass;
state.gamePort = serverInfo.port;
state.raw.carInfo = carInfo.Cars;
state.raw.serverInfo = serverInfo;
state.players = carInfo.Cars.reduce((r, e) => {
if (e.IsConnected) {
r.push({
name: e.DriverName,
car: e.Model,
skin: e.Skin,
nation: e.DriverNation,
team: e.DriverTeam
});
}
return r;
}, state.players);
}
}
module.exports = AssettoCorsa;