Core/Misc: Added Loading.Locales to enable/disable the load of locales

Port From (https://github.com/TrinityCore/TrinityCore/commit/3fd967754388b7b859dbd8b954ec68a844e172f0)
This commit is contained in:
Hondacrx
2024-08-25 21:03:45 -04:00
parent 9ad961e64a
commit c98e58a7e1
8 changed files with 76 additions and 22 deletions
@@ -1685,6 +1685,7 @@ namespace Framework.Constants
ListenRangeSay,
ListenRangeTextemote,
ListenRangeYell,
LoadLocales,
LogdbClearinterval,
LogdbCleartime,
MailDeliveryDelay,
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Game.DataStorage
foreach (var dir in Directory.GetDirectories(db2Path))
{
Locale locale = Path.GetFileName(dir).ToEnum<Locale>();
if (SharedConst.IsValidLocale(locale))
if (SharedConst.IsValidLocale(locale) && (WorldConfig.GetBoolValue(WorldCfg.LoadLocales) || locale == defaultLocale))
availableDb2Locales[(int)locale] = true;
}
@@ -141,8 +141,13 @@ namespace Game.Entities
public void InitializeQueryData()
{
for (var loc = Locale.enUS; loc < Locale.Total; ++loc)
{
if (!WorldConfig.GetBoolValue(WorldCfg.LoadLocales) && loc != SharedConst.DefaultLocale)
continue;
QueryData[(int)loc] = BuildQueryData(loc, Difficulty.None);
}
}
public QueryCreatureResponse BuildQueryData(Locale locale, Difficulty difficulty)
{
+1 -4
View File
@@ -3257,11 +3257,8 @@ namespace Game
}
foreach (var unusedSpells in spellsByTrainer)
{
Log.outError(LogFilter.Sql, $"Table `trainer_spell` references non-existing trainer (TrainerId: {unusedSpells.Key}) for SpellId {unusedSpells.Value.SpellId}, ignoring");
}
SQLResult trainerLocalesResult = DB.World.Query("SELECT Id, locale, Greeting_lang FROM trainer_locale");
if (!trainerLocalesResult.IsEmpty())
{
@@ -3271,7 +3268,7 @@ namespace Game
string localeName = trainerLocalesResult.Read<string>(1);
Locale locale = localeName.ToEnum<Locale>();
if (!SharedConst.IsValidLocale(locale) || locale == Locale.enUS)
if (!SharedConst.IsValidLocale(locale) || !WorldConfig.GetBoolValue(WorldCfg.LoadLocales) || locale == Locale.enUS)
continue;
Trainer trainer = trainers.LookupByKey(trainerId);
+17
View File
@@ -304,6 +304,9 @@ namespace Game
void LoadConditionalConditionalQuestDescription(SQLFields fields)
{
Locale locale = fields.Read<string>(4).ToEnum<Locale>();
if (!WorldConfig.GetBoolValue(WorldCfg.LoadLocales) && locale != SharedConst.DefaultLocale)
return;
if (locale >= Locale.Total)
{
Log.outError(LogFilter.Sql, $"Table `quest_description_conditional` has invalid locale {fields.Read<string>(4)} set for quest {fields.Read<uint>(0)}. Skipped.");
@@ -325,6 +328,9 @@ namespace Game
void LoadConditionalConditionalRequestItemsText(SQLFields fields)
{
Locale locale = fields.Read<string>(4).ToEnum<Locale>();
if (!WorldConfig.GetBoolValue(WorldCfg.LoadLocales) && locale != SharedConst.DefaultLocale)
return;
if (locale >= Locale.Total)
{
Log.outError(LogFilter.Sql, $"Table `quest_request_items_conditional` has invalid locale {fields.Read<string>(4)} set for quest {fields.Read<uint>(0)}. Skipped.");
@@ -347,6 +353,9 @@ namespace Game
void LoadConditionalConditionalOfferRewardText(SQLFields fields)
{
Locale locale = fields.Read<string>(4).ToEnum<Locale>();
if (!WorldConfig.GetBoolValue(WorldCfg.LoadLocales) && locale != SharedConst.DefaultLocale)
return;
if (locale >= Locale.Total)
{
Log.outError(LogFilter.Sql, $"Table `quest_offer_reward_conditional` has invalid locale {fields.Read<string>(4)} set for quest {fields.Read<uint>(0)}. Skipped.");
@@ -369,6 +378,9 @@ namespace Game
void LoadConditionalConditionalQuestCompletionLog(SQLFields fields)
{
Locale locale = fields.Read<string>(4).ToEnum<Locale>();
if (!WorldConfig.GetBoolValue(WorldCfg.LoadLocales) && locale != SharedConst.DefaultLocale)
return;
if (locale >= Locale.Total)
{
Log.outError(LogFilter.Sql, $"Table `quest_completion_log_conditional` has invalid locale {fields.Read<string>(4)} set for quest {fields.Read<uint>(0)}. Skipped.");
@@ -604,8 +616,13 @@ namespace Game
public void InitializeQueryData()
{
for (var loc = Locale.enUS; loc < Locale.Total; ++loc)
{
if (!WorldConfig.GetBoolValue(WorldCfg.LoadLocales) && loc != SharedConst.DefaultLocale)
continue;
response[(int)loc] = BuildQueryData(loc, null);
}
}
public QueryQuestInfoResponse BuildQueryData(Locale loc, Player player)
{
+3
View File
@@ -1009,6 +1009,9 @@ namespace Game
// Enable AE loot
Values[WorldCfg.EnableAeLoot] = GetDefaultValue("Loot.EnableAELoot", true);
// Loading of Locales
Values[WorldCfg.LoadLocales] = GetDefaultValue("Load.Locales", true);
// call ScriptMgr if we're reloading the configuration
if (reload)
Global.ScriptMgr.OnConfigLoad(reload);
+16
View File
@@ -520,6 +520,8 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading Localization strings...");
uint oldMSTime = Time.GetMSTime();
if (WorldConfig.GetBoolValue(WorldCfg.LoadLocales))
{
Global.ObjectMgr.LoadCreatureLocales();
Global.ObjectMgr.LoadGameObjectLocales();
Global.ObjectMgr.LoadQuestTemplateLocale();
@@ -529,6 +531,8 @@ namespace Game
Global.ObjectMgr.LoadPageTextLocales();
Global.ObjectMgr.LoadGossipMenuItemsLocales();
Global.ObjectMgr.LoadPointOfInterestLocales();
}
Log.outInfo(LogFilter.ServerLoading, "Localization strings loaded in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime));
Log.outInfo(LogFilter.ServerLoading, "Loading Account Roles and Permissions...");
@@ -702,6 +706,7 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading Quest Greetings...");
Global.ObjectMgr.LoadQuestGreetings();
if (WorldConfig.GetBoolValue(WorldCfg.LoadLocales))
Global.ObjectMgr.LoadQuestGreetingLocales();
Log.outInfo(LogFilter.ServerLoading, "Loading Objects Pooling Data...");
@@ -797,8 +802,11 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading Player Choices...");
Global.ObjectMgr.LoadPlayerChoices();
if (WorldConfig.GetBoolValue(WorldCfg.LoadLocales))
{
Log.outInfo(LogFilter.ServerLoading, "Loading Player Choices Locales...");
Global.ObjectMgr.LoadPlayerChoicesLocale();
}
Log.outInfo(LogFilter.ServerLoading, "Loading Jump Charge Params...");
Global.ObjectMgr.LoadJumpChargeParams();
@@ -844,8 +852,13 @@ namespace Game
Global.AchievementMgr.LoadAchievementScripts();
Log.outInfo(LogFilter.ServerLoading, "Loading Achievement Rewards...");
Global.AchievementMgr.LoadRewards();
if (WorldConfig.GetBoolValue(WorldCfg.LoadLocales))
{
Log.outInfo(LogFilter.ServerLoading, "Loading Achievement Reward Locales...");
Global.AchievementMgr.LoadRewardLocales();
}
Log.outInfo(LogFilter.ServerLoading, "Loading Completed Achievements...");
Global.AchievementMgr.LoadCompletedAchievements();
@@ -985,8 +998,11 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading Creature Texts...");
Global.CreatureTextMgr.LoadCreatureTexts();
if (WorldConfig.GetBoolValue(WorldCfg.LoadLocales))
{
Log.outInfo(LogFilter.ServerLoading, "Loading Creature Text Locales...");
Global.CreatureTextMgr.LoadCreatureTextLocales();
}
Log.outInfo(LogFilter.ServerLoading, "Loading creature StaticFlags overrides...");
Global.ObjectMgr.LoadCreatureStaticFlagsOverride(); // must be after LoadCreatures
+15
View File
@@ -4020,3 +4020,18 @@ Pvp.FactionBalance.Pct20 = 0.8
#
###################################################################################################
###################################################################################################
# LOAD SETTINGS
#
# These settings control content loading
#
# Load.Locales
# Description: Toggles the loading of Locales.
# Default: 0 - (Disabled)
# 1 - (Enabled)
Load.Locales = 1
#
###################################################################################################