From 9471febd32f98a234dbffd836cdf1f02188b02d9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 25 十二月 2025 15:51:38 +0800
Subject: [PATCH] 16 卡牌服务端(战斗服务器后台重读支持;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py                                           |   29 ++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py                          |    1 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DataRecordPack.py                                         |    8 ++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_ReloadConfig.py |    1 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py                                              |    8 +++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py                                             |    1 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py        |   13 ++++++
 7 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DataRecordPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DataRecordPack.py
index 7b5e86e..fa5bb2e 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DataRecordPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DataRecordPack.py
@@ -140,6 +140,14 @@
     GameWorld.GetGameWorld().EventShell_SendEventEx(eventTypeStr, len(eventTypeStr), dataStr, len(dataStr))
     return
 
+def DR_Reload(reloadType):
+    ## 重读流向
+    GroupName = GameWorld.GetServerGroupName()
+    ServerID = GameWorld.GetGameWorld().GetServerID()
+    dataDict = {"GroupName":GroupName, "ServerID":ServerID, "ReloadType":reloadType}
+    SendEventPack("Reload", dataDict, checkBatServer=False)
+    return
+
 ## 登陆
 #  @param curPlayer 玩家实例
 #  @return: None
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
index ea5120e..13de66e 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
@@ -133,7 +133,9 @@
             reload(reloadPath)
         except Exception:
             continue
-
+        
+    import DataRecordPack
+    DataRecordPack.DR_Reload("script")
     Log("Reload Begin : time = %s"%GetCurrentDataTimeStr())
     return
 
@@ -1347,6 +1349,10 @@
     ## 是否战斗服务器
     return ToIntDef(ReadChConfig.GetPyMongoConfig("platform", "BattleServer"), 0) == 1
 
+def GetServerGroupName():
+    ## 服务器组名,取 ServersRoute 中的配置
+    return ReadChConfig.GetServersRouteConfig("platform", "GroupName")
+
 def GetServerGroupID():
     ## 服务器组ID,必须唯一,代表这台物理服务器
     return ToIntDef(ReadChConfig.GetPyMongoConfig("platform", "GroupID"), 0)
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 0cf3556..cc14de1 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
@@ -118,6 +118,7 @@
         GameWorld.Log("服务器启动成功: ServerGroupID=%s,serverID=%s,serverDay=%s,isMixServer=%s,mixServerDay=%s" 
                       % (serverGroupID, serverID, serverDay, isMixServer, mixServerDay))
     PyGameData.g_serverInitOK = True
+    DataRecordPack.DR_Reload("restart")
     return
 
 def AllMapServerInitOK(tick):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
index 8ddc2d2..e6e1232 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
@@ -23,6 +23,7 @@
 g_minuteProcess = -1 # 每分钟触发一次,上次处理的分钟
 g_serverClosing = 0 # 是否关服中 0-非关服中;1-关服中;2-关服结束
 g_closeSaveDataOK = False # 关服数据入库是否成功
+g_batServerGMTTimeDict = {} # 战斗服务器处理GMT命令时间戳记录 {"GMT_xxx":上一次处理时间戳, ...}
 
 g_objPoolMgr = None # 对象池管理器
 g_batObjMgr = None # 战斗对象管理
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_ReloadConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_ReloadConfig.py
index aa56475..f3dba83 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_ReloadConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_ReloadConfig.py
@@ -24,6 +24,7 @@
 # @return None 
 def OnExec(gmCmdDict):
     reloadType = gmCmdDict.get("reloadType")
+    GameWorld.Log("服务器执行重读! reloadType=%s" % reloadType)
     if reloadType == "script":
         GameWorld.__ReloadScript()
     else:
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py
index ee3afd2..5b8add7 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py
@@ -45,6 +45,7 @@
 import PyGameData
 import GameWorld
 import DBDataMgr
+import time
       
 ################################################################## 
                 ####### python逻辑入口 ####### 
@@ -320,6 +321,13 @@
         execType = GMCommon.Def_Unknow
         execInfo = ''
         if callFunc != None:
+            if GameWorld.IsBattleServer():
+                lastTime = PyGameData.g_batServerGMTTimeDict.get(self.funcName, 0)
+                curTime = int(time.time())
+                if lastTime and curTime - lastTime <= 60:
+                    GameWorld.Log("战斗服务器1分钟内不重复处理GMT命令! %s, lastTime=%s" % (self.funcName, GameWorld.ChangeTimeNumToStr(lastTime)))
+                    return
+                PyGameData.g_batServerGMTTimeDict[self.funcName] = curTime
             ret = callFunc(self.gmCmdDict)
             if isinstance(ret, int):
                 execType = ret
@@ -439,7 +447,10 @@
     resultMsg = json.dumps(resultDcit, ensure_ascii=False)
     
     mylog.info("gm result:%s"%resultMsg)
-    SendToGMToolCommandResult(orderId, resultMsg)
+    if GameWorld.IsBattleServer():
+        mylog.info("战斗服务器暂时不回复GM命令处理结果")
+    else:
+        SendToGMToolCommandResult(orderId, resultMsg)
     return
 
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py
index b396ced..c122de1 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ReadChConfig.py
@@ -40,6 +40,7 @@
 
 AllChConfig = {}
 GeneralProgramme = {}
+ServersRouteConfig = None
 PyMongoDataServerConfig = None
 DBAllChConfig = {}
 
@@ -103,6 +104,8 @@
     GameWorld.Log("=== 设置重读配置 ===")
     GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_ReloadConfig, 1)
     IpyGameDataPY.IPYData.IpyDataClear()
+    import DataRecordPack
+    DataRecordPack.DR_Reload("config")
     return
 
 ## 重读,清除配置
@@ -112,6 +115,7 @@
     global AllChConfig
     global GeneralProgramme
     global PyMongoDataServerConfig
+    global ServersRouteConfig
     global DBAllChConfig
     
     #重读所有的配置表
@@ -119,6 +123,7 @@
     GeneralProgramme = {}
     FormulaControl.ClearCompileFormulaDist()
     PyMongoDataServerConfig = None
+    ServersRouteConfig = None
     DBAllChConfig = {}
     
     GameWorld.Log('MapServer_Reload_ChConfig')
@@ -215,6 +220,30 @@
 
 ## -----------------------------------------------------------
 
+def GetServersRouteConfig(section, option, raw=False, defaultValue=None, isLog=True):
+    global ServersRouteConfig
+    
+    if not ServersRouteConfig:
+        filePath = ChConfig.GetServersRoutePath() + "\\PyMongoDataServer.ini"
+        
+        if not os.path.isfile(filePath):
+            GameWorld.Log('无法找到文件 = %s'%(filePath))
+            raise Exception('无法找到文件 = %s'%(filePath))
+        
+        ServersRouteConfig = ConfigParser.ConfigParser()
+        ServersRouteConfig.read(filePath)
+        GameWorld.DebugLog("Reload %s" % str(filePath))
+        
+    if not ServersRouteConfig.has_option(section, option):
+        if defaultValue != None:
+            return defaultValue
+        if isLog:
+            GameWorld.ErrLog("ServersRoute->PyMongoDataServer.ini找不到配置: section=%s,option=%s" % (section, option))
+        return ""
+    
+    strParam = ServersRouteConfig.get(section, option, raw)
+    return strParam
+
 ## PyMongoDataServer.ini配置读取
 #  @param section: 分段区块名
 #  @param option: 配置项名

--
Gitblit v1.8.0