hxp
2024-07-08 e718ef8d79b1d1a7f546ec686b70e752cb60e3fa
ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
@@ -44,24 +44,38 @@
#import PlayerFamilyStore
import PlayerSocial
import PlayerFamilyParty
import PlayerSealDemon
#import PlayerSealDemon
import PlayerBillboard
import PlayerLVAward
import PlayerDuJie
import PlayerFamilySWRH
import IpyGameDataPY
import PlayerTalk
import PlayerGeTui
import PlayerStore
import GameWorldActionControl
import GameWorldFamilyWar
import PlayerFBHelpBattle
import GameWorldSkyTower
import GMT_CTG
import PyGameData
import GMShell
import IPY_PlayerDefine
import GameWorldArena
import CrossLuckyCloudBuy
import CrossRealmPK
import CrossChampionship
import AuctionHouse
import PlayerAssist
import PlayerFB
import PlayerLove
import PlayerCharm
import CrossRealmPlayer
import CrossBattlefield
import CrossActAllRecharge
import CrossYaomoBoss
import GameWorldMineArea
import PlayerRecData
import GameWorship
#---------------------------------------------------------------------
#---------------------------------------------------------------------
@@ -86,9 +100,7 @@
    except:
        curPlayer.Kick(IPY_PlayerDefine.disWaitForPlayerLoinError)
        import traceback
        GameWorld.ErrLog("玩家上线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
        if GameWorld.GetGameWorld().GetDebugLevel():
            raise Exception("玩家上线逻辑错误~~~~\r\n%s" % traceback.format_exc())
        GameWorld.RaiseException("玩家上线逻辑错误\r\n%s" % traceback.format_exc())
    return
#---------------------------------------------------------------------
@@ -119,6 +131,8 @@
    if GameWorld.IsCrossServer():
        #跨服PK
        CrossRealmPK.OnPlayerLoginCrossServer(curPlayer)
        #协助
        PlayerAssist.OnPlayerLoginCrossServer(curPlayer)
        return
    
    #玩家家族刷新
@@ -126,7 +140,9 @@
    PlayerFamily.PlayerLoginRefreshFamily(curPlayer, tick)
    #玩家队伍初始化
    PlayerTeam.OnPlayerLoginRefreshTeam(curPlayer, tick)
    PlayerCompensation.NotifyPlayerCompensation(curPlayer)
    #PlayerCompensation.NotifyPlayerCompensation(curPlayer)
    __UpdOnedayJobPlayerLoginoffTime(curPlayer)
    CrossRealmPlayer.OnPlayerLogin(curPlayer)
    
    if not PlayerControl.GetIsTJG(curPlayer):
        # 只有通知逻辑的应该放此处减少IO,如有逻辑处理存储等不可放在此处
@@ -157,7 +173,7 @@
        #仙盟宴会
        PlayerFamilyParty.OnPlayerLogin(curPlayer)
        #封魔坛
        PlayerSealDemon.OnPlayerLogin(curPlayer)
        #PlayerSealDemon.OnPlayerLogin(curPlayer)
        #仙魔之争
        PlayerXMZZ.OnXMZZOnLogin(curPlayer)
        #等级奖励
@@ -166,27 +182,106 @@
        PlayerStore.OnPlayerLogin(curPlayer)
        #通知世界boss信息
        GameWorldBoss.OnPlayerLogin(curPlayer)
        #家族副本boss状态通知
        PlayerFamilyBoss.OnLogin(curPlayer)
        #渡劫
        PlayerDuJie.OnPlayerLogin(curPlayer)
        #守卫人皇
        PlayerFamilySWRH.OnLogin(curPlayer)
        PlayerTalk.LoginChatMi(curPlayer)
        PlayerGeTui.CleanNewGuyCallBackGeTui(curPlayer.GetID())
        PlayerTalk.NotifyTalkCache(curPlayer)
        #活动
        GameWorldActionControl.OnPlayerLogin(curPlayer)
        #玩家等级记录
        PyGameData.g_todayPlayerLVDict[curPlayer.GetID()] = curPlayer.GetLV()
        #副本助战
        PlayerFBHelpBattle.OnHelpPlayerLogin(curPlayer)
        #竞技场
        GameWorldArena.OnPlayerLogin(curPlayer)
        #跨服PK
        CrossRealmPK.OnPlayerLogin(curPlayer)
        #幸运云购
        CrossLuckyCloudBuy.OnPlayerLogin(curPlayer)
        #诛仙BOSS
        PlayerZhuXianBoss.OnPlayerLogin(curPlayer)
        #骑宠boss状态通知
        PlayerHorsePetBoss.OnLogin(curPlayer)
        #协助
        PlayerAssist.OnPlayerLogin(curPlayer)
        #天星塔
        GameWorldSkyTower.OnPlayerLogin(curPlayer)
        #福地
        GameWorldMineArea.OnPlayerLogin(curPlayer)
        GMT_CTG.OnPlayerLogin(curPlayer)
    else:
        pass
    return
def DoPlayerRealLoginOK(curPlayer, loginMsg, tick):
    ''' 玩家最终登录成功处理, 由  MapServer  DoPlayerRealLoginOK  通知
        该函数为地图最终登录成功才会执行到,以后一些功能类的登录处理建议均写到这里
        旧的功能先不动( __DoPlayerLoginServer 函数中的功能),如果有登录相关的bug再考虑是否移动到此函数
    '''
    isMixServerFirstLogin = loginMsg[0]
    GameWorld.Log("GameServer->DoPlayerRealLoginOK, isMixServerFirstLogin=%s" % isMixServerFirstLogin, curPlayer.GetPlayerID())
    if GameWorld.IsCrossServer():
        return
    PyGameData.g_dbPlayerIDMap[curPlayer.GetPlayerID()] = curPlayer.GetAccID()
    if not PlayerControl.GetIsTJG(curPlayer):
        #家族副本boss状态通知
        PlayerFamilyBoss.OnLogin(curPlayer)
        #魅力
        PlayerCharm.OnPlayerLogin(curPlayer)
        #情缘
        PlayerLove.OnPlayerLogin(curPlayer)
        #膜拜
        GameWorship.OnPlayerLogin(curPlayer)
        #跨服战场
        CrossBattlefield.OnPlayerLogin(curPlayer)
        #跨服排位
        CrossChampionship.OnPlayerLogin(curPlayer, tick)
        #跨服全民充值
        CrossActAllRecharge.OnPlayerLogin(curPlayer)
        #跨服妖魔boss
        CrossYaomoBoss.OnPlayerLogin(curPlayer)
        #玩家记录
        PlayerRecData.OnPlayerLogin(curPlayer)
    if isMixServerFirstLogin:
        PlayerCharm.OnMixServerFirstLogin(curPlayer)
    PyGameData.g_noPlayerLoginWarningMailState = 2
    return
def __UpdOnedayJobPlayerLoginoffTime(curPlayer):
    ## 更新一天内职业对应玩家登录、离线时间
    job = curPlayer.GetJob()
    playerID = curPlayer.GetPlayerID()
    if job not in PyGameData.g_onedayJobPlayerLoginoffTimeDict:
        PyGameData.g_onedayJobPlayerLoginoffTimeDict[job] = {}
    playerLoginoffTimeDict = PyGameData.g_onedayJobPlayerLoginoffTimeDict[job]
    playerLoginoffTimeDict[playerID] = int(time.time())
    #GameWorld.DebugLog("更新职业对应玩家登录离线时间: %s" % PyGameData.g_onedayJobPlayerLoginoffTimeDict)
    return
def CheckOnedayJobPlayerLoginoffTimeout():
    ## 检查一天内职业对应玩家登录、离线时间超时玩家,每小时检查一次
    maxTime = 24 * 3600 # 暂定24小时
    curTime = int(time.time())
    #GameWorld.DebugLog("处理24小时内在线的角色职业玩家: curTime=%s,maxTime=%s, %s" % (curTime, maxTime, PyGameData.g_onedayJobPlayerLoginoffTimeDict))
    playerManager = GameWorld.GetPlayerManager()
    for playerDict in PyGameData.g_onedayJobPlayerLoginoffTimeDict.values():
        for playerID, loginoffTime in playerDict.items():
            if playerManager.FindPlayerByID(playerID):
                #GameWorld.DebugLog("    在线不处理, playerID=%s" % playerID)
                continue
            if curTime - loginoffTime > maxTime:
                playerDict.pop(playerID)
                #GameWorld.DebugLog("    超时玩家,移除! playerID=%s,loginoffTime=%s" % (playerID, loginoffTime))
    #GameWorld.DebugLog("    处理完毕,剩余玩家! %s" % PyGameData.g_onedayJobPlayerLoginoffTimeDict)
    return
## 增加高手玩家上线广播
@@ -477,9 +572,7 @@
        __Func_PlayerDisconnect(curPlayer, tick)
    except:
        import traceback
        GameWorld.ErrLog("玩家下线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
        if GameWorld.GetGameWorld().GetDebugLevel():
            raise Exception("玩家下线逻辑错误~~~~\r\n%s" % traceback.format_exc())
        GameWorld.RaiseException("玩家下线逻辑错误\r\n%s" % traceback.format_exc())
    #调用底层下线
    curPlayer.DoDisconnect()
    return
@@ -503,13 +596,22 @@
    PlayerFamily.PlayerLogoffRefreshFamily(curPlayer, tick)
    PlayerFriend.OnPlayerDisconnect(curPlayer, tick)
    
    PlayerGeTui.NewGuyCallBackGeTui(curPlayer, tick)
    __UpdOnedayJobPlayerLoginoffTime(curPlayer)
    # 设置家族成员离线时间
    SetPlayerOfflineTime(curPlayer)
    #拍卖行
    AuctionHouse.OnPlayerLeaveServer(curPlayer)
    #协助
    PlayerAssist.OnLeaveServer(curPlayer)
    #红包
    PlayerFamilyRedPacket.OnLeaveServer(curPlayer)
    #------------镖车逻辑
    #TruckPlayerDisconnectProcess(curPlayer, tick)
    if not PlayerControl.GetIsTJG(curPlayer):
        playerID = curPlayer.GetPlayerID()
        PyGameData.g_unTJLogoffTime[playerID] = int(time.time())
    return
## 设置玩家离线时间
@@ -517,8 +619,8 @@
#  @return None
#  @remarks 函数详细说明.
def SetPlayerOfflineTime(curPlayer):
    if PlayerControl.GetIsTJG(curPlayer):
        return
    #if PlayerControl.GetIsTJG(curPlayer):
    #    return
    
    curPlayerID = curPlayer.GetPlayerID()
    curFamily = curPlayer.GetFamily()
@@ -572,6 +674,7 @@
    
    playerStatePack = IPY_GameServer.IPY_GRefreshPlayerProperty()
    packValue = playerStatePack.GetValue()
    packValueEx = playerStatePack.GetValueEx()
    packType = playerStatePack.GetType()
    
    #---特殊逻辑处理---
@@ -579,6 +682,10 @@
        PlayerControl.SetGMForbidenTalk(curPlayer, packValue)
        return
    
    if packType == ShareDefine.CDBPlayerRefresh_ExAttr17:
        PlayerControl.SetPlayerAccState(curPlayer, packValue)
        return
    if packType == IPY_GameServer.CDBPlayerRefresh_State:
        # 脱机在线
        PlayerControl.SetIsTJG(curPlayer, packValue)
@@ -594,7 +701,7 @@
        return
    
    if packType == IPY_GameServer.CDBPlayerRefresh_FightPower:
        curPlayer.SetFightPower(packValue)
        curPlayer.SetFightPower(packValue, packValueEx)
        return
    if packType == IPY_GameServer.CDBPlayerRefresh_ExAttr2:
@@ -602,17 +709,26 @@
        PlayerTeam.SetTeamCheckState(curPlayer, packValue)
        return
    
    #if packType == IPY_GameServer.CDBPlayerRefresh_ExAttr1:
    #    PlayerControl.SetAssistTagPlayerID(curPlayer, packValue)
    #    return
    if packType == IPY_GameServer.CDBPlayerRefresh_ExAttr3:
        PlayerControl.SetFBFuncLineID(curPlayer, packValue)
        return
    #---常规逻辑处理---
        
    elif packType == IPY_GameServer.CDBPlayerRefresh_LV:
        curPlayer.SetLV(packValue)
        PlayerSocial.UpdateSocialInfo(curPlayer, packType, packValue)
        #玩家等级记录
        playerID = curPlayer.GetID()
        if playerID in PyGameData.g_todayPlayerLVDict:
            PyGameData.g_todayPlayerLVDict[playerID] = packValue
    elif packType == IPY_GameServer.CDBPlayerRefresh_Job:
        if packValue != curPlayer.GetJob():
            PlayerBillboard.DelJobFightPowerBillboard(curPlayer, curPlayer.GetJob())
        curPlayer.SetJob(packValue)
        
#    elif packType == IPY_GameServer.CDBPlayerRefresh_CurrentPlayerType:
@@ -640,13 +756,11 @@
        PlayerControl.SetCrossMapID(curPlayer, packValue, False)
        
    elif packType == IPY_GameServer.CDBPlayerRefresh_ExAttr9:
        PlayerControl.SetVIPExpireTime(curPlayer, packValue)
        curPlayer.SetExAttr9(packValue)
        #PlayerControl.SetVIPExpireTime(curPlayer, packValue)
        
    elif packType == IPY_GameServer.CDBPlayerRefresh_ExAttr10:
        PlayerControl.SetChatBubbleBox(curPlayer, packValue)
    elif packType == IPY_GameServer.CDBPlayerRefresh_ExAttr11:
        PlayerControl.SetTodayXianyuanCoin(curPlayer, packValue)
        
    elif packType == IPY_GameServer.CDBPlayerRefresh_ExAttr13:
        PlayerControl.SetPlayerServerGroupID(curPlayer, packValue)
@@ -656,10 +770,14 @@
    
    elif packType == IPY_GameServer.CDBPlayerRefresh_OfficialRank:
        curPlayer.SetOfficialRank(packValue)
        PlayerSocial.UpdateSocialInfo(curPlayer, packType, packValue)
        #更新排行榜的境界
        PlayerBillboard.UpdateBillboardRealm(curPlayer)
    elif packType == IPY_GameServer.CDBPlayerRefresh_Face:
        curPlayer.SetFace(packValue)
        PlayerBillboard.UpdateBillboardFace(curPlayer)
        
    #社交信息
    PlayerSocial.UpdateSocialInfo(curPlayer.GetID(), packType, packValue)
    #组队成员刷新
    PlayerTeam.PlayerTeamMemberRefresh(curPlayer, packType, packValue, tick)
    #家族刷新
@@ -684,6 +802,7 @@
    GameWorldBoss.OnPlayerChangeMap(curPlayer)
    PlayerFamily.OnPlayerChangeMap(curPlayer, tick)
    PlayerFamilyParty.OnPlayerChangeMap(curPlayer, tick)
    GameWorldFamilyWar.OnPlayerChangeMap(curPlayer)
    return 
## 玩家切换真实地图
@@ -1112,11 +1231,6 @@
#  @param tick 时间戳
#  @return None
def Sync_PyServerDataTimeToClient(curPlayer, tick):
    if not GameWorld.RefurbishPlayerTick(curPlayer, ChConfig.TYPE_Player_Tick_SyncClientTick, tick):
        #间隔未到
        return
    # 服务器时间
    serverTime = GameWorld.GetServerTime()
    if not serverTime:
@@ -1130,7 +1244,8 @@
    serverDateTime.Hour = serverTime.hour
    serverDateTime.Minute = serverTime.minute
    serverDateTime.Second = serverTime.second
    serverDateTime.MicSecond = serverTime.microsecond
    serverDateTime.MicSecond = serverTime.microsecond
    serverDateTime.CrossServerTime = GameWorld.GetCrossServerTimeStr()
    
    # 通知客户端同步时间
    NetPackCommon.SendFakePack(curPlayer, serverDateTime)