Fix position desync causing item interaction failures
This commit is contained in:
@@ -140,6 +140,11 @@ export function createOnMessageHandler(deps: MessageHandlerDeps): (message: Inco
|
||||
}
|
||||
|
||||
case 'update_position': {
|
||||
if (message.id === deps.state.player.id) {
|
||||
deps.state.player.x = message.x;
|
||||
deps.state.player.y = message.y;
|
||||
break;
|
||||
}
|
||||
const peer = deps.state.peers.get(message.id);
|
||||
const prevX = peer?.x ?? message.x;
|
||||
const prevY = peer?.y ?? message.y;
|
||||
|
||||
@@ -225,7 +225,7 @@ export type IncomingMessage = z.infer<typeof incomingMessageSchema>;
|
||||
export type OutgoingMessage =
|
||||
| { type: 'signal'; targetId: string; sdp?: RTCSessionDescriptionInit; ice?: RTCIceCandidateInit }
|
||||
| { type: 'update_position'; x: number; y: number }
|
||||
| { type: 'teleport_complete' }
|
||||
| { type: 'teleport_complete'; x: number; y: number }
|
||||
| { type: 'update_nickname'; nickname: string }
|
||||
| { type: 'chat_message'; message: string }
|
||||
| { type: 'ping'; clientSentAt: number }
|
||||
|
||||
Reference in New Issue
Block a user