configure motd/forcedDifficulty per server

This commit is contained in:
Moritz Schmidt 2017-09-30 21:49:42 +02:00 committed by Björn Dahlgren
parent af17f8a76d
commit 49ceacf8ae
5 changed files with 36 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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: '',

View File

@ -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"),

View File

@ -35,6 +35,30 @@
</div>
</div>
<div class="form-group">
<label for="motd" class="col-sm-2 control-label">MOTD</label>
<div class="col-sm-10">
<textarea rows="3"
class="form-control motd"
data-field="motd"
placeholder="No MOTD will be shown"><%-motd %></textarea>
<p class="help-block">Message of the day. Shown to players when connected</p>
</div>
</div>
<div class="form-group">
<label for="forcedDifficulty" class="col-sm-2 control-label">Difficulty</label>
<div class="col-sm-10">
<select class="form-control forcedDifficulty" data-field="forcedDifficulty" value="<%- (forcedDifficulty || '') %>">
<%= ["", "Recruit", "Regular", "Veteran", "Custom"].map(function (difficulty) {
var selected = difficulty == forcedDifficulty ? 'selected' : '';
return '<option value="' + difficulty + '" ' + selected + '>' + (difficulty || 'Not set') + '</option>';
}).join('\n') %>
</select>
<p class="help-block">Difficulty that is always used unless mission rotation states otherwise</p>
</div>
</div>
<div class="form-group">
<label for="headless-clients" class="col-sm-2 control-label">Headless Clients</label>
<div class="col-sm-10">