From aa5bbfd04e85ea8a0c63fe9b8bd220a1898f70a7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 27 Mar 2022 22:36:40 +0200 Subject: Enable/disable debugging commands as a global server setting. --- public/common/play.js | 3 --- server.js | 10 ++++++++++ 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); -- cgit v1.2.3