You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
1.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using ProtoCSStruct;
namespace World
{
public static class WorldGlobalDataSvc
{
private static long m_lastSaveDbTime;
private static long m_lastBroadcastTime;//通知玩家
//定时存储数据
private static void TickSaveWorldGlobalData(long nowSecond)
{
//平时300秒保存一次,停服的时候5秒
long saveIntervalSecond = 300;
if (WorldServerUtils.GetApp().CurrStopStage == ServerStopStage.stopping)
{
saveIntervalSecond = 5;
m_lastSaveDbTime = 0;
}
if (nowSecond - m_lastSaveDbTime <= saveIntervalSecond)
{
return;
}
m_lastSaveDbTime = nowSecond;
WorldGlobalDataUtils.SaveAllWorldGlobalData();
}
private static void TickBroadcastWorldGlobalData(long nowSecond)
{
if (WorldServerUtils.GetApp().CurrStopStage == ServerStopStage.stopping)
{
return;
}
//30秒通知一次
if (nowSecond - m_lastBroadcastTime <= 30)
{
return;
}
m_lastBroadcastTime = nowSecond;
WorldGlobalDataUtils.BroadcastAllWorldGlobalData();
}
//数据变化时 保存 广播 数据
public static void OnTick(long nowSecond)
{
TickSaveWorldGlobalData(nowSecond);
TickBroadcastWorldGlobalData(nowSecond);
}
}
}