Handle different types of servers

This commit is contained in:
Björn Dahlgren 2014-04-07 01:16:08 +02:00
parent 6643d6ece1
commit b6eadd5ed6
2 changed files with 27 additions and 5 deletions

View File

@ -1,3 +1,4 @@
module.exports = { module.exports = {
path: 'path-to-arma3-directory' path: 'path-to-arma3-directory',
type: 'linux', // Can be either linux, windows or wine
}; };

View File

@ -12,7 +12,11 @@ function Server(id, title, port, mods) {
} }
Server.prototype.armaServerPath = function() { Server.prototype.armaServerPath = function() {
return config.path + '/arma3server'; if (config.type === "linux") {
return config.path + '/arma3server';
}
return config.path + '/arma3server.exe';
} }
Server.prototype.makeModsParameter = function() { Server.prototype.makeModsParameter = function() {
@ -24,10 +28,27 @@ Server.prototype.makePortParameter = function() {
} }
Server.prototype.start = function() { Server.prototype.start = function() {
var mods = this.makeModsParameter(); var startParams = [];
var port = this.makePortParameter(); var gamePath = this.armaServerPath();
var process = spawn(this.armaServerPath(), [mods, port, '-config=server.cfg', '-noSound', '-world=empty']); if (config.type === "wine") {
gamePath = "wine";
startParams.push(this.armaServerPath());
}
startParams.push(this.makePortParameter());
startParams.push('-config=server.cfg');
startParams.push('-noSound');
startParams.push('-world=empty');
if (this.mods.length) {
startParams.push(this.makeModsParameter());
}
console.log(gamePath);
console.log(startParams);
var process = spawn(gamePath, startParams);
var self = this; var self = this;
process.stdout.on('data', function (data) { process.stdout.on('data', function (data) {