Пример #1
0
def init():
    print "init scene"
    global gVirtualSceneId, gSaveVirtualSceneId
    global gRealSceneKeeper, gSceneProxy, gGreenletLocal, gdSceneModule
    global gbInitScene
    gVirtualSceneId = u.guIdWithPostfix(0, 200,
                                        False)  # 不需要存盘的虚拟场景开始编号, 如2XX01
    gSaveVirtualSceneId = u.guIdWithPostfix(config.ZONE_NO, 200,
                                            False)  # 需要存盘的虚拟场景开始编号, 如2XX+区号
    gRealSceneKeeper = keeper.cKeeper()  # 永久场景实例存放处,临时场景的实例不在这里
    gSceneProxy = u.cKeyMapProxy()  # 永久场景与临时场景都可以在这里查找
    gGreenletLocal = gevent.local.local()

    # 场景类
    gdSceneModule = {
        "默认": scene.object.RealScene,  # 默认实场景
        "活动": scene.scenehd.Scene,  # 活动场景
        "仙盟": scene.sceneguild.Scene,  # 帮派场景
    }

    initScene()
    gbInitScene = True

    initSceneRandMapData()
Пример #2
0
		return instruction.ADMIN

	#根据不同方法名取得不同的对象,若是返回假值,表示没有通过授权
	#这里return的对象必须是controller子类的实例
	def _getControllerForDealRequest(self,sMethodName,iReqId):#override 获取ctrl,在处理对端的请求时		
		return self

	def _onDisConnected(self):#override
		gEndPointKeeper.removeObj(self.epId())		
		endPointWithSocket.cEndPointWithSocket._onDisConnected(self)

def nextEndPointId():
	global giEndPointId
	if 'giEndPointId' not in globals():
		giEndPointId=0
	giEndPointId+=1
	return giEndPointId

import keeper

if 'gEndPointKeeper' not in globals():
	gEndPointKeeper=keeper.cKeeper()#channel id 映射 channel

import gevent.server
import u
import c
import misc
import log
import terminal_main_pb2
import timeU
import config
Пример #3
0
#-*-coding:utf-8-*-
#作者:马昭@曹县闫店楼镇
import u
import c
import keeper
import gevent.event

if 'gbOnce' not in globals():
    gbOnce = True

    if 'sceneService' in SYS_ARGV:
        gEntityKeeper = keeper.cKeeper()  #实体实例存放处
        # gEntityProxy = u.cKeyMapProxy()#用主服务器的实体id关联实体对象
        gEnginerEntityProxy = u.cKeyMapProxy()  #用引擎层的实体id关联实体对象


#实体基类
class cEntity(object):
    def __init__(self, iScriptEttId, iEttType, sBaseSerialized):
        self.handle = zfmPyEx.createEntity(iEttType)
        if not self.handle:
            raise Exception, '实体创建失败'
        self.iScriptEttId = iScriptEttId  #脚本层id
        self.iEngineEttId = self.handle.iEttId  #引擎层的实体id
        self.iEttType = iEttType
        self.sBaseSerialized = sBaseSerialized  #序列化好的外观数据
        self.sEnterSerialized = ""
        self.sLeaveSerialized = ""
        gEnginerEntityProxy.addObj(self, self.iEngineEttId)
        self.iSceneId = 0
        self.x, self.y = 0, 0
Пример #4
0
# -*- coding: utf-8 -*-
import keeper

__all__ = ["getWarMgr", ]

if "gWarMgr" not in globals():
	gWarMgr = keeper.cKeeper()
	
def getWarMgr():
	'''战斗管理器
	'''
	global gWarMgr
	return gWarMgr


# 失败选项,可以调整顺序
level2Option = (
	{"option":1, "level":0},  # 录像
	{"option":2, "level":0},  # 宠物
	{"option":3, "level":30},  # 修炼
	{"option":4, "level":45},  # 强化
)


def failBox(who, npcObj):
	pid = who.id
	npcId = npcObj.id
	gevent.spawn(failBox2, pid, npcId)
	
def failBox2(pid, npcId):
	who = getRole(pid)
Пример #5
0
#-*-coding:utf-8-*-
import u
import c
import keeper

#场景服队伍对象

if 'gbOnce' not in globals():
    gbOnce = True

    if 'sceneService' in SYS_ARGV:
        gTeamKeeper = keeper.cKeeper()  #实体实例存放处


class SSTeam(object):  #实体基类
    def __init__(self, id):
        self.id = id
        self.memberList = []  # 全部队员
        self.leaveList = []  # 暂离队员
        self.offlineList = []  # 离线队员
        self.leader = 0  # 队长

    def this(self):
        return self

    @property
    def size(self):
        '''全部队员数量
		'''
        return len(self.memberList)
Пример #6
0
def nextEndPointId():
	global giEndPointId
	if 'giEndPointId' not in globals():
		giEndPointId=0
	giEndPointId+=1
	return giEndPointId

def getEndPointByZoneNo(iZoneNo):
	return gdZoneNoMapEndPoint.get(iZoneNo)

if 'gdZoneNoMapEndPoint' not in globals():
	gdZoneNoMapEndPoint={}#区号映射channel,value是proxy

import keeper

if 'gEndPointKeeper' not in globals():
	gEndPointKeeper=keeper.cKeeper()

import traceback
import socket
import gevent
import gevent.server
import u
import c
import misc
import log
import terminal_main_pb2
import account

import role
import config
Пример #7
0
for serviceCls in client4gate.service4gate.gdChatService.get('service',()):
	gdService[backEnd_pb2.CHAT_SERVICE].append(serviceCls())

for serviceCls in client4gate.service4gate.gdFightService.get('service',()):
	gdService[backEnd_pb2.FIGHT_SERVICE].append(serviceCls())	

import keeper
import collections
import gateService.timingWheel

if 'gbOnce' not in globals():
	gbOnce=True

	if 'gateService' in SYS_ARGV:
		giConnId=0
		gConnKeeper=keeper.cKeeper()#连接id 映射 连接对象

		gdeqRecentConnection=collections.deque()#双端队列,记录最近的连接信息

		gTimingWheel=gateService.timingWheel.cTimingWheel(6,10)#刻度数,间隔秒数 6*10=60秒
	
import socket

import gevent
import gevent.server
import gevent.queue
import gevent.core
import gevent.event
import universal.public_pb2

import u
Пример #8
0
def initServer():
    iListenPort = config.ROUTE_PORT_FOR_BACK_END
    oServer = gevent.server.StreamServer(('127.0.0.1', iListenPort),
                                         u.cFunctor(afterAccept, iListenPort))
    print('starting route server for back end on port {}'.format(iListenPort))
    return oServer


import keeper
import u

if 'gbOnce' not in globals():
    gbOnce = True

    if 'routeService' in SYS_ARGV:
        gBackEndKeeper = keeper.cKeeper()  #连接id 映射 连接对象

        gBackEndProxy = u.cKeyMapProxy()

import traceback
import gevent
import gevent.socket
import gevent.queue
import gevent
import gevent.server
import gevent.queue
import gevent.core
import universal.public_pb2

import config
import backEnd
Пример #9
0
        path = "aoiLog"
    log.log(path, str)
    # print str


class cProxyManager(misc.cEndPointProxyManager):
    def _getEndPoint(self, iEndPointId):  #override
        return gEndPointKeeper.getObj(iEndPointId)


def initTimer():  #设置定时器
    scene.mapdata.loadMapData()
    import sceneService.asyncAoi
    sceneService.asyncAoi.initTimer()
    # sceneService.asyncAoi.initAoiAsyncWatch()


# def testF():
# 	print gevent.getcurrent()
# 	#gevent.sleep(2)

# watcher =gevent.get_hub().loop.check()#idleprepare
# watcher.start(testF)

if 'gbOnce' not in globals():
    gbOnce = True

    if 'sceneService' in SYS_ARGV:
        gEndPointKeeper = keeper.cKeeper()  #end point id 映射 endPoint
        gRoleIdMapEndPoint = cProxyManager()  #角色id映射end point,value是proxy
Пример #10
0
#-*-coding:utf-8-*-
#作者:马昭@曹县闫店楼镇
import u
import c
import keeper
import gevent.event

#SEE_AMOUNT=10 #每个人所能看到玩家的个数

if 'gbOnce' not in globals():
    gbOnce = True

    if 'sceneService' in SYS_ARGV:
        gSceneKeeper = keeper.cKeeper()  #场景实例存放处
        # gSceneProxy = u.cKeyMapProxy()#用主服务器的场景id关联场景对象
        gEnginerSceneProxy = u.cKeyMapProxy()  #用引擎层的实体id关联实体对象


#场景
class cScene(object):  #场景基类
    def __init__(self, iScriptSceneId, iWidth, iHeight, iRes, iBroadcastRole):
        self.iWidth, self.iHeight = iWidth, iHeight  #场景可行走区域的宽与高
        self.iRes = iRes
        self.iBroadcastRole = iBroadcastRole  #特殊处理是否能看到其它玩家(0:可以 1:不可以)
        #iPhone 6 Plus:1242*2208 -->49.68*88.32
        #iPad Retina:1546*2048 -->61.84*81.92
        #宽高都取最大-->61.84*88.32 各除以3-->20.6133*29.4399
        # iGridWidth,iGridHeight=30,21
        iGridWidth, iGridHeight = 45, 31  #底层用9宫格iGridWidth,iGridHeight=宽高都取最大-->61.84*88.32 各除以2
        #客户端的位置从1开始计算,所以传入底层的场景iWidth iHeight要加1
        if iGridWidth > self.iWidth + 1:
Пример #11
0
    ep.setIP(sIP).setPort(iPort).setSocket(sock)
    ep.start()
    return ep


def start(iZoneNo, sIp='127.0.0.1'):
    iPort = config.MESH_PORT
    oClient = client.cStreamClient((sIp, iPort),
                                   u.cFunctor(afterConnect, iZoneNo))
    gMeshClientKeeper.addObj(oClient, iZoneNo)

    print('mesh client(zoneNo={}):starting try to connect to ip:{} port:{}'.
          format(iZoneNo, sIp, iPort))
    oClient.connect(0)


import keeper

if 'gMeshClientKeeper' not in globals():
    gMeshClientKeeper = keeper.cKeeper()

import socket
import traceback
import gevent
import gevent.socket
import gevent.queue

import misc
import u
import log
import config