mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Remove global config variable from server file
This commit is contained in:
parent
931e913a3e
commit
3c56bba515
@ -5,8 +5,6 @@ var slugify = require('slugify')
|
||||
|
||||
var ArmaServer = require('arma-server')
|
||||
|
||||
var config = require('../config.js')
|
||||
|
||||
var queryInterval = 5000
|
||||
var queryTypes = {
|
||||
arma1: 'arma',
|
||||
@ -19,18 +17,6 @@ var queryTypes = {
|
||||
ofpresistance: 'operationflashpoint'
|
||||
}
|
||||
|
||||
var createServerTitle = function (title) {
|
||||
if (config.prefix) {
|
||||
title = config.prefix + title
|
||||
}
|
||||
|
||||
if (config.suffix) {
|
||||
title = title + config.suffix
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
var Server = function (config, logs, options) {
|
||||
this.config = config
|
||||
this.logs = logs
|
||||
@ -39,6 +25,18 @@ var Server = function (config, logs, options) {
|
||||
|
||||
Server.prototype = new events.EventEmitter()
|
||||
|
||||
Server.prototype.createServerTitle = function (title) {
|
||||
if (this.config.prefix) {
|
||||
title = this.config.prefix + title
|
||||
}
|
||||
|
||||
if (this.config.suffix) {
|
||||
title = title + this.config.suffix
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
Server.prototype.generateId = function () {
|
||||
return slugify(this.title).replace(/\./g, '-')
|
||||
}
|
||||
@ -76,7 +74,7 @@ Server.prototype.queryStatus = function () {
|
||||
var self = this
|
||||
Gamedig.query(
|
||||
{
|
||||
type: queryTypes[config.game],
|
||||
type: queryTypes[this.config.game],
|
||||
host: '127.0.0.1',
|
||||
port: self.port
|
||||
},
|
||||
@ -100,8 +98,8 @@ Server.prototype.queryStatus = function () {
|
||||
Server.prototype.getParameters = function () {
|
||||
var parameters = []
|
||||
|
||||
if (config.parameters && Array.isArray(config.parameters)) {
|
||||
parameters = parameters.concat(config.parameters)
|
||||
if (this.config.parameters && Array.isArray(this.config.parameters)) {
|
||||
parameters = parameters.concat(this.config.parameters)
|
||||
}
|
||||
|
||||
if (this.parameters && Array.isArray(this.parameters)) {
|
||||
@ -114,8 +112,8 @@ Server.prototype.getParameters = function () {
|
||||
Server.prototype.getAdditionalConfigurationOptions = function () {
|
||||
var additionalConfigurationOptions = ''
|
||||
|
||||
if (config.additionalConfigurationOptions) {
|
||||
additionalConfigurationOptions += config.additionalConfigurationOptions
|
||||
if (this.config.additionalConfigurationOptions) {
|
||||
additionalConfigurationOptions += this.config.additionalConfigurationOptions
|
||||
}
|
||||
|
||||
if (this.additionalConfigurationOptions) {
|
||||
@ -137,16 +135,16 @@ Server.prototype.start = function () {
|
||||
var parameters = this.getParameters()
|
||||
var server = new ArmaServer.Server({
|
||||
additionalConfigurationOptions: this.getAdditionalConfigurationOptions(),
|
||||
admins: config.admins,
|
||||
admins: this.config.admins,
|
||||
allowedFilePatching: this.allowed_file_patching || 1,
|
||||
battleEye: this.battle_eye ? 1 : 0,
|
||||
config: this.id,
|
||||
disableVoN: this.von ? 0 : 1,
|
||||
game: config.game,
|
||||
game: this.config.game,
|
||||
filePatching: this.file_patching || false,
|
||||
forcedDifficulty: this.forcedDifficulty || null,
|
||||
headlessClients: this.number_of_headless_clients > 0 ? ['127.0.0.1'] : null,
|
||||
hostname: createServerTitle(this.title),
|
||||
hostname: this.createServerTitle(this.title),
|
||||
localClient: this.number_of_headless_clients > 0 ? ['127.0.0.1'] : null,
|
||||
missions: this.missions,
|
||||
mods: this.mods,
|
||||
@ -159,7 +157,7 @@ Server.prototype.start = function () {
|
||||
platform: this.config.type,
|
||||
players: this.max_players,
|
||||
port: this.port,
|
||||
serverMods: config.serverMods,
|
||||
serverMods: this.config.serverMods,
|
||||
verifySignatures: this.verify_signatures ? 2 : 0
|
||||
})
|
||||
server.writeServerConfig()
|
||||
@ -204,7 +202,7 @@ Server.prototype.startHeadlessClients = function () {
|
||||
var headlessClientInstances = _.times(this.number_of_headless_clients, function (i) {
|
||||
var headless = new ArmaServer.Headless({
|
||||
filePatching: self.file_patching,
|
||||
game: config.game,
|
||||
game: self.config.game,
|
||||
host: '127.0.0.1',
|
||||
mods: self.mods,
|
||||
parameters: parameters,
|
||||
|
Loading…
Reference in New Issue
Block a user