Core: Updated to 11.2.0

Port From (https://github.com/TrinityCore/TrinityCore/commit/5cf0c6c8bb2c4e58a2d66ba5f304af34d18a4782)
This commit is contained in:
Hondacrx
2025-08-25 20:48:29 -04:00
parent d64045154a
commit aaa669210a
63 changed files with 5958 additions and 5434 deletions
+65 -102
View File
@@ -725,6 +725,25 @@ namespace Game.Entities
}
}
void _LoadCharacterBankTabSettings(SQLResult result)
{
if (!result.IsEmpty())
{
do
{
if (result.Read<byte>(0) >= (InventorySlots.BankBagEnd - InventorySlots.BankBagStart))
continue;
SetCharacterBankTabSettings(result.Read<byte>(0), result.Read<string>(1), result.Read<string>(2),
result.Read<string>(3), (BagSlotFlags)result.Read<uint>(4));
} while (result.NextRow());
}
while (m_activePlayerData.CharacterBankTabSettings.Size() < m_activePlayerData.NumCharacterBankTabs)
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.CharacterBankTabSettings), new BankTabSettings());
}
void _LoadCurrency(SQLResult result)
{
if (result.IsEmpty())
@@ -1272,7 +1291,13 @@ namespace Game.Entities
});
if (activeConfig >= 0)
SetActiveCombatTraitConfigID(m_activePlayerData.TraitConfigs[activeConfig].ID);
{
TraitConfig activeTraitConfig = m_activePlayerData.TraitConfigs[activeConfig];
SetActiveCombatTraitConfigID(activeTraitConfig.ID);
int activeSubTree = activeTraitConfig.SubTrees.FindIndexIf(subTree => subTree.Active != 0);
if (activeSubTree >= 0)
SetCurrentCombatTraitConfigSubTreeID(activeTraitConfig.SubTrees[activeSubTree].TraitSubTreeID);
}
foreach (TraitConfig traitConfig in m_activePlayerData.TraitConfigs)
{
@@ -1340,55 +1365,6 @@ namespace Game.Entities
RemoveAtLoginFlag(AtLoginFlags.Resurrect);
}
void _LoadVoidStorage(SQLResult result)
{
if (result.IsEmpty())
return;
do
{
// SELECT itemId, itemEntry, slot, creatorGuid, randomBonusListId, fixedScalingLevel, artifactKnowledgeLevel, context, bonusListIDs FROM character_void_storage WHERE playerGuid = ?
ulong itemId = result.Read<ulong>(0);
uint itemEntry = result.Read<uint>(1);
byte slot = result.Read<byte>(2);
ObjectGuid creatorGuid = result.Read<ulong>(3) != 0 ? ObjectGuid.Create(HighGuid.Player, result.Read<ulong>(3)) : ObjectGuid.Empty;
uint randomBonusListId = result.Read<uint>(4);
uint fixedScalingLevel = result.Read<uint>(5);
uint artifactKnowledgeLevel = result.Read<uint>(6);
ItemContext context = (ItemContext)result.Read<byte>(7);
List<uint> bonusListIDs = new();
var bonusListIdTokens = new StringArray(result.Read<string>(8), ' ');
for (var i = 0; i < bonusListIdTokens.Length; ++i)
{
if (uint.TryParse(bonusListIdTokens[i], out uint id))
bonusListIDs.Add(id);
}
if (itemId == 0)
{
Log.outError(LogFilter.Player, "Player:_LoadVoidStorage - Player (GUID: {0}, name: {1}) has an item with an invalid id (item id: item id: {2}, entry: {3}).", GetGUID().ToString(), GetName(), itemId, itemEntry);
continue;
}
if (Global.ObjectMgr.GetItemTemplate(itemEntry) == null)
{
Log.outError(LogFilter.Player, "Player:_LoadVoidStorage - Player (GUID: {0}, name: {1}) has an item with an invalid entry (item id: item id: {2}, entry: {3}).", GetGUID().ToString(), GetName(), itemId, itemEntry);
continue;
}
if (slot >= SharedConst.VoidStorageMaxSlot)
{
Log.outError(LogFilter.Player, "Player:_LoadVoidStorage - Player (GUID: {0}, name: {1}) has an item with an invalid slot (item id: item id: {2}, entry: {3}, slot: {4}).", GetGUID().ToString(), GetName(), itemId, itemEntry, slot);
continue;
}
_voidStorageItems[slot] = new VoidStorageItem(itemId, itemEntry, creatorGuid, randomBonusListId, fixedScalingLevel, artifactKnowledgeLevel, context, bonusListIDs);
BonusData bonus = new(new ItemInstance(_voidStorageItems[slot]));
GetSession().GetCollectionMgr().AddItemAppearance(itemEntry, bonus.AppearanceModID);
}
while (result.NextRow());
}
public void _LoadMail(SQLResult mailsResult, SQLResult mailItemsResult, SQLResult artifactResult, SQLResult azeriteItemResult, SQLResult azeriteItemMilestonePowersResult, SQLResult azeriteItemUnlockedEssencesResult, SQLResult azeriteEmpoweredItemResult)
{
@@ -2762,6 +2738,26 @@ namespace Game.Entities
_playerDataFlagsNeedSave.Clear();
}
void _SaveCharacterBankTabSettings(SQLTransaction trans)
{
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CHARACTER_BANK_TAB_SETTINGS);
stmt.AddValue(0, GetGUID().GetCounter());
trans.Append(stmt);
for (int i = 0; i < m_activePlayerData.CharacterBankTabSettings.Size(); ++i)
{
BankTabSettings tabSetting = m_activePlayerData.CharacterBankTabSettings[i];
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.INS_CHARACTER_BANK_TAB_SETTINGS);
stmt.AddValue(0, GetGUID().GetCounter());
stmt.AddValue(1, i);
stmt.AddValue(2, tabSetting.Name);
stmt.AddValue(3, tabSetting.Icon);
stmt.AddValue(4, tabSetting.Description);
stmt.AddValue(5, tabSetting.DepositFlags);
trans.Append(stmt);
}
}
public void SaveInventoryAndGoldToDB(SQLTransaction trans)
{
_SaveInventory(trans);
@@ -2867,42 +2863,7 @@ namespace Game.Entities
}
}
}
void _SaveVoidStorage(SQLTransaction trans)
{
PreparedStatement stmt;
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
{
if (_voidStorageItems[i] == null) // unused item
{
// DELETE FROM void_storage WHERE slot = ? AND playerGuid = ?
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CHAR_VOID_STORAGE_ITEM_BY_SLOT);
stmt.AddValue(0, i);
stmt.AddValue(1, GetGUID().GetCounter());
}
else
{
// REPLACE INTO character_void_storage (itemId, playerGuid, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, upgradeId, fixedScalingLevel, artifactKnowledgeLevel, bonusListIDs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.REP_CHAR_VOID_STORAGE_ITEM);
stmt.AddValue(0, _voidStorageItems[i].ItemId);
stmt.AddValue(1, GetGUID().GetCounter());
stmt.AddValue(2, _voidStorageItems[i].ItemEntry);
stmt.AddValue(3, i);
stmt.AddValue(4, _voidStorageItems[i].CreatorGuid.GetCounter());
stmt.AddValue(5, (byte)_voidStorageItems[i].RandomBonusListId);
stmt.AddValue(6, _voidStorageItems[i].FixedScalingLevel);
stmt.AddValue(7, _voidStorageItems[i].ArtifactKnowledgeLevel);
stmt.AddValue(8, (byte)_voidStorageItems[i].Context);
StringBuilder bonusListIDs = new();
foreach (uint bonusListID in _voidStorageItems[i].BonusListIDs)
bonusListIDs.AppendFormat("{0} ", bonusListID);
stmt.AddValue(9, bonusListIDs.ToString());
}
trans.Append(stmt);
}
}
void _SaveCUFProfiles(SQLTransaction trans)
{
PreparedStatement stmt;
@@ -3006,10 +2967,8 @@ namespace Game.Entities
bagSlotFlags[i] = (BagSlotFlags)result.Read<uint>(fieldIndex++);
byte bankSlots = result.Read<byte>(fieldIndex++);
BagSlotFlags[] bankBagSlotFlags = new BagSlotFlags[7];
byte bankTabs = result.Read<byte>(fieldIndex++);
BagSlotFlags bankBagFlags = (BagSlotFlags)result.Read<uint>(fieldIndex++);
for (var i = 0; i < bankBagSlotFlags.Length; ++i)
bankBagSlotFlags[i] = (BagSlotFlags)result.Read<uint>(fieldIndex++);
PlayerRestState restState = (PlayerRestState)result.Read<byte>(fieldIndex++);
PlayerFlags playerFlags = (PlayerFlags)result.Read<uint>(fieldIndex++);
@@ -3179,9 +3138,8 @@ namespace Game.Entities
ReplaceAllBagSlotFlags(bagIndex, bagSlotFlags[bagIndex]);
SetBankBagSlotCount(bankSlots);
SetCharacterBankTabCount(bankTabs);
SetBankAutoSortDisabled(bankBagFlags.HasFlag(BagSlotFlags.DisableAutoSort));
for (int bagIndex = 0; bagIndex < bankBagSlotFlags.Length; ++bagIndex)
ReplaceAllBankBagSlotFlags(bagIndex, bankBagSlotFlags[bagIndex]);
SetNativeGender(gender);
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.Inebriation), drunk);
@@ -3608,12 +3566,11 @@ namespace Game.Entities
// must be before inventory (some items required reputation check)
reputationMgr.LoadFromDB(holder.GetResult(PlayerLoginQueryLoad.Reputation));
_LoadCharacterBankTabSettings(holder.GetResult(PlayerLoginQueryLoad.BankTabSettings));
_LoadInventory(holder.GetResult(PlayerLoginQueryLoad.Inventory), holder.GetResult(PlayerLoginQueryLoad.Artifacts), holder.GetResult(PlayerLoginQueryLoad.Azerite),
holder.GetResult(PlayerLoginQueryLoad.AzeriteMilestonePowers), holder.GetResult(PlayerLoginQueryLoad.AzeriteUnlockedEssences), holder.GetResult(PlayerLoginQueryLoad.AzeriteEmpowered), time_diff);
if (IsVoidStorageUnlocked())
_LoadVoidStorage(holder.GetResult(PlayerLoginQueryLoad.VoidStorage));
// update items with duration and realtime
UpdateItemDuration(time_diff, true);
@@ -3884,13 +3841,12 @@ namespace Game.Entities
foreach (uint bagSlotFlag in m_activePlayerData.BagSlotFlags)
stmt.AddValue(index++, bagSlotFlag);
stmt.AddValue(index++, GetBankBagSlotCount());
stmt.AddValue(index++, GetCharacterBankTabCount());
inventoryFlags = BagSlotFlags.None;
if (m_activePlayerData.BankAutoSortDisabled)
inventoryFlags |= BagSlotFlags.DisableAutoSort;
stmt.AddValue(index++, (uint)inventoryFlags);
foreach (uint bankBagSlotFlag in m_activePlayerData.BankBagSlotFlags)
stmt.AddValue(index++, bankBagSlotFlag);
stmt.AddValue(index++, m_activePlayerData.RestInfo[(int)RestTypes.XP].StateID);
stmt.AddValue(index++, m_playerData.PlayerFlags);
@@ -4019,13 +3975,12 @@ namespace Game.Entities
foreach (uint bagSlotFlag in m_activePlayerData.BagSlotFlags)
stmt.AddValue(index++, bagSlotFlag);
stmt.AddValue(index++, GetBankBagSlotCount());
stmt.AddValue(index++, GetCharacterBankTabCount());
inventoryFlags = BagSlotFlags.None;
if (m_activePlayerData.BankAutoSortDisabled)
inventoryFlags |= BagSlotFlags.DisableAutoSort;
stmt.AddValue(index++, (uint)inventoryFlags);
foreach (uint bankBagSlotFlag in m_activePlayerData.BankBagSlotFlags)
stmt.AddValue(index++, bankBagSlotFlag);
stmt.AddValue(index++, m_activePlayerData.RestInfo[(int)RestTypes.XP].StateID);
stmt.AddValue(index++, m_playerData.PlayerFlags);
@@ -4179,7 +4134,6 @@ namespace Game.Entities
_SaveCustomizations(characterTransaction);
_SaveBGData(characterTransaction);
_SaveInventory(characterTransaction);
_SaveVoidStorage(characterTransaction);
_SaveQuestStatus(characterTransaction);
_SaveDailyQuestStatus(characterTransaction);
_SaveWeeklyQuestStatus(characterTransaction);
@@ -4203,6 +4157,7 @@ namespace Game.Entities
_SaveCurrency(characterTransaction);
_SaveCUFProfiles(characterTransaction);
_SavePlayerData(characterTransaction);
_SaveCharacterBankTabSettings(characterTransaction);
if (_garrison != null)
_garrison.SaveToDB(characterTransaction);
@@ -4717,10 +4672,6 @@ namespace Game.Entities
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CHAR_VOID_STORAGE_ITEM_BY_CHAR_GUID);
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CHAR_FISHINGSTEPS);
stmt.AddValue(0, guid);
trans.Append(stmt);
@@ -4755,6 +4706,18 @@ namespace Game.Entities
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_PLAYER_DATA_ELEMENTS_CHARACTER_BY_GUID);
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_PLAYER_DATA_FLAGS_CHARACTER_BY_GUID);
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_CHARACTER_BANK_TAB_SETTINGS);
stmt.AddValue(0, guid);
trans.Append(stmt);
Global.CharacterCacheStorage.DeleteCharacterCacheEntry(playerGuid, name);
break;
}
@@ -41,7 +41,6 @@ namespace Game.Entities
List<ObjectGuid> m_itemSoulboundTradeable = new();
List<ObjectGuid> m_refundableItems = new();
public List<Item> ItemUpdateQueue = new();
VoidStorageItem[] _voidStorageItems = new VoidStorageItem[SharedConst.VoidStorageMaxSlot];
Item[] m_items = new Item[(int)PlayerSlots.Count];
uint m_WeaponProficiency;
uint m_ArmorProficiency;
@@ -490,32 +489,6 @@ namespace Game.Entities
public uint leftduration;
}
public class VoidStorageItem
{
public VoidStorageItem(ulong id, uint entry, ObjectGuid creator, uint randomBonusListId, uint fixedScalingLevel, uint artifactKnowledgeLevel, ItemContext context, List<uint> bonuses)
{
ItemId = id;
ItemEntry = entry;
CreatorGuid = creator;
RandomBonusListId = randomBonusListId;
FixedScalingLevel = fixedScalingLevel;
ArtifactKnowledgeLevel = artifactKnowledgeLevel;
Context = context;
foreach (var value in bonuses)
BonusListIDs.Add(value);
}
public ulong ItemId;
public uint ItemEntry;
public ObjectGuid CreatorGuid;
public uint RandomBonusListId;
public uint FixedScalingLevel;
public uint ArtifactKnowledgeLevel;
public ItemContext Context;
public List<uint> BonusListIDs = new();
}
public class EquipmentSetInfo
{
public EquipmentSetInfo()
+60 -294
View File
@@ -1449,7 +1449,7 @@ namespace Game.Entities
return res; // return latest error if any
}
Item EquipNewItem(ushort pos, uint item, ItemContext context, bool update)
public Item EquipNewItem(ushort pos, uint item, ItemContext context, bool update)
{
Item pItem = Item.CreateItem(item, 1, context, this);
if (pItem != null)
@@ -2055,12 +2055,6 @@ namespace Game.Entities
}
}
if (IsReagentBankPos(dst) && !IsReagentBankUnlocked())
{
SendEquipError(InventoryResult.ReagentBankLocked, pSrcItem, pDstItem);
return;
}
// NOW this is or item move (swap with empty), or swap with another item (including bags in bag possitions)
// or swap empty bag with another empty or not empty bag (with items exchange)
@@ -2094,8 +2088,7 @@ namespace Game.Entities
RemoveItem(srcbag, srcslot, true);
BankItem(dest, pSrcItem, true);
if (!IsReagentBankPos(dst))
ItemRemovedQuestCheck(pSrcItem.GetEntry(), pSrcItem.GetCount());
ItemRemovedQuestCheck(pSrcItem.GetEntry(), pSrcItem.GetCount());
}
else if (IsEquipmentPos(dst))
{
@@ -2738,18 +2731,10 @@ namespace Game.Entities
if (slot >= InventorySlots.ItemStart && slot < InventorySlots.ItemStart + GetInventorySlotCount())
return true;
// bank main slots
if (slot >= InventorySlots.BankItemStart && slot < InventorySlots.BankItemEnd)
return true;
// bank bag slots
if (slot >= InventorySlots.BankBagStart && slot < InventorySlots.BankBagEnd)
return true;
// reagent bank bag slots
if (slot >= InventorySlots.ReagentStart && slot < InventorySlots.ReagentEnd)
return true;
return false;
}
@@ -4080,8 +4065,6 @@ namespace Game.Entities
return true;
if (bag >= InventorySlots.ReagentBagStart && bag < InventorySlots.ReagentBagEnd)
return true;
if (bag == InventorySlots.Bag0 && (slot >= InventorySlots.ReagentStart && slot < InventorySlots.ReagentEnd))
return true;
if (bag == InventorySlots.Bag0 && (slot >= InventorySlots.ChildEquipmentStart && slot < InventorySlots.ChildEquipmentEnd))
return true;
return false;
@@ -4168,10 +4151,6 @@ namespace Game.Entities
// prevent cheating
if ((slot >= InventorySlots.BuyBackStart && slot < InventorySlots.BuyBackEnd) || slot >= (byte)PlayerSlots.End)
return InventoryResult.WrongBagType;
// can't store anything else than crafting reagents in Reagent Bank
if (IsReagentBankPos(bag, slot) && (!IsReagentBankUnlocked() || !pProto.IsCraftingReagent()))
return InventoryResult.WrongBagType;
}
else
{
@@ -4271,14 +4250,10 @@ namespace Game.Entities
public static bool IsBankPos(byte bag, byte slot)
{
if (bag == InventorySlots.Bag0 && (slot >= InventorySlots.BankItemStart && slot < InventorySlots.BankItemEnd))
return true;
if (bag == InventorySlots.Bag0 && (slot >= InventorySlots.BankBagStart && slot < InventorySlots.BankBagEnd))
return true;
if (bag >= InventorySlots.BankBagStart && bag < InventorySlots.BankBagEnd)
return true;
if (bag == InventorySlots.Bag0 && (slot >= InventorySlots.ReagentStart && slot < InventorySlots.ReagentEnd))
return true;
return false;
}
@@ -4293,12 +4268,6 @@ namespace Game.Entities
Cypher.Assert(bag == ItemConst.NullBag && slot == ItemConst.NullSlot); // when reagentBankOnly is true then bag & slot must be hardcoded constants, not client input
}
if ((IsReagentBankPos(bag, slot) || reagentBankOnly) && !IsReagentBankUnlocked())
return InventoryResult.ReagentBankLocked;
byte slotStart = reagentBankOnly ? InventorySlots.ReagentStart : InventorySlots.BankItemStart;
byte slotEnd = reagentBankOnly ? InventorySlots.ReagentEnd : InventorySlots.BankItemEnd;
uint count = pItem.GetCount();
Log.outDebug(LogFilter.Player, "STORAGE: CanBankItem bag = {0}, slot = {1}, item = {2}, count = {3}", bag, slot, pItem.GetEntry(), count);
@@ -4334,7 +4303,7 @@ namespace Game.Entities
if (!pItem.IsBag())
return InventoryResult.WrongSlot;
if (slot - InventorySlots.BagStart >= GetBankBagSlotCount())
if (slot - InventorySlots.BagStart >= GetCharacterBankTabCount())
return InventoryResult.NoBankSlot;
res = CanUseItem(pItem, not_loading);
@@ -4363,12 +4332,7 @@ namespace Game.Entities
{
if (bag == InventorySlots.Bag0)
{
res = CanStoreItem_InInventorySlots(slotStart, slotEnd, dest, pProto, ref count, true, pItem, bag, slot);
if (res != InventoryResult.Ok)
return res;
if (count == 0)
return InventoryResult.Ok;
return InventoryResult.WrongSlot; // TODO: check if INVENTORY_SLOT_BAG_0 condition is neccessary
}
else
{
@@ -4387,12 +4351,7 @@ namespace Game.Entities
// search free slot in bag
if (bag == InventorySlots.Bag0)
{
res = CanStoreItem_InInventorySlots(slotStart, slotEnd, dest, pProto, ref count, false, pItem, bag, slot);
if (res != InventoryResult.Ok)
return res;
if (count == 0)
return InventoryResult.Ok;
return InventoryResult.WrongSlot; // TODO: check if INVENTORY_SLOT_BAG_0 condition is neccessary
}
else
{
@@ -4413,79 +4372,37 @@ namespace Game.Entities
// search stack for merge to
if (pProto.GetMaxStackSize() != 1)
{
// in slots
res = CanStoreItem_InInventorySlots(slotStart, slotEnd, dest, pProto, ref count, true, pItem, bag, slot);
// in regular bags
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
// only consider tabs marked as reagents if requested
if (reagentBankOnly && (m_activePlayerData.CharacterBankTabSettings[i - InventorySlots.BankBagStart].DepositFlags & (int)BagSlotFlags.PriorityReagents) == 0)
continue;
res = CanStoreItem_InBag(i, dest, pProto, ref count, true, true, pItem, bag, slot);
if (res != InventoryResult.Ok)
continue;
if (count == 0)
return InventoryResult.Ok;
}
}
// search free space in regular bags
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
// only consider tabs marked as reagents if requested
if (reagentBankOnly && (m_activePlayerData.CharacterBankTabSettings[i - InventorySlots.BankBagStart].DepositFlags & (int)BagSlotFlags.PriorityReagents) == 0)
continue;
res = CanStoreItem_InBag(i, dest, pProto, ref count, false, true, pItem, bag, slot);
if (res != InventoryResult.Ok)
return res;
continue;
if (count == 0)
return InventoryResult.Ok;
// don't try to store reagents anywhere else than in Reagent Bank if we're on it
if (!reagentBankOnly)
{
// in special bags
if (pProto.GetBagFamily() != BagFamilyMask.None)
{
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
res = CanStoreItem_InBag(i, dest, pProto, ref count, true, false, pItem, bag, slot);
if (res != InventoryResult.Ok)
continue;
if (count == 0)
return InventoryResult.Ok;
}
}
// in regular bags
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
res = CanStoreItem_InBag(i, dest, pProto, ref count, true, true, pItem, bag, slot);
if (res != InventoryResult.Ok)
continue;
if (count == 0)
return InventoryResult.Ok;
}
}
}
// search free place in special bag
if (!reagentBankOnly && pProto.GetBagFamily() != BagFamilyMask.None)
{
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
res = CanStoreItem_InBag(i, dest, pProto, ref count, false, false, pItem, bag, slot);
if (res != InventoryResult.Ok)
continue;
if (count == 0)
return InventoryResult.Ok;
}
}
// search free space
res = CanStoreItem_InInventorySlots(slotStart, slotEnd, dest, pProto, ref count, false, pItem, bag, slot);
if (res != InventoryResult.Ok)
return res;
if (count == 0)
return InventoryResult.Ok;
// search free space in regular bags (don't try to store reagents anywhere else than in Reagent Bank if we're on it)
if (!reagentBankOnly)
{
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
res = CanStoreItem_InBag(i, dest, pProto, ref count, false, true, pItem, bag, slot);
if (res != InventoryResult.Ok)
continue;
if (count == 0)
return InventoryResult.Ok;
}
}
return reagentBankOnly ? InventoryResult.ReagentBankFull : InventoryResult.BankFull;
}
@@ -4530,10 +4447,6 @@ namespace Game.Entities
if (location.HasFlag(ItemSearchLocation.Bank))
{
for (byte i = InventorySlots.BankItemStart; i < InventorySlots.BankItemEnd; ++i)
if (GetItemByPos(InventorySlots.Bag0, i) == null)
++freeSlotCount;
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; ++i)
{
Bag bag = GetBagByPos(i);
@@ -4556,25 +4469,11 @@ namespace Game.Entities
if (bag.GetItemByPos(j) == null)
++freeSlotCount;
}
for (byte i = InventorySlots.ReagentStart; i < InventorySlots.ReagentEnd; ++i)
if (GetItemByPos(InventorySlots.Bag0, i) == null)
++freeSlotCount;
}
return freeSlotCount;
}
//Reagent
public static bool IsReagentBankPos(ushort pos) { return IsReagentBankPos((byte)(pos >> 8), (byte)(pos & 255)); }
public static bool IsReagentBankPos(byte bag, byte slot)
{
if (bag == InventorySlots.Bag0 && (slot >= InventorySlots.ReagentStart && slot < InventorySlots.ReagentEnd))
return true;
return false;
}
//Bags
public Bag GetBagByPos(byte bag)
{
@@ -4898,7 +4797,7 @@ namespace Game.Entities
return ItemConst.NullSlot;
}
InventoryResult CanEquipNewItem(byte slot, out ushort dest, uint item, bool swap)
public InventoryResult CanEquipNewItem(byte slot, out ushort dest, uint item, bool swap)
{
dest = 0;
Item pItem = Item.CreateItem(item, 1, ItemContext.None, this);
@@ -5253,6 +5152,14 @@ namespace Game.Entities
//Child
public static bool IsChildEquipmentPos(ushort pos) { return IsChildEquipmentPos((byte)(pos >> 8), (byte)(pos & 255)); }
public static bool IsAccountBankPos(ushort pos) { return IsBankPos((byte)(pos >> 8), (byte)(pos & 255)); }
public static bool IsAccountBankPos(byte bag, byte slot)
{
if (bag >= (int)AccountBankBagSlots.Start && bag < (int)AccountBankBagSlots.End)
return true;
return false;
}
//Artifact
void ApplyArtifactPowers(Item item, bool apply)
{
@@ -5776,34 +5683,6 @@ namespace Game.Entities
}
}
// in bank
for (byte i = InventorySlots.BankItemStart; i < InventorySlots.BankItemEnd; i++)
{
Item item = GetItemByPos(InventorySlots.Bag0, i);
if (item != null)
{
if (item.GetEntry() == itemEntry && !item.IsInTrade())
{
if (item.GetCount() + remcount <= count)
{
remcount += item.GetCount();
DestroyItem(InventorySlots.Bag0, i, update);
if (remcount >= count)
return remcount;
}
else
{
item.SetCount(item.GetCount() - count + remcount);
ItemRemovedQuestCheck(item.GetEntry(), count - remcount);
if (IsInWorld && update)
item.SendUpdateToPlayer(this);
item.SetState(ItemUpdateState.Changed, this);
return count;
}
}
}
}
// in bank bags
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; i++)
{
@@ -5872,35 +5751,6 @@ namespace Game.Entities
}
}
for (byte i = InventorySlots.ReagentStart; i < InventorySlots.ReagentEnd; ++i)
{
Item item = GetItemByPos(InventorySlots.Bag0, i);
if (item != null)
{
if (item.GetEntry() == itemEntry && !item.IsInTrade())
{
if (item.GetCount() + remcount <= count)
{
// all keys can be unequipped
remcount += item.GetCount();
DestroyItem(InventorySlots.Bag0, i, update);
if (remcount >= count)
return remcount;
}
else
{
item.SetCount(item.GetCount() - count + remcount);
ItemRemovedQuestCheck(item.GetEntry(), count - remcount);
if (IsInWorld && update)
item.SendUpdateToPlayer(this);
item.SetState(ItemUpdateState.Changed, this);
return count;
}
}
}
}
for (byte i = InventorySlots.ChildEquipmentStart; i < InventorySlots.ChildEquipmentEnd; ++i)
{
Item item = GetItemByPos(InventorySlots.Bag0, i);
@@ -6014,6 +5864,27 @@ namespace Game.Entities
public byte GetBankBagSlotCount() { return m_activePlayerData.NumBankSlots; }
public void SetBankBagSlotCount(byte count) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumBankSlots), count); }
public byte GetCharacterBankTabCount() { return m_activePlayerData.NumCharacterBankTabs; }
public void SetCharacterBankTabCount(byte count) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumCharacterBankTabs), count); }
public byte GetAccountBankTabCount() { return m_activePlayerData.NumAccountBankTabs; }
public void SetAccountBankTabCount(byte count) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumAccountBankTabs), count); }
public void SetCharacterBankTabSettings(uint tabId, string name, string icon, string description, BagSlotFlags depositFlags)
{
var setter = m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.CharacterBankTabSettings, (int)tabId);
SetBankTabSettings(setter, name, icon, description, depositFlags);
}
public void SetAccountBankTabSettings(uint tabId, string name, string icon, string description, BagSlotFlags depositFlags)
{
var setter = m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.AccountBankTabSettings, (int)tabId);
SetBankTabSettings(setter, name, icon, description, depositFlags);
}
public void SetBankTabSettings(BankTabSettings bantTabSettings, string name, string icon, string description, BagSlotFlags depositFlags)
{
SetUpdateFieldValue(bantTabSettings.ModifyValue(bantTabSettings.Name), name);
SetUpdateFieldValue(bantTabSettings.ModifyValue(bantTabSettings.Icon), icon);
SetUpdateFieldValue(bantTabSettings.ModifyValue(bantTabSettings.Description), description);
SetUpdateFieldValue(bantTabSettings.ModifyValue(bantTabSettings.DepositFlags), (int)depositFlags);
}
public bool IsBackpackAutoSortDisabled() { return m_activePlayerData.BackpackAutoSortDisabled; }
public void SetBackpackAutoSortDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BackpackAutoSortDisabled), disabled); }
@@ -6025,10 +5896,6 @@ namespace Game.Entities
public void SetBagSlotFlag(int bagIndex, BagSlotFlags flags) { SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BagSlotFlags, bagIndex), (uint)flags); }
public void RemoveBagSlotFlag(int bagIndex, BagSlotFlags flags) { RemoveUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BagSlotFlags, bagIndex), (uint)flags); }
public void ReplaceAllBagSlotFlags(int bagIndex, BagSlotFlags flags) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BagSlotFlags, bagIndex), (uint)flags); }
public BagSlotFlags GetBankBagSlotFlags(int bagIndex) { return (BagSlotFlags)m_activePlayerData.BankBagSlotFlags[bagIndex]; }
public void SetBankBagSlotFlag(int bagIndex, BagSlotFlags flags) { SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankBagSlotFlags, bagIndex), (uint)flags); }
public void RemoveBankBagSlotFlag(int bagIndex, BagSlotFlags flags) { RemoveUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankBagSlotFlags, bagIndex), (uint)flags); }
public void ReplaceAllBankBagSlotFlags(int bagIndex, BagSlotFlags flags) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankBagSlotFlags, bagIndex), (uint)flags); }
//Loot
public ObjectGuid GetLootGUID() { return m_playerData.LootTargetGUID; }
@@ -6308,91 +6175,6 @@ namespace Game.Entities
}
}
//Void Storage
public bool IsVoidStorageUnlocked() { return HasPlayerFlag(PlayerFlags.VoidUnlocked); }
public void UnlockVoidStorage() { SetPlayerFlag(PlayerFlags.VoidUnlocked); }
public void LockVoidStorage() { RemovePlayerFlag(PlayerFlags.VoidUnlocked); }
public byte GetNextVoidStorageFreeSlot()
{
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
if (_voidStorageItems[i] == null) // unused item
return i;
return SharedConst.VoidStorageMaxSlot;
}
public byte GetNumOfVoidStorageFreeSlots()
{
byte count = 0;
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
if (_voidStorageItems[i] == null)
count++;
return count;
}
public byte AddVoidStorageItem(VoidStorageItem item)
{
byte slot = GetNextVoidStorageFreeSlot();
if (slot >= SharedConst.VoidStorageMaxSlot)
{
GetSession().SendVoidStorageTransferResult(VoidTransferError.Full);
return 255;
}
_voidStorageItems[slot] = item;
return slot;
}
public void DeleteVoidStorageItem(byte slot)
{
if (slot >= SharedConst.VoidStorageMaxSlot)
{
GetSession().SendVoidStorageTransferResult(VoidTransferError.InternalError1);
return;
}
_voidStorageItems[slot] = null;
}
public bool SwapVoidStorageItem(byte oldSlot, byte newSlot)
{
if (oldSlot >= SharedConst.VoidStorageMaxSlot || newSlot >= SharedConst.VoidStorageMaxSlot || oldSlot == newSlot)
return false;
_voidStorageItems.Swap(newSlot, oldSlot);
return true;
}
public VoidStorageItem GetVoidStorageItem(byte slot)
{
if (slot >= SharedConst.VoidStorageMaxSlot)
{
GetSession().SendVoidStorageTransferResult(VoidTransferError.InternalError1);
return null;
}
return _voidStorageItems[slot];
}
public VoidStorageItem GetVoidStorageItem(ulong id, out byte slot)
{
slot = 0;
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
{
if (_voidStorageItems[i] != null && _voidStorageItems[i].ItemId == id)
{
slot = i;
return _voidStorageItems[i];
}
}
return null;
}
//Misc
void UpdateItemLevelAreaBasedScaling()
{
@@ -6469,14 +6251,6 @@ namespace Game.Entities
if (location.HasAnyFlag(ItemSearchLocation.Bank))
{
for (byte i = InventorySlots.BankItemStart; i < InventorySlots.BankItemEnd; ++i)
{
Item item = GetItemByPos(InventorySlots.Bag0, i);
if (item != null)
if (!callback(item))
return false;
}
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; ++i)
{
Bag bag = GetBagByPos(i);
@@ -6509,14 +6283,6 @@ namespace Game.Entities
}
}
}
for (byte i = InventorySlots.ReagentStart; i < InventorySlots.ReagentEnd; ++i)
{
Item item = GetItemByPos(InventorySlots.Bag0, i);
if (item != null)
if (!callback(item))
return false;
}
}
return true;
+23 -1
View File
@@ -365,9 +365,20 @@ namespace Game.Entities
&& ((TraitCombatConfigFlags)(int)traitConfig.CombatConfigFlags & TraitCombatConfigFlags.ActiveForSpec) != TraitCombatConfigFlags.None;
});
if (specTraitConfigIndex >= 0)
SetActiveCombatTraitConfigID(m_activePlayerData.TraitConfigs[specTraitConfigIndex].ID);
{
TraitConfig activeTraitConfig = m_activePlayerData.TraitConfigs[specTraitConfigIndex];
SetActiveCombatTraitConfigID(activeTraitConfig.ID);
int activeSubTree = activeTraitConfig.SubTrees.FindIndexIf(subTree => subTree.Active != 0);
if (activeSubTree >= 0)
SetCurrentCombatTraitConfigSubTreeID(activeTraitConfig.SubTrees[activeSubTree].TraitSubTreeID);
else
SetCurrentCombatTraitConfigSubTreeID(0);
}
else
{
SetActiveCombatTraitConfigID(0);
SetCurrentCombatTraitConfigSubTreeID(0);
}
foreach (var talentInfo in CliDB.TalentStorage.Values)
{
@@ -1136,6 +1147,17 @@ namespace Game.Entities
}
}
if (applyTraits)
{
int activeSubTree = editedConfig.SubTrees.FindIndexIf(subTree => subTree.Active != 0);
if (activeSubTree >= 0)
SetCurrentCombatTraitConfigSubTreeID(editedConfig.SubTrees[activeSubTree].TraitSubTreeID);
else
SetCurrentCombatTraitConfigSubTreeID(0);
Item.UpdateItemSetAuras(this, false);
}
m_traitConfigStates[editedConfigId] = PlayerSpellState.Changed;
}
+3 -18
View File
@@ -143,9 +143,6 @@ namespace Game.Entities
_cinematicMgr.Dispose();
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
_voidStorageItems[i] = null;
ClearResurrectRequestData();
WorldMgr.DecreasePlayerCount();
@@ -599,21 +596,8 @@ namespace Game.Entities
if (target == this)
{
for (byte i = EquipmentSlot.Start; i < InventorySlots.BankBagEnd; ++i)
{
if (m_items[i] == null)
continue;
m_items[i].DestroyForPlayer(target);
}
for (byte i = InventorySlots.ReagentStart; i < InventorySlots.ChildEquipmentEnd; ++i)
{
if (m_items[i] == null)
continue;
m_items[i].DestroyForPlayer(target);
}
foreach (Item item in m_items)
item?.DestroyForPlayer(target);
}
}
public override void CleanupsBeforeDelete(bool finalCleanup = true)
@@ -7697,6 +7681,7 @@ namespace Game.Entities
}
void SetActiveCombatTraitConfigID(int traitConfigId) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ActiveCombatTraitConfigID), (uint)traitConfigId); }
void SetCurrentCombatTraitConfigSubTreeID(int traitSubTreeId) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.CurrentCombatTraitConfigSubTreeID), traitSubTreeId); }
void InitPrimaryProfessions()
{