From 21b48b7c0d3c2402ece50bdb28a3ddadccc8a951 Mon Sep 17 00:00:00 2001 From: genxium Date: Tue, 17 Jan 2023 13:07:26 +0800 Subject: [PATCH] Updated frontend input generation. --- frontend/assets/scripts/Map.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/assets/scripts/Map.js b/frontend/assets/scripts/Map.js index 409ab60..5203bce 100644 --- a/frontend/assets/scripts/Map.js +++ b/frontend/assets/scripts/Map.js @@ -918,7 +918,11 @@ batchInputFrameIdRange=[${batch[0].inputFrameId}, ${batch[batch.length - 1].inpu try { let st = performance.now(); const noDelayInputFrameId = gopkgs.ConvertToNoDelayInputFrameId(self.renderFrameId); - const [prevSelfInput, currSelfInput] = self.getOrPrefabInputFrameUpsync(noDelayInputFrameId); + let prevSelfInput = null, + currSelfInput = null; + if (gopkgs.ShouldGenerateInputFrameUpsync(self.renderFrameId)) { + [prevSelfInput, currSelfInput] = self.getOrPrefabInputFrameUpsync(noDelayInputFrameId); + } let t0 = performance.now(); if (self.shouldSendInputFrameUpsyncBatch(prevSelfInput, currSelfInput, self.lastUpsyncInputFrameId, noDelayInputFrameId)) { @@ -1192,13 +1196,8 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame throw `Couldn't find renderFrame for i=${i} to rollback (are you using Firefox?), self.renderFrameId=${self.renderFrameId}, lastAllConfirmedInputFrameId=${self.lastAllConfirmedInputFrameId}, might've been interruptted by onRoomDownsyncFrame`; } const j = gopkgs.ConvertToDelayedInputFrameId(i); - const delayedInputFrame = self.recentInputCache.GetByFrameId(j); // Don't make prediction here, the inputFrameDownsyncs in recentInputCache was already predicted while prefabbing - if (null == delayedInputFrame) { - // Shouldn't happen! - throw `Failed to get cached delayedInputFrame for i=${i}, j=${j}, renderFrameId=${self.renderFrameId}, lastUpsyncInputFrameId=${self.lastUpsyncInputFrameId}, lastAllConfirmedInputFrameId=${self.lastAllConfirmedInputFrameId}, chaserRenderFrameId=${self.chaserRenderFrameId}; recentRenderCache=${self._stringifyRecentRenderCache(false)}, recentInputCache=${self._stringifyRecentInputCache(false)}`; - } + const delayedInputFrame = self.getOrPrefabInputFrameUpsync(j); - const jPrev = gopkgs.ConvertToDelayedInputFrameId(i - 1); if (self.frameDataLoggingEnabled) { const actuallyUsedInputClone = delayedInputFrame.InputList.slice(); const inputFrameDownsyncClone = {