let song commands through

This commit is contained in:
legop3
2026-01-21 13:47:29 -05:00
parent 55c72e0d9b
commit fe94c38963
2 changed files with 12 additions and 25 deletions
+2 -1
View File
@@ -64,7 +64,8 @@ io.on('connection', (socket) => {
if (!roverId) {
throw new Error('roverId required');
}
if (!roverManager.canDrive(roverId, socket)) {
const isSongCommand = type === 'song';
if (!isSongCommand && !roverManager.canDrive(roverId, socket)) {
throw new Error('Not your turn or no control');
}
const payload = data ? { ...data } : {};
+10 -24
View File
@@ -104,22 +104,12 @@ export default function VideoTile({
return Math.max(0, Math.min(1, 1 - Math.min(driveCap, auxCap)));
}, [limiterCaps]);
const limiterActive = Boolean(overcurrentLimiter?.isActive);
const limiterLabels = useMemo(() => {
if (!limiterCaps) return [];
const labels = [];
const driveCap = Number.isFinite(limiterCaps?.drive?.cap) ? limiterCaps.drive.cap : 1;
const auxCap = Number.isFinite(limiterCaps?.aux?.cap) ? limiterCaps.aux.cap : 1;
if (Boolean(limiterGroups?.drive) || driveCap < 0.999) labels.push('Drive wheels');
if (Boolean(limiterGroups?.aux) || auxCap < 0.999) labels.push('Aux motors');
return labels;
}, [limiterCaps, limiterGroups]);
const overlayActive = Boolean(overcurrentMotors.length || limiterActive);
const overlayLabelsRaw = overcurrentMotors.length
? overcurrentMotors.map((name) => OVERCURRENT_LABELS[name] || name)
: limiterLabels.length
? limiterLabels
const overlayMotors = overcurrentMotors.length
? overcurrentMotors
: limiterActive
? ['limiter']
: [];
const overlayLabels = overlayLabelsRaw.length ? overlayLabelsRaw : ['Overcurrent'];
const overlayFill = limiterFill ?? (overcurrentMotors.length ? 1 : 0);
const scheduleRestart = useCallback(() => {
clearTimeout(restartTimer.current);
@@ -446,12 +436,7 @@ export default function VideoTile({
labelScale={hudLabelScale}
/>
<HudChatInput compact={mobileHud} />
<OvercurrentOverlay
labels={overlayLabels}
fill={limiterFill ?? (overcurrentMotors.length ? 1 : 0)}
visible={overlayActive}
compact={mobileHud}
/>
<OvercurrentOverlay motors={overlayMotors} fill={overlayFill} compact={mobileHud} />
<LowBatteryOverlay charge={batteryCharge} config={batteryConfig} compact={mobileHud} />
{showVerticalBattery && batteryVisual.available ? (
<BatteryBarVertical visual={batteryVisual} />
@@ -749,11 +734,12 @@ const OVERCURRENT_LABELS = {
rightWheel: 'Right wheel',
mainBrush: 'Main brush',
sideBrush: 'Side brush',
limiter: 'Overcurrent limit',
};
function OvercurrentOverlay({ labels, fill = 0, visible = false, compact = false }) {
if (!visible) return null;
const safeLabels = Array.isArray(labels) && labels.length ? labels : ['Overcurrent'];
function OvercurrentOverlay({ motors, fill = 0, compact = false }) {
if (!motors?.length) return null;
const safeLabels = motors.map((name) => OVERCURRENT_LABELS[name] || name);
const containerClass = compact ? 'p-2' : 'p-4';
const textClass = compact ? 'text-lg' : 'text-4xl';
const subTextClass = compact ? 'text-xs' : 'text-xl';