Beispiel #1
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
    }
Beispiel #2
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}
Beispiel #3
0
def createguestaccount_282(key, dynamicId, request_proto):
    account = "guest_"
    pwd = "123456"
    idx = dbuser.getGuestUserIdx()
    account = account + str(idx)
    dbuser.creatUserInfo(account, pwd, helper.get_svr_tm())
    userinfo = dbuser.CheckUserInfo(account)
    if not userinfo:
        log.msg("create guestaccount failed ", account)
        return

    response = {}
    response["account"] = account
    response["pwd"] = pwd
    buf = netutil.s2c_data2buf("S2C_ACCOUNT_GUEST", response)
    GlobalObject().root.callChild("net", "pushObject",
                                  ProtocolDesc.S2C_ACCOUNT_GUEST, buf,
                                  [dynamicId])
    return
Beispiel #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)  # 检测用户信息

    # 用户不存在 用户名密码长度大于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
    }
Beispiel #5
0
def registerToServer(dynamicId, username, password):
    '''注册
	@param dynamicId:int 客户端动态ID
	@param username:str 用户名
	@param password:str 用户密码
	'''
    result = False
    userinfo = dbuser.CheckUserInfo(username)
    if not userinfo and 3 < len(username) < 12 and 3 < len(password) < 12:
        result = dbuser.creatUserInfo(username, password)
    if result:
        res = loginToServer(dynamicId, username, password)
        return res
    else:
        return {'result': False, 'message': u"用户名已存在"}
Beispiel #6
0
def registerToServer(dynamicId,username,password):
	'''注册
	@param dynamicId:int 客户端动态ID
	@param username:str 用户名
	@param password:str 用户密码
	'''
	result=False
	userinfo=dbuser.CheckUserInfo(username)
	if not userinfo and 3<len(username)<12 and 3<len(password)<12:
		result=dbuser.creatUserInfo(username,password)
	if result:
		res=loginToServer(dynamicId,username,password)
		return res
	else:
		return {'result':False,'message':u"用户名已存在"}
Beispiel #7
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}
Beispiel #8
0
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