修复 8 人及以上联机时部分玩家断连的问题#22
Open
RampageRain wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改内容
本 PR 尝试修复 8 人及以上联机时部分玩家断连的问题。
主要修改:
LobbyPlayer.slotId从 2 bits 扩展到 4 bits,用于支持 0-15 共 16 个玩家槽位Serialize/Deserialize原因说明
第 8 个玩家的 slotId 是 7,可以被 3 bits 表达。
但大厅玩家列表长度在 8 人时会变成 8。玩家列表长度是数量,不是从 0 开始的槽位下标,因此 8 已经超出了 3 bits 的表达范围。
如果某些官方 Lobby 消息仍然使用 3 bits 读写玩家列表长度,就可能导致网络包序列化/反序列化异常或数据错位,从而造成部分客户端断连。
说明
5 bits 可以表达 0-31,足够当前 16 人上限使用。
当前代码中的最大人数仍然会被限制在 16。
Fixes #21