| | |
| | | import ReadChConfig
|
| | | import PlayerFamily
|
| | | import IPY_GameServer
|
| | | import PlayerFBHelpBattle
|
| | | import IpyGameDataPY
|
| | | import ShareDefine
|
| | | import ChConfig
|
| | |
|
| | |
| | | ##更新缓存数据
|
| | | # @param PlayerID, PropData, ItemData, PlusData, isSaveDB
|
| | | # @return None
|
| | | def UpdatePlayerCache(PlayerID, PropData, ItemData, PlusData, isSaveDB=False):
|
| | | def UpdatePlayerCache(PlayerID, PropData, ItemData, PlusData, isSaveDB=False, packData=None):
|
| | | curCache = ViewCacheMgr.FindCache(PlayerID)
|
| | | if not curCache:
|
| | | curCache = ViewCacheMgr.AddNewCache(PlayerID)
|
| | | curCache.SetUpdateTime(GameWorld.GetCurrentDataTimeStr())
|
| | | if packData:
|
| | | curCache.SetPlayerLV(packData.PlayerLV)
|
| | | curCache.SetOffTime(packData.OffTime)
|
| | |
|
| | |
|
| | | GameWorld.DebugLog('ViewCache### UpdatePlayerCache PlayerID %s, \
|
| | |
| | | curCache.SetPlusDataNoSave(PlusData,len(PlusData))
|
| | | curCache.SetNeedSaveDB(isSaveDB) #设置需要保存到数据库
|
| | |
|
| | | # 同步更新助战信息
|
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(PlayerID):
|
| | | PropDataDict = eval(PropData)
|
| | | fightPower = PropDataDict.get("FightPower", 0)
|
| | | familyID = PropDataDict.get("FamilyID", 0)
|
| | | playerName = PropDataDict.get("Name", "")
|
| | | PlayerFBHelpBattle.UpdateCheckInPlayerInfo(PlayerID, fightPower, familyID, playerName)
|
| | | |
| | | #暂时关闭
|
| | | #===========================================================================
|
| | | # FamilyIDKey = "FamilyID"
|
| | |
| | | ##玩家下线缓存数据
|
| | | # @param PlayerID, PlayerLV, PropData, ItemData, PlusData
|
| | | # @return None
|
| | | def OnPlayerLogout(PlayerID, PlayerLV, PropData, ItemData, PlusData): |
| | | def OnPlayerLogout(curPackData): |
| | | PlayerID = curPackData.PlayerID
|
| | | PlayerLV = curPackData.PlayerLV
|
| | | #不需要保存离线数据的,直接删除缓存数据
|
| | | if not IsNeedSaveLogoutPlayer(PlayerID, PlayerLV):
|
| | | ViewCacheMgr.DeleteCache(PlayerID)
|
| | | return
|
| | | #更新数据,并设置需要保存数据库
|
| | | UpdatePlayerCache(PlayerID, PropData, ItemData, PlusData, True) |
| | | UpdatePlayerCache(PlayerID, curPackData.PropData, curPackData.ItemData, curPackData.PlusData, True, packData=curPackData) |
| | | return
|
| | |
|
| | | ## 根据规则判定是否需要继续保存离线玩家数据
|
| | | # @param PlayerID, PlayerLV
|
| | | # @return None
|
| | | def IsNeedSaveLogoutPlayer(PlayerID, PlayerLV):
|
| | | SaveDBLimitLV, NeedCheckBillBoardType, HighLadderLimitOrder = ReadChConfig.GetEvalChConfig("CacheSaveLimit")
|
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(PlayerID):
|
| | | return True
|
| | | |
| | | SaveDBLimitLV = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1)
|
| | | #校验玩家等级
|
| | | if PlayerLV < SaveDBLimitLV:
|
| | | return False
|
| | |
| | |
|
| | | # 上榜用户
|
| | | def IsNeedSaveViewCacheAllInfo(PlayerID):
|
| | | SaveDBLimitLV, NeedCheckBillBoardType, HighLadderLimitOrder = ReadChConfig.GetEvalChConfig("CacheSaveLimit")
|
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(PlayerID):
|
| | | return True
|
| | | NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2)
|
| | | #校验玩家是否上排行榜
|
| | | billboardMgr = GameWorld.GetBillboard()
|
| | | for BillBoardType in NeedCheckBillBoardType:
|
| | |
| | | PlayerID = curPackData.PlayerID
|
| | | PlayerLV = curPackData.PlayerLV
|
| | | if curPackData.IsLogouting:
|
| | | OnPlayerLogout(PlayerID, PlayerLV, \
|
| | | curPackData.PropData, curPackData.ItemData, curPackData.PlusData)
|
| | | OnPlayerLogout(curPackData)
|
| | | else:
|
| | | # 此处保存设置为True是为安全防范,比如突然断电,宕机等情况 导致误以为不保存,故等级可设置高一点
|
| | | UpdatePlayerCache(PlayerID, curPackData.PropData, \
|
| | | curPackData.ItemData, curPackData.PlusData, True if PlayerLV > 150 else False)
|
| | | curPackData.ItemData, curPackData.PlusData, True if PlayerLV > 150 else False, packData=curPackData)
|
| | | GameWorld.DebugLog('ViewCache### OnMGUpdatePlayerCache out')
|
| | | return
|
| | |
|
| | |
| | | answerPack.LV = 1
|
| | | answerPack.RealmLV = 1
|
| | | answerPack.OnlineType = ChConfig.Def_Offline
|
| | | answerPack.ServerGroupID = 0
|
| | | else:
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | |
|
| | |
| | | answerPack.LV = cacheDict["LV"]
|
| | | answerPack.RealmLV = cacheDict["RealmLV"]
|
| | | answerPack.OnlineType = ChConfig.Def_Offline
|
| | | answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
|
| | |
|
| | | else:
|
| | | answerPack.PlayerID = clientPack.PlayerID
|
| | |
| | | answerPack.RealmLV = tagPlayer.GetOfficialRank()
|
| | | answerPack.OnlineType = ChConfig.Def_Online
|
| | | answerPack.IsInTeam = tagPlayer.GetTeamID() > 0
|
| | | answerPack.ServerGroupID = PlayerControl.GetPlayerServerGroupID(tagPlayer)
|
| | |
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | NetPackCommon.SendFakePack(curPlayer, answerPack)
|
| | | return
|
| | |
|
| | | def OnPlayerLeaveFamily(playerID):
|
| | | GameWorld.DebugLog("ViewCache->OnPlayerLeaveFamily", playerID)
|
| | | def OnPlayerFamilyChange(playerID, familyID, familyName):
|
| | | GameWorld.DebugLog("ViewCache->OnPlayerFamilyChange", playerID)
|
| | | curCache = ViewCacheMgr.FindCache(playerID)
|
| | | if not curCache:
|
| | | return
|
| | | PropData = eval(curCache.GetPropData())
|
| | | PropData["FamilyID"] = 0
|
| | | PropData["FamilyName"] = ""
|
| | | PropData["FamilyID"] = familyID
|
| | | PropData["FamilyName"] = familyName
|
| | | playerLV = PropData["LV"]
|
| | |
|
| | | PropData = json.dumps(PropData, ensure_ascii=False)
|
| | | ItemData = curCache.GetItemData()
|
| | | PlusData = curCache.GetPlusData()
|
| | | ItemData = GetItemData(curCache)
|
| | | PlusData = GetPlusData(curCache)
|
| | | UpdatePlayerCache(playerID, PropData, ItemData, PlusData, True if playerLV > 150 else False)
|
| | | return
|
| | |
|