From c2d45420190e02447a79a680199ab4636ce986e2 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 20 五月 2025 15:49:29 +0800
Subject: [PATCH] 16 卡牌服务端(优化备档存取逻辑,GetServerID改为取接口;调整单服StartDB渠口、启动加载数据流程,支持服层级每秒、每分Process)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
index 9e4ecb5..c486584 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
@@ -17,8 +17,10 @@
 
 import DBDataMgr
 import GameWorld
+import IpyGameDataPY
 import PlayerEventCounter
 import ShareDefine
+import PlayerTeam
 import PyGameData
 
 import datetime
@@ -57,15 +59,23 @@
     
     return Get_Server_Hour(), Get_Server_Day(), Get_Server_Week(), Get_Server_Month(), Get_Server_Year()
 
+#调用该函数时,C++已经设置好区服,如果改变区服需重启
+def StartDB(tick):
+    #初始化数据库, 恢复备档(按区服记录), 加载静态表
+    from PyMongoDB import PyMongoMain
+    PyMongoMain.StartDB()
+    InitGameWorld(tick)
+    return
+
 def InitGameWorld(tick):
     ## GameWorld初始化
     if PyGameData.g_initGameTime:
         return
-    PyGameData.g_initGameTime = int(time.time())
-    serverID = GameWorld.GetServerID()
+    serverID = GameWorld.GetGameWorld().GetServerID()
     GameWorld.Log("服务器启动初始化InitGameWorld: serverID=%s" % serverID)
     DBDataMgr.OnServerStart() # 优先加载公共数据
     LoadDBPlayer()
+    PyGameData.g_initGameTime = int(time.time()) # 放到加载数据之后
     
     #初始话开服时间、星期几
     initOpenServerTime = DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_InitOpenServerTime)
@@ -90,7 +100,7 @@
     else:
         serverGroupID = GameWorld.GetServerGroupID()
         GameWorld.Log("服务器启动成功: ServerGroupID=%s,serverID=%s" % (serverGroupID, serverID))
-    GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_WorldKey_GameWorldInitOK, 1)
+    PyGameData.g_serverInitOK = True
     return
 
 def AllMapServerInitOK(tick):
@@ -107,7 +117,7 @@
     @param openServerTime: 开服时间戳
     @return: 1-成功;-1-设置的时间异常;-2-已经设置过且开服了,不能重复设置
     '''
-    serverID = GameWorld.GetServerID()
+    serverID = GameWorld.GetGameWorld().GetServerID()
     curTime = int(time.time())
     if openServerTime < curTime:
         GameWorld.ErrLog("当前时间已经超过设置的开服时间,不能设置! serverID=%s" % serverID)
@@ -145,7 +155,7 @@
 def OnNewServerOpen(tick):
     '''新服开启需要处理的逻辑'''
     
-    serverID = GameWorld.GetServerID()
+    serverID = GameWorld.GetGameWorld().GetServerID()
     GameWorld.Log("执行正式开服重置逻辑... serverID=%s" % serverID)
     
     setOpenServerTime = DBDataMgr.GetEventTrigMgr().GetValue(ShareDefine.Def_SetOpenServerTime)
@@ -215,11 +225,27 @@
 
 def OnHighProcess(tick):
     ## 每秒分钟执行一次
+    if not PyGameData.g_initGameTime:
+        return
+    if tick - PyGameData.g_highProcessTick < 1000:
+        return
+    PyGameData.g_highProcessTick = tick
+    OnMinute(tick)
+    
+    # 其他逻辑
+    
+    
+    
     return
 
 def OnMinute(tick):
     ## 每整分钟执行一次
     curTime = GameWorld.GetCurrentTime()
+    curMinute = curTime.minute
+    if curMinute == PyGameData.g_minuteProcess:
+        return
+    PyGameData.g_minuteProcess = curMinute
+    
     #检查服务器正式开服
     DoCheckNewServerOpen(tick)
     DBDataMgr.OnMinute(curTime)
@@ -229,6 +255,9 @@
     #GameWorldActionControl.Dispose_OperationActionState()
     #GameWorldActionControl.Dispose_DailyActionState()
     #GameWorldActionControl.Dispose_FBStateTime()
+    
+    PlayerTeam.OnCheckTeamPlayerDisconnectTimeout(tick)
+    __CheckIpyDataRecycle(curTime)
     return
     
 def DoLogic_GameWorldEvenByTime(tick):
@@ -307,3 +336,29 @@
     PlayerEventCounter.DoLogic_OnYear(tick)
     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

--
Gitblit v1.8.0