summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-03-27 22:36:40 +0200
committerTor Andersson <tor@ccxvii.net>2022-03-27 22:45:29 +0200
commitaa5bbfd04e85ea8a0c63fe9b8bd220a1898f70a7 (patch)
treeff920e02ad348e5c1726190825bd0fce512162e3
parent2b71f3a51d694682c7fc6cb42d3197c958847fc3 (diff)
downloadserver-aa5bbfd04e85ea8a0c63fe9b8bd220a1898f70a7.tar.gz
Enable/disable debugging commands as a global server setting.
-rw-r--r--public/common/play.js3
-rw-r--r--server.js10
2 files changed, 10 insertions, 3 deletions
diff --git a/public/common/play.js b/public/common/play.js
index ae3e622..13ce453 100644
--- a/public/common/play.js
+++ b/public/common/play.js
@@ -659,9 +659,6 @@ async function init_replay() {
case "resign":
s = rules.resign(s, item.role);
break;
- case "restore":
- s = JSON.parse(item.arguments);
- break;
default:
s = rules.action(s, item.role, item.action, item.arguments);
break;
diff --git a/server.js b/server.js
index 9342d80..b38c368 100644
--- a/server.js
+++ b/server.js
@@ -12,6 +12,8 @@ const sqlite3 = require('better-sqlite3');
require('dotenv').config();
+let DEBUG = process.env.DEBUG || 0;
+
let HTTP_PORT = process.env.HTTP_PORT || 8080;
let HTTPS_PORT = process.env.HTTPS_PORT;
@@ -1698,6 +1700,8 @@ function on_chat(socket, message) {
}
function on_debug(socket) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
SLOG(socket, "DEBUG");
try {
let game_state = SQL_SELECT_GAME_STATE.get(socket.game_id);
@@ -1711,6 +1715,8 @@ function on_debug(socket) {
}
function on_save(socket) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
SLOG(socket, "SAVE");
try {
let game_state = SQL_SELECT_GAME_STATE.get(socket.game_id);
@@ -1724,6 +1730,8 @@ function on_save(socket) {
}
function on_restore(socket, state_text) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
SLOG(socket, "RESTORE");
try {
let state = JSON.parse(state_text);
@@ -1749,6 +1757,8 @@ function broadcast_presence(game_id) {
}
function on_restart(socket, scenario) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
try {
let seed = random_seed();
let options = JSON.parse(SQL_SELECT_GAME.get(socket.game_id).options);