Core/Players: Load faction change items from db2 instead of db
Port From (https://github.com/TrinityCore/TrinityCore/commit/7b11d17f4928d17637ad8182f9c632d90f873db4)
This commit is contained in:
@@ -361,7 +361,7 @@ namespace Game.DataStorage
|
||||
public float PriceVariance;
|
||||
public float PriceRandomValue;
|
||||
public int[] Flags = new int[4];
|
||||
public int FactionRelated;
|
||||
public uint FactionRelated;
|
||||
public int ModifiedCraftingReagentItemID;
|
||||
public uint ContentTuningID;
|
||||
public uint PlayerLevelToItemLevelCurveID;
|
||||
|
||||
@@ -260,6 +260,7 @@ namespace Game.Entities
|
||||
public ItemFlags2 GetFlags2() { return (ItemFlags2)ExtendedData.Flags[1]; }
|
||||
public ItemFlags3 GetFlags3() { return (ItemFlags3)ExtendedData.Flags[2]; }
|
||||
public ItemFlags4 GetFlags4() { return (ItemFlags4)ExtendedData.Flags[3]; }
|
||||
public uint GetOtherFactionItemId() { return ExtendedData.FactionRelated; }
|
||||
public float GetPriceRandomValue() { return ExtendedData.PriceRandomValue; }
|
||||
public float GetPriceVariance() { return ExtendedData.PriceVariance; }
|
||||
public uint GetBuyCount() { return Math.Max(ExtendedData.VendorStackCount, 1u); }
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.AI;
|
||||
using Game.Conditions;
|
||||
using Game.DataStorage;
|
||||
using Game.Groups;
|
||||
@@ -27,7 +28,6 @@ using Game.Networking.Packets;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Game.AI;
|
||||
|
||||
namespace Game.Entities
|
||||
{
|
||||
|
||||
@@ -6539,30 +6539,20 @@ namespace Game
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
SQLResult result = DB.World.Query("SELECT alliance_id, horde_id FROM player_factionchange_items");
|
||||
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 faction change item pairs. DB table `player_factionchange_items` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint count = 0;
|
||||
do
|
||||
foreach (var itemPair in ItemTemplateStorage)
|
||||
{
|
||||
uint alliance = result.Read<uint>(0);
|
||||
uint horde = result.Read<uint>(1);
|
||||
if (itemPair.Value.GetOtherFactionItemId() == 0)
|
||||
continue;
|
||||
|
||||
if (GetItemTemplate(alliance) == null)
|
||||
Log.outError(LogFilter.Sql, "Item {0} (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance);
|
||||
else if (GetItemTemplate(horde) == null)
|
||||
Log.outError(LogFilter.Sql, "Item {0} (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde);
|
||||
else
|
||||
FactionChangeItems[alliance] = horde;
|
||||
if (itemPair.Value.GetFlags2().HasFlag(ItemFlags2.FactionHorde))
|
||||
FactionChangeItemsHordeToAlliance[itemPair.Key] = itemPair.Value.GetOtherFactionItemId();
|
||||
|
||||
if (itemPair.Value.GetFlags2().HasFlag(ItemFlags2.FactionAlliance))
|
||||
FactionChangeItemsAllianceToHorde[itemPair.Key] = itemPair.Value.GetOtherFactionItemId();
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} faction change item pairs in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
@@ -10420,7 +10410,8 @@ namespace Game
|
||||
|
||||
//Faction Change
|
||||
public Dictionary<uint, uint> FactionChangeAchievements = new();
|
||||
public Dictionary<uint, uint> FactionChangeItems = new();
|
||||
public Dictionary<uint, uint> FactionChangeItemsAllianceToHorde = new();
|
||||
public Dictionary<uint, uint> FactionChangeItemsHordeToAlliance = new();
|
||||
public Dictionary<uint, uint> FactionChangeQuests = new();
|
||||
public Dictionary<uint, uint> FactionChangeReputation = new();
|
||||
public Dictionary<uint, uint> FactionChangeSpells = new();
|
||||
|
||||
@@ -1997,14 +1997,15 @@ namespace Game
|
||||
}
|
||||
|
||||
// Item conversion
|
||||
foreach (var it in Global.ObjectMgr.FactionChangeItems)
|
||||
var itemConversionMap = newTeamId == TeamId.Alliance ? Global.ObjectMgr.FactionChangeItemsHordeToAlliance : Global.ObjectMgr.FactionChangeItemsAllianceToHorde;
|
||||
foreach (var it in itemConversionMap)
|
||||
{
|
||||
uint item_alliance = it.Key;
|
||||
uint item_horde = it.Value;
|
||||
uint oldItemId = it.Key;
|
||||
uint newItemId = it.Value;
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_INVENTORY_FACTION_CHANGE);
|
||||
stmt.AddValue(0, (newTeamId == TeamId.Alliance ? item_alliance : item_horde));
|
||||
stmt.AddValue(1, (newTeamId == TeamId.Alliance ? item_horde : item_alliance));
|
||||
stmt.AddValue(0, newItemId);
|
||||
stmt.AddValue(1, oldItemId);
|
||||
stmt.AddValue(2, lowGuid);
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS `player_factionchange_items`;
|
||||
Reference in New Issue
Block a user