[Scummvm-git-logs] scummvm-sites multiplayer -> d12bd4eee97238a3e1fcca3f2d33c559c3eda988

LittleToonCat noreply at scummvm.org
Tue Oct 15 05:07:36 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-sites' repo located at https://github.com/scummvm/scummvm-sites .

Summary:
d12bd4eee9 MULTIPLAYER: Ability to not start new games.


Commit: d12bd4eee97238a3e1fcca3f2d33c559c3eda988
    https://github.com/scummvm/scummvm-sites/commit/d12bd4eee97238a3e1fcca3f2d33c559c3eda988
Author: Little Cat (toontownlittlecat at gmail.com)
Date: 2024-10-15T02:07:24-03:00

Commit Message:
MULTIPLAYER: Ability to not start new games.

Changed paths:
    lobby/net/ChallengeMessages.js
    lobby/net/NetworkConnection.js
    lobby/run.js
    lobby/webhook/InternalWebhook.js


diff --git a/lobby/net/ChallengeMessages.js b/lobby/net/ChallengeMessages.js
index 890f04f..76b1087 100644
--- a/lobby/net/ChallengeMessages.js
+++ b/lobby/net/ChallengeMessages.js
@@ -108,6 +108,12 @@ server.handleMessage('challenge_player', async (client, args) => {
         clearTimeout(busyTimeouts[client.userId]);
     }
 
+    if (process.env.DISABLE_NEW_GAMES !== "0") {
+        client.send("decline_challenge", {not_responding: 1});
+        client.alert(2, process.env.DISABLE_NEW_GAMES_REASON || "Server maintenance is being planned, you cannot start new games until maintenance has ended.  Sorry for the inconvenience.");
+        return;
+    }
+
     process.send({cmd: "receive_challenge", user: challengeUserId,
                                             opponent: client.userId,
                                             stadium: stadium});
diff --git a/lobby/net/NetworkConnection.js b/lobby/net/NetworkConnection.js
index d65c62e..df70432 100644
--- a/lobby/net/NetworkConnection.js
+++ b/lobby/net/NetworkConnection.js
@@ -108,6 +108,11 @@ class NetworkConnection {
         this.socket.write(json + "\n");
     }
 
+    alert(type, message) {
+        if (this.terminated) return;
+        this.send("system_alert", {"type": type, message: message});
+    }
+
     kick(type, reason) {
         if (this.terminated) return;
         this.logger.warn("Kicking:", reason);
diff --git a/lobby/run.js b/lobby/run.js
index ce6a7a1..d220916 100644
--- a/lobby/run.js
+++ b/lobby/run.js
@@ -51,6 +51,11 @@ const credentials = {
     }
 };
 
+// Enable new games by default
+if (!process.env.DISABLE_NEW_GAMES) {
+    process.env.DISABLE_NEW_GAMES = "0";
+}
+
 if (cluster.isMaster) {
     // Fork out workers
     for (let i = 0; i < (config['cores'] || 1); i++) {
diff --git a/lobby/webhook/InternalWebhook.js b/lobby/webhook/InternalWebhook.js
index 262a186..6d2912c 100644
--- a/lobby/webhook/InternalWebhook.js
+++ b/lobby/webhook/InternalWebhook.js
@@ -84,7 +84,21 @@ class InternalWebhook {
                   type: 901,
                   reason: reason});
             res.status(200).json({message: `Kick request received for user id ${req.params.userId}.`})
-        })
+        });
+
+        this.app.post("/getGamesEnabled", (req, res) => {
+            res.status(200).json({enabled: process.env.DISABLE_NEW_GAMES === "0", message: process.env.DISABLE_NEW_GAMES_REASON || ""});
+        });
+
+        this.app.post("/setGamesEnabled", (req, res) => {
+            const enabled = req.body.enabled;
+            const reason = req.body.message;
+
+            process.env.DISABLE_NEW_GAMES = enabled === true ? "0" : "1";
+            process.env.DISABLE_NEW_GAMES_REASON = reason || "";
+
+            res.status(200).json({message: "Updated successfully"});
+        });
     }
 }
 




More information about the Scummvm-git-logs mailing list