Core/Creatures: Added possibility to automatically despawn personal summons on quest remove
Port From (https://github.com/TrinityCore/TrinityCore/commit/b3dce0ac08d4f740505037aff2cad7685444db15)
This commit is contained in:
@@ -1761,8 +1761,6 @@ namespace Game
|
||||
// We load the creature models after loading but before checking
|
||||
LoadCreatureTemplateModels();
|
||||
|
||||
LoadCreatureSummonedData();
|
||||
|
||||
// Checking needs to be done after loading because of the difficulty self referencing
|
||||
foreach (var template in creatureTemplateStorage.Values)
|
||||
CheckCreatureTemplate(template);
|
||||
@@ -2018,12 +2016,13 @@ namespace Game
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} creature template models in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||
}
|
||||
void LoadCreatureSummonedData()
|
||||
|
||||
public void LoadCreatureSummonedData()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// 0 1 2 3
|
||||
SQLResult result = DB.World.Query("SELECT CreatureID, CreatureIDVisibleToSummoner, GroundMountDisplayID, FlyingMountDisplayID FROM creature_summoned_data");
|
||||
// 0 1 2 3 4
|
||||
SQLResult result = DB.World.Query("SELECT CreatureID, CreatureIDVisibleToSummoner, GroundMountDisplayID, FlyingMountDisplayID, DespawnOnQuestsRemoved FROM creature_summoned_data");
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 creature summoned data definitions. DB table `creature_summoned_data` is empty.");
|
||||
@@ -2074,6 +2073,28 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.IsNull(4))
|
||||
{
|
||||
List<uint> questList = new();
|
||||
foreach (string questStr in result.Read<string>(4).Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (!uint.TryParse(questStr, out uint questId))
|
||||
continue;
|
||||
|
||||
Quest quest = GetQuestTemplate(questId);
|
||||
if (quest == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `creature_summoned_data` references non-existing quest {questId} in DespawnOnQuestsRemoved for creature {creatureId}, skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
questList.Add(questId);
|
||||
}
|
||||
|
||||
if (!questList.Empty())
|
||||
summonedData.DespawnOnQuestsRemoved = questList;
|
||||
}
|
||||
|
||||
} while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {creatureSummonedDataStorage.Count} creature summoned data definitions in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||
|
||||
Reference in New Issue
Block a user