def enterScene(dynamicId, characterId, placeId,force): '''进入场景 @param dynamicId: int 客户端的ID @param characterId: int 角色的ID @param placeId: int 场景的ID @param force: bool ''' vplayer = VCharacterManager().getVCharacterByClientId(dynamicId) if not vplayer: return None nownode = SceneSerManager().getBsetScenNodeId() d = GlobalObject().root.callChild(nownode,601,dynamicId, characterId, placeId,force,None) vplayer.setNode(nownode) SceneSerManager().addClient(nownode, vplayer.dynamicId) return d
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
def enterScene(dynamicId, characterId, placeId, force): '''进入场景 @param dynamicId: int 客户端的ID @param characterId: int 角色的ID @param placeId: int 场景的ID @param force: bool ''' vplayer = VCharacterManager().getVCharacterByClientId(dynamicId) if not vplayer: return None nownode = SceneSerManager().getBestScenNodeId() # 获取最佳的game服务器 # 调用子节点 childname, *args d = GlobalObject().root.callChild(nownode, 601, dynamicId, characterId, placeId, force, None) vplayer.setNode(nownode) # 设置节点服务器 SceneSerManager().addClient(nownode, vplayer.dynamicId) # 添加到场景服务器 return d
def dropClient(deferResult, dynamicId, vcharacter): '''清理客户端的记录 @param result:写入后返回的结果 ''' node = vcharacter.getNode() if node: #角色在场景中的处理 SceneSerManager().dropClient(node, dynamicId) VCharacterManager().dropVCharacterByClientId(dynamicId) UsersManager().dropUserByDynamicId(dynamicId)
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