[Scummvm-git-logs] scummvm-sites multiplayer -> 127d52602c6d01082dcaa0c01a5f9e9e77bd1eab
LittleToonCat
noreply at scummvm.org
Fri Apr 21 23:23:14 UTC 2023
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:
127d52602c MULTIPLAYER: Downloads and competitive mods check.
Commit: 127d52602c6d01082dcaa0c01a5f9e9e77bd1eab
https://github.com/scummvm/scummvm-sites/commit/127d52602c6d01082dcaa0c01a5f9e9e77bd1eab
Author: Little Cat (toontownlittlecat at gmail.com)
Date: 2023-04-21T20:23:03-03:00
Commit Message:
MULTIPLAYER: Downloads and competitive mods check.
We're substituting the ping system to check if both users has
competitive mods enabled.
Changed paths:
lobby/database/Redis.js
lobby/database/WebAPI.js
lobby/net/ChallengeMessages.js
lobby/net/DatabaseMessages.js
lobby/net/NetworkConnection.js
diff --git a/lobby/database/Redis.js b/lobby/database/Redis.js
index ee85f94..c21d6bc 100644
--- a/lobby/database/Redis.js
+++ b/lobby/database/Redis.js
@@ -133,6 +133,10 @@ class Redis {
return {error: 1, message: "Redis does not support token logins."};
}
+ async getNews() {
+ return {error: 0, news: ""};
+ }
+
async removeUser(userId, game) {
// We don't want to remove users from a dev database.
if (database != this) {
diff --git a/lobby/database/WebAPI.js b/lobby/database/WebAPI.js
index 0757a06..340b56f 100644
--- a/lobby/database/WebAPI.js
+++ b/lobby/database/WebAPI.js
@@ -49,6 +49,11 @@ class WebAPI {
return user;
}
+ async getNews() {
+ const news = await this.post('/get_news', {token: this.token});
+ return news;
+ }
+
async setIcon(userId, icon) {
const response = await this.post('/set_icon', {token: this.token,
userId: userId,
diff --git a/lobby/net/ChallengeMessages.js b/lobby/net/ChallengeMessages.js
index 4d1fa62..890f04f 100644
--- a/lobby/net/ChallengeMessages.js
+++ b/lobby/net/ChallengeMessages.js
@@ -28,6 +28,46 @@ const logEvent = require('../global/EventLogger.js').logEvent;
// Hack for baseball
const busyTimeouts = {};
+server.handleMessage("ping_player", async (client, args) => {
+ const user = args.user;
+ logEvent('ping_player', client, args.version, {'user': user});
+
+ // We're substituting the ping system to check if both users
+ // has competitive mods enabled:
+ if (client.competitiveMods) {
+ process.send({cmd: "ping_player", user: user,
+ pinger: client.userId});
+
+ }
+});
+
+process.on('ping_player', async (args) => {
+ const userId = args.user;
+ const pinger = args.pinger;
+
+ for (const client of server.connections) {
+ if (client.userId == userId) {
+ if (client.competitiveMods) {
+ process.send({cmd: "ping_result", user: pinger,
+ result: 10});
+ }
+ return;
+ }
+ }
+});
+
+process.on('ping_result', async (args) => {
+ const userId = args.user;
+ const result = args.result;
+
+ for (const client of server.connections) {
+ if (client.userId == userId) {
+ client.send("ping_result", {result: result});
+ return;
+ }
+ }
+});
+
server.handleMessage('set_phone_status', async (client, args) => {
const status = args.status;
if (status === undefined) {
diff --git a/lobby/net/DatabaseMessages.js b/lobby/net/DatabaseMessages.js
index 0d6faa9..a3d27c8 100644
--- a/lobby/net/DatabaseMessages.js
+++ b/lobby/net/DatabaseMessages.js
@@ -55,6 +55,7 @@ server.handleMessage("login", async (client, args) => {
}
client.game = game;
client.version = version;
+ client.competitiveMods = competitive_mods || false;
const user = await database.getUser(username, password, game);
logEvent('login', client, args.version, {'user': user.id, 'username': user.user, 'game': game, 'competitive_mods': competitive_mods});
@@ -99,6 +100,20 @@ server.handleMessage('get_profile', async (client, args) => {
client.send("profile_info", {profile: profile});
});
+server.handleMessage('download_file', async (client, args) => {
+ const filename = args.filename;
+ logEvent('download_file', client, args.version, {'filename': filename});
+
+ let data = "";
+ if (filename == "news.ini") {
+ const news = await database.getNews();
+ if (!news.error)
+ data = news.news;
+ }
+
+ client.send("file_data", {filename: filename, data: data});
+});
+
server.handleMessage('set_icon', async (client, args) => {
const icon = args.icon;
logEvent('set_icon', client, args.version, {'icon': icon});
diff --git a/lobby/net/NetworkConnection.js b/lobby/net/NetworkConnection.js
index 12b2b1d..d65c62e 100644
--- a/lobby/net/NetworkConnection.js
+++ b/lobby/net/NetworkConnection.js
@@ -32,6 +32,7 @@ class NetworkConnection {
this.userId = 0;
this.game = '';
this.version = '';
+ this.competitiveMods = false;
this.areaId = 0;
More information about the Scummvm-git-logs
mailing list