| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- Json = Json or require("common.Json")
- local Config = require("Config")
- local CommonDefine = require("common.CommonDefine")
- local Log = require("common.Log")
- local CommonDB = require("common.CommonDB")
- local LogDefine = require("common.LogDefine")
- local Msg = require("core.Msg")
- local ObjHuman = require("core.ObjHuman")
- local CreateRole = require("role.CreateRole")
- local PlatformDefine = require("platform.Define")
- local PfLogic = require("platform.PfLogic")
- local LuaMongo = _G.lua_mongo
- local DB = require("common.DB")
- local RoleDBLogic = require("role.RoleDBLogic")
- local Util = require("common.Util")
- local AuthCheck = require("scene.AuthCheck")
- local ApiLogic = require("platform.ApiLogic")
- local CDKLoigc = require("present.CDK")
- local MailManager = require("mail.MailManager")
- local QQBigShot = require("platform.QQBigShot")
- local BanLogic = require("scene.BanLogic")
- local function HumanLogin_Handle(human, params)
- print("[HumanLogin_Handle] 进入了判断")
- table.print_lua_table(params)
- if params.dwkLevel then
- print("[HumanLogin_Handle] 获取到的等级 dwkLevel = "..params.dwkLevel)
- QQBigShot.QQBigShot_HumanLoginHandle(human, params.dwkLevel)
- end
- end
- -- 是否禁止登录
- local function isBan(uuid, channelId, account, appId)
- return BanLogic.CheckBan(uuid, channelId, account, appId)
- end
- --在线玩家列表不再从 ObjHuman.onlineAccount 获取, 改为从 ObjHuman.onlineNewUniqueTag 获取
- function CG_TEST_PROTO(fd,msg)
- print("============ CG_TEST_PROTO")
- local param = Json.Decode(msg.param)
- local uTag = RoleDBLogic.Generateuuid(param.channel_id, msg.account, msg.serverTag)
- if param.type == "UseCDKV2" then
- -- local human = ObjHuman.onlineAccount[msg.account]
- local human = ObjHuman.onlineNewUniqueTag[uTag]
- if not human then
- -- 玩家不在线 做一个离线处理
- return
- end
- CDKLoigc.cdkDoV2(human,{
- itemList = param.itemList,
- })
- elseif param.type == "UseCDK" then
- -- local human = ObjHuman.onlineAccount[msg.account]
- local human = ObjHuman.onlineNewUniqueTag[uTag]
- if not human then
- -- 玩家不在线 做一个离线处理
- return
- end
- local batch = Json.Decode(param.batchInfo)
- CDKLoigc.cdkDo(human,{
- itemList = Json.Decode(batch.itenList),
- serverList = Json.Decode(batch.serverList),
- batch = tonumber(batch.batch),
- useCnt = tonumber(batch.cnt),
- err = param.err,
- })
- elseif param.type == "UseFixCDK" then
- -- local human = ObjHuman.onlineAccount[msg.account]
- local human = ObjHuman.onlineNewUniqueTag[uTag]
- if not human then
- -- 玩家不在线 做一个离线处理
- return
- end
- CDKLoigc.cdkFixDo(human,param.code) --
- elseif param.type == "sendMail" then
- local mail = Json.Decode(param.mail)
- MailManager.add(MailManager.SYSTEM,mail.uuid,mail.title,mail.content,mail.items,nil,nil,nil,nil,nil,nil,mail.expire)
- elseif param.type == "kickAllUser" then
- -- for _,h in pairs(ObjHuman.onlineAccount) do
- -- ObjHuman.doDisconnect(h, CommonDefine.DISCONNECT_KICK_ALL)
- -- sendDisconnect(h.fd,CommonDefine.DISCONNECT_KICK_ALL)
- -- end
- for _,h in pairs(ObjHuman.onlineNewUniqueTag) do
- ObjHuman.doDisconnect(h, CommonDefine.DISCONNECT_KICK_ALL)
- sendDisconnect(h.fd,CommonDefine.DISCONNECT_KICK_ALL)
- end
- end
- end
- function CG_AA_DISCONNECT(human)
- if type(human) ~= "table" then return end
- ObjHuman.doDisconnect(human, CommonDefine.DISCONNECT_NORMAL)
- end
- function setLoginParams(human, msg, params)
- human.lang = msg.lang
- human.region = (msg.region == "") and "CN" or string.upper(msg.region)
- human.ip = (msg.ip ~= "") and msg.ip or _G.global.get_ip_from_fd(human.fd)
- -- 有些字段重复赋值,看看以后要不要干掉。。。
- human.pf = params.pf
- human.isIOS = params.isIOS or 0
- human.vopenid = params.openid or ""
- human.openkey = params.openkey or ""
- human.phpChanelID = params.phpChanelID or ""
- human.appid = params.appid
- human.gameName = params.gameName or ""
- human.version = params.version or nil
- human.serverTag = msg.serverTag
- human.pf_info = human.pf_info or {}
- human.pf_info.openid = params.openid or ""
- human.pf_info.openkey = params.openkey or ""
- human.pf_info.pf = params.pf or ""
- human.pf_info.pfkey = params.pfkey or ""
- human.pf_info.zoneid = params.zoneid or 0
- human.pf_info.serverid = params.serverid or 0
- human.pf_info.tcTime = os.time()
- human.pf_info.lvYellow = params.lvYellow or 0
- human.pf_info.yearYellow = params.yearYellow or 0
- human.pf_info.superYellow = params.superYellow or 0
- human.pf_info.lvBlue = params.lvBlue or 0
- human.pf_info.yearBlue = params.yearBlue or 0
- human.pf_info.superBlue = params.superBlue or 0
- human.pf_info.validTimeBlue = params.validTimeBlue or 0
- human.pf_info.vipSevenk = params.vipSevenk or 0
- human.pf_info.validTimeSevenk = params.validTimeSevenk or 0
- human.pf_info.phpChanelID = params.phpChanelID or ""
- human.pf_info.phoneSystem = params.phoneSystem or "android"
- human.pf_info.from_openid = params.from_openid or ""
- end
- function sendDisconnect(fd, errCode)
- local mm = Msg.gc.GC_DISCONNECT
- mm.code = errCode
- mm.msg = CommonDefine.DISCONNECT_MSG[errCode]
- Msg.send(mm, fd)
- end
- function CG_ASK_LOGIN(fd, msg)
- -- 测试支付回调 有时间换个地方
- if msg.account == "H1EqhbpA80jt0Jw6Q3T2" then
- print("测试支付回调")
- local payParams = Json.Decode(msg.params)
- print(table.print_lua_table(payParams))
- oJsonInput = {
- type=1,
- id=payParams.id,--商品id
- cnt=payParams.cnt, --数量
- money=payParams.money, -- 金额
- account=payParams.account, --账号
- serverTag = msg.serverTag, --区服标识
- order=payParams.order,--订单号
- region="cn",
- channelID = payParams.channel_id
- }
- local buyRet = ApiLogic.deliver(oJsonInput,{})
- Log.write(Log.LOGID_OSS_DELIVER,Json.Encode(buyRet))
- -- if ApiLogic.deliver(oJsonInput,{}) then
- -- return
- -- end
- return
- end
- if _G.is_middle == true then return end
- --判断是否是数字类型
- if type(fd) ~= "number" then
- assert()
- end
- --如果在线人数大于最大可容纳在线人数时,断开链接
- local onlineCnt = ObjHuman.getOnlineCnt()
- if onlineCnt >= CommonDefine.MAX_ONLINE_COUNT then
- return sendDisconnect(fd, CommonDefine.DISCONNECT_MAX_ONLINE)
- end
- --目前暂未校验,返回的都是true,后续如果需要校验,再看看是否需要把区服标识传入
- local retAuth = AuthCheck.authCheck(msg.account, msg.authkey, msg.timestamp, msg.ip)
- if retAuth ~= true then
- return sendDisconnect(fd, CommonDefine.DISCONNECT_AUTH_FAIL)
- end
- local account = msg.account
- local serverTag = msg.serverTag
- local params = Json.Decode(msg.params)
- print("CG_ASK_LOGIN", msg.account, msg.serverTag, params.phpChanelID, type(params.phpChanelID))
- --如果是已经登录的,也断开连接
- --local human_old = ObjHuman.onlineAccount[account]
- local uTag = RoleDBLogic.Generateuuid(params.phpChanelID, account, serverTag)
- local human_old = ObjHuman.onlineNewUniqueTag[uTag]
- if human_old then
- ObjHuman.doDisconnect(human_old, CommonDefine.DISCONNECT_DUPLICATE)
- end
- --创建新角色
- -- local human = ObjHuman.create(fd, account, human_old and human_old.db, nil)
- local human = ObjHuman.create(fd, account, human_old and human_old.db, uTag)
- setLoginParams(human, msg, params) -- 设置登录参数
- -- 禁止登录检测
- -- if isBan(human.db and human.db._id, params.phpChanelID, account, params.appid) then
- -- return
- -- end
- if human.db == nil then
- -- 新号
- local ip,time = CommonDB.getBanIp(msg.ip)
- if (time and time > os.time()) then
- ObjHuman.doDisconnect(human, CommonDefine.DISCONNECT_BANIP)
- return
- else
- CommonDB.delBanIp(msg.ip)
- end
-
- Log.write(Log.LOGID_OSS_CREATELOSS,account, "", LogDefine.HUMAN_LOST.ENTRANCE, human.ip, human.pf, human.appid, human.phpChanelID)
- CreateRole.createNewRole(human)
- -- HumanLogin_Handle(human, params)
- else
- -- 封号
- if human.db.banUserTime == -1 or
- (human.db.banUserTime and human.db.banUserTime > os.time()) then
- ObjHuman.doDisconnect(human, CommonDefine.DISCONNECT_BANUSER)
- return
- end
- local ip,time = CommonDB.getBanIp(msg.ip)
- if (time and time > os.time()) then
- ObjHuman.doDisconnect(human, CommonDefine.DISCONNECT_BANIP)
- return
- else
- CommonDB.delBanIp(msg.ip)
- end
- ObjHuman.onLogin(human, nil)
- -- HumanLogin_Handle(human, params)
- end
- -- -- 单次上报时长设置为登录时间
- -- human.db.onlineTimeDayReport = os.time()
- end
- function CG_HEART_BEAT(human, msg)
- local msgRet = Msg.gc.GC_HEART_BEAT
- msgRet.timeStamp = os.time()
- Msg.send(msgRet, human.fd)
- end
- -- 记录fps
- local FPS_TB = {["guaji"]=1, ["zhandou"]=1, ["zhucheng"]=1, ["buzhen"]=1}
- function CG_PHONE_FPS(human, msg)
- if FPS_TB[msg.fpsType] == nil then return end
- human.db.fpsTb = human.db.fpsTb or {}
- human.db.fpsTb[msg.fpsType] = { lv = human.db.lv, startFps = msg.startFps, endFps = msg.endFps}
- end
- function CG_HEART_BEAT_M(human)
- end
- function CG_ASK_DISCONNECT(human)
- ObjHuman.doDisconnect(human, CommonDefine.DISCONNECT_NORMAL)
- end
- function CG_CLIENT_ERROR(human, msg)
- Log.write(Log.LOGID_OSS_CLIENT_ERR, human.db and human.db._id or "", human.db and human.db.account or human.account, human.db and human.db.name or "", msg.err)
- end
- function CG_CLIENT_LOAD_ERROR(human, msg)
- Log.write(Log.LOGID_OSS_CLIENT_LOAD_ERR, human.db and human.db._id or "", human.db and human.db.account or human.account, human.db and human.db.name or "", msg.err)
- end
- IOS_FLAG_CHARGECLOSE = 0 -- 提示关闭
- IOS_FLAG_CHARGEOPENTIP = 1 -- 提示开放
- IOS_FLAG_CHARGEOPEN = 2 -- 充值开放
- function getIosChargeOpenFlag(human)
- if PfLogic.isFkwTishen() == true then
- if human.isIOS == 1 then
- return IOS_FLAG_CHARGECLOSE
- end
- end
-
- if PfLogic.isKunTangTishen() == true then
- return IOS_FLAG_CHARGECLOSE
- end
-
- return IOS_FLAG_CHARGEOPEN
- end
- function canCharge(human)
- if getIosChargeOpenFlag(human) == IOS_FLAG_CHARGECLOSE then
- return
- end
- return true
- end
- function CG_SET_BAN(fd, msg)
- BanLogic.Update_Ban_Info(msg.banInfo)
- end
|