From 05672ed6e854b0179482788d4b15e3f8eb727c0e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 28 十一月 2025 15:06:09 +0800
Subject: [PATCH] 16 卡牌服务端(优化服务器时间、天封包A004 A103同步:过天、回调时间、时间误差超过10秒时补同步;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 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 697275e..78b2a7c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
@@ -17,6 +17,7 @@
 
 import DBDataMgr
 import GameWorld
+import PlayerFamily
 import IpyGameDataPY
 import IPY_GameWorld
 import PlayerEventCounter
@@ -24,9 +25,9 @@
 import NetPackCommon
 import PlayerOnline
 import ShareDefine
-import PlayerTeam
 import PyGameData
 import BattleObj
+import ChPlayer
 import ObjPool
 
 import datetime
@@ -233,9 +234,23 @@
     ## 每秒分钟执行一次
     if not PyGameData.g_initGameTime:
         return
-    if tick - PyGameData.g_highProcessTick < 1000:
+    curTime = int(time.time())
+    if not PyGameData.g_highProcessTime:
+        PyGameData.g_highProcessTime = curTime
+        
+    if curTime < PyGameData.g_highProcessTime:
+        GameWorld.Log("时间回调了: lastProcessTime=%s" % (GameWorld.ChangeTimeNumToStr(PyGameData.g_highProcessTime)))
+        PyGameData.g_highProcessTime = curTime
+        OnFixServerTimeProcess()
+        
+    passSeconds = curTime - PyGameData.g_highProcessTime
+    if passSeconds < 1:
         return
-    PyGameData.g_highProcessTick = tick
+    if passSeconds > 10:
+        GameWorld.Log("时间误差过大: passSeconds=%s,lastProcessTime=%s" % (passSeconds, GameWorld.ChangeTimeNumToStr(PyGameData.g_highProcessTime)))
+        OnFixServerTimeProcess()
+        
+    PyGameData.g_highProcessTime = curTime
     
     if PyGameData.g_serverClosing:
         CheckCloseMapOK()
@@ -249,6 +264,21 @@
     
     return
 
+def OnFixServerTimeProcess():
+    
+    # 补同步一次服务器时间给前端
+    playerManager = GameWorld.GetPlayerManager()
+    for i in xrange(playerManager.GetPlayerCount()):
+        curPlayer = playerManager.GetPlayerByIndex(i)
+        
+        if not GameWorld.IsNormalPlayer(curPlayer):
+            continue
+        
+        ChPlayer.Sync_PyServerDataTimeToClient(curPlayer)
+        ChPlayer.Sync_OpenServerDay(curPlayer)
+        
+    return
+        
 def OnMinute(tick):
     ## 每整分钟执行一次
     curTime = GameWorld.GetCurrentTime()
@@ -266,11 +296,11 @@
     #GameWorldActionControl.Dispose_OperationActionState()
     #GameWorldActionControl.Dispose_DailyActionState()
     #GameWorldActionControl.Dispose_FBStateTime()
+    PlayerFamily.OnMinute()
     PlayerOnline.OnMinute()
     BattleObj.OnMinute()
     ObjPool.OnMinute()
     
-    PlayerTeam.OnCheckTeamPlayerDisconnectTimeout(tick)
     __CheckIpyDataRecycle(curTime)
     return
     

--
Gitblit v1.8.0