[Scummvm-git-logs] scummvm-sites multiplayer -> f7a7e428eb0c07f6c5458d9bdd9ad04e6f650336
shkupfer
noreply at scummvm.org
Thu Aug 17 02:02:40 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:
f7a7e428eb MULTIPLAYER: Return error when teams have same players
Commit: f7a7e428eb0c07f6c5458d9bdd9ad04e6f650336
https://github.com/scummvm/scummvm-sites/commit/f7a7e428eb0c07f6c5458d9bdd9ad04e6f650336
Author: shkupfer (shkupfer at ncsu.edu)
Date: 2023-08-16T22:02:35-04:00
Commit Message:
MULTIPLAYER: Return error when teams have same players
Changed paths:
lobby/net/DatabaseMessages.js
diff --git a/lobby/net/DatabaseMessages.js b/lobby/net/DatabaseMessages.js
index a3d27c8..7d7da57 100644
--- a/lobby/net/DatabaseMessages.js
+++ b/lobby/net/DatabaseMessages.js
@@ -199,18 +199,33 @@ server.handleMessage('get_teams', async (client, args) => {
logEvent('get_teams', client, args.version, {'userTeam': userTeamResponse, 'opponentTeam': opponentTeamResponse});
- let userMessages = [];
+ let responseErrorMessages = [];
if (userTeamResponse.error) {
- userMessages.push("User: " + userTeamResponse.message);
+ responseErrorMessages.push("User: " + userTeamResponse.message);
}
if (opponentTeamResponse.error) {
- userMessages.push("Opponent: " + opponentTeamResponse.message);
+ responseErrorMessages.push("Opponent: " + opponentTeamResponse.message);
}
- if (userMessages.length > 0) {
- const errorMessage = userMessages.join(" ");
- client.send("teams", {error: 1, message: errorMessage, user: [], opponent: []});
- } else {
- const teams = {error: 0, message: "", user: userTeamResponse.team, opponent: opponentTeamResponse.team};
- client.send("teams", teams);
+
+ if (responseErrorMessages.length > 0) {
+ const fullErrorMessage = responseErrorMessages.join(" ");
+ client.send("teams", {error: 1, message: fullErrorMessage, user: [], opponent: []});
+ return;
+ }
+
+ let duplicatePlayers = userTeamResponse.team.filter(
+ player => opponentTeamResponse.team.indexOf(player) != -1
+ );
+ if (duplicatePlayers.length > 0) {
+ client.send("teams", {
+ error: 1,
+ message: `Both teams have the same player(s): ${duplicatePlayers.join(", ")}`,
+ user: [],
+ opponent: []
+ });
+ return;
}
+
+ const teams = {error: 0, message: "", user: userTeamResponse.team, opponent: opponentTeamResponse.team};
+ client.send("teams", teams);
});
More information about the Scummvm-git-logs
mailing list