--服务器IP列表
LoginIpList = 
{
	['怒海争锋'] = '120.92.176.214',
	['青梅煮酒'] = '120.92.176.215',
	['剑胆琴心'] = '121.14.64.120',
	['幽月轮'] = '121.14.64.78',
	['双剑合璧'] = '120.92.176.156',
	['天下归一'] = '120.92.176.156',
	['日月凌空'] = '120.92.176.156',
	['比翼齐飞'] = '120.92.176.34',
	['鹏程万里'] = '120.92.176.34',
	['破阵子'] = '120.92.176.116',
	['天鹅坪'] = '120.92.176.35',
	['飞鸢泛月'] = '120.92.176.34',
	['雪絮金屏'] = '120.92.176.34',
	['侠肝义胆'] = '120.92.176.35',
	['鱼跃龙门'] = '120.92.176.116',
	['穆如清风'] = '120.92.176.116',
	['念奴娇'] = '120.92.176.116',
	['行云流水'] = '120.92.176.116',
	['五台山'] = '120.92.176.34',
	['君子如风'] = '120.92.176.35',
	['攻无不克'] = '120.92.176.35',
	['碧血忠魂'] = '120.92.176.35',
	['时乘六龙'] = '120.92.176.35',
	['纵横江湖'] = '120.92.176.35',
	['步月登云'] = '120.92.176.35',
	['长风破晓'] = '120.92.176.156',
	['潮生碧海'] = '120.92.176.34',
	['风雷刀谷'] = '120.92.176.21',
	['四海一家'] = '120.92.176.21',
	['李忘生'] = '120.92.176.21',
	['松烟竹雾'] = '120.92.176.21',
	['飞龙在天'] = '120.92.176.21',
	['叶芷青'] = '120.92.176.21',
	['天长地久'] = '120.92.176.21',
	['楼台烟雨'] = '120.92.176.21',
	['无悔江湖'] = '120.92.176.21',
	['登峰造极'] = '120.92.176.21',
	['飞凤涅磐'] = '120.92.176.21',
	['铁血丹心'] = '120.92.176.21',
	['赞青春'] = '120.92.176.21',
	['跃马扬鞭'] = '120.92.176.21',
	['银枪暮雪'] = '120.92.176.21',
	['西京烟雨'] = '120.92.176.21',
	['黑云压城'] = '120.92.176.21',
	['君山岛'] = '120.92.176.21',
	['荡气回肠'] = '120.92.176.21',
	['银蛇献瑞'] = '120.92.176.21',
	['龙战于野'] = '120.92.176.21',
	['往生涧'] = '120.92.176.21',
	['金风飒飒'] = '120.92.176.21',
	['万马奔腾'] = '120.92.176.21',
	['醉舞狂歌'] = '120.92.176.21',
	['情深意重'] = '120.92.176.21',
	['王昌龄'] = '120.92.176.21',
	['谁与争锋'] = '120.92.176.21',
	['林白轩'] = '120.92.176.21',
	['高绛婷'] = '120.92.176.21',
	['玄正'] = '120.92.176.21',
	['王维'] = '120.92.176.21',
	['柳风骨'] = '120.92.176.21',
	['李承恩'] = '120.92.176.21',
	['谢云流'] = '120.92.176.21',
	['李白'] = '120.92.176.21',
	['杜甫'] = '120.92.176.21',
	['卧虎藏龙'] = '120.92.176.21',
	['唐简'] = '120.92.176.21',
	['七侠五义'] = '120.92.176.21',
	['孟浩然'] = '120.92.176.21',
	['吕洞宾'] = '120.92.176.21',
	['公孙幽'] = '120.92.176.21',
	['歃血为盟'] = '120.92.176.21',
	['于睿'] = '120.92.176.21',
	['僧一行'] = '120.92.176.21',
	['东方宇轩'] = '120.92.176.21',
	['叶孟秋'] = '120.92.176.21',
	['杨宁'] = '120.92.176.21',
	['点墨山河'] = '120.92.176.21',
	['天罗地网'] = '120.92.176.21',
	['暴雨梨花'] = '120.92.176.21',
	['琴瑟和鸣'] = '120.92.176.21',
	['缘定三生'] = '120.92.176.21',
	['乱世争锋'] = '120.92.176.21',
	['行者无疆'] = '120.92.176.21',
	['花月别院'] = '120.92.176.21',
	['百转千回'] = '120.92.176.21',
	['怒海争锋'] = '120.92.176.214',
	['青梅煮酒'] = '120.92.176.215',
	['碧海青天'] = '120.92.176.156',
	['星火燎原'] = '120.92.176.156',
	['春花秋月'] = '120.92.176.156',
	['锦绣山河'] = '120.92.176.156',
	['千古风流'] = '120.92.176.156',
	['大美江湖'] = '120.92.176.156',
	['长安城'] = '121.14.64.3',
	['龙争虎斗'] = '121.14.64.5',
	['神龙摆尾'] = '121.14.64.5',
	['海誓山盟'] = '121.14.64.5',
	['幽雨坪'] = '121.14.64.5',
	['翠烟山'] = '121.14.64.5',
	['逍遥林'] = '121.14.64.5',
	['枫华谷'] = '121.14.64.5',
	['义薄云天'] = '121.14.64.5',
	['晴昼海'] = '121.14.64.5',
	['金水镇'] = '121.14.64.5',
	['昆仑'] = '121.14.64.5',
	['扬州城'] = '121.14.64.3',
	['巴陵县'] = '121.14.64.3',
	['南屏山'] = '121.14.64.3',
	['洛道'] = '121.14.64.3',
	['洛阳城'] = '121.14.64.3',
	['龙门荒漠'] = '121.14.64.3',
	['萍踪侠影'] = '121.14.64.3',
	['独步天下'] = '121.14.64.3',
	['夜幕星河'] = '121.14.64.5',
	['白帝城'] = '121.14.64.5',
	['荻花宫'] = '121.14.64.5',
	['风花雪月'] = '121.14.64.5',
	['群英汇'] = '121.14.64.5',
	['壮志凌云'] = '121.14.64.5',
	['逍遥游'] = '121.14.64.5',
	['枫林如火'] = '121.14.64.5',
	['华清池'] = '121.14.64.5',
	['追风蹑景'] = '121.14.64.5',
	['傲视天地'] = '121.14.64.5',
	['步莲台'] = '121.14.64.5',
	['天子峰'] = '121.14.64.5',
	['落星湖'] = '121.14.64.5',
	['空雾峰'] = '121.14.64.5',
	['天工坊'] = '121.14.64.5',
	['灵霄峡'] = '121.14.64.5',
	['日轮山城'] = '121.14.64.5',
	['云湖天池'] = '121.14.64.5',
	['上陵苑'] = '121.14.64.5',
	['三才阵'] = '121.14.64.5',
	['无盐岛'] = '121.14.64.5',
	['紫微山'] = '121.14.64.5',
	['演武场'] = '121.14.64.5',
	['英雄擂'] = '121.14.64.5',
	['浮光掠影'] = '121.14.64.5',
	['肝胆相照'] = '121.14.64.5',
	['侠骨丹心'] = '121.14.64.5',
	['相知莫问'] = '121.14.64.5',
	['金蛇漫舞'] = '121.14.64.5',
	['秀明尘身'] = '121.14.64.5',
	['秦王殿'] = '121.14.64.5',
	['微山书院'] = '121.14.64.5',
	['比翼双飞'] = '121.14.64.5',
	['出神入化'] = '121.14.64.5',
	['双狼之战'] = '121.14.64.5',
	['鹤舞九霄'] = '121.14.64.5',
	['战魂劫'] = '121.14.64.5',
	['大雄宝殿'] = '121.14.64.5',
	['天王殿'] = '121.14.64.5',
	['敬德楼'] = '121.14.64.5',
	['血龙出渊'] = '121.14.64.5',
	['凌烟阁'] = '121.14.64.5',
	['达摩院'] = '121.14.64.5',
	['太极广场'] = '121.14.64.5',
	['纯阳宫'] = '121.14.64.5',
	['落雁峰'] = '121.14.64.5',
	['青萝山'] = '121.14.64.5',
	['无极道场'] = '121.14.64.5',
	['忆盈楼'] = '121.14.64.5',
	['三星望月'] = '121.14.64.5',
	['飞星遁影'] = '121.14.64.5',
	['忆青春'] = '121.14.64.5',
	['蝶恋花'] = '121.14.64.72',
	['日月明尊'] = '121.14.64.72',
	['沁园春'] = '121.14.64.72',
	['初心不泯'] = '121.14.64.72',
	['厉兵秣马'] = '121.14.64.72',
	['登萍渡水'] = '121.14.64.72',
	['叱咤风云'] = '121.14.64.72',
	['策马江湖'] = '121.14.64.72',
	['潜龙勿用'] = '121.14.64.72',
	['惊鸿游龙'] = '121.14.64.72',
	['龙腾虎跃'] = '121.14.64.72',
	['千机阁'] = '121.14.64.72',
	['飞骏谷'] = '121.14.64.72',
	['虎牢关'] = '121.14.64.72',
	['六祖台'] = '121.14.64.72',
	['午阳岗'] = '121.14.64.72',
	['战江湖'] = '121.14.64.72',
	['藏经阁'] = '121.14.64.72',
	['饮马川'] = '121.14.64.72',
	['轩辕台'] = '121.14.64.72',
	['知节殿'] = '121.14.64.72',
	['论剑峰'] = '121.14.64.72',
	['少室山'] = '121.14.64.72',
	['燕子坞'] = '121.14.64.72',
	['思过崖'] = '121.14.64.72',
	['山河齐颂'] = '121.14.64.72',
	['红尘寻梦'] = '121.14.64.72',
	['名扬四海'] = '121.14.64.72',
	['名动江湖'] = '121.14.64.72',
	['春和景明'] = '121.14.64.72',
	['气吞山河'] = '121.14.64.72',
	['天马行空'] = '121.14.64.72',
	['天佑中华'] = '121.14.64.72',
	['烈日斩'] = '121.14.64.72',
	['众志成城'] = '121.14.64.72',
	['鹰击长空'] = '121.14.64.72',
	['天女散花'] = '121.14.64.72',
	['英雄结义'] = '121.14.64.72',
	['国色天香'] = '121.14.64.72',
	['倾国倾城'] = '121.14.64.72',
	['剑指龙城'] = '121.14.64.72',
	['大圣归来'] = '121.14.64.72',
	['情深似海'] = '121.14.64.3',
	['一苇渡江'] = '121.14.64.3',
	['仙侣庭园'] = '121.14.64.3',
	['雪月天枪'] = '121.14.64.3',
	['破茧成蝶'] = '121.14.64.3',
	['恋青春'] = '121.14.64.3',
	['光明顶'] = '121.14.64.3',
	['不归海'] = '121.14.64.3',
	['圣火令'] = '121.14.64.3',
	['乱世长安'] = '121.14.64.3',
	['快意恩仇'] = '121.14.64.3',
	['斗转星移'] = '121.14.64.155',
	['乾坤一掷'] = '121.14.64.92',
	['梦江南'] = '121.14.64.29',
	['唯我独尊'] = '121.14.64.14',
	['幽月轮'] = '121.14.64.78',
	['平步青云'] = '121.14.64.78',
	['千岛湖'] = '121.14.64.78',
	['金榜题名'] = '121.14.64.53',
	['剑胆琴心'] = '121.14.64.120',
	['山雨欲来'] = '121.14.64.78',
	['笑傲江湖'] = '121.14.64.78',
	['圣墓山'] = '121.14.64.78',
	['风雨同舟'] = '121.14.64.155',
	['金戈铁马'] = '121.14.64.155',
	['枫泾古镇'] = '121.14.64.29',
	['华山论剑'] = '121.14.64.92',
	['满江红'] = '121.14.64.14',
	['侠客行'] = '121.14.64.14',
	['如梦令'] = '121.14.64.29',
	['世外蓬莱'] = '121.14.64.120',
	['风骨霸刀'] = '121.14.64.162',
	['百家争鸣'] = '121.14.64.162',
	['暗香掠影'] = '121.14.64.162',
	['引仙水榭'] = '121.14.64.23',
	['亢龙有悔'] = '121.14.64.224',
	['绝代天骄'] = '121.14.64.162',
	['战无不胜'] = '121.14.64.23',
	['星河清梦'] = '121.14.64.224',
	['龙飞凤舞'] = '121.14.64.162',
	['梦回大唐'] = '121.14.64.162',
	['侠骨柔情'] = '121.14.64.23',
	['致青春'] = '121.14.64.23',
	['双龙取水'] = '121.14.64.224',
	['见龙在田'] = '121.14.64.224',
	['大明宫'] = '121.14.64.224',
	['武林同庆'] = '121.14.64.162',
	['止戈为武'] = '120.92.176.166',
	['百无禁忌'] = '121.14.64.184',
}

--服务器名列表
LoginServerNameList = 
{
	['怒海争锋'] = '双线新服',
	['青梅煮酒'] = '双线新服',
	['剑胆琴心'] = '电信新服',
	['幽月轮'] = '电信新服',
	['双剑合璧'] = '双线一区',
	['天下归一'] = '双线一区',
	['日月凌空'] = '双线一区',
	['比翼齐飞'] = '双线一区',
	['鹏程万里'] = '双线一区',
	['破阵子'] = '双线一区',
	['天鹅坪'] = '双线一区',
	['飞鸢泛月'] = '双线一区',
	['雪絮金屏'] = '双线一区',
	['侠肝义胆'] = '双线一区',
	['鱼跃龙门'] = '双线一区',
	['穆如清风'] = '双线一区',
	['念奴娇'] = '双线一区',
	['行云流水'] = '双线一区',
	['五台山'] = '双线一区',
	['君子如风'] = '双线一区',
	['攻无不克'] = '双线一区',
	['碧血忠魂'] = '双线一区',
	['时乘六龙'] = '双线一区',
	['纵横江湖'] = '双线一区',
	['步月登云'] = '双线一区',
	['长风破晓'] = '双线一区',
	['潮生碧海'] = '双线一区',
	['风雷刀谷'] = '双线二区',
	['四海一家'] = '双线二区',
	['李忘生'] = '双线二区',
	['松烟竹雾'] = '双线二区',
	['飞龙在天'] = '双线二区',
	['叶芷青'] = '双线二区',
	['天长地久'] = '双线二区',
	['楼台烟雨'] = '双线二区',
	['无悔江湖'] = '双线二区',
	['登峰造极'] = '双线二区',
	['飞凤涅磐'] = '双线二区',
	['铁血丹心'] = '双线二区',
	['赞青春'] = '双线二区',
	['跃马扬鞭'] = '双线二区',
	['银枪暮雪'] = '双线二区',
	['西京烟雨'] = '双线二区',
	['黑云压城'] = '双线二区',
	['君山岛'] = '双线二区',
	['荡气回肠'] = '双线二区',
	['银蛇献瑞'] = '双线二区',
	['龙战于野'] = '双线二区',
	['往生涧'] = '双线二区',
	['金风飒飒'] = '双线二区',
	['万马奔腾'] = '双线二区',
	['醉舞狂歌'] = '双线二区',
	['情深意重'] = '双线二区',
	['王昌龄'] = '双线二区',
	['谁与争锋'] = '双线二区',
	['林白轩'] = '双线二区',
	['高绛婷'] = '双线二区',
	['玄正'] = '双线二区',
	['王维'] = '双线二区',
	['柳风骨'] = '双线二区',
	['李承恩'] = '双线二区',
	['谢云流'] = '双线二区',
	['李白'] = '双线二区',
	['杜甫'] = '双线二区',
	['卧虎藏龙'] = '双线二区',
	['唐简'] = '双线二区',
	['七侠五义'] = '双线二区',
	['孟浩然'] = '双线二区',
	['吕洞宾'] = '双线二区',
	['公孙幽'] = '双线二区',
	['歃血为盟'] = '双线二区',
	['于睿'] = '双线二区',
	['僧一行'] = '双线二区',
	['东方宇轩'] = '双线二区',
	['叶孟秋'] = '双线二区',
	['杨宁'] = '双线二区',
	['点墨山河'] = '双线二区',
	['天罗地网'] = '双线二区',
	['暴雨梨花'] = '双线二区',
	['琴瑟和鸣'] = '双线二区',
	['缘定三生'] = '双线二区',
	['乱世争锋'] = '双线二区',
	['行者无疆'] = '双线二区',
	['花月别院'] = '双线二区',
	['百转千回'] = '双线二区',
	['怒海争锋'] = '双线四区',
	['青梅煮酒'] = '双线四区',
	['碧海青天'] = '双线一区',
	['星火燎原'] = '双线一区',
	['春花秋月'] = '双线一区',
	['锦绣山河'] = '双线一区',
	['千古风流'] = '双线一区',
	['大美江湖'] = '双线一区',
	['长安城'] = '电信一区',
	['龙争虎斗'] = '电信一区',
	['神龙摆尾'] = '电信一区',
	['海誓山盟'] = '电信一区',
	['幽雨坪'] = '电信一区',
	['翠烟山'] = '电信一区',
	['逍遥林'] = '电信一区',
	['枫华谷'] = '电信一区',
	['义薄云天'] = '电信一区',
	['晴昼海'] = '电信一区',
	['金水镇'] = '电信一区',
	['昆仑'] = '电信一区',
	['扬州城'] = '电信一区',
	['巴陵县'] = '电信一区',
	['南屏山'] = '电信一区',
	['洛道'] = '电信一区',
	['洛阳城'] = '电信一区',
	['龙门荒漠'] = '电信一区',
	['萍踪侠影'] = '电信一区',
	['独步天下'] = '电信一区',
	['夜幕星河'] = '电信一区',
	['白帝城'] = '电信一区',
	['荻花宫'] = '电信一区',
	['风花雪月'] = '电信一区',
	['群英汇'] = '电信一区',
	['壮志凌云'] = '电信一区',
	['逍遥游'] = '电信一区',
	['枫林如火'] = '电信一区',
	['华清池'] = '电信一区',
	['追风蹑景'] = '电信一区',
	['傲视天地'] = '电信一区',
	['步莲台'] = '电信一区',
	['天子峰'] = '电信一区',
	['落星湖'] = '电信一区',
	['空雾峰'] = '电信一区',
	['天工坊'] = '电信一区',
	['灵霄峡'] = '电信一区',
	['日轮山城'] = '电信一区',
	['云湖天池'] = '电信一区',
	['上陵苑'] = '电信一区',
	['三才阵'] = '电信一区',
	['无盐岛'] = '电信一区',
	['紫微山'] = '电信一区',
	['演武场'] = '电信一区',
	['英雄擂'] = '电信一区',
	['浮光掠影'] = '电信一区',
	['肝胆相照'] = '电信一区',
	['侠骨丹心'] = '电信一区',
	['相知莫问'] = '电信一区',
	['金蛇漫舞'] = '电信一区',
	['秀明尘身'] = '电信一区',
	['秦王殿'] = '电信一区',
	['微山书院'] = '电信一区',
	['比翼双飞'] = '电信一区',
	['出神入化'] = '电信一区',
	['双狼之战'] = '电信一区',
	['鹤舞九霄'] = '电信一区',
	['战魂劫'] = '电信一区',
	['大雄宝殿'] = '电信一区',
	['天王殿'] = '电信一区',
	['敬德楼'] = '电信一区',
	['血龙出渊'] = '电信一区',
	['凌烟阁'] = '电信一区',
	['达摩院'] = '电信一区',
	['太极广场'] = '电信一区',
	['纯阳宫'] = '电信一区',
	['落雁峰'] = '电信一区',
	['青萝山'] = '电信一区',
	['无极道场'] = '电信一区',
	['忆盈楼'] = '电信一区',
	['三星望月'] = '电信一区',
	['飞星遁影'] = '电信一区',
	['忆青春'] = '电信一区',
	['蝶恋花'] = '电信一区',
	['日月明尊'] = '电信一区',
	['沁园春'] = '电信一区',
	['初心不泯'] = '电信一区',
	['厉兵秣马'] = '电信一区',
	['登萍渡水'] = '电信一区',
	['叱咤风云'] = '电信一区',
	['策马江湖'] = '电信一区',
	['潜龙勿用'] = '电信一区',
	['惊鸿游龙'] = '电信一区',
	['龙腾虎跃'] = '电信一区',
	['千机阁'] = '电信一区',
	['飞骏谷'] = '电信一区',
	['虎牢关'] = '电信一区',
	['六祖台'] = '电信一区',
	['午阳岗'] = '电信一区',
	['战江湖'] = '电信一区',
	['藏经阁'] = '电信一区',
	['饮马川'] = '电信一区',
	['轩辕台'] = '电信一区',
	['知节殿'] = '电信一区',
	['论剑峰'] = '电信一区',
	['少室山'] = '电信一区',
	['燕子坞'] = '电信一区',
	['思过崖'] = '电信一区',
	['山河齐颂'] = '电信一区',
	['红尘寻梦'] = '电信一区',
	['名扬四海'] = '电信一区',
	['名动江湖'] = '电信一区',
	['春和景明'] = '电信一区',
	['气吞山河'] = '电信一区',
	['天马行空'] = '电信一区',
	['天佑中华'] = '电信一区',
	['烈日斩'] = '电信一区',
	['众志成城'] = '电信一区',
	['鹰击长空'] = '电信一区',
	['天女散花'] = '电信一区',
	['英雄结义'] = '电信一区',
	['国色天香'] = '电信一区',
	['倾国倾城'] = '电信一区',
	['剑指龙城'] = '电信一区',
	['大圣归来'] = '电信一区',
	['情深似海'] = '电信一区',
	['一苇渡江'] = '电信一区',
	['仙侣庭园'] = '电信一区',
	['雪月天枪'] = '电信一区',
	['破茧成蝶'] = '电信一区',
	['恋青春'] = '电信一区',
	['光明顶'] = '电信一区',
	['不归海'] = '电信一区',
	['圣火令'] = '电信一区',
	['乱世长安'] = '电信一区',
	['快意恩仇'] = '电信一区',
	['斗转星移'] = '电信五区',
	['乾坤一掷'] = '电信五区',
	['梦江南'] = '电信五区',
	['唯我独尊'] = '电信五区',
	['幽月轮'] = '电信五区',
	['平步青云'] = '电信五区',
	['千岛湖'] = '电信五区',
	['金榜题名'] = '电信五区',
	['剑胆琴心'] = '电信五区',
	['山雨欲来'] = '电信五区',
	['笑傲江湖'] = '电信五区',
	['圣墓山'] = '电信五区',
	['风雨同舟'] = '电信五区',
	['金戈铁马'] = '电信五区',
	['枫泾古镇'] = '电信五区',
	['华山论剑'] = '电信五区',
	['满江红'] = '电信五区',
	['侠客行'] = '电信五区',
	['如梦令'] = '电信五区',
	['世外蓬莱'] = '电信五区',
	['风骨霸刀'] = '电信八区',
	['百家争鸣'] = '电信八区',
	['暗香掠影'] = '电信八区',
	['引仙水榭'] = '电信八区',
	['亢龙有悔'] = '电信八区',
	['绝代天骄'] = '电信八区',
	['战无不胜'] = '电信八区',
	['星河清梦'] = '电信八区',
	['龙飞凤舞'] = '电信八区',
	['梦回大唐'] = '电信八区',
	['侠骨柔情'] = '电信八区',
	['致青春'] = '电信八区',
	['双龙取水'] = '电信八区',
	['见龙在田'] = '电信八区',
	['大明宫'] = '电信八区',
	['武林同庆'] = '电信八区',
	['止戈为武'] = '双线PVP搞事区',
	['百无禁忌'] = '电信PVP搞事区',
}


--登录 ('电信五区(可空)', '如梦令', '121.14.64.29'(可空), 'username', 'password')
--gcLogin ('', '如梦令', '', 'username', 'password')
function gcLogin(szRegion, szServer, szServerIp, szAccount, szPassword)
	-- local szRegion = '电信五区'
	-- local szServer = '如梦令'
	-- local szServerIp = '121.14.64.29'
	-- local szAccount = ''
	-- local szPassword = ''
	-- local szRoleName = ''
	if szRegion == nil or szRegion == '' then
		szRegion = LoginServerNameList[szServer]
	end
	
	if szServerIp == nil or szServerIp == '' then
		szServerIp = LoginIpList[szServer]
	end
	
	if Login.m_StateLeaveFunction == Login.LeaveCustomRole then
		Login.EnterRoleList()
		return
	end
	--账号登录
	local hPFrame = Station.Lookup("Normal/LoginPassword") --输入密码
	if hPFrame and hPFrame:IsVisible() then
		if  szRegion and szServer and szAccount and szPassword then
			Login.m_szRoleFullName = szRoleName
			LoginServerList.szRegion = szRegion
			LoginServerList.szServer = szServer
			hPFrame:Lookup("WndPassword/Wnd_PasswordContent/Edit_Account"):SetText(szAccount)
			hPFrame:Lookup("WndPassword/Wnd_PasswordContent/Edit_Password"):SetText(szPassword)
			Login.m_bSelectServer = true
			Login.m_szServerIP, Login.m_nServerPort = szServerIp, 3724
			LoginPassword.SaveAccountAndPassword()
			g_tLoginData.bAcceptEULA = true --接受用户协议
			Login.BeginWait("登录中...")
			Login_CancelLogin()
			Login_SetGatewayAddress(Login.m_szServerIP, Login.m_nServerPort)
			Login_SetAccountPassword(Login.m_szAccount, Login.m_szPassword, szVersionEx ~= "snda")
			Login_ConnectGateway()
		end
	end
end



--取当前角色状态--1登录界面，2选择角色界面，3游戏中正常，4加载中
function gcGetCurState()

	frame = Station.Lookup("Normal/LoginPassword")
	if frame then
		if frame:IsVisible() then
			return 1	--登录界面
		end
	end
	
	local frame = Station.Lookup("Topmost/LoginRoleList")
	if frame then
		return 2--选择角色界面
	end
	
	frame = Station.Lookup("Topmost2/LoadingPanel")
	if frame then
		if frame:IsVisible() then
			return 4	--加载中
		end
	end
	
	
	if(GetClientPlayer()) then
		return 3--游戏中正常
	else
		return 4--加载中
	end

end


--点击按钮更换服务器(大区, 服务器)
--gcLoginChangeUiServer('电信五区', '梦江南')
function gcLoginChangeUiServer(szRegion, szServer)
	if not szRegion or not szServer then
		return false
	end
	if szRegion == '' or szServer == '' then
		return false
	end

	--打开服务器窗口
	local Btn_ChangeServer = Station.Lookup("Normal/LoginServerPanel/Wnd_ServerPanel/Btn_ChangeServer")
	if Btn_ChangeServer then
		this = Btn_ChangeServer
		LoginServerPanel.OnLButtonClick()
	end
	--换大区
	local MainWnd = Station.Lookup( 'Topmost/LoginServerList/WndScroll_Region' )
	if MainWnd then
		local handle = MainWnd:Lookup('','')
		Handle_RegionList = handle:Lookup('Handle_RegionList')
		local handle_num = Handle_RegionList:GetItemCount()
		for i = 0, handle_num - 1, 1 do
			local btn_hd = Handle_RegionList:Lookup(i)
			local Text_Region = btn_hd:Lookup('Text_Region')
			
			if Text_Region:GetText() == szRegion then
				this = btn_hd
				LoginServerList.OnItemLButtonClick()
			end
		end
	end
	--换服务器
	local MainWnd = Station.Lookup( 'Topmost/LoginServerList/WndScroll_Server' )
	if MainWnd then
		local handle = MainWnd:Lookup('','')
		Handle_ServerList = handle:Lookup('Handle_ServerList')
		local handle_num = Handle_ServerList:GetItemCount()
		for i = 0, handle_num - 1, 1 do
			local btn_hd = Handle_ServerList:Lookup(i)
			local Text_Name = btn_hd:Lookup('Text_Name')
			if Text_Name:GetText() == szServer then
				this = btn_hd
				LoginServerList.OnItemLButtonClick()
			end
		end
	end
	--如果是PVP服务器会弹出一个框 点击确定
	--Topmost/LoginServerList/Wnd_PVPWarn/Btn_PVPWarnOk/  type:WndButton
	local Btn_PVPWarnOk = Station.Lookup("Topmost/LoginServerList/Wnd_PVPWarn/Btn_PVPWarnOk")
	if Btn_PVPWarnOk then
		this = Btn_PVPWarnOk
		LoginServerList.OnLButtonClick()
	end
	--点击确定
	--Topmost/LoginServerList/Wnd_Button/Btn_Ok/  type:WndButton
	local Btn_Ok = Station.Lookup("Topmost/LoginServerList/Wnd_Button/Btn_Ok")
	if Btn_Ok then
		this = Btn_Ok
		LoginServerList.OnLButtonClick()
	end
end

--判断附近是否存在邮寄信使NPC
function IsExistMailNpc()
	local id=0
	local NpcLst = GetNpcList()
    for _, NpcId in pairs(NpcLst) do
		local NpcObj = GetNpc(NpcId)
		if string.find(NpcObj.szName,"信使") or  string.find(NpcObj.szTitle,"信使")  then
			id=NpcId
			if GetDistance(NpcObj.nX,NpcObj.nY,NpcObj.nZ)>5 then
				 return 99
			end
			InteractNpc(id)
			return id
		end
    end	
	return id
end

function GetDistance(nX, nY, nZ)
	local me = GetClientPlayer()
	if not nY and not nZ then
		local tar = nX
		nX, nY, nZ = tar.nX, tar.nY, tar.nZ
	elseif not nZ then
		return math.floor(((me.nX - nX) ^ 2 + (me.nY - nY) ^ 2) ^ 0.5)/64
	end
	return math.floor(((me.nX - nX) ^ 2 + (me.nY - nY) ^ 2 + (me.nZ/8 - nZ/8) ^ 2) ^ 0.5)/64
end 


function OutTalkData(index,num)
local  a=Station.Lookup('Lowest2/ChatPanel' .. index .. '/Wnd_Message','Handle_Message')
local handle=a
local str1=''
local lastnum=0
	if handle and handle:GetType() == 'Handle' then
		local handle_num = handle:GetItemCount()
		if handle_num >40 then
			lastnum =handle_num-40
		end 
		if handle_num and handle_num > 0 then
			for i = lastnum, handle_num - 1, 1 do
				local TmpHandle = handle:Lookup(i)
			
					if TmpHandle:GetType() == 'Text' then
						str1=str1..(string.format('%s',  TmpHandle:GetText()))
					elseif TmpHandle.szName then
						str1=str1..(string.format('%s',  TmpHandle.szName))
					else
						str1=str1..(string.format('[%s]',  TmpHandle:GetName()))
					end
				
			end
		end
	end
	if	num == 1 then
		for line in string.gmatch(str1, "([^\n]+)[\n]*$") do
		  str1=line
		end
		return str1
	end
--local t = {}
--local i = 0
--while true do
  --  i = string.find(str1, '\n', i+1)  -- 查找下一行
    --if i == nil then break end
--table.insert(t, i)
--end
--local j=table.getn(t)	--换行符数量
--local x=t[j-num]	--根据需求取倒数第几个换行符的位置
--str1=string.sub(str1,x) --取出文本内容
return(str1)
end




function Recruit(content)
	local Btn_Ok = Station.Lookup("Normal/TeamBuilding/PageSet_TeamBuild/Page_TeamManagement/Btn_Edit/")
	if Btn_Ok then
		this = Btn_Ok
		TeamBuilding.OnLButtonClick()
		else
		return 1
	end
	Btn_Ok = Station.Lookup("Normal/TeamBuilding/PageSet_TeamBuild/Page_TeamManagement/Btn_Del/")
	if Btn_Ok then
		this = Btn_Ok
		TeamBuilding.OnLButtonClick()
		else
		return 2
	end
	 Btn_Ok = Station.Lookup("Normal/TeamBuilding/Wnd_SendMessage/Edit_RecruitMsg/")
	if Btn_Ok then	
		Btn_Ok:SetText(content)
		else
		return 3
	end
	 Btn_Ok = Station.Lookup("Normal/TeamBuilding/Wnd_SendMessage/Btn_PubLishMessage/")
	if Btn_Ok then
		this = Btn_Ok
		TeamBuilding.OnLButtonClick()
		return 0
	end
end
function CreateRole(name, Menpai,Tixing)
Login.Enter("school_select")
local m_tSchoolParam = Table_GetCreateRoleParam() 
local m_dwKungfuIndex = m_tSchoolParam[Menpai].dwKungfuIndex 
Login.Enter("rolecreate", Tixing, Menpai, m_dwKungfuIndex)
Station.Lookup("Topmost/LoginCustomRoleNext/WndRoleName/Edit_Name"):SetText(name) 
end
	
	--选中角色 不进入(传入角色名或下标，下标0开始)
function gcClickRole(szName_or_nIndex)

	--Topmost/LoginRoleList/WndRoleList/Wnd_RoleList/WndScroll_RoleList/WndContainer_RoleList/Wnd_Role/Wnd_Info/  type:WndWindow

	local nIndex = 0
	if type(szName_or_nIndex) == 'string' then
		--角色名
		--取角色索引
		local nRoleCount = Login_GetRoleCount() --角色数量
		for i = 0, nRoleCount - 1, 1 do
			local t = Login_GetRoleInfo(i)
			if  t.RoleName == szName_or_nIndex then
				nIndex = i
			end
		end
	else
		--索引
		nIndex = szName_or_nIndex
	end
	
	--根据索引找到控件句柄
	local Wnd_Role = Station.Lookup('Topmost/LoginRoleList/WndRoleList/Wnd_RoleList/WndScroll_RoleList/WndContainer_RoleList/Wnd_Role')
	if Wnd_Role then
		--Wnd_Role = Wnd_Role:GetNext()
		for i = 0, nIndex - 1, 1 do
			if Wnd_Role then
				Wnd_Role = Wnd_Role:GetNext()
			end
		end
		--执行点击
		if Wnd_Role then
			local Wnd_Info = Wnd_Role:Lookup('Wnd_Info')
			if Wnd_Info then
				this = Wnd_Info
				LoginRoleList.OnLButtonClick()
				Wnd.OpenWindow('LoginDeleteRole')
				return 1
			end
		end
	end
	
	return 0
end



function tClickRole(szName)
	local h9=Station.Lookup('Topmost/LoginDeleteRole/WndDeleteRole/')
	if h9 then 
		Wnd.CloseWindow('LoginDeleteRole')
	end
local nIndex =0
local nRoleCount = Login_GetRoleCount() --角色数量
for i=0,nRoleCount -1 ,1  do
	local Wnd_Role = Station.Lookup('Topmost/LoginRoleList/WndRoleList/Wnd_RoleList/WndScroll_RoleList/WndContainer_RoleList/Wnd_Role')
	if Wnd_Role then
		nIndex =i
		for j = 0, nIndex - 1, 1 do
			if Wnd_Role then
				Wnd_Role = Wnd_Role:GetNext()
			end
		end
		--执行点击
		if Wnd_Role then
			local Wnd_Info = Wnd_Role:Lookup('Wnd_Info')
			if Wnd_Info then
				this = Wnd_Info
				LoginRoleList.OnLButtonClick()
				if LoginRoleList.GetSelectedRoleEquip().RoleName==szName then
					if  LoginRoleList.GetSelectedRoleEquip().RoleLevel > 2 then
						return '3'
					end
					Wnd.OpenWindow('LoginDeleteRole')
					 local h2=Station.Lookup('Topmost/LoginDeleteRole/WndDeleteRole/')
						if h2 then
							local h=h2:Lookup('','')
							local  d=  h:Lookup('Image_Question')
								if d then
									d:SetAbsPos(0,0)
									local x,y=d:GetSize()
									return x..','..y
								end
						end
				end
			end
		end
	end
end 
return '0'
end
function aa(x,y)
	return x*y+3
end