From 1a9aa08e61a036b6c051cb072f7b4c8c746662b3 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 03 十二月 2025 19:55:26 +0800
Subject: [PATCH] 129 【战斗】战斗系统-服务端(优化战斗与结算逻辑分离;优化战斗结果同步及战报;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py | 43 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 39 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 ecd028e..b907893 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,8 @@
import DBDataMgr
import GameWorld
+import PyMongoMain
+import PlayerFamily
import IpyGameDataPY
import IPY_GameWorld
import PlayerEventCounter
@@ -26,6 +28,7 @@
import ShareDefine
import PyGameData
import BattleObj
+import ChPlayer
import ObjPool
import datetime
@@ -67,7 +70,7 @@
#调用该函数时,C++已经设置好区服,如果改变区服需重启
def StartDB(tick):
#初始化数据库, 恢复备档(按区服记录), 加载静态表
- from PyMongoDB import PyMongoMain
+ #from PyMongoDB import PyMongoMain
PyMongoMain.StartDB()
InitGameWorld(tick)
return
@@ -232,13 +235,29 @@
## 每秒分钟执行一次
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()
return
+
+ PyMongoMain.GetUserCtrlDB().onSecondProcess()
OnMinute(tick)
@@ -248,6 +267,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()
@@ -265,9 +299,10 @@
#GameWorldActionControl.Dispose_OperationActionState()
#GameWorldActionControl.Dispose_DailyActionState()
#GameWorldActionControl.Dispose_FBStateTime()
+ PlayerFamily.OnMinute()
PlayerOnline.OnMinute()
BattleObj.OnMinute()
- ObjPool.OnMinute()
+ ObjPool.OnMinute(curTime)
__CheckIpyDataRecycle(curTime)
return
--
Gitblit v1.8.0