Skip to content
Permalink
Browse files

A number of things that were updated since the last time I looked at …

…this.
  • Loading branch information...
roncli committed Jan 17, 2017
1 parent 1268543 commit b981550bff3ba65c7866db7195cc7a7f43b921b0
@@ -21,9 +21,8 @@
"descent3console": "0.1.8",
"descent3launcher": "0.1.3",
"descent3mn3tools": "0.1.3",
"express": "4.13.0",
"handlebars": "3.0.3",
"ws": "0.7.2"
"express": "4.13.4",
"ws": "1.0.1"
},
"devDependencies": {},
"engines": {
@@ -9,19 +9,22 @@
<link rel="stylesheet" href="/css/player-colors.css"/>
</head>
<body>
<div class="jumbotron text-center" style="padding: 0;">
<h1>Descent DSN</h1>
</div>
<div class="container-fluid">
<div class="col-xs-12">
<offline ng-if="data.offline"></offline>
<error ng-if="data.error"></error>
<div ng-if="!data.offline && !data.error">
<server-tabs></server-tabs><br />
<content></content>
</div>
<div class="jumbotron text-center" style="padding: 0;">
<h1>Descent DSN</h1>
</div>
<div class="container-fluid">
<div class="col-xs-12">
<offline ng-if="data.offline"></offline>
<error ng-if="data.error"></error>
<div ng-if="!data.offline && !data.error">
<server-tabs></server-tabs>
<br/>
<content></content>
</div>
</div><br />
<div class="text-center text-muted small">Descent DSN &copy;2015 roncli Productions</div>
</div>
</div>
<br/>

<div class="text-center text-muted small">Descent DSN &copy;2015-2016 roncli Productions</div>
</body>
</html>
@@ -247,6 +247,13 @@ var app = angular.module("ddsn", []),
};
});

app.directive("addServerModification", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-modification.htm"
};
});

app.directive("addServerLaunch", function() {
return {
restrict: "E",
@@ -481,6 +488,12 @@ var app = angular.module("ddsn", []),
data.settings.addServer.game.timeLimitValid = data.settings.addServer.game.timeLimit === null || (typeof data.settings.addServer.game.timeLimit === "number" && data.settings.addServer.game.timeLimit >= 1 && data.settings.addServer.game.timeLimit % 1 === 0);
};

$scope.validModifications = function() {
return data.settings.modifications.filter(function(mod) {
return mod.valid;
});
};

$scope.missionSearch = function() {
if (!data.settings.addServer.game.missionSearch || data.settings.addServer.game.missionSearch.length < 2) {
return;
@@ -584,6 +597,25 @@ var app = angular.module("ddsn", []),
$scope.launchServer();
};

$scope.loadSavedServer = function(server) {
data.settings.addServer = JSON.parse(JSON.stringify(server));

data.settings.addServer.server.port = 2092;
data.settings.addServer.server.gamespyport = 20143;

while (data.servers.filter($scope.checkPort).length > 0) {
data.settings.addServer.server.port++;
}

while (data.servers.filter($scope.checkGameSpyPort).length > 0) {
data.settings.addServer.server.gamespyport++;
}

data.settings.addServer.saveServerName = undefined;

$scope.openAddServer("server");
};

$scope.launchServer = function() {
var server, savedServer;

@@ -1115,6 +1147,43 @@ var app = angular.module("ddsn", []),
}
}

if (data.settings.modifications) {
data.settings.modifications.forEach(function(mod) {
var fx;

try {
fx = new Function("return " + mod.code);
mod.codeValid = true;
mod.valid = true;
} catch (ex) {
mod.codeValid = false;
mod.valid = false;
}

if (mod.options) {
mod.options.forEach(function(option) {
if (option.validations) {
option.validations.forEach(function(validation) {
var fx;
try {
fx = new Function("return " + validation.code);
validation.fx = fx();
validation.valid = true;
} catch (ex) {
validation.valid = false;
mod.valid = false;
}
});
}
});
}
});

if (scope.validModifications().length > 0) {
data.currentAddServerMod = scope.validModifications()[0];
}
}

scope.$apply();
}());
break;
@@ -0,0 +1,8 @@
<div ng-if="data.currentAddServerMod">
<div ng-repeat="option in data.currentAddServerMod.options">
<div ng-class="{true: 'input-group', false: 'input-group has-error'}[modOptionIsValid(data.currentAddServerMod.name, option.name)]">
<span class="input-group-addon">{{option.description}}</span>
<input type="text" class="form-control" ng-model="data.settings.addServer.modifications[data.currentAddServerMod.name].option[option.name]" ng-blur="updateModOption(data.currentAddServerMod.name, option.name)"/>
</div>
</div>
</div>
@@ -0,0 +1,6 @@
<ul class="nav nav-pills">
<li role="presentation" ng-repeat="mod in validModifications()">
<button ng-class="{true: 'btn btn-success', false: 'btn btn-primary'}[data.currentAddServerMod === mod.name]" ng-click="openAddServerMod(mod.name)"><span class="glyphicon glyphicon-wrench"></span> {{mod.title}}</button>
</li>
</ul>
<add-server-modification></add-server-modification>
@@ -5,11 +5,12 @@
<td colspan="2">Select a server to quick launch. Servers will be launched on port 2092 and GameSpy port 20143, or the first available port not in use.</td>
</tr>
<tr ng-repeat="server in data.settings.savedServers">
<td class="text-right">
<td class="text-right" style="vertical-align: middle;">
{{server.saveServerName}}
</td>
<td>
<td style="vertical-align: middle;">
<button class="btn btn-sm btn-success" ng-click="quickLaunchServer(server)">Quick Launch</button>
<button class="btn btn-sm btn-success" ng-click="loadSavedServer(server)">Load Settings</button>
<button class="btn btn-sm btn-danger" ng-click="deleteSavedServer(server)"><span class="glyphicon glyphicon-remove"></span></button>
</td>
</tr>
@@ -1,15 +1,5 @@
<div ng-if="data.serverTab === 'news'">
<news></news>
</div>
<div ng-if="data.serverTab === 'dashboard'">
<dashboard></dashboard>
</div>
<div ng-if="data.serverTab === 'server'">
<server></server>
</div>
<div ng-if="data.serverTab === 'addServer'">
<add-server></add-server>
</div>
<div ng-if="data.serverTab === 'settings'">
<settings></settings>
</div>
<news ng-if="data.serverTab === 'news'"></news>
<dashboard ng-if="data.serverTab === 'dashboard'"></dashboard>
<server ng-if="data.serverTab === 'server'"></server>
<add-server ng-if="data.serverTab === 'addServer'"></add-server>
<settings ng-if="data.serverTab === 'settings'"></settings>
@@ -3,3 +3,65 @@
<div ng-repeat="line in data.currentServer.console | limitTo : -100 track by $index" style="white-space: pre;">{{line}}</div>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">Say:</span>
<input type="text" class="form-control" ng-model="data.settings.addServer.game.motd" />
<span class="input-group-btn">
<button class="btn btn-default">Send</button>
</span>
</div><br />
<div class="navbar navbar-inverse">
<ul class="nav navbar-nav">
<li class="dropup">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Server</a>
<ul class="dropdown-menu">
<li><a href="#">Set Maximum Players</a></li>
<li><a href="#">Set Goal Limit</a></li>
<li><a href="#">Set Time Limit</a></li>
<li><a href="#">Set Packets Per Second</a></li>
<li><a href="#">Set Powerup Respawn Time</a></li>
<li><a href="#">Set Server HUD Name Level</a></li>
<li class="divider"></li>
<li><a href="#">Warp to Level</a></li>
<li><a href="#">Force Players to Wait</a></li>
<li class="divider"></li>
<li><a href="#">Quit Server</a></li>
</ul>
</li>
<li class="dropup">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Teams</a>
<ul class="dropdown-menu">
<li><a href="#">Set Team Name</a></li>
<li><a href="#">Allow Team Change</a></li>
<li><a href="#">Auto Balance Teams</a></li>
<li class="divider"></li>
<li><a href="#">Change Team</a></li>
<li><a href="#">Balance Teams Now</a></li>
</ul>
</li>
<li class="dropup">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Stats</a>
<ul class="dropdown-menu">
<li><a href="#">Net Game Information</a></li>
<li><a href="#">List Players</a></li>
<li><a href="#">Player Information</a></li>
<li class="divider"></li>
<li><a href="#">Auto Save Stats on Disconnect</a></li>
<li><a href="#">Auto Save Stats on Level End</a></li>
<li class="divider"></li>
<li><a href="#">Save Stats Now</a></li>
</ul>
</li>
<li class="dropup">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin</a>
<ul class="dropdown-menu">
<li><a href="#">Ban List</a></li>
<li class="divider"></li>
<li><a href="#">Ban</a></li>
<li><a href="#">Remove Ban</a></li>
<li><a href="#">Kick</a></li>
<li><a href="#">Rehash hosts.allow and hosts.deny</a></li>
</ul>
</li>
</ul>
</div>
@@ -107,6 +107,14 @@ module.exports = function() {

wss = new WebSocket.Server({port: 20921});

wss.broadcast = function(message) {
message = JSON.stringify(message);

wss.clients.forEach(function(client) {
client.send(message);
});
};

// Listen for new connections.
wss.on("connection", function(ws) {
var sendMissions = function(missions) {
@@ -124,14 +132,6 @@ module.exports = function() {
}));
};

wss.broadcast = function(message) {
message = JSON.stringify(message);

wss.clients.forEach(function(client) {
client.send(message);
});
};

// Parse any messages.
ws.on("message", function(data) {
var message = JSON.parse(data),
@@ -191,6 +191,7 @@ module.exports = function() {
settings.default.game.respawnTimeValid = true;
settings.default.game.audioTauntDelayValid = true;
settings.default.allowed.shipsValid = true;
settings.default.modifications = [];
settings.addServer = JSON.parse(JSON.stringify(settings.default));

// Get network interfaces.
@@ -201,6 +202,64 @@ module.exports = function() {
}
}

// Get mods.
if (!settings.modifications) {
settings.modifications = [
{
name: "autoShutdown",
title: "Auto Shutdown",
description: "Shutdown the server after a period of inactivity.",
options: [
{
name: "inactivity",
description: "Minutes of inactivity to shutdown server after:",
default: 5,
validations: [
{
code:
"function(param) {\
return typeof param === \"number\" && param > 0 && param % 1 === 0;\
}",
message: "You must enter a positive integer."
}
]
}
],
code:
"function(server, options) {\
var players = 0,\
serverTimeout = null,\
timeout = function() {\
serverTimeout = setTimeout(function() {\
server.quit();\
}, options.inactivity * 60000);\
};\
\
server.on(\"joined\", function() {\
players++;\
clearTimeout(serverTimeout);\
});\
\
server.on(\"left\", function() {\
players--;\
if (players === 0) {\
timeout();\
}\
});\
\
server.on(\"disconnected\", function() {\
players--;\
if (players === 0) {\
timeout();\
}\
});\
\
timeout();\
}"
}
];
}

(function(callback) {
if (settings.descent3 && settings.descent3.pathValid) {
// Get connection types.
@@ -948,7 +1007,7 @@ module.exports = function() {
});

// Log any errors and restart the worker.
d.on("error2", function(err) {
d.on("error", function(err) {
console.log("An error occurred:", err);

if (wss) {

0 comments on commit b981550

Please sign in to comment.
You can’t perform that action at this time.