From e3fe7736346a6c596570bdb3323f8fed3eade552 Mon Sep 17 00:00:00 2001 From: genxium Date: Mon, 5 Dec 2022 21:17:18 +0800 Subject: [PATCH] Fixed (refRenderFrameId, snapshotStFrameId) pairing in "markConfirmationIfApplicable". --- battle_srv/models/room.go | 16 ++++++++++------ frontend/assets/scenes/login.fire | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/battle_srv/models/room.go b/battle_srv/models/room.go index c02c002..0678091 100644 --- a/battle_srv/models/room.go +++ b/battle_srv/models/room.go @@ -1102,18 +1102,22 @@ func (pR *Room) markConfirmationIfApplicable(inputFrameUpsyncBatch []*InputFrame } } + refRenderFrameIdIfNeeded := pR.CurDynamicsRenderFrameId - 1 var inputsBufferSnapshot []*InputFrameDownsync = nil if 0 < newAllConfirmedCount { - snapshotStFrameId := pR.LastAllConfirmedInputFrameId - newAllConfirmedCount - if snapshotStFrameId < 0 { - // This applies to the first all-confirmed inputFrame whose inputFrameId is 0 - snapshotStFrameId = 0 - } + /* + [WARNING] + + If "pR.InputsBufferLock" was previously held by "battleMainLoop -> applyInputFrameDownsyncDynamics", then this value would be just (pR.LastAllConfirmedInputFrameId - newAllConfirmedCount). + + However if "pR.InputsBufferLock" was previously held by another "OnBattleCmdReceived -> markConfirmationIfApplicable", this value might be smaller than (pR.LastAllConfirmedInputFrameId - newAllConfirmedCount)! + */ + snapshotStFrameId := pR.ConvertToInputFrameId(refRenderFrameIdIfNeeded, pR.InputDelayFrames) + // Duplicate downsynced inputFrameIds will be filtered out by frontend. inputsBufferSnapshot = pR.createInputsBufferSnapshot(snapshotStFrameId, pR.LastAllConfirmedInputFrameId+1) } Logger.Debug(fmt.Sprintf("markConfirmationIfApplicable for roomId=%v returning newAllConfirmedCount=%d: InputsBuffer=%v", pR.Id, newAllConfirmedCount, pR.InputsBufferString(false))) - refRenderFrameIdIfNeeded := pR.CurDynamicsRenderFrameId - 1 return newAllConfirmedCount, refRenderFrameIdIfNeeded, inputsBufferSnapshot } diff --git a/frontend/assets/scenes/login.fire b/frontend/assets/scenes/login.fire index 0deae0c..921e208 100644 --- a/frontend/assets/scenes/login.fire +++ b/frontend/assets/scenes/login.fire @@ -440,7 +440,7 @@ "array": [ 0, 0, - 210.2448888647705, + 210.43753679824133, 0, 0, 0,