Core/Chat: Custom channel preservation rewrite. Channel data is now loaded at startup, and written to the DB periodically, instead of both things happening in real time.

Port From (https://github.com/TrinityCore/TrinityCore/commit/8839fa3fe24e72e4506e94389663b82ab2292649)
This commit is contained in:
hondacrx
2022-01-02 13:44:00 -05:00
parent 4c0eb3f2e2
commit 75d3497d38
7 changed files with 142 additions and 87 deletions
+1
View File
@@ -224,6 +224,7 @@ namespace Game
Values[WorldCfg.MailLevelReq] = GetDefaultValue("LevelReq.Mail", 1);
Values[WorldCfg.PreserveCustomChannels] = GetDefaultValue("PreserveCustomChannels", false);
Values[WorldCfg.PreserveCustomChannelDuration] = GetDefaultValue("PreserveCustomChannelDuration", 14);
Values[WorldCfg.PreserveCustomChannelInterval] = GetDefaultValue("PreserveCustomChannelInterval", 5);
Values[WorldCfg.GridUnload] = GetDefaultValue("GridUnload", true);
Values[WorldCfg.BasemapLoadGrids] = GetDefaultValue("BaseMapLoadAllGrids", false);
if ((bool)Values[WorldCfg.BasemapLoadGrids] && (bool)Values[WorldCfg.GridUnload])
+19 -2
View File
@@ -1005,6 +1005,8 @@ namespace Game
m_timers[WorldTimers.WhoList].SetInterval(5 * Time.InMilliseconds); // update who list cache every 5 seconds
m_timers[WorldTimers.ChannelSave].SetInterval(WorldConfig.GetIntValue(WorldCfg.PreserveCustomChannelInterval) * Time.Minute * Time.InMilliseconds);
//to set mailtimer to return mails every day between 4 and 5 am
//mailtimer is increased when updating auctions
//one second is 1000 -(tested on win system)
@@ -1027,8 +1029,8 @@ namespace Game
// Delete all characters which have been deleted X days before
Player.DeleteOldCharacters();
// Delete all custom channels which haven't been used for PreserveCustomChannelDuration days.
Channel.CleanOldChannelsInDB();
Log.outInfo(LogFilter.ServerLoading, "Initializing chat channels...");
ChannelManager.LoadFromDB();
Log.outInfo(LogFilter.ServerLoading, "Initializing Opcodes...");
PacketManager.Initialize();
@@ -1291,6 +1293,20 @@ namespace Game
Global.WhoListStorageMgr.Update();
}
if (m_timers[WorldTimers.ChannelSave].Passed())
{
m_timers[WorldTimers.ChannelSave].Reset();
if (WorldConfig.GetBoolValue(WorldCfg.PreserveCustomChannels))
{
ChannelManager mgr1 = ChannelManager.ForTeam(Team.Alliance);
mgr1.SaveToDB();
ChannelManager mgr2 = ChannelManager.ForTeam(Team.Horde);
if (mgr1 != mgr2)
mgr2.SaveToDB();
}
}
// Handle daily quests reset time
if (currentGameTime > m_NextDailyQuestReset)
{
@@ -2514,6 +2530,7 @@ namespace Game
GuildSave,
Blackmarket,
WhoList,
ChannelSave,
Max
}