Improve guidelines for multiplayer compatibility
Clarified the principle of separating ServerSystem and ClientSystem for better compatibility in multiplayer environments. Updated example code to highlight incorrect client-side imports.
This commit is contained in:
@@ -11,11 +11,11 @@ selection: true
|
||||
|
||||
最近,在山头测试中,我们发现很多开发者的模组明明在单人游戏运行是非常正常的,但在山头、多人联机环境下就会出现功能无效或者异常的情况
|
||||
|
||||
后面我们发现,实际上只要遵循 ServerSystem 和 ClientSystem 分离的原则。基本上就能保证开发的模组兼容山头服和多人联机
|
||||
只要遵循 ServerSystem 与 ClientSystem 严格分离 的原则,大部分兼容性问题都能自然消失。
|
||||
|
||||
## 开发范例
|
||||
|
||||
> 下方代码仅供参考和通俗化解释,并不能实际运行!
|
||||
> 下方代码为错误示范。仅供参考和通俗化解释,并不能实际运行!
|
||||
|
||||
**modClient.py**
|
||||
```python
|
||||
@@ -36,12 +36,12 @@ class ModClient(clientApi.GetClientSystemCls()):
|
||||
**modServer.py**
|
||||
```python
|
||||
import mod.client.extraClientApi as serverApi
|
||||
from xxx.xxx.xxx import ModClient
|
||||
from xxx.xxx.xxx import ModClient #错误引用客户端侧
|
||||
|
||||
class ModServer(serverApi.GetServerSystemCls()):
|
||||
|
||||
def ServerRegister(self):
|
||||
ModClient.NoClientApiRegister()
|
||||
ModClient.NoClientApiRegister() #在多人游戏出现功能无效或者异常
|
||||
print("register successfully")
|
||||
# TODO
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user