Fixed (refRenderFrameId, snapshotStFrameId) pairing in "markConfirmationIfApplicable".

This commit is contained in:
genxium 2022-12-05 21:17:18 +08:00
parent 17cac19c62
commit e3fe773634
2 changed files with 11 additions and 7 deletions

View File

@ -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
}

View File

@ -440,7 +440,7 @@
"array": [
0,
0,
210.2448888647705,
210.43753679824133,
0,
0,
0,