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