Make spawn and movement acceptance server-authoritative

This commit is contained in:
Jage9
2026-02-24 19:52:38 -05:00
parent a588148039
commit 7488ac9f67
12 changed files with 78 additions and 29 deletions

View File

@@ -31,7 +31,6 @@ export type ConnectFlowDeps = {
signalingConnect: (onMessage: (message: unknown) => Promise<void>) => Promise<void>;
signalingDisconnect: () => void;
onMessage: (message: unknown) => Promise<void>;
worldGridSize: number;
persistPlayerPosition: () => void;
peerManagerCleanupAll: () => void;
radioCleanupAll: () => void;
@@ -66,25 +65,6 @@ export async function runConnectFlow(deps: ConnectFlowDeps): Promise<void> {
return;
}
deps.state.player.x = Math.floor(Math.random() * deps.worldGridSize);
deps.state.player.y = Math.floor(Math.random() * deps.worldGridSize);
const storedPosition = localStorage.getItem('spatialChatPosition');
if (storedPosition) {
try {
const parsed = JSON.parse(storedPosition) as { x?: number; y?: number };
if (Number.isFinite(parsed.x) && Number.isFinite(parsed.y)) {
const x = Math.floor(parsed.x as number);
const y = Math.floor(parsed.y as number);
if (x >= 0 && x < deps.worldGridSize && y >= 0 && y < deps.worldGridSize) {
deps.state.player.x = x;
deps.state.player.y = y;
}
}
} catch {
// Ignore malformed saved positions.
}
}
try {
await deps.mediaPopulateAudioDevices();
if (deps.dom.audioInputSelect.options.length === 0) {