fix(complement-race): use sendMove with correct parameters for position updates

Fixed ReferenceError where makeMove was undefined. The correct function
is sendMove from useArcadeSession, which requires playerId and userId
parameters in addition to the move type and data.

Changes:
- Changed makeMove to sendMove
- Added playerId and userId to the move object
- Added localPlayerId guard to prevent updates before player is identified
- Updated dependency array to include localPlayerId, viewerId, and sendMove

This fixes the runtime error preventing ghost trains from working.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-10-22 12:41:29 -05:00
parent ada0becee5
commit 06cd94b24c
1 changed files with 13 additions and 4 deletions

View File

@ -566,20 +566,29 @@ export function ComplementRaceProvider({ children }: { children: ReactNode }) {
// Broadcast position to server for multiplayer ghost trains
useEffect(() => {
if (!compatibleState.isGameActive || compatibleState.style !== 'sprint') {
if (!compatibleState.isGameActive || compatibleState.style !== 'sprint' || !localPlayerId) {
return
}
// Send position update every 200ms
const interval = setInterval(() => {
makeMove({
sendMove({
type: 'UPDATE_POSITION',
playerId: localPlayerId,
userId: viewerId || '',
data: { position: clientPosition },
})
} as ComplementRaceMove)
}, 200)
return () => clearInterval(interval)
}, [compatibleState.isGameActive, compatibleState.style, clientPosition, makeMove])
}, [
compatibleState.isGameActive,
compatibleState.style,
clientPosition,
localPlayerId,
viewerId,
sendMove,
])
// Keep lastLogRef for future debugging needs
// (removed debug logging)