| | |
| | | import ChPyNetSendPack
|
| | | import traceback
|
| | | import ChGameToMapPyPack
|
| | | from PyMongoDB.DBCommon import CommonDefine
|
| | | #-------------------------------------------------------------------------------
|
| | | #---全局变量---
|
| | |
|
| | |
| | | # @return 无返回值
|
| | | # @remarks
|
| | | def SendFakePack(curPlayer, clientPack):
|
| | | if not clientPack:
|
| | | return
|
| | | # Log("SendFakePack: clientPack = %s"%[clientPack.GetBuffer()])
|
| | | innerPackData = clientPack.GetBuffer()
|
| | | if len(innerPackData) < clientPack.GetLength():
|
| | |
| | | #curPlayer.SendFakePack(innerPackData, len(innerPackData))
|
| | | curPlayer.SendFakePack(clientPack.GetBuffer(), clientPack.GetLength())
|
| | |
|
| | | def SendFackPackOnline(clientPack, parseFunc=None, *args):
|
| | | ## 发送给全服在线玩家
|
| | | # @param parseFunc: 中间处理逻辑,可以做一些修改包数据的逻辑或者过滤某些玩家不发送,返回值为True时发送
|
| | | # @param args: parseFunc方法参数(curPlayer, ...)
|
| | | playerManager = GameWorld.GetPlayerManager()
|
| | | for i in xrange(playerManager.OnlineCount()):
|
| | | curPlayer = playerManager.OnlineAt(i)
|
| | | if not GameWorld.IsNormalPlayer(curPlayer):
|
| | | continue
|
| | | if parseFunc and not parseFunc(curPlayer, *args):
|
| | | continue
|
| | | SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | #-------------------------------------------------------------------------------
|
| | | #---Py封包注册信息
|
| | |
| | | ##发送Map到GameServer的沟通包
|
| | | #
|
| | | def SendPyPackToGameServer(sendPack):
|
| | | if hasattr(sendPack, 'PlayerID'):
|
| | | if sendPack.PlayerID >= 100000000:
|
| | | return
|
| | | routeIndex = GameWorld.GetGameWorld().GetLineNO()
|
| | | #这里必须用GetRealMapID,GetMapID 实际取到的是DataMapID,在有分线的地图会问题
|
| | | mapID = GameWorld.GetGameWorld().GetRealMapID() |
| | | #先写入当前地图标识,方便GameServer回包时可以正确通知到对应地图
|
| | | data = ''
|
| | | data = CommFunc.WriteBYTE(data, routeIndex) #1
|
| | | data = CommFunc.WriteDWORD(data, mapID) #4
|
| | | data = CommFunc.WriteString(data, sendPack.GetLength(), sendPack.GetBuffer())
|
| | | # if hasattr(sendPack, 'PlayerID'):
|
| | | # if sendPack.PlayerID >= 100000000:
|
| | | # return
|
| | | # routeIndex = GameWorld.GetGameWorld().GetLineNO()
|
| | | # #这里必须用GetRealMapID,GetMapID 实际取到的是DataMapID,在有分线的地图会问题
|
| | | # mapID = GameWorld.GetGameWorld().GetRealMapID() |
| | | # #先写入当前地图标识,方便GameServer回包时可以正确通知到对应地图
|
| | | # data = ''
|
| | | # data = CommFunc.WriteBYTE(data, routeIndex) #1
|
| | | # data = CommFunc.WriteDWORD(data, mapID) #4
|
| | | # data = CommFunc.WriteString(data, sendPack.GetLength(), sendPack.GetBuffer())
|
| | |
|
| | | dataLen = 1 + 4 + sendPack.GetLength()
|
| | | # dataLen = 1 + 4 + sendPack.GetLength()
|
| | |
|
| | | GameWorld.GetGameWorld().SendGameServerGeneralPack(dataLen, data)
|
| | | # GameWorld.GetGameWorld().SendGameServerGeneralPack(dataLen, data)
|
| | | return
|
| | |
|
| | |
|
| | | |
| | | ##向地图(c++)发送数据
|
| | | # 结构体要求第一个类型为枚举 TDataServerToBalanceServer,不需要封包头,用类型做判断
|
| | | def SendPyPackToMapServerSelf(data, datalen):
|
| | | GameWorld.GetGameWorld().SendPyPackToMapServerSelf(datalen, data)
|
| | | return
|
| | |
|
| | |
|
| | |
|
| | | # 向ServersRoute发送数据
|
| | | def SendPyPackToServersRoute(data, datalen):
|
| | | GameWorld.GetGameWorld().SendPyPackToServersRoute(datalen, data)
|
| | | return |