From 49ceacf8aead7e5da885009bc65f3f48303993a2 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sat, 30 Sep 2017 21:49:42 +0200 Subject: [PATCH] configure motd/forcedDifficulty per server --- lib/manager.js | 2 ++ lib/server.js | 6 ++++++ public/js/app/models/server.js | 2 ++ public/js/app/views/servers/form.js | 2 ++ public/js/tpl/servers/form.html | 24 ++++++++++++++++++++++++ 5 files changed, 36 insertions(+) diff --git a/lib/manager.js b/lib/manager.js index ea46a1f..5770dd8 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -104,9 +104,11 @@ Manager.prototype.save = function () { admin_password: server.admin_password, auto_start: server.auto_start, battle_eye: server.battle_eye, + forcedDifficulty: server.forcedDifficulty, max_players: server.max_players, missions: server.missions, mods: server.mods, + motd: server.motd, number_of_headless_clients: server.number_of_headless_clients, parameters: server.parameters, password: server.password, diff --git a/lib/server.js b/lib/server.js index 1fe3060..f29486e 100644 --- a/lib/server.js +++ b/lib/server.js @@ -48,9 +48,11 @@ Server.prototype.update = function (options) { this.admin_password = options.admin_password this.auto_start = options.auto_start this.battle_eye = options.battle_eye + this.forcedDifficulty = options.forcedDifficulty || null this.max_players = options.max_players this.missions = options.missions this.mods = options.mods || [] + this.motd = options.motd || null this.number_of_headless_clients = options.number_of_headless_clients || 0 this.password = options.password this.parameters = options.parameters @@ -114,11 +116,13 @@ Server.prototype.start = function () { config: this.id, disableVoN: this.von ? 0 : 1, game: config.game, + forcedDifficulty: this.forcedDifficulty || null, headlessClients: this.number_of_headless_clients > 0 ? ['127.0.0.1'] : null, hostname: createServerTitle(this.title), localClient: this.number_of_headless_clients > 0 ? ['127.0.0.1'] : null, missions: this.missions, mods: this.mods, + motd: (this.motd && this.motd.split('\n')) || null, parameters: parameters, password: this.password, passwordAdmin: this.admin_password, @@ -271,8 +275,10 @@ Server.prototype.toJSON = function () { auto_start: this.auto_start, battle_eye: this.battle_eye, id: this.id, + forcedDifficulty: this.forcedDifficulty, max_players: this.max_players, missions: this.missions, + motd: this.motd, mods: this.mods, number_of_headless_clients: this.number_of_headless_clients, parameters: this.parameters, diff --git a/public/js/app/models/server.js b/public/js/app/models/server.js index 8fe9fbb..3527e5c 100644 --- a/public/js/app/models/server.js +++ b/public/js/app/models/server.js @@ -11,8 +11,10 @@ define(function (require) { admin_password: '', auto_start: false, battle_eye: false, + forcedDifficulty: '', max_players: null, mods: [], + motd: '', number_of_headless_clients: 0, parameters: [], password: '', diff --git a/public/js/app/views/servers/form.js b/public/js/app/views/servers/form.js index f012e2e..21b309e 100644 --- a/public/js/app/views/servers/form.js +++ b/public/js/app/views/servers/form.js @@ -22,7 +22,9 @@ define(function (require) { admin_password: this.$("form .admin-password").val(), auto_start: this.$("form .auto-start").prop("checked"), battle_eye: this.$("form .battle-eye").prop("checked"), + forcedDifficulty: this.$("form .forcedDifficulty").val(), max_players: this.$("form .max-players").val(), + motd: this.$("form .motd").val(), number_of_headless_clients: this.$("form .headless-clients").val(), password: this.$("form .password").val(), persistent: this.$("form .persistent").prop("checked"), diff --git a/public/js/tpl/servers/form.html b/public/js/tpl/servers/form.html index 034d195..5489ba5 100644 --- a/public/js/tpl/servers/form.html +++ b/public/js/tpl/servers/form.html @@ -35,6 +35,30 @@ +
+ +
+ +

Message of the day. Shown to players when connected

+
+
+ +
+ +
+ +

Difficulty that is always used unless mission rotation states otherwise

+
+
+