Fix position desync causing item interaction failures
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Maintainer-controlled web client version.
|
||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||
window.CHGRID_WEB_VERSION = "2026.02.25 R238";
|
||||
window.CHGRID_WEB_VERSION = "2026.02.25 R239";
|
||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||
|
||||
@@ -1094,8 +1094,7 @@ function updateTeleport(): void {
|
||||
const completionStatus = activeTeleport.completionStatus;
|
||||
state.player.x = activeTeleport.targetX;
|
||||
state.player.y = activeTeleport.targetY;
|
||||
signaling.send({ type: 'update_position', x: activeTeleport.targetX, y: activeTeleport.targetY });
|
||||
signaling.send({ type: 'teleport_complete' });
|
||||
signaling.send({ type: 'teleport_complete', x: activeTeleport.targetX, y: activeTeleport.targetY });
|
||||
activeTeleport = null;
|
||||
stopTeleportLoopAudio();
|
||||
persistPlayerPosition();
|
||||
|
||||
@@ -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