From 0bf260dc72b06bb322e939434e02d117dcfc48ff Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期一, 15 四月 2024 17:49:43 +0800 Subject: [PATCH] 10138 内存分析(地图24小时内没有玩家在线则回收py表数据) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py | 38 ++++++++++++++++++++++++++++++++------ 1 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py index b27cf92..397afc1 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py @@ -51,6 +51,7 @@ import PlayerTeam import GameMap import NPCRealmRefresh +import IpyGameDataPY #--------------------------------------------------------------------- ## 副本开启 # @param gameWorld IPY_GameWorld @@ -548,7 +549,9 @@ __ProcessRouteServer(gameWorld, tick) #每分钟触发 - __RefreshOnMinute(tick) + curTime = GameWorld.GetCurrentTime() + __OnMapMinute(curTime, tick) + __RefreshOnMinute(curTime, tick) #五分钟触发 __RefreshOnFiveMinute(tick) #定时检测关闭超时文件 @@ -752,17 +755,13 @@ ## 按分钟刷新 # @param tick # @return None -def __RefreshOnMinute(tick): +def __RefreshOnMinute(curTime, tick): gameWorld = GameWorld.GetGameWorld() lastTick = gameWorld.GetTickByType(ChConfig.TYPE_Map_Tick_ProcessMinute) tickInterval = ChConfig.TYPE_Map_Tick_Time[ChConfig.TYPE_Map_Tick_ProcessMinute] if tick - lastTick < tickInterval: return gameWorld.SetTickByType(ChConfig.TYPE_Map_Tick_ProcessMinute, tick) - - curTime = GameWorld.GetCurrentTime() - - __OnMapMinute(curTime, tick) playerManager = GameWorld.GetMapCopyPlayerManager() for index in xrange(playerManager.GetPlayerCount()): @@ -780,8 +779,35 @@ return PyGameData.g_mapLastProcess_Minute = curMinute PlayerTeam.OnCheckTeamPlayerDisconnectTimeout(tick) + + __CheckIpyDataRecycle(curTime) return +def __CheckIpyDataRecycle(timeNow): + ## 检查IpyData数据回收 + playerCount = GameWorld.GetPlayerManager().OnlineCount() + if playerCount: + PyGameData.g_ipyDataRecycleCheckTime = 0 + #GameWorld.DebugLog("地图还有玩家在线! playerCount=%s" % playerCount) + return + + curTime = GameWorld.ChangeDatetimeToNum(timeNow) + if not PyGameData.g_ipyDataRecycleCheckTime: + PyGameData.g_ipyDataRecycleCheckTime = curTime + #GameWorld.DebugLog("地图没有玩家在线") + return + + if PyGameData.g_ipyDataRecycleCheckTime == 1: + # 已经回收了 + #GameWorld.DebugLog("本次已经回收过了") + return + + if curTime - PyGameData.g_ipyDataRecycleCheckTime < 24 * 3600: + #GameWorld.DebugLog("还未到达回收时间, passSeconds=%s" % (curTime - PyGameData.g_ipyDataRecycleCheckTime)) + return + PyGameData.g_ipyDataRecycleCheckTime = 1 + IpyGameDataPY.IPYData.Recycle() + return ## 整半小时触发 <00和30分钟时触发> # @param curPlayer -- Gitblit v1.8.0