mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 11:48:56 +00:00
Fixed recovery upon reconnection.
This commit is contained in:
parent
2d080ad134
commit
4369729d9c
@ -537,7 +537,8 @@ func (pR *Room) StartBattle() {
|
||||
2. reconnection
|
||||
*/
|
||||
shouldResync1 := (MAGIC_LAST_SENT_INPUT_FRAME_ID_READDED == player.LastSentInputFrameId)
|
||||
shouldResync2 := (0 < unconfirmedMask) // This condition is critical, if we don't send resync upon this condition, the might never get its input synced
|
||||
// shouldResync2 := (0 < (unconfirmedMask & uint64(1 << uint32(player.JoinIndex-1)))) // This condition is critical, if we don't send resync upon this condition, the "reconnected or slowly-clocking player" might never get its input synced
|
||||
shouldResync2 := (0 < unconfirmedMask) // An easier version of the above, might keep sending "refRenderFrame"s to still connected players when any player is disconnected
|
||||
if pR.BackendDynamicsEnabled && (shouldResync1 || shouldResync2) {
|
||||
tmp := pR.RenderFrameBuffer.GetByFrameId(refRenderFrameId)
|
||||
if nil == tmp {
|
||||
@ -975,6 +976,7 @@ func (pR *Room) OnPlayerBattleColliderAcked(playerId int32) bool {
|
||||
DisplayName: eachPlayer.DisplayName,
|
||||
Avatar: eachPlayer.Avatar,
|
||||
JoinIndex: eachPlayer.JoinIndex,
|
||||
ColliderRadius: eachPlayer.ColliderRadius,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1251,6 +1253,8 @@ func (pR *Room) applyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputF
|
||||
|
||||
if 0 < encodedInput {
|
||||
Logger.Debug(fmt.Sprintf("Checking collision for playerId=%v: virtual (%d, %d) -> (%d, %d), now playerShape=%v", playerId, currPlayerDownsync.VirtualGridX, currPlayerDownsync.VirtualGridY, newVx, newVy, ConvexPolygonStr(playerCollider.Shape.(*resolv.ConvexPolygon))))
|
||||
nextRenderFramePlayers[playerId].Dir.Dx = decodedInput[0]
|
||||
nextRenderFramePlayers[playerId].Dir.Dy = decodedInput[1]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,17 @@ cc.Class({
|
||||
if (null != qDict && qDict["expectedRoomId"]) {
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
}
|
||||
|
||||
self.checkIntAuthTokenExpire().then(
|
||||
(intAuthToken) => {
|
||||
console.log("Successfully found `intAuthToken` in local cache");
|
||||
self.useTokenLogin(intAuthToken);
|
||||
},
|
||||
() => {
|
||||
console.warn("Failed to find `intAuthToken` in local cache");
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
getRetCodeList() {
|
||||
|
@ -479,6 +479,7 @@ cc.Class({
|
||||
const dx = boundaryObj[i].x - x0;
|
||||
const dy = boundaryObj[i].y - y0;
|
||||
pts.push([dx, dy]);
|
||||
/*
|
||||
if (self.showCriticalCoordinateLabels) {
|
||||
const barrierVertLabelNode = new cc.Node();
|
||||
switch (i % 4) {
|
||||
@ -505,6 +506,7 @@ cc.Class({
|
||||
|
||||
barrierVertLabelNode.active = true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
const newBarrier = self.collisionSys.createPolygon(x0, y0, pts);
|
||||
// console.log("Created barrier: ", newBarrier);
|
||||
@ -797,8 +799,8 @@ cc.Class({
|
||||
newPlayerNode.active = true;
|
||||
const playerScriptIns = newPlayerNode.getComponent("SelfPlayer");
|
||||
playerScriptIns.scheduleNewDirection({
|
||||
dx: 0,
|
||||
dy: 0
|
||||
dx: playerRichInfo.dir.dx,
|
||||
dy: playerRichInfo.dir.dy
|
||||
}, true);
|
||||
|
||||
return [newPlayerNode, playerScriptIns];
|
||||
@ -943,10 +945,13 @@ cc.Class({
|
||||
setLocalZOrder(toShowNode, 10);
|
||||
},
|
||||
|
||||
hideFindingPlayersGUI() {
|
||||
hideFindingPlayersGUI(rdf) {
|
||||
const self = this;
|
||||
if (null == self.findingPlayerNode.parent) return;
|
||||
self.findingPlayerNode.parent.removeChild(self.findingPlayerNode);
|
||||
if (null != rdf) {
|
||||
self._initPlayerRichInfoDict(rdf.players, rdf.playerMetas);
|
||||
}
|
||||
},
|
||||
|
||||
onBattleReadyToStart(rdf) {
|
||||
|
@ -156,7 +156,7 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_PLAYER_READDED_AND_ACKED:
|
||||
// Deliberately left blank for now
|
||||
mapIns.hideFindingPlayersGUI();
|
||||
mapIns.hideFindingPlayersGUI(resp.rdf);
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_BATTLE_READY_TO_START:
|
||||
mapIns.onBattleReadyToStart(resp.rdf);
|
||||
|
Loading…
Reference in New Issue
Block a user