mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-17 12:36:46 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e3fe773634 | ||
|
17cac19c62 |
@@ -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
|
||||
}
|
||||
|
||||
@@ -1605,20 +1609,21 @@ func (pR *Room) downsyncToSinglePlayer(playerId int32, player *Player, refRender
|
||||
func (pR *Room) createInputsBufferSnapshot(stFrameId, edFrameId int32) []*InputFrameDownsync {
|
||||
// [WARNING] This function MUST BE called while "pR.InputsBufferLock" is locked!
|
||||
snapshot := make([]*InputFrameDownsync, 0, edFrameId-stFrameId)
|
||||
prevFrameFound := true
|
||||
prevFrameFound := false
|
||||
j := stFrameId
|
||||
for j < edFrameId {
|
||||
tmp := pR.InputsBuffer.GetByFrameId(j)
|
||||
if nil == tmp {
|
||||
if false == prevFrameFound {
|
||||
// The "id"s are always consecutive
|
||||
break
|
||||
j++
|
||||
continue // allowed to keep not finding the requested inputFrames at the beginning
|
||||
} else {
|
||||
prevFrameFound = false
|
||||
continue
|
||||
break // The "id"s are always consecutive
|
||||
}
|
||||
}
|
||||
prevFrameFound = true
|
||||
foo := tmp.(*InputFrameDownsync)
|
||||
|
||||
bar := &InputFrameDownsync{
|
||||
InputFrameId: foo.InputFrameId,
|
||||
InputList: make([]uint64, len(foo.InputList)),
|
||||
|
@@ -440,7 +440,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
210.7506841057913,
|
||||
210.43753679824133,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
Reference in New Issue
Block a user