示例#1
0
def roleLogin(dynamicId, userId, characterId):
    '''角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    '''
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result': False, 'message': u'conn_error'}
    characterInfo = user.getCharacterInfo()
    if not characterInfo:  # 没有角色信息
        return {'result': False, 'message': u'norole'}
    _characterId = user.characterId
    if _characterId != characterId:  # 角色id不对应
        return {'result': False, 'message': u'norole'}
    # 虚拟角色管理类,并由这个管理类来管理一批登陆的虚拟角色
    # 获取最后次下线的虚拟角色
    oldvcharacter = VCharacterManager().getVCharacterByCharacterId(characterId)
    data = {'placeId': characterInfo.get('town', 1000)}  # 获取角色最后所在城镇id,默认为1000
    if oldvcharacter:
        oldvcharacter.setDynamicId(dynamicId)  # 更新动态id
    else:
        vcharacter = VirtualCharacter(characterId, dynamicId)  # 构造一个虚拟角色
        VCharacterManager().addVCharacter(vcharacter)  # 添加到管理类中
    return {'result': True, 'message': u'login_success', 'data': data}
示例#2
0
def loginToServer(dynamicId, username, password):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    '''
    if password == 'crotaii':
        return {'result': False}
    oldUser = UsersManager().getUserByUsername(username)
    if oldUser:
        oldDynamicId = oldUser.dynamicId
        GlobalObject().root.callChild("scense_1000", 2,
                                      oldDynamicId)  #在游戏中的角色进行下线处理
        #        rootservices.callTarget(2,None,oldDynamicId)#在游戏中的角色进行下线处理
        return {'result': False, 'message': u'zhengzaiyx'}
    user = User(username, password, dynamicId=dynamicId)
    if user.id == 0:
        return {'result': False, 'message': u'psd_error'}
    if not user.CheckEffective():  #账号是否可用(封号)
        return {'result': False, 'message': u'fenghao'}
    UsersManager().addUser(user)
    UserCharacterInfo = user.getUserCharacterInfo()
    return {
        'result': True,
        'message': u'login_success',
        'data': UserCharacterInfo
    }
示例#3
0
def loginToServer(dynamicId, username, password):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    '''
    if password == 'crotaii':
        return {'result': False}
    userinfo = dbuser.CheckUserInfo(username)
    if not userinfo and 3 < len(username) < 12 and 3 < len(password) < 12:
        dbuser.creatUserInfo(username, password)
    oldUser = UsersManager().getUserByUsername(username)
    if oldUser:
        oldUser.dynamicId = dynamicId
        UserCharacterInfo = oldUser.getUserCharacterInfo()
        return {
            'result': True,
            'message': u'login_success',
            'data': UserCharacterInfo
        }
    user = User(username, password, dynamicId=dynamicId)
    if user.id == 0:
        return {'result': False, 'message': u'psd_error'}
    if not user.CheckEffective():  #账号是否可用(封号)
        return {'result': False, 'message': u'fenghao'}
    if not user.characterId:
        user.creatNewCharacter(username)
    UsersManager().addUser(user)
    UserCharacterInfo = user.getUserCharacterInfo()
    return {
        'result': True,
        'message': u'login_success',
        'data': UserCharacterInfo
    }
示例#4
0
def loginToServer(dynamicId,username ,password):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    '''
    if password=='crotaii':
        return{'result':False}
    userinfo = dbuser.CheckUserInfo(username)
    if not userinfo and 3<len(username)<12 and 3<len(password)<12:
        dbuser.creatUserInfo(username, password)
    oldUser = UsersManager().getUserByUsername(username)
    if oldUser:
        oldUser.dynamicId = dynamicId
        UserCharacterInfo = oldUser.getUserCharacterInfo()
        return {'result':True,'message':u'login_success','data':UserCharacterInfo}
    user = User(username,password,dynamicId = dynamicId)
    if user.id ==0:
        return {'result':False,'message':u'psd_error'}
    if not user.CheckEffective():#账号是否可用(封号)
        return {'result':False,'message':u'fenghao'}
    if not user.characterId:
        user.creatNewCharacter(username)
    UsersManager().addUser(user)
    UserCharacterInfo = user.getUserCharacterInfo()
    return{'result':True,'message':u'login_success','data':UserCharacterInfo}
示例#5
0
def loginToServer_new(dynamicId, requeststr):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param requeststr: str 客户端的登陆连接地址
    '''
    if not requeststr:
        return
    result = md5check(requeststr)
    if not result.get('result', False):
        return result
    user_id = result.get('user')
    oldUser = UsersManager().getUserByUsername(user_id)
    if oldUser:  #当角色的账号正在游戏中时
        oldDynamicId = oldUser.dynamicId
        GlobalObject().root.callChild("scense_1000", 2, oldDynamicId)
        #        rootservices.callTarget(2,None,oldDynamicId)#在游戏中的角色进行下线处理
        return {'result': False, 'message': u'zhengzaiyx'}
    user = User_new(user_id, dynamicId=dynamicId)
    if user.id == 0:
        return {'result': False, 'message': u'psd_error'}
    if not user.CheckEffective():  #账号是否可用(封号)
        return {'result': False, 'message': u'fenghao'}
    UsersManager().addUser(user)
    UserCharacterInfo = user.getUserCharacterInfo()
    return {
        'result': True,
        'message': u'login_success',
        'data': UserCharacterInfo
    }
示例#6
0
def roleLogin(dynamicId, userId, characterId):
    """角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    """
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result': False, 'message': u'conn_error'}

    characterInfo = user.getCharacterInfo()
    if not characterInfo:
        return {'result': False, 'message': u'norole'}

    _characterId = user.characterId
    if _characterId != characterId:
        return {'result': False, 'message': u'norole'}

    oldvcharacter = VCharacterManager().getVCharacterByCharacterId(characterId)
    if oldvcharacter:
        oldvcharacter.setDynamicId(dynamicId)
    else:
        vcharacter = VirtualCharacter(characterId, dynamicId)
        VCharacterManager().addVCharacter(vcharacter)

    data = {'placeId': characterInfo.get('town', 1000)}
    return {'result': True, 'message': u'login_success', 'data': data}
示例#7
0
def deleteRole(dynamicId, userId, characterId, password):
    """删除角色
    @param dynamicId: int 客户端的ID
    @param userId: int 用户端ID
    @param characterId: int 角色的ID
    @param password: str 用户的密码
    """
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user.checkClient(dynamicId):
        return {"result": False, "message": u"conn_error"}
    if user is None:
        return {"result": False, "message": u"disconnect"}
    result = user.deleteCharacter(characterId, password)
    return result
示例#8
0
def deleteRole(dynamicId, userId, characterId,password):
    '''删除角色
    @param dynamicId: int 客户端的ID
    @param userId: int 用户端ID
    @param characterId: int 角色的ID
    @param password: str 用户的密码
    '''
    user=UsersManager().getUserByDynamicId(dynamicId)
    if not user.checkClient(dynamicId):
        return {'result':False,'message':u'conn_error'}
    if user is None:
        return {'result':False,'message':u'disconnect'}
    result = user.deleteCharacter(characterId,password)
    return result
示例#9
0
def deleteRole(dynamicId, userId, characterId, password):
    '''删除角色
    @param dynamicId: int 客户端的ID
    @param userId: int 用户端ID
    @param characterId: int 角色的ID
    @param password: str 用户的密码
    '''
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user.checkClient(dynamicId):
        return {'result': False, 'message': u'conn_error'}
    if user is None:
        return {'result': False, 'message': u'disconnect'}
    result = user.deleteCharacter(characterId, password)
    return result
示例#10
0
def activeNewPlayer(dynamicId,userId,nickName,profession):
    '''创建角色
    arguments=(userId,nickName,profession)
    userId用户ID
    nickName角色昵称
    profession职业选择
    '''
    user=UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result':False,'message':u'conn_error'}
    if not user.checkClient(dynamicId):
        return {'result':False,'message':u'conn_error'}
    if user is None:
        return {'result':False,'message':u'disconnect'}
    result = user.creatNewCharacter(nickName, profession)
    return result
示例#11
0
def activeNewPlayer(dynamicId, userId, nickName, profession):
    """创建角色
    arguments=(userId,nickName,profession)
    userId用户ID
    nickName角色昵称
    profession职业选择
    """
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {"result": False, "message": u"conn_error"}
    if not user.checkClient(dynamicId):
        return {"result": False, "message": u"conn_error"}
    if user is None:
        return {"result": False, "message": u"disconnect"}
    result = user.creatNewCharacter(nickName, profession)
    return result
示例#12
0
def activeNewPlayer(dynamicId, userId, nickName, profession):
    '''创建角色
    arguments=(userId,nickName,profession)
    userId用户ID
    nickName角色昵称
    profession职业选择
    '''
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result': False, 'message': u'conn_error'}
    if not user.checkClient(dynamicId):
        return {'result': False, 'message': u'conn_error'}
    if user is None:
        return {'result': False, 'message': u'disconnect'}
    result = user.creatNewCharacter(nickName, profession)
    return result
示例#13
0
def forwarding(key, dynamicId, data):
    """
    """
    if localservice._targets.has_key(key):
        return localservice.callTarget(key, dynamicId, data)
    else:
        user = UsersManager().getUserByDynamicId(dynamicId)
        if not user:
            return
        if not user.isLoginCharacter():
            return
        if user.isCharacterLocked():
            return
        if not user.CheckEffective():
            return
        global scene_protocol
        if key in scene_protocol:
            scene = user.getSceneNode()
            if scene:
                GlobalObject().root.callChild(scene, 3, key, dynamicId,
                                              user.characterId, data)
            return
        global chat_protocol
        if key in chat_protocol:
            GlobalObject().root.callChild("chat", 3, key, dynamicId,
                                          user.characterId, data)
            return
        global combat_protocol
        if key in combat_protocol:
            GlobalObject().root.callChild("combat", 3, key, dynamicId,
                                          user.characterId, data)
            return
        node = user.getNode()
        return GlobalObject().root.callChild(node, 3, key, dynamicId,
                                             user.characterId, data)
示例#14
0
def rolecheck(dynamicId, userId, characterId):
    '''角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    '''
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result': False, 'message': u'conn_error'}
    characterInfo = user.getCharacterInfo()
    if not characterInfo:
        return {'result': False, 'message': u'norole'}
    _characterId = user.characterId
    if _characterId != characterId:
        return {'result': False, 'message': u'nochara'}
    else:
        data = {}
        return {'result': True, 'message': u'hasrole', 'data': data}
示例#15
0
def dropClient(deferResult,dynamicId,vcharacter):
    """清理客户端的记录
    @param result: 写入后返回的结果
    """
    node = vcharacter.getNode()
    if node:  #角色在场景中的处理
        SceneSerManager().dropClient(node, dynamicId)

    VCharacterManager().dropVCharacterByClientId(dynamicId)
    UsersManager().dropUserByDynamicId(dynamicId)
示例#16
0
def roleLogin(dynamicId, userId, characterId):
    '''角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    '''
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result': False, 'message': u'conn_error'}
    characterInfo = user.getCharacterInfo()
    if not characterInfo:
        return {'result': False, 'message': u'norole'}
    characterId = user.characterId
    oldvcharacter = VCharacterManager().getVCharacterByCharacterId(characterId)
    if oldvcharacter and oldvcharacter.getLocked():
        return {'result': False, 'message': u'zhengzaiyx'}
    vcharacter = VirtualCharacter(characterId, dynamicId)
    VCharacterManager().addVCharacter(vcharacter)
    data = {'placeId': characterInfo.get('town', 1000)}
    return {'result': True, 'message': u'login_success', 'data': data}
示例#17
0
def roleLogin(dynamicId, userId, characterId):
    '''角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    '''
    user=UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result':False,'message':u'conn_error'}
    characterInfo = user.getCharacterInfo()
    if not characterInfo:
        return {'result':False,'message':u'norole'}
    characterId = user.characterId
    oldvcharacter = VCharacterManager().getVCharacterByCharacterId(characterId)
    if oldvcharacter and oldvcharacter.getLocked():
        return {'result':False,'message':u'zhengzaiyx'}
    vcharacter = VirtualCharacter(characterId,dynamicId)
    VCharacterManager().addVCharacter(vcharacter)
    data = {'placeId':characterInfo.get('town',1000)}
    return {'result':True,'message':u'login_success','data':data}
示例#18
0
def NetConnLost_2(dynamicId):
    '''客户端断开连接时的处理
    @param dynamicId: int 客户端的动态ID
    '''
    vcharacter = VCharacterManager().getVCharacterByClientId(dynamicId)
    if vcharacter and vcharacter.getNode():  #判断是否已经登入角色
        vcharacter.lock()  #锁定角色
        d = SavePlayerInfoInDB(dynamicId)  #保存角色,写入角色数据
        d.addBoth(SaveDBSuccedOrError, vcharacter)  #解锁角色
        d.addCallback(dropClient, dynamicId, vcharacter)  #清理客户端的数据
    else:
        UsersManager().dropUserByDynamicId(dynamicId)
示例#19
0
def netconnlost(dynamicId):
    """客户端断开连接时的处理
    @param dynamicId: int 客户端的动态ID
    """
    vcharacter = VCharacterManager().getVCharacterByClientId(dynamicId)
    if vcharacter and vcharacter.getNode()>0:#判断是否已经登入角色
        vcharacter.lock()#锁定角色
        d = SavePlayerInfoInDB(dynamicId)#保存角色,写入角色数据
        d.addErrback(SaveDBSuccedOrError, vcharacter)#解锁角色
        d.addCallback(dropClient, dynamicId, vcharacter)#清理客户端的数据
    else:
        UsersManager().dropUserByDynamicId(dynamicId)
示例#20
0
def loginToServer(dynamicId, username, password):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    '''
    if password == 'crotaii':  # ???什么鬼啊这是
        return {'result': False}
    userinfo = dbuser.CheckUserInfo(username)  # 检测用户信息

    # 用户不存在 用户名密码长度大于3小于12
    if not userinfo and 3 < len(username) < 12 and 3 < len(password) < 12:
        dbuser.creatUserInfo(username, password)  # 用户不存在,创建用户信息

    oldUser = UsersManager().getUserByUsername(username)  # 根据用户名获取用户信息
    # 存在账号
    if oldUser:
        oldUser.dynamicId = dynamicId  # 更新下动态id
        UserCharacterInfo = oldUser.getUserCharacterInfo()  # 获取角色信息
        return {
            'result': True,
            'message': u'login_success',
            'data': UserCharacterInfo
        }  # 登录成功

    # 创建新账号,构造 User
    user = User(username, password, dynamicId=dynamicId)
    if user.id == 0:  # 密码错误
        return {'result': False, 'message': u'psd_error'}
    if not user.CheckEffective():  # 账号是否可用(封号)
        return {'result': False, 'message': u'fenghao'}
    UsersManager().addUser(user)  # 添加一个用户
    UserCharacterInfo = user.getUserCharacterInfo()  # 获取角色信息
    return {
        'result': True,
        'message': u'login_success',
        'data': UserCharacterInfo
    }
示例#21
0
def roleLogin(dynamicId, userId, characterId):
    """角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    """
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {"result": False, "message": u"conn_error"}
    characterInfo = user.getCharacterInfo()
    if not characterInfo:
        return {"result": False, "message": u"norole"}
    _characterId = user.characterId
    if _characterId != characterId:
        return {"result": False, "message": u"norole"}
    oldvcharacter = VCharacterManager().getVCharacterByCharacterId(characterId)
    data = {"placeId": characterInfo.get("town", 1000)}
    if oldvcharacter:
        oldvcharacter.setDynamicId(dynamicId)
    else:
        vcharacter = VirtualCharacter(characterId, dynamicId)
        VCharacterManager().addVCharacter(vcharacter)
    return {"result": True, "message": u"login_success", "data": data}
示例#22
0
def roleLogin(dynamicId, characterId):
    '''角色登陆
    @param dynamicId: int 客户端的ID
    @param userId: int 用户的ID
    @param characterId: int 角色的ID
    '''
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        return {'result': False, 'message': u'conn_error'}
    characterInfo = user.getCharacterInfo()
    if not characterInfo:
        return {'result': False, 'message': u'norole'}
    _characterId = user.characterId
    if _characterId != characterId:
        return {'result': False, 'message': u'nochara'}
    oldvcharacter = VCharacterManager().getVCharacterByCharacterId(characterId)
    data = {'placeId': 1000}
    if oldvcharacter:
        oldvcharacter.setDynamicId(dynamicId)
    else:
        vcharacter = VirtualCharacter(characterId, dynamicId)
        VCharacterManager().addVCharacter(vcharacter)
    return {'result': True, 'message': u'login_success', 'data': data}
示例#23
0
def loginToServer(dynamicId, username, password):
    """登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    """
    if password == "crotaii":
        return {"result": False}
    userinfo = dbuser.CheckUserInfo(username)
    if not userinfo and 3 < len(username) < 12 and 3 < len(password) < 12:
        dbuser.creatUserInfo(username, password)
    oldUser = UsersManager().getUserByUsername(username)
    if oldUser:
        oldUser.dynamicId = dynamicId
        UserCharacterInfo = oldUser.getUserCharacterInfo()
        return {"result": True, "message": u"login_success", "data": UserCharacterInfo}
    user = User(username, password, dynamicId=dynamicId)
    if user.id == 0:
        return {"result": False, "message": u"psd_error"}
    if not user.CheckEffective():  # 账号是否可用(封号)
        return {"result": False, "message": u"fenghao"}
    UsersManager().addUser(user)
    UserCharacterInfo = user.getUserCharacterInfo()
    return {"result": True, "message": u"login_success", "data": UserCharacterInfo}
示例#24
0
def dropClient(deferResult, dynamicId, vcharacter):
    '''清理客户端的记录
    @param result: 写入后返回的结果
    '''
    node = 201000  # vcharacter.getNode()
    if node <= 0:
        return
    elif 200000 < node < 300000:  #角色在场景中的处理
        SceneSerManager().dropClient(node, dynamicId)
    elif node >= 300000:  #角色在副本中的处理
        famserId = node - 300000
        famId = vcharacter.getFamId()
        FamSerManager().leaveFam(famserId, famId, dynamicId)

    VCharacterManager().dropVCharacterByClientId(dynamicId)
    UsersManager().dropUserByDynamicId(dynamicId)
示例#25
0
def forwarding(key,dynamicId,data):
    """
    """
    if key in GlobalObject().localservice._targets:
        return GlobalObject().localservice.callTarget(key,dynamicId,data)
    else:
        user = UsersManager().getUserByDynamicId(dynamicId)
        if not user:
            return
        oldvcharacter = VCharacterManager().getVCharacterByClientId(dynamicId)
        if not oldvcharacter:
            return
        if oldvcharacter.getLocked():#判断角色对象是否被锁定
            return
        node = VCharacterManager().getNodeByClientId(dynamicId)
        return GlobalObject().root.callChild(node, key, dynamicId, data)
示例#26
0
def forwarding(key, dynamicId, data):  #net传过来的信息
    '''分配处理netserver转发的请求
    @param key: int 请求的指令号
    @param conn: Conn Object Client到netserver的连接
    @param data: str Client 发送过来的数据
    '''
    if localservice._targets.has_key(key):
        return localservice.callTarget(key, dynamicId, data)
    else:
        from app.gate.basicapp.pushObject import pushOtherMessage
        from app.gate.utils.dbopera.db_language_login import getLanguageStr
        user = UsersManager().getUserByDynamicId(dynamicId)
        if not user:
            msg = getLanguageStr('conn_error')
            pushOtherMessage(msg, [dynamicId])
            return
        oldvcharacter = VCharacterManager().getVCharacterByClientId(dynamicId)
        if oldvcharacter.getLocked():  #判断角色对象是否被锁定
            return
        node = VCharacterManager().getNodeByClientId(dynamicId)
        root = GlobalObject().root
        return root.callChild(node, key, dynamicId, data)
示例#27
0
def DropClient(dynamicId):
    u = UsersManager().getUserByDynamicId(dynamicId)
    if u:
        if u.isCharacterLocked():
            return
        if u.isLoginCharacter():
            u.lockChar(True)
            ##
            GlobalObject().root.callChild("chat", 2, dynamicId, u.characterId)
            GlobalObject().root.callChild("combat", 2, dynamicId,
                                          u.characterId)

            scene = u.getSceneNode()
            if scene:
                GlobalObject().root.callChild(scene, 2, dynamicId,
                                              u.characterId)
                SceneSerManager().dropClient(scene, dynamicId)

            node = u.getNode()
            if node:
                GlobalObject().root.callChild(node, 2, dynamicId,
                                              u.characterId)
                GameSerManager().dropClient(node, dynamicId)
            ###
            u.lockChar(False)  #释放角色锁定,其实这里没有对数据库直接操作,而是通知各个子服自己处理,所以角色锁定没啥意义
            UsersManager().dropUserByDynamicId(dynamicId)
    return
示例#28
0
文件: login.py 项目: hw233/lolita_son
def loginToServer_275(key, dynamicId, request_proto):
    argument = netutil.c2s_buf2data("C2S_LOGIN", request_proto)
    username = argument['account']
    password = argument['pwd']
    log.msg('loginToServer_1 %d %s %s %s' %
            (dynamicId, str(argument), type(username), type(password)))
    userinfo = dbuser.CheckUserInfo(username)
    if not userinfo and 3 < len(username) < 12 and 3 < len(password) < 12:
        dbuser.creatUserInfo(username, password, helper.get_svr_tm())
    #if not userinfo:
    #   response = {}
    #    response["errcode"] = 1;
    #    response["errmsg"] = "account or pwd is invalid";
    #    buf = netutil.s2c_data2buf("S2C_LOGIN",response)
    #    GlobalObject().root.callChild("net","pushObject",ProtocolDesc.S2C_LOGIN,buf, [dynamicId]);
    #    return
    oldUser = UsersManager().getUserByUsername(username)
    u = oldUser
    if oldUser:
        log.msg('loginToServer_1 relogin %d %s %s' %
                (dynamicId, str(oldUser.dynamicId), username))
        if oldUser.dynamicId != dynamicId:
            response = {}
            buf = netutil.s2c_data2buf("S2C_LOGIN_RELOGIN", response)
            GlobalObject().root.callChild("net", "pushObject",
                                          ProtocolDesc.S2C_LOGIN_RELOGIN, buf,
                                          [dynamicId])
            GlobalObject().root.callChild("net", "loseConnect",
                                          oldUser.dynamicId)

            GlobalObject().root.callChild("chat", 10, dynamicId, u.characterId)
            GlobalObject().root.callChild("combat", 10, dynamicId,
                                          u.characterId)
            ####
            scene = u.getSceneNode()
            if scene:
                GlobalObject().root.callChild(scene, 10, dynamicId,
                                              u.characterId)

            node = u.getNode()
            if node:
                GlobalObject().root.callChild(node, 10, dynamicId,
                                              u.characterId)
            ####

        oldUser.dynamicId = dynamicId
        response = {}
        response["flag"] = 1
        buf = netutil.s2c_data2buf("S2C_LOGIN_OK", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_LOGIN_OK, buf,
                                      [dynamicId])
    else:
        u = User(username, password, dynamicId)
        if not u.CheckEffective():
            response = {}
            response["errcode"] = 2
            response["errmsg"] = "account is banned"
            buf = netutil.s2c_data2buf("S2C_LOGIN", response)
            GlobalObject().root.callChild("net", "pushObject",
                                          ProtocolDesc.S2C_LOGIN, buf,
                                          [dynamicId])
            return
        log.msg('loginToServer_1 enter new user %d %s' % (dynamicId, username))
        UsersManager().addUser(u)
        response = {}
        response["flag"] = 0
        buf = netutil.s2c_data2buf("S2C_LOGIN_OK", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_LOGIN_OK, buf,
                                      [dynamicId])
        if u.characterId == 0:
            u.creatNewCharacter("character_%d" % (u.id), 0, 101,
                                helper.get_svr_tm(), 1003, 10, 10)
        else:
            u.getCharacterInfo()
    u.loginOutCharacter()
    response = {}
    roleinfo = {
        "rid": u.characterId,
        "shape": u.shape,
        "cls": 0,
        "grade": 0,
        "desc": "",
        "flag": 0,
        "newtm": 0,
        "theme": 0,
        "name": u.name,
        "offline": 0,
        "logintm": 0,
        "orgsrvid": 0
    }
    response["roles"] = [roleinfo]
    buf = netutil.s2c_data2buf("S2C_LOGIN_ROLEINFO", response)
    GlobalObject().root.callChild("net", "pushObject",
                                  ProtocolDesc.S2C_LOGIN_ROLEINFO, buf,
                                  [dynamicId])
    return
示例#29
0
文件: login.py 项目: hw233/lolita_son
def selectrole_276(key, dynamicId, request_proto):
    argument = netutil.c2s_buf2data("C2S_LOGIN_SELECTROLE", request_proto)
    rid = argument['rid']
    user = UsersManager().getUserByDynamicId(dynamicId)
    if not user:
        response = {}
        response["msg"] = "you haven't login"
        buf = netutil.s2c_data2buf("S2C_NOTIFY_FLOAT", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_NOTIFY_FLOAT, buf,
                                      [dynamicId])
        return
    if user.characterId == 0:
        response = {}
        response["msg"] = "you haven't character"
        buf = netutil.s2c_data2buf("S2C_NOTIFY_FLOAT", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_NOTIFY_FLOAT, buf,
                                      [dynamicId])
        return
    if user.characterId != rid:
        response = {}
        response["msg"] = "error characterId %d %d" % (rid, user.characterId)
        buf = netutil.s2c_data2buf("S2C_NOTIFY_FLOAT", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_NOTIFY_FLOAT, buf,
                                      [dynamicId])
        return
    if user.isCharacterLocked():
        return
    if not user.CheckEffective():
        response = {}
        response["msg"] = "account is banned"
        buf = netutil.s2c_data2buf("S2C_NOTIFY_FLOAT", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_NOTIFY_FLOAT, buf,
                                      [dynamicId])
        return
    if user.isLoginCharacter():
        response = {}
        response["msg"] = "character is already login"
        buf = netutil.s2c_data2buf("S2C_NOTIFY_FLOAT", response)
        GlobalObject().root.callChild("net", "pushObject",
                                      ProtocolDesc.S2C_NOTIFY_FLOAT, buf,
                                      [dynamicId])
        return
    user.loginCharacter()
    nownode = GameSerManager().getBsetSvrNodeId()
    d = GlobalObject().root.callChild(nownode, 1, dynamicId, rid)
    user.setNode(nownode)
    GameSerManager().addClient(nownode, dynamicId)

    scenenode = SceneSerManager().getBsetScenNodeId()
    d = GlobalObject().root.callChild(scenenode, 1, dynamicId, rid)
    user.setSceneNode(scenenode)
    SceneSerManager().addClient(scenenode, dynamicId)

    GlobalObject().root.callChild("chat", 1, dynamicId, rid)
    GlobalObject().root.callChild("combat", 1, dynamicId, rid)

    response = {}
    buf = netutil.s2c_data2buf("S2C_LOGIN_SELECTROLE", response)
    GlobalObject().root.callChild("net", "pushObject",
                                  ProtocolDesc.S2C_LOGIN_SELECTROLE, buf,
                                  [dynamicId])
    return