Core: SOme code cleanup, more to follow.
This commit is contained in:
+21
-21
@@ -82,10 +82,10 @@ namespace Game.Loots
|
||||
|
||||
public uint itemid;
|
||||
public uint randomBonusListId;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
public List<uint> BonusListIDs = new();
|
||||
public ItemContext context;
|
||||
public List<Condition> conditions = new List<Condition>(); // additional loot condition
|
||||
public List<ObjectGuid> allowedGUIDs = new List<ObjectGuid>();
|
||||
public List<Condition> conditions = new(); // additional loot condition
|
||||
public List<ObjectGuid> allowedGUIDs = new();
|
||||
public ObjectGuid rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list!
|
||||
public byte count;
|
||||
public bool is_looted;
|
||||
@@ -160,7 +160,7 @@ namespace Game.Loots
|
||||
|
||||
for (uint i = 0; i < stacks && lootItems.Count < limit; ++i)
|
||||
{
|
||||
LootItem generatedLoot = new LootItem(item);
|
||||
LootItem generatedLoot = new(item);
|
||||
generatedLoot.context = _itemContext;
|
||||
generatedLoot.count = (byte)Math.Min(count, proto.GetMaxStackSize());
|
||||
if (_itemContext != 0)
|
||||
@@ -282,7 +282,7 @@ namespace Game.Loots
|
||||
|
||||
List<NotNormalLootItem> FillFFALoot(Player player)
|
||||
{
|
||||
List<NotNormalLootItem> ql = new List<NotNormalLootItem>();
|
||||
List<NotNormalLootItem> ql = new();
|
||||
|
||||
for (byte i = 0; i < items.Count; ++i)
|
||||
{
|
||||
@@ -306,7 +306,7 @@ namespace Game.Loots
|
||||
if (items.Count == SharedConst.MaxNRLootItems)
|
||||
return null;
|
||||
|
||||
List<NotNormalLootItem> ql = new List<NotNormalLootItem>();
|
||||
List<NotNormalLootItem> ql = new();
|
||||
|
||||
for (byte i = 0; i < quest_items.Count; ++i)
|
||||
{
|
||||
@@ -339,7 +339,7 @@ namespace Game.Loots
|
||||
|
||||
List<NotNormalLootItem> FillNonQuestNonFFAConditionalLoot(Player player, bool presentAtLooting)
|
||||
{
|
||||
List<NotNormalLootItem> ql = new List<NotNormalLootItem>();
|
||||
List<NotNormalLootItem> ql = new();
|
||||
|
||||
for (byte i = 0; i < items.Count; ++i)
|
||||
{
|
||||
@@ -642,7 +642,7 @@ namespace Game.Loots
|
||||
// item shall not be displayed.
|
||||
continue;
|
||||
|
||||
LootItemData lootItem = new LootItemData();
|
||||
LootItemData lootItem = new();
|
||||
lootItem.LootListID = (byte)(i + 1);
|
||||
lootItem.UIType = slot_type;
|
||||
lootItem.Quantity = items[i].count;
|
||||
@@ -659,7 +659,7 @@ namespace Game.Loots
|
||||
{
|
||||
if (!items[i].is_looted && !items[i].freeforall && items[i].conditions.Empty() && items[i].AllowedForPlayer(viewer))
|
||||
{
|
||||
LootItemData lootItem = new LootItemData();
|
||||
LootItemData lootItem = new();
|
||||
lootItem.LootListID = (byte)(i + 1);
|
||||
lootItem.UIType = (permission == PermissionTypes.Owner ? LootSlotType.Owner : LootSlotType.AllowLoot);
|
||||
lootItem.Quantity = items[i].count;
|
||||
@@ -684,7 +684,7 @@ namespace Game.Loots
|
||||
LootItem item = quest_items[qi.index];
|
||||
if (!qi.is_looted && !item.is_looted)
|
||||
{
|
||||
LootItemData lootItem = new LootItemData();
|
||||
LootItemData lootItem = new();
|
||||
lootItem.LootListID = (byte)(items.Count + i + 1);
|
||||
lootItem.Quantity = item.count;
|
||||
lootItem.Loot = new ItemInstance(item);
|
||||
@@ -722,7 +722,7 @@ namespace Game.Loots
|
||||
LootItem item = items[fi.index];
|
||||
if (!fi.is_looted && !item.is_looted)
|
||||
{
|
||||
LootItemData lootItem = new LootItemData();
|
||||
LootItemData lootItem = new();
|
||||
lootItem.LootListID = (byte)(fi.index + 1);
|
||||
lootItem.UIType = slotType;
|
||||
lootItem.Quantity = item.count;
|
||||
@@ -741,7 +741,7 @@ namespace Game.Loots
|
||||
LootItem item = items[ci.index];
|
||||
if (!ci.is_looted && !item.is_looted)
|
||||
{
|
||||
LootItemData lootItem = new LootItemData();
|
||||
LootItemData lootItem = new();
|
||||
lootItem.LootListID = (byte)(ci.index + 1);
|
||||
lootItem.Quantity = item.count;
|
||||
lootItem.Loot = new ItemInstance(item);
|
||||
@@ -812,8 +812,8 @@ namespace Game.Loots
|
||||
public MultiMap<ObjectGuid, NotNormalLootItem> GetPlayerFFAItems() { return PlayerFFAItems; }
|
||||
public MultiMap<ObjectGuid, NotNormalLootItem> GetPlayerNonQuestNonFFAConditionalItems() { return PlayerNonQuestNonFFAConditionalItems; }
|
||||
|
||||
public List<LootItem> items = new List<LootItem>();
|
||||
public List<LootItem> quest_items = new List<LootItem>();
|
||||
public List<LootItem> items = new();
|
||||
public List<LootItem> quest_items = new();
|
||||
public uint gold;
|
||||
public byte unlootedCount;
|
||||
public ObjectGuid roundRobinPlayer; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released.
|
||||
@@ -822,13 +822,13 @@ namespace Game.Loots
|
||||
|
||||
public ObjectGuid containerID;
|
||||
|
||||
List<ObjectGuid> PlayersLooting = new List<ObjectGuid>();
|
||||
MultiMap<ObjectGuid, NotNormalLootItem> PlayerQuestItems = new MultiMap<ObjectGuid, NotNormalLootItem>();
|
||||
MultiMap<ObjectGuid, NotNormalLootItem> PlayerFFAItems = new MultiMap<ObjectGuid, NotNormalLootItem>();
|
||||
MultiMap<ObjectGuid, NotNormalLootItem> PlayerNonQuestNonFFAConditionalItems = new MultiMap<ObjectGuid, NotNormalLootItem>();
|
||||
List<ObjectGuid> PlayersLooting = new();
|
||||
MultiMap<ObjectGuid, NotNormalLootItem> PlayerQuestItems = new();
|
||||
MultiMap<ObjectGuid, NotNormalLootItem> PlayerFFAItems = new();
|
||||
MultiMap<ObjectGuid, NotNormalLootItem> PlayerNonQuestNonFFAConditionalItems = new();
|
||||
|
||||
// All rolls are registered here. They need to know, when the loot is not valid anymore
|
||||
LootValidatorRefManager i_LootValidatorRefManager = new LootValidatorRefManager();
|
||||
LootValidatorRefManager i_LootValidatorRefManager = new();
|
||||
|
||||
// Loot GUID
|
||||
ObjectGuid _GUID;
|
||||
@@ -861,8 +861,8 @@ namespace Game.Loots
|
||||
return _byOrder;
|
||||
}
|
||||
|
||||
List<ResultValue> _byOrder = new List<ResultValue>();
|
||||
Dictionary<Item, int> _byItem = new Dictionary<Item, int>();
|
||||
List<ResultValue> _byOrder = new();
|
||||
Dictionary<Item, int> _byItem = new();
|
||||
|
||||
public struct ResultValue
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Game.Loots
|
||||
|
||||
StoredLootContainer storedContainer = _lootItemStorage[key];
|
||||
|
||||
LootItem lootItem = new LootItem();
|
||||
LootItem lootItem = new();
|
||||
lootItem.itemid = result.Read<uint>(1);
|
||||
lootItem.count = result.Read<byte>(2);
|
||||
lootItem.follow_loot_rules = result.Read<bool>(3);
|
||||
@@ -59,7 +59,7 @@ namespace Game.Loots
|
||||
lootItem.needs_quest = result.Read<bool>(8);
|
||||
lootItem.randomBonusListId = result.Read<uint>(9);
|
||||
lootItem.context = (ItemContext)result.Read<byte>(10);
|
||||
StringArray bonusLists = new StringArray(result.Read<string>(11), ' ');
|
||||
StringArray bonusLists = new(result.Read<string>(11), ' ');
|
||||
|
||||
foreach (string str in bonusLists)
|
||||
lootItem.BonusListIDs.Add(uint.Parse(str));
|
||||
@@ -111,7 +111,7 @@ namespace Game.Loots
|
||||
{
|
||||
foreach (var storedItemPair in container.GetLootItems())
|
||||
{
|
||||
LootItem li = new LootItem();
|
||||
LootItem li = new();
|
||||
li.itemid = storedItemPair.Key;
|
||||
li.count = (byte)storedItemPair.Value.Count;
|
||||
li.follow_loot_rules = storedItemPair.Value.FollowRules;
|
||||
@@ -156,7 +156,7 @@ namespace Game.Loots
|
||||
{
|
||||
_lootItemStorage.TryRemove(containerId, out _);
|
||||
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
SQLTransaction trans = new();
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ITEMCONTAINER_ITEMS);
|
||||
stmt.AddValue(0, containerId);
|
||||
trans.Append(stmt);
|
||||
@@ -188,9 +188,9 @@ namespace Game.Loots
|
||||
return;
|
||||
}
|
||||
|
||||
StoredLootContainer container = new StoredLootContainer(loot.containerID.GetCounter());
|
||||
StoredLootContainer container = new(loot.containerID.GetCounter());
|
||||
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
SQLTransaction trans = new();
|
||||
if (loot.gold != 0)
|
||||
container.AddMoney(loot.gold, trans);
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Game.Loots
|
||||
_lootItemStorage.TryAdd(loot.containerID.GetCounter(), container);
|
||||
}
|
||||
|
||||
ConcurrentDictionary<ulong, StoredLootContainer> _lootItemStorage = new ConcurrentDictionary<ulong, StoredLootContainer>();
|
||||
ConcurrentDictionary<ulong, StoredLootContainer> _lootItemStorage = new();
|
||||
}
|
||||
|
||||
class StoredLootContainer
|
||||
@@ -254,7 +254,7 @@ namespace Game.Loots
|
||||
|
||||
foreach (uint token in lootItem.BonusListIDs)
|
||||
{
|
||||
StringBuilder bonusListIDs = new StringBuilder();
|
||||
StringBuilder bonusListIDs = new();
|
||||
foreach (int bonusListID in lootItem.BonusListIDs)
|
||||
bonusListIDs.Append(bonusListID + ' ');
|
||||
|
||||
@@ -314,7 +314,7 @@ namespace Game.Loots
|
||||
|
||||
public MultiMap<uint, StoredLootItem> GetLootItems() { return _lootItems; }
|
||||
|
||||
MultiMap<uint, StoredLootItem> _lootItems = new MultiMap<uint, StoredLootItem>();
|
||||
MultiMap<uint, StoredLootItem> _lootItems = new();
|
||||
ulong _containerId;
|
||||
uint _money;
|
||||
}
|
||||
@@ -346,6 +346,6 @@ namespace Game.Loots
|
||||
public bool NeedsQuest;
|
||||
public uint RandomBonusListId;
|
||||
public ItemContext Context;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
public List<uint> BonusListIDs = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Game.Loots
|
||||
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
List<uint> lootIdSet, lootIdSetUsed = new List<uint>();
|
||||
List<uint> lootIdSet, lootIdSetUsed = new();
|
||||
uint count = Creature.LoadAndCollectLootIds(out lootIdSet);
|
||||
|
||||
// Remove real entries and check loot existence
|
||||
@@ -109,7 +109,7 @@ namespace Game.Loots
|
||||
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
List<uint> lootIdSet, lootIdSetUsed = new List<uint>();
|
||||
List<uint> lootIdSet, lootIdSetUsed = new();
|
||||
uint count = Disenchant.LoadAndCollectLootIds(out lootIdSet);
|
||||
|
||||
foreach (var disenchant in CliDB.ItemDisenchantLootStorage.Values)
|
||||
@@ -162,7 +162,7 @@ namespace Game.Loots
|
||||
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
List<uint> lootIdSet, lootIdSetUsed = new List<uint>();
|
||||
List<uint> lootIdSet, lootIdSetUsed = new();
|
||||
uint count = Gameobject.LoadAndCollectLootIds(out lootIdSet);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
@@ -251,7 +251,7 @@ namespace Game.Loots
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
List<uint> lootIdSet;
|
||||
List<uint> lootIdSetUsed = new List<uint>();
|
||||
List<uint> lootIdSetUsed = new();
|
||||
uint count = Pickpocketing.LoadAndCollectLootIds(out lootIdSet);
|
||||
|
||||
// Remove real entries and check loot existence
|
||||
@@ -339,7 +339,7 @@ namespace Game.Loots
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
List<uint> lootIdSet;
|
||||
List<uint> lootIdSetUsed = new List<uint>();
|
||||
List<uint> lootIdSetUsed = new();
|
||||
uint count = Skinning.LoadAndCollectLootIds(out lootIdSet);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
@@ -614,7 +614,7 @@ namespace Game.Loots
|
||||
{
|
||||
foreach (var pair in m_LootTemplates)
|
||||
{
|
||||
List<Condition> empty = new List<Condition>();
|
||||
List<Condition> empty = new();
|
||||
pair.Value.CopyConditions(empty);
|
||||
}
|
||||
}
|
||||
@@ -661,7 +661,7 @@ namespace Game.Loots
|
||||
return 0;
|
||||
}
|
||||
|
||||
LootStoreItem storeitem = new LootStoreItem(item, reference, chance, needsquest, lootmode, groupid, mincount, maxcount);
|
||||
LootStoreItem storeitem = new(item, reference, chance, needsquest, lootmode, groupid, mincount, maxcount);
|
||||
|
||||
if (!storeitem.IsValid(this, entry)) // Validity checks
|
||||
continue;
|
||||
@@ -686,7 +686,7 @@ namespace Game.Loots
|
||||
m_LootTemplates.Clear();
|
||||
}
|
||||
|
||||
LootTemplateMap m_LootTemplates = new LootTemplateMap();
|
||||
LootTemplateMap m_LootTemplates = new();
|
||||
string m_name;
|
||||
string m_entryName;
|
||||
bool m_ratesAllowed;
|
||||
@@ -932,8 +932,8 @@ namespace Game.Loots
|
||||
return false;//not found or not reference
|
||||
}
|
||||
|
||||
LootStoreItemList Entries = new LootStoreItemList(); // not grouped only
|
||||
Dictionary<int, LootGroup> Groups = new Dictionary<int,LootGroup>(); // groups have own (optimised) processing, grouped entries go there
|
||||
LootStoreItemList Entries = new(); // not grouped only
|
||||
Dictionary<int, LootGroup> Groups = new(); // groups have own (optimised) processing, grouped entries go there
|
||||
|
||||
public class LootGroup // A set of loot definitions for items (refs are not allowed)
|
||||
{
|
||||
@@ -1042,8 +1042,8 @@ namespace Game.Loots
|
||||
i.conditions.Clear();
|
||||
}
|
||||
|
||||
LootStoreItemList ExplicitlyChanced = new LootStoreItemList(); // Entries with chances defined in DB
|
||||
LootStoreItemList EqualChanced = new LootStoreItemList(); // Zero chances - every entry takes the same chance
|
||||
LootStoreItemList ExplicitlyChanced = new(); // Entries with chances defined in DB
|
||||
LootStoreItemList EqualChanced = new(); // Zero chances - every entry takes the same chance
|
||||
|
||||
LootStoreItem Roll(Loot loot, ushort lootMode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user