mirror of
https://github.com/genxium/DelayNoMore
synced 2025-01-13 22:41:30 +00:00
Fixed timing for upsync confirmation merge.
This commit is contained in:
parent
09b12c5b16
commit
1004fd45db
@ -1029,26 +1029,7 @@ func (pR *Room) prefabInputFrameDownsync(inputFrameId int32) *pb.InputFrameDowns
|
|||||||
InputList: currInputList,
|
InputList: currInputList,
|
||||||
ConfirmedList: uint64(0),
|
ConfirmedList: uint64(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, player := range pR.Players {
|
|
||||||
// Enrich by already arrived player upsync commands
|
|
||||||
bufIndex := pR.toDiscreteInputsBufferIndex(currInputFrameDownsync.InputFrameId, player.JoinIndex)
|
|
||||||
tmp, loaded := pR.DiscreteInputsBuffer.LoadAndDelete(bufIndex)
|
|
||||||
if !loaded {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
inputFrameUpsync := tmp.(*pb.InputFrameUpsync)
|
|
||||||
indiceInJoinIndexBooleanArr := uint32(player.JoinIndex - 1)
|
|
||||||
currInputFrameDownsync.InputList[indiceInJoinIndexBooleanArr] = pR.EncodeUpsyncCmd(inputFrameUpsync)
|
|
||||||
currInputFrameDownsync.ConfirmedList |= (1 << indiceInJoinIndexBooleanArr)
|
|
||||||
}
|
|
||||||
|
|
||||||
totPlayerCnt := uint32(pR.Capacity)
|
|
||||||
allConfirmedMask := uint64((1 << totPlayerCnt) - 1)
|
|
||||||
if currInputFrameDownsync.ConfirmedList == allConfirmedMask {
|
|
||||||
pR.onInputFrameDownsyncAllConfirmed(currInputFrameDownsync, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
pR.InputsBuffer.Put(currInputFrameDownsync)
|
pR.InputsBuffer.Put(currInputFrameDownsync)
|
||||||
return currInputFrameDownsync
|
return currInputFrameDownsync
|
||||||
@ -1077,21 +1058,28 @@ func (pR *Room) forceConfirmationIfApplicable() uint64 {
|
|||||||
panic(fmt.Sprintf("inputFrameId2=%v doesn't exist for roomId=%v, this is abnormal because the server should prefab inputFrameDownsync in a most advanced pace, check the prefab logic! InputsBuffer=%v", inputFrameId2, pR.Id, pR.InputsBufferString(false)))
|
panic(fmt.Sprintf("inputFrameId2=%v doesn't exist for roomId=%v, this is abnormal because the server should prefab inputFrameDownsync in a most advanced pace, check the prefab logic! InputsBuffer=%v", inputFrameId2, pR.Id, pR.InputsBufferString(false)))
|
||||||
}
|
}
|
||||||
inputFrame2 := tmp.(*pb.InputFrameDownsync)
|
inputFrame2 := tmp.(*pb.InputFrameDownsync)
|
||||||
|
for _, player := range pR.Players {
|
||||||
|
// Enrich by already arrived player upsync commands
|
||||||
|
bufIndex := pR.toDiscreteInputsBufferIndex(inputFrame2.InputFrameId, player.JoinIndex)
|
||||||
|
tmp, loaded := pR.DiscreteInputsBuffer.LoadAndDelete(bufIndex)
|
||||||
|
if !loaded {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
inputFrameUpsync := tmp.(*pb.InputFrameUpsync)
|
||||||
|
indiceInJoinIndexBooleanArr := uint32(player.JoinIndex - 1)
|
||||||
|
inputFrame2.InputList[indiceInJoinIndexBooleanArr] = pR.EncodeUpsyncCmd(inputFrameUpsync)
|
||||||
|
inputFrame2.ConfirmedList |= (1 << indiceInJoinIndexBooleanArr)
|
||||||
|
}
|
||||||
|
|
||||||
totPlayerCnt := uint32(pR.Capacity)
|
totPlayerCnt := uint32(pR.Capacity)
|
||||||
allConfirmedMask := uint64((1 << totPlayerCnt) - 1)
|
allConfirmedMask := uint64((1 << totPlayerCnt) - 1)
|
||||||
if swapped := atomic.CompareAndSwapUint64(&(inputFrame2.ConfirmedList), allConfirmedMask, allConfirmedMask); swapped {
|
|
||||||
// This could happen if the frontend upsync command arrived between type#1 and type#2 checks.
|
|
||||||
Logger.Debug(fmt.Sprintf("inputFrameId2=%v is already all-confirmed for roomId=%v[type#2], no need to force confirmation of it", inputFrameId2, pR.Id))
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force confirmation of "inputFrame2"
|
// Force confirmation of "inputFrame2"
|
||||||
oldConfirmedList := atomic.LoadUint64(&(inputFrame2.ConfirmedList))
|
oldConfirmedList := inputFrame2.ConfirmedList
|
||||||
atomic.StoreUint64(&(inputFrame2.ConfirmedList), allConfirmedMask)
|
unconfirmedMask := (oldConfirmedList ^ allConfirmedMask)
|
||||||
|
inputFrame2.ConfirmedList = allConfirmedMask
|
||||||
pR.onInputFrameDownsyncAllConfirmed(inputFrame2, -1)
|
pR.onInputFrameDownsyncAllConfirmed(inputFrame2, -1)
|
||||||
|
|
||||||
unconfirmedMask := (oldConfirmedList ^ allConfirmedMask)
|
|
||||||
return unconfirmedMask
|
return unconfirmedMask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
210.74654679407692,
|
209.57814771583418,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user