summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-03-18 17:51:28 +0100
committerTor Andersson <tor@ccxvii.net>2022-03-18 21:41:34 +0100
commit6863e07e6efd9c7b5cd8c0191b506698c155f3a4 (patch)
tree8416abe056730a9b9257adf05d339b817fa2329f
parentd912d3501da09d8b568a6a6b26e708e12e0bef45 (diff)
downloadserver-6863e07e6efd9c7b5cd8c0191b506698c155f3a4.tar.gz
Don't allow joining from rematch multiple times when random roles.
-rw-r--r--server.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/server.js b/server.js
index a2baf74..fd05b6d 100644
--- a/server.js
+++ b/server.js
@@ -1141,11 +1141,14 @@ function join_rematch(req, res, game_id, role) {
try {
let is_random = SQL_SELECT_GAME_RANDOM.get(game_id);
if (is_random) {
- for (let i = 1; i <= 6; ++i) {
- let info = SQL_INSERT_PLAYER_ROLE.run(game_id, 'Random ' + i, req.user.user_id);
- if (info.changes === 1) {
- update_join_clients_players(game_id);
- break;
+ let role = SQL_SELECT_PLAYER_ROLE.get(game_id, req.user.user_id);
+ if (!role) {
+ for (let i = 1; i <= 6; ++i) {
+ let info = SQL_INSERT_PLAYER_ROLE.run(game_id, 'Random ' + i, req.user.user_id);
+ if (info.changes === 1) {
+ update_join_clients_players(game_id);
+ break;
+ }
}
}
} else {