switch to global cooldown, tracking per user is useless i realized lol

This commit is contained in:
legop3
2026-05-28 17:34:10 -04:00
parent 955b613527
commit 94ef97f5bb
2 changed files with 16 additions and 22 deletions
+8 -9
View File
@@ -1,14 +1,13 @@
1. FIX NO AUDIO DURING NOT YOUR TURN!!!
2. make sure audio forwarding doesnt stop when you switch tabs
3. add "reboot your own rover" feature
1. make sure audio forwarding doesnt stop when you switch tabs
2. add "reboot your own rover" feature
1. time delay and you can only do it if youre the only one on. server locks the rover then tells it to reboot
4. add a clear socket disconnection indicator in the web UI
5. add votekicking
3. add a clear socket disconnection indicator in the web UI
4. add votekicking
1. simply just disconnect the users socket.
6. add faster way for admins to login, like an invisible button in top left or something
7. add discord bot typing thing for when someone requests a replay
8. change replay title for ones requested from discord, something other than "requester driving rover"
9. fix rover request spam queue cheat
5. add faster way for admins to login, like an invisible button in top left or something
6. add discord bot typing thing for when someone requests a replay
7. change replay title for ones requested from discord, something other than "requester driving rover"
8. fix rover request spam queue cheat
# relative pipe dreams:
@@ -10,16 +10,15 @@ const { stopRover } = require('../turnService/actions');
const { issueCommand } = require('../commandService');
const { publishEvent } = require('../eventBus');
const USER_COOLDOWN_MS = 2 * 60 * 1000;
const userCooldowns = new Map(); // socketId -> blockedUntil
const USER_COOLDOWN_MS = 6 * 60 * 1000;
let globalCooldownUntil = 0;
function getCooldownLeftMs(socketId) {
const blockedUntil = Number(userCooldowns.get(socketId) || 0);
return Math.max(0, blockedUntil - Date.now());
function getCooldownLeftMs() {
return Math.max(0, Number(globalCooldownUntil) - Date.now());
}
function setCooldown(socketId) {
userCooldowns.set(socketId, Date.now() + USER_COOLDOWN_MS);
function setCooldown() {
globalCooldownUntil = Date.now() + USER_COOLDOWN_MS;
}
function canRequestReboot(socket) {
@@ -34,7 +33,7 @@ function canRequestReboot(socket) {
if (!(record.drivers instanceof Set) || record.drivers.size !== 1 || !record.drivers.has(socket.id)) {
throw new Error('Reboot blocked while other drivers are connected');
}
const cooldownLeftMs = getCooldownLeftMs(socket.id);
const cooldownLeftMs = getCooldownLeftMs();
if (cooldownLeftMs > 0) {
throw new Error(`Reboot cooldown active (${Math.ceil(cooldownLeftMs / 1000)}s)`);
}
@@ -47,7 +46,7 @@ io.on('connection', (socket) => {
const { roverId, record } = canRequestReboot(socket);
stopRover(roverId);
issueCommand(roverId, { type: 'reboot', reboot: { delayMs: 300 } });
setCooldown(socket.id);
setCooldown();
const requester = socket?.data?.user?.username || socket.id;
publishEvent({
source: 'roverRebootService',
@@ -67,10 +66,6 @@ io.on('connection', (socket) => {
socket.on('session:rebootOwnRover', handleRebootOwnRover);
socket.on('rebootOwnRover', handleRebootOwnRover);
socket.on('disconnect', () => {
userCooldowns.delete(socket.id);
});
});
module.exports = {};