From a7ab0247c7b8eff06ad104bee39bc035384ca43e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 23 七月 2025 12:08:22 +0800
Subject: [PATCH] 80 【常规】背包-服务端(增加背包购买格子;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py |   59 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 48 insertions(+), 11 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 318d0f4..0b2a0a9 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldEvent.py
@@ -18,11 +18,14 @@
 import DBDataMgr
 import GameWorld
 import IpyGameDataPY
+import IPY_GameWorld
 import PlayerEventCounter
+import PlayerControl
+import NetPackCommon
+import PlayerOnline
 import ShareDefine
 import PlayerTeam
 import PyGameData
-import NetPackCommon
 
 import datetime
 import time
@@ -231,6 +234,11 @@
     if tick - PyGameData.g_highProcessTick < 1000:
         return
     PyGameData.g_highProcessTick = tick
+    
+    if PyGameData.g_serverClosing:
+        CheckCloseMapOK()
+        return
+    
     OnMinute(tick)
     
     # 其他逻辑
@@ -256,6 +264,7 @@
     #GameWorldActionControl.Dispose_OperationActionState()
     #GameWorldActionControl.Dispose_DailyActionState()
     #GameWorldActionControl.Dispose_FBStateTime()
+    PlayerOnline.OnMinute()
     
     PlayerTeam.OnCheckTeamPlayerDisconnectTimeout(tick)
     __CheckIpyDataRecycle(curTime)
@@ -367,15 +376,43 @@
 
 # 关闭地图通知py处理
 def CloseMap(tick):
+    serverID = GameWorld.GetGameWorld().GetServerID()
+    GameWorld.Log("地图服务器关闭开始保存数据! serverID=%s" % serverID)
+    PyGameData.g_serverClosing = 1
+    
+    playerManager = GameWorld.GetPlayerManager()
+    for i in xrange(playerManager.GetPlayerCount()):
+        curPlayer = playerManager.GetPlayerByIndex(i)
+        if not curPlayer or curPlayer.GetID() == 0 or curPlayer.IsEmpty():
+            continue
+        
+        #镜像玩家回收、真实玩家踢下线
+        if GameWorld.IsMirrorPlayer(curPlayer):
+            PlayerControl.DeleteMirror(curPlayer)
+        else:
+            curPlayer.Kick(IPY_GameWorld.disMapServerClose)
+            
+    DBDataMgr.OnServerClose()
+    return
+
+def CheckCloseMapOK():
+    '''检查等待关服数据处理完毕
+    没有玩家了,且公共数据已入库完毕
+    '''
+    if PyGameData.g_serverClosing != 1:
+        return
+    if not PyGameData.g_closeSaveDataOK:
+        return
+    if GameWorld.GetPlayerManager().OnlineCount():
+        return
+    DBDataMgr.ClearBackupFile() # 正常关服数据处理完毕可直接删除备档
+    
     from PyMongoDB.DBCommon import CommonDefine
     from PyMongoDB.Common import CommFunc
-    #初始化数据库, 恢复备档(按区服记录), 加载静态表
-    try:
-        pass
-    finally:
-        #回发地图 处理完成,必须被调用地图才能正常关闭
-        data = ''
-        data = CommFunc.WriteBYTE(data, CommonDefine.dgPlayerSaveGameServerData)  
-        NetPackCommon.SendPyPackToMapServerSelf(data, len(data))
-        GameWorld.Log("python 已处理地图关闭逻辑")
-    return
\ No newline at end of file
+    data = ''
+    data = CommFunc.WriteBYTE(data, CommonDefine.dgPlayerSaveGameServerData)  
+    NetPackCommon.SendPyPackToMapServerSelf(data, len(data))
+    GameWorld.Log("python 已处理地图关闭逻辑")
+    PyGameData.g_serverClosing = 2
+    return
+    
\ No newline at end of file

--
Gitblit v1.8.0