mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 11:48:56 +00:00
Fixed backend downsyncToAll battleState filtering.
This commit is contained in:
parent
348c889e14
commit
c4489e0912
@ -434,6 +434,8 @@ func (pR *Room) StartBattle() {
|
|||||||
switch thatPlayerBattleState {
|
switch thatPlayerBattleState {
|
||||||
case PlayerBattleStateIns.DISCONNECTED:
|
case PlayerBattleStateIns.DISCONNECTED:
|
||||||
case PlayerBattleStateIns.LOST:
|
case PlayerBattleStateIns.LOST:
|
||||||
|
case PlayerBattleStateIns.EXPELLED_DURING_GAME:
|
||||||
|
case PlayerBattleStateIns.EXPELLED_IN_DISMISSAL:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
kickoffFrame := pR.RenderFrameBuffer.GetByFrameId(0).(*RoomDownsyncFrame)
|
kickoffFrame := pR.RenderFrameBuffer.GetByFrameId(0).(*RoomDownsyncFrame)
|
||||||
@ -761,10 +763,16 @@ func (pR *Room) OnDismissed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pR *Room) expelPlayerDuringGame(playerId int32) {
|
func (pR *Room) expelPlayerDuringGame(playerId int32) {
|
||||||
defer pR.onPlayerExpelledDuringGame(playerId)
|
if signalToCloseConnOfThisPlayer, existent := pR.PlayerSignalToCloseDict[playerId]; existent {
|
||||||
|
signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") // TODO: Specify an error code
|
||||||
|
}
|
||||||
|
pR.onPlayerExpelledDuringGame(playerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pR *Room) expelPlayerForDismissal(playerId int32) {
|
func (pR *Room) expelPlayerForDismissal(playerId int32) {
|
||||||
|
if signalToCloseConnOfThisPlayer, existent := pR.PlayerSignalToCloseDict[playerId]; existent {
|
||||||
|
signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") // TODO: Specify an error code
|
||||||
|
}
|
||||||
pR.onPlayerExpelledForDismissal(playerId)
|
pR.onPlayerExpelledForDismissal(playerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1441,6 +1449,15 @@ func (pR *Room) printBarrier(barrierCollider *resolv.Object) {
|
|||||||
|
|
||||||
func (pR *Room) downsyncToAllPlayers(upperToSendInputFrameId int32, unconfirmedMask uint64, prohibitsInputsBufferLock bool) {
|
func (pR *Room) downsyncToAllPlayers(upperToSendInputFrameId int32, unconfirmedMask uint64, prohibitsInputsBufferLock bool) {
|
||||||
for playerId, player := range pR.Players {
|
for playerId, player := range pR.Players {
|
||||||
|
thatPlayerBattleState := atomic.LoadInt32(&(player.BattleState))
|
||||||
|
switch thatPlayerBattleState {
|
||||||
|
case PlayerBattleStateIns.DISCONNECTED:
|
||||||
|
case PlayerBattleStateIns.LOST:
|
||||||
|
case PlayerBattleStateIns.EXPELLED_DURING_GAME:
|
||||||
|
case PlayerBattleStateIns.EXPELLED_IN_DISMISSAL:
|
||||||
|
case PlayerBattleStateIns.READDED_PENDING_BATTLE_COLLIDER_ACK: // This is the reason why battleState filter is put at "downsyncToAllPlayers" instead of "downsyncToSinglePlayer"
|
||||||
|
continue
|
||||||
|
}
|
||||||
pR.downsyncToSinglePlayer(playerId, player, pR.LastAllConfirmedInputFrameId, unconfirmedMask, prohibitsInputsBufferLock)
|
pR.downsyncToSinglePlayer(playerId, player, pR.LastAllConfirmedInputFrameId, unconfirmedMask, prohibitsInputsBufferLock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1501,12 +1518,12 @@ func (pR *Room) downsyncToSinglePlayer(playerId int32, player *Player, upperToSe
|
|||||||
panic(fmt.Sprintf("Required refRenderFrameId=%v for roomId=%v, renderFrameId=%v, playerId=%v, playerLastSentInputFrameId=%v, j=%v doesn't exist! InputsBuffer=%v, RenderFrameBuffer=%v", refRenderFrameId, pR.Id, pR.RenderFrameId, playerId, player.LastSentInputFrameId, j, pR.InputsBufferString(false), pR.RenderFrameBufferString()))
|
panic(fmt.Sprintf("Required refRenderFrameId=%v for roomId=%v, renderFrameId=%v, playerId=%v, playerLastSentInputFrameId=%v, j=%v doesn't exist! InputsBuffer=%v, RenderFrameBuffer=%v", refRenderFrameId, pR.Id, pR.RenderFrameId, playerId, player.LastSentInputFrameId, j, pR.InputsBufferString(false), pR.RenderFrameBufferString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Warn(fmt.Sprintf("Sending refRenderFrameId=%v for roomId=%v, , playerId=%v, playerJoinIndex=%v, renderFrameId=%v, curDynamicsRenderFrameId=%v, playerLastSentInputFrameId=%v, lowerToSentInputFrameId=%v, upperToSendInputFrameId=%v, j=%v: InputsBuffer=%v", refRenderFrameId, pR.Id, playerId, player.JoinIndex, pR.RenderFrameId, pR.CurDynamicsRenderFrameId, player.LastSentInputFrameId, lowerToSentInputFrameId, upperToSendInputFrameId, j, pR.InputsBufferString(false)))
|
|
||||||
refRenderFrame := tmp.(*RoomDownsyncFrame)
|
refRenderFrame := tmp.(*RoomDownsyncFrame)
|
||||||
for playerId, player := range pR.Players {
|
for playerId, player := range pR.Players {
|
||||||
refRenderFrame.Players[playerId].ColliderRadius = player.ColliderRadius // hardcoded for now
|
refRenderFrame.Players[playerId].ColliderRadius = player.ColliderRadius // hardcoded for now
|
||||||
}
|
}
|
||||||
refRenderFrame.BackendUnconfirmedMask = unconfirmedMask
|
refRenderFrame.BackendUnconfirmedMask = unconfirmedMask
|
||||||
|
Logger.Warn(fmt.Sprintf("Sending refRenderFrameId=%v for roomId=%v, , playerId=%v, playerJoinIndex=%v, renderFrameId=%v, curDynamicsRenderFrameId=%v, playerLastSentInputFrameId=%v, lowerToSentInputFrameId=%v, upperToSendInputFrameId=%v, j=%v: InputsBuffer=%v", refRenderFrameId, pR.Id, playerId, player.JoinIndex, pR.RenderFrameId, pR.CurDynamicsRenderFrameId, player.LastSentInputFrameId, lowerToSentInputFrameId, upperToSendInputFrameId, j, pR.InputsBufferString(false)))
|
||||||
pR.sendSafely(refRenderFrame, toSendInputFrameDownsyncs, DOWNSYNC_MSG_ACT_FORCED_RESYNC, playerId)
|
pR.sendSafely(refRenderFrame, toSendInputFrameDownsyncs, DOWNSYNC_MSG_ACT_FORCED_RESYNC, playerId)
|
||||||
} else {
|
} else {
|
||||||
pR.sendSafely(nil, toSendInputFrameDownsyncs, DOWNSYNC_MSG_ACT_INPUT_BATCH, playerId)
|
pR.sendSafely(nil, toSendInputFrameDownsyncs, DOWNSYNC_MSG_ACT_INPUT_BATCH, playerId)
|
||||||
|
@ -485,7 +485,7 @@ cc.Class({
|
|||||||
++barrierIdCounter;
|
++barrierIdCounter;
|
||||||
const collisionBarrierIndex = (self.collisionBarrierIndexPrefix + barrierIdCounter);
|
const collisionBarrierIndex = (self.collisionBarrierIndexPrefix + barrierIdCounter);
|
||||||
self.collisionSysMap.set(collisionBarrierIndex, newBarrierCollider);
|
self.collisionSysMap.set(collisionBarrierIndex, newBarrierCollider);
|
||||||
console.log(`Created new barrier collider: ${newBarrierCollider}`);
|
// console.log(`Created new barrier collider: ${collisionBarrierIndex}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
self.selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
||||||
@ -926,9 +926,6 @@ cc.Class({
|
|||||||
const self = this;
|
const self = this;
|
||||||
if (null == self.findingPlayerNode.parent) return;
|
if (null == self.findingPlayerNode.parent) return;
|
||||||
self.findingPlayerNode.parent.removeChild(self.findingPlayerNode);
|
self.findingPlayerNode.parent.removeChild(self.findingPlayerNode);
|
||||||
if (null != rdf) {
|
|
||||||
self._initPlayerRichInfoDict(rdf.players);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onBattleReadyToStart(rdf) {
|
onBattleReadyToStart(rdf) {
|
||||||
|
@ -146,9 +146,10 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const resp = window.pb.protos.WsResp.decode(new Uint8Array(evt.data));
|
const resp = window.pb.protos.WsResp.decode(new Uint8Array(evt.data));
|
||||||
|
// console.log(`Got non-empty onmessage decoded: resp.act=${resp.act}`);
|
||||||
switch (resp.act) {
|
switch (resp.act) {
|
||||||
case window.DOWNSYNC_MSG_ACT_HB_REQ:
|
case window.DOWNSYNC_MSG_ACT_HB_REQ:
|
||||||
window.handleHbRequirements(resp); // 获取boundRoomId并存储到localStorage
|
window.handleHbRequirements(resp);
|
||||||
break;
|
break;
|
||||||
case window.DOWNSYNC_MSG_ACT_PLAYER_ADDED_AND_ACKED:
|
case window.DOWNSYNC_MSG_ACT_PLAYER_ADDED_AND_ACKED:
|
||||||
mapIns.onPlayerAdded(resp.rdf);
|
mapIns.onPlayerAdded(resp.rdf);
|
||||||
@ -167,11 +168,9 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
|||||||
break;
|
break;
|
||||||
case window.DOWNSYNC_MSG_ACT_FORCED_RESYNC:
|
case window.DOWNSYNC_MSG_ACT_FORCED_RESYNC:
|
||||||
if (null == resp.inputFrameDownsyncBatch || 0 >= resp.inputFrameDownsyncBatch.length) {
|
if (null == resp.inputFrameDownsyncBatch || 0 >= resp.inputFrameDownsyncBatch.length) {
|
||||||
console.error(`Got empty inputFrameDownsyncBatch upon resync@localRenderFrameId=${mapIns.renderFrameId}, @lastAllConfirmedRenderFrameId=${mapIns.lastAllConfirmedRenderFrameId}, @lastAllConfirmedInputFrameId=${mapIns.lastAllConfirmedInputFrameId}, @chaserRenderFrameId=${mapIns.chaserRenderFrameId}, @localRecentInputCache=${mapIns._stringifyRecentInputCache(false)}, the incoming resp=
|
console.error(`Got empty inputFrameDownsyncBatch upon resync@localRenderFrameId=${mapIns.renderFrameId}, @lastAllConfirmedRenderFrameId=${mapIns.lastAllConfirmedRenderFrameId}, @lastAllConfirmedInputFrameId=${mapIns.lastAllConfirmedInputFrameId}, @chaserRenderFrameId=${mapIns.chaserRenderFrameId}, @localRecentInputCache=${mapIns._stringifyRecentInputCache(false)}, the incoming resp=${JSON.stringify(resp, null, 2)}`);
|
||||||
${JSON.stringify(resp, null, 2)}`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const inputFrameIdConsecutive = (resp.inputFrameDownsyncBatch[0].inputFrameId == mapIns.lastAllConfirmedInputFrameId + 1);
|
|
||||||
mapIns.onRoomDownsyncFrame(resp.rdf, resp.inputFrameDownsyncBatch);
|
mapIns.onRoomDownsyncFrame(resp.rdf, resp.inputFrameDownsyncBatch);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user