Skip to content

Commit ec50794

Browse files
committed
[修改]1. 修改全局参数的 SaveDataInterval 变动适配
1 parent a9bd58a commit ec50794

3 files changed

Lines changed: 5 additions & 22 deletions

File tree

GameFrameX.Core/Timer/GlobalTimer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static async Task Loop()
8080
/// <returns>下次回存时间</returns>
8181
private static long NextSaveTime()
8282
{
83-
return TimeHelper.UnixTimeMilliseconds() + GlobalSettings.SaveIntervalInMilliSeconds;
83+
return TimeHelper.UnixTimeMilliseconds() + GlobalSettings.CurrentSetting.SaveDataInterval;
8484
}
8585

8686
/// <summary>

GameFrameX.StartUp/AppStartUpBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public bool Init(ServerType serverType, AppSetting setting, string[] args = null
5050
Init();
5151
Setting.CheckNotNull(nameof(Setting));
5252
GlobalSettings.SetCurrentSetting(setting);
53-
GlobalSettings.SaveIntervalInMilliSeconds = Setting.SaveDataInterval;
5453
return true;
5554
}
5655

GameFrameX.Utility/Setting/GlobalSettings.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public static class GlobalSettings
1212
/// </summary>
1313
private static readonly List<AppSetting> Settings = new(16);
1414

15-
private static int _saveIntervalInMilliSeconds;
16-
1715
/// <summary>
1816
/// 获取当前应用程序设置
1917
/// </summary>
@@ -33,24 +31,6 @@ public static class GlobalSettings
3331
/// </summary>
3432
public static DateTime LaunchTime { get; set; }
3533

36-
/// <summary>
37-
/// 数据存储间隔 单位 毫秒,默认5分钟,最小1秒
38-
/// </summary>
39-
public static int SaveIntervalInMilliSeconds
40-
{
41-
get { return _saveIntervalInMilliSeconds; }
42-
set
43-
{
44-
if (value < 1000)
45-
{
46-
_saveIntervalInMilliSeconds = GlobalConst.SaveIntervalInMilliSeconds;
47-
return;
48-
}
49-
50-
_saveIntervalInMilliSeconds = value;
51-
}
52-
}
53-
5434
/// <summary>
5535
/// 加载启动配置
5636
/// </summary>
@@ -96,6 +76,10 @@ public static void SetCurrentSetting(AppSetting setting)
9676
{
9777
ArgumentNullException.ThrowIfNull(setting, nameof(setting));
9878
CurrentSetting = setting;
79+
if (setting.SaveDataInterval < 1000)
80+
{
81+
setting.SaveDataInterval = GlobalConst.SaveIntervalInMilliSeconds;
82+
}
9983
}
10084

10185
/// <summary>

0 commit comments

Comments
 (0)