Enhanced inplace rdf update.

This commit is contained in:
genxium
2023-02-17 18:54:51 +08:00
parent 60866674b5
commit b19549b0a8
9 changed files with 7681 additions and 225 deletions

View File

@@ -518,7 +518,7 @@
"array": [
0,
0,
209.66956379694378,
210.4441731196186,
0,
0,
0,

View File

@@ -188,6 +188,8 @@ cc.Class({
prefabbedInputList[k] = (prefabbedInputList[k] & 15);
}
}
// [WARNING] Do not blindly use "selfJoinIndexMask" here, as the "actuallyUsedInput for self" couldn't be confirmed while prefabbing, otherwise we'd have confirmed a wrong self input by "_markConfirmationIfApplicable()"!
let initConfirmedList = 0;
if (null != existingInputFrame) {
// When "null != existingInputFrame", it implies that "true == canConfirmSelf" here
@@ -197,10 +199,21 @@ cc.Class({
prefabbedInputList[(joinIndex - 1)] = currSelfInput;
while (self.recentInputCache.GetEdFrameId() <= inputFrameId) {
// Fill the gap
// [WARNING] Do not blindly use "selfJoinIndexMask" here, as the "actuallyUsedInput for self" couldn't be confirmed while prefabbing, otherwise we'd have confirmed a wrong self input by "_markConfirmationIfApplicable()"!
const prefabbedInputFrameDownsync = gopkgs.NewInputFrameDownsync(self.recentInputCache.GetEdFrameId(), prefabbedInputList, initConfirmedList);
// console.log(`Prefabbed inputFrameId=${prefabbedInputFrameDownsync.GetInputFrameId()}`);
self.recentInputCache.Put(prefabbedInputFrameDownsync);
const gapInputFrameId = self.recentInputCache.GetEdFrameId();
self.recentInputCache.DryPut();
let ifdHolder = gopkgs.GetInputFrameDownsync(self.recentInputCache, gapInputFrameId);
if (null == ifdHolder) {
// Lazy heap alloc, calling "gopkgs.NewInputFrameDownsync" would trigger not only heap alloc but also "gopherjs $externalize", neither is efficient T_T
const prefabbedInputFrameDownsync = gopkgs.NewInputFrameDownsync(gapInputFrameId, prefabbedInputList, initConfirmedList);
// console.log(`Prefabbed inputFrameId=${prefabbedInputFrameDownsync.GetInputFrameId()}`);
self.recentInputCache.SetByFrameId(prefabbedInputFrameDownsync, gapInputFrameId);
} else {
gopkgs.SetInputFrameId(ifdHolder, gapInputFrameId);
for (let k = 0; k < window.boundRoomCapacity; ++k) {
gopkgs.SetInput(ifdHolder, k, prefabbedInputList[k]);
}
gopkgs.SetConfirmedList(ifdHolder, initConfirmedList);
}
}
return [previousSelfInput, currSelfInput];
@@ -680,7 +693,7 @@ cc.Class({
}
// This function is also applicable to "re-joining".
const rdf = gopkgs.NewRoomDownsyncFrameJs(pbRdf.id, jsPlayersArr, pbRdf.bulletLocalIdCounter, jsMeleeBulletsArr, jsFireballBulletsArr);
const rdf = gopkgs.NewRoomDownsyncFrameJs(pbRdf.id, jsPlayersArr, pbRdf.bulletLocalIdCounter, jsMeleeBulletsArr, jsFireballBulletsArr); // TODO: Check whether a "proper" preallocated rdf is available and reuse it to avoid redundant heap alloc. By "proper" I mean "pbRdf.id" should yield a "non window.RING_BUFF_FAILED_TO_SET" result, yet currently it's a bit difficult to sort out the following codes for efficient reuse, thus I'm keeping it as-is.
const self = window.mapIns;
self.onInputFrameDownsyncBatch(accompaniedInputFrameDownsyncBatch); // Important to do this step before setting IN_BATTLE
if (!self.recentRenderCache) {

View File

@@ -35,7 +35,7 @@ cc.Class({
self.inputFrameUpsyncDelayTolerance = 2;
self.collisionMinStep = 8;
self.renderCacheSize = 1024;
self.renderCacheSize = 128;
self.serverFps = 60;
self.rollbackEstimatedDt = 0.016667;
self.rollbackEstimatedDtMillis = 16.667;

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"ver": "1.0.5",
"uuid": "eeaa56f4-bd6c-4208-bec4-6ab1aa39ca93",
"uuid": "02c5cdc1-9797-49ab-bc11-963215909926",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,