Core: SOme code cleanup, more to follow.

This commit is contained in:
hondacrx
2021-03-20 22:48:48 -04:00
parent 62f554f2e0
commit 62ec699ec6
318 changed files with 5080 additions and 5125 deletions
@@ -34,7 +34,7 @@ namespace Game.Entities
float m_suppressedOrientation; // Stores the creature's "real" orientation while casting
long _lastDamagedTime; // Part of Evade mechanics
MultiMap<byte, byte> m_textRepeat = new MultiMap<byte, byte>();
MultiMap<byte, byte> m_textRepeat = new();
// Regenerate health
bool _regenerateHealth; // Set on creation
@@ -61,7 +61,7 @@ namespace Game.Entities
public uint m_originalEntry;
Position m_homePosition;
Position m_transportHomePosition = new Position();
Position m_transportHomePosition = new();
bool DisableReputationGain;
@@ -90,9 +90,9 @@ namespace Game.Entities
uint m_combatPulseDelay; // (secs) how often the creature puts the entire zone in combat (only works in dungeons)
// vendor items
List<VendorItemCount> m_vendorItemCounts = new List<VendorItemCount>();
List<VendorItemCount> m_vendorItemCounts = new();
public Loot loot = new Loot();
public Loot loot = new();
public uint m_groupLootTimer; // (msecs)timer used for group loot
public ObjectGuid lootingGroupLowGUID; // used to find group which is looting corpse
ObjectGuid m_lootRecipient;
+11 -11
View File
@@ -798,7 +798,7 @@ namespace Game.Entities
else
lowGuid = map.GenerateLowGuid(HighGuid.Creature);
Creature creature = new Creature();
Creature creature = new();
if (!creature.Create(lowGuid, map, entry, pos, null, vehId))
return null;
@@ -807,7 +807,7 @@ namespace Game.Entities
public static Creature CreateCreatureFromDB(ulong spawnId, Map map, bool addToMap = true, bool allowDuplicate = false)
{
Creature creature = new Creature();
Creature creature = new();
if (!creature.LoadFromDB(spawnId, map, addToMap, allowDuplicate))
return null;
@@ -1181,7 +1181,7 @@ namespace Game.Entities
data.phaseGroup = GetDBPhase() < 0 ? (uint)-GetDBPhase() : data.phaseGroup;
// update in DB
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_CREATURE);
stmt.AddValue(0, m_spawnId);
@@ -1500,7 +1500,7 @@ namespace Game.Entities
GetMap().RemoveRespawnTime(SpawnObjectType.Creature, m_spawnId);
Global.ObjectMgr.DeleteCreatureData(m_spawnId);
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_CREATURE);
stmt.AddValue(0, m_spawnId);
@@ -1772,7 +1772,7 @@ namespace Game.Entities
SetDeathState(DeathState.JustRespawned);
CreatureModel display = new CreatureModel(GetNativeDisplayId(), GetNativeDisplayScale(), 1.0f);
CreatureModel display = new(GetNativeDisplayId(), GetNativeDisplayScale(), 1.0f);
if (Global.ObjectMgr.GetCreatureModelRandomGender(ref display, GetCreatureTemplate()) != null)
{
SetDisplayId(display.CreatureDisplayID, display.DisplayScale);
@@ -1977,7 +1977,7 @@ namespace Game.Entities
public void SendAIReaction(AiReaction reactionType)
{
AIReaction packet = new AIReaction();
AIReaction packet = new();
packet.UnitGUID = GetGUID();
packet.Reaction = reactionType;
@@ -1995,7 +1995,7 @@ namespace Game.Entities
if (radius > 0)
{
List<Creature> assistList = new List<Creature>();
List<Creature> assistList = new();
var u_check = new AnyAssistCreatureInRangeCheck(this, GetVictim(), radius);
var searcher = new CreatureListSearcher(this, assistList, u_check);
@@ -2003,7 +2003,7 @@ namespace Game.Entities
if (!assistList.Empty())
{
AssistDelayEvent e = new AssistDelayEvent(GetVictim().GetGUID(), this);
AssistDelayEvent e = new(GetVictim().GetGUID(), this);
while (!assistList.Empty())
{
// Pushing guids because in delay can happen some creature gets despawned
@@ -2271,7 +2271,7 @@ namespace Game.Entities
{
Team enemy_team = attacker.GetTeam();
ZoneUnderAttack packet = new ZoneUnderAttack();
ZoneUnderAttack packet = new();
packet.AreaID = (int)GetAreaId();
Global.WorldMgr.SendGlobalMessage(packet, null, (enemy_team == Team.Alliance ? Team.Horde : Team.Alliance));
}
@@ -2969,7 +2969,7 @@ namespace Game.Entities
// If an alive instance of this spawnId is already found, skip creation
// If only dead instance(s) exist, despawn them and spawn a new (maybe also dead) version
var creatureBounds = map.GetCreatureBySpawnIdStore().LookupByKey(spawnId);
List<Creature> despawnList = new List<Creature>();
List<Creature> despawnList = new();
foreach (var creature in creatureBounds)
{
@@ -3305,7 +3305,7 @@ namespace Game.Entities
ObjectGuid m_victim;
List<ObjectGuid> m_assistants = new List<ObjectGuid>();
List<ObjectGuid> m_assistants = new();
Unit m_owner;
}
+11 -11
View File
@@ -30,7 +30,7 @@ namespace Game.Entities
public uint Entry;
public uint[] DifficultyEntry = new uint[SharedConst.MaxCreatureDifficulties];
public uint[] KillCredit = new uint[SharedConst.MaxCreatureKillCredit];
public List<CreatureModel> Models = new List<CreatureModel>();
public List<CreatureModel> Models = new();
public string Name;
public string FemaleName;
public string SubName;
@@ -38,7 +38,7 @@ namespace Game.Entities
public string IconName;
public uint GossipMenuId;
public short Minlevel;
public Dictionary<Difficulty, CreatureLevelScaling> scalingStorage = new Dictionary<Difficulty, CreatureLevelScaling>();
public Dictionary<Difficulty, CreatureLevelScaling> scalingStorage = new();
public short Maxlevel;
public int HealthScalingExpansion;
public uint RequiredExpansion;
@@ -235,7 +235,7 @@ namespace Game.Entities
QueryData.CreatureID = Entry;
QueryData.Allow = true;
CreatureStats stats = new CreatureStats();
CreatureStats stats = new();
stats.Leader = RacialLeader;
stats.Name[0] = Name;
@@ -308,10 +308,10 @@ namespace Game.Entities
public class CreatureLocale
{
public StringArray Name = new StringArray((int)Locale.Total);
public StringArray NameAlt = new StringArray((int)Locale.Total);
public StringArray Title = new StringArray((int)Locale.Total);
public StringArray TitleAlt = new StringArray((int)Locale.Total);
public StringArray Name = new((int)Locale.Total);
public StringArray NameAlt = new((int)Locale.Total);
public StringArray Title = new((int)Locale.Total);
public StringArray TitleAlt = new((int)Locale.Total);
}
public struct EquipmentItem
@@ -355,8 +355,8 @@ namespace Game.Entities
public class CreatureModel
{
public static CreatureModel DefaultInvisibleModel = new CreatureModel(11686, 1.0f, 1.0f);
public static CreatureModel DefaultVisibleModel = new CreatureModel(17519, 1.0f, 1.0f);
public static CreatureModel DefaultInvisibleModel = new(11686, 1.0f, 1.0f);
public static CreatureModel DefaultVisibleModel = new(17519, 1.0f, 1.0f);
public uint CreatureDisplayID;
public float DisplayScale;
@@ -402,7 +402,7 @@ namespace Game.Entities
public uint incrtime; // time for restore items amount if maxcount != 0
public uint ExtendedCost;
public ItemVendorType Type;
public List<uint> BonusListIDs = new List<uint>();
public List<uint> BonusListIDs = new();
public uint PlayerConditionId;
public bool IgnoreFiltering;
@@ -412,7 +412,7 @@ namespace Game.Entities
public class VendorItemData
{
List<VendorItem> m_items = new List<VendorItem>();
List<VendorItem> m_items = new();
public VendorItem GetItem(uint slot)
{
@@ -43,7 +43,7 @@ namespace Game.Entities
else
{
Log.outDebug(LogFilter.Unit, "Group not found: {0}. Creating new group.", leaderGuid);
CreatureGroup group = new CreatureGroup(leaderGuid);
CreatureGroup group = new(leaderGuid);
map.CreatureGroupHolder[leaderGuid] = group;
group.AddMember(member);
}
@@ -126,7 +126,7 @@ namespace Game.Entities
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creatures in formations in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
}
public static Dictionary<ulong, FormationInfo> CreatureGroupMap = new Dictionary<ulong, FormationInfo>();
public static Dictionary<ulong, FormationInfo> CreatureGroupMap = new();
}
public class FormationInfo
@@ -251,7 +251,7 @@ namespace Game.Entities
if (!member.IsFlying())
member.UpdateGroundPositionZ(dx, dy, ref dz);
Position point = new Position(dx, dy, dz, destination.GetOrientation());
Position point = new(dx, dy, dz, destination.GetOrientation());
member.GetMotionMaster().MoveFormation(id, point, moveType, !member.IsWithinDist(m_leader, dist + 5.0f), orientation);
member.SetHomePosition(dx, dy, dz, pathangle);
@@ -279,7 +279,7 @@ namespace Game.Entities
public bool IsLeader(Creature creature) { return m_leader == creature; }
Creature m_leader;
Dictionary<Creature, FormationInfo> m_members = new Dictionary<Creature, FormationInfo>();
Dictionary<Creature, FormationInfo> m_members = new();
ulong m_groupID;
bool m_Formed;
+23 -23
View File
@@ -49,7 +49,7 @@ namespace Game.Misc
}
}
GossipMenuItem menuItem = new GossipMenuItem();
GossipMenuItem menuItem = new();
menuItem.MenuItemIcon = (byte)icon;
menuItem.Message = message;
@@ -131,7 +131,7 @@ namespace Game.Misc
public void AddGossipMenuItemData(uint optionIndex, uint gossipActionMenuId, uint gossipActionPoi)
{
GossipMenuItemData itemData = new GossipMenuItemData();
GossipMenuItemData itemData = new();
itemData.GossipActionMenuId = gossipActionMenuId;
itemData.GossipActionPoi = gossipActionPoi;
@@ -208,8 +208,8 @@ namespace Game.Misc
return _menuItems;
}
Dictionary<uint, GossipMenuItem> _menuItems = new Dictionary<uint, GossipMenuItem>();
Dictionary<uint, GossipMenuItemData> _menuItemData = new Dictionary<uint, GossipMenuItemData>();
Dictionary<uint, GossipMenuItem> _menuItems = new();
Dictionary<uint, GossipMenuItemData> _menuItemData = new();
uint _menuId;
Locale _locale;
}
@@ -247,14 +247,14 @@ namespace Game.Misc
_interactionData.Reset();
_interactionData.SourceGuid = objectGUID;
GossipMessagePkt packet = new GossipMessagePkt();
GossipMessagePkt packet = new();
packet.GossipGUID = objectGUID;
packet.GossipID = (int)_gossipMenu.GetMenuId();
packet.TextID = (int)titleTextId;
foreach (var pair in _gossipMenu.GetMenuItems())
{
ClientGossipOptions opt = new ClientGossipOptions();
ClientGossipOptions opt = new();
GossipMenuItem item = pair.Value;
opt.ClientOption = (int)pair.Key;
opt.OptionNPC = item.MenuItemIcon;
@@ -274,7 +274,7 @@ namespace Game.Misc
Quest quest = Global.ObjectMgr.GetQuestTemplate(questID);
if (quest != null)
{
ClientGossipText text = new ClientGossipText();
ClientGossipText text = new();
text.QuestID = questID;
text.ContentTuningID = quest.ContentTuningId;
text.QuestType = item.QuestIcon;
@@ -314,7 +314,7 @@ namespace Game.Misc
return;
}
GossipPOI packet = new GossipPOI();
GossipPOI packet = new();
packet.Id = pointOfInterest.Id;
packet.Name = pointOfInterest.Name;
@@ -339,7 +339,7 @@ namespace Game.Misc
ObjectGuid guid = questgiver.GetGUID();
Locale localeConstant = _session.GetSessionDbLocaleIndex();
QuestGiverQuestListMessage questList = new QuestGiverQuestListMessage();
QuestGiverQuestListMessage questList = new();
questList.QuestGiverGUID = guid;
QuestGreeting questGreeting = Global.ObjectMgr.GetQuestGreeting(questgiver.GetTypeId(), questgiver.GetEntry());
@@ -365,7 +365,7 @@ namespace Game.Misc
Quest quest = Global.ObjectMgr.GetQuestTemplate(questID);
if (quest != null)
{
ClientGossipText text = new ClientGossipText();
ClientGossipText text = new();
text.QuestID = questID;
text.ContentTuningID = quest.ContentTuningId;
text.QuestType = questMenuItem.QuestIcon;
@@ -399,7 +399,7 @@ namespace Game.Misc
public void SendQuestGiverQuestDetails(Quest quest, ObjectGuid npcGUID, bool autoLaunched, bool displayPopup)
{
QuestGiverQuestDetails packet = new QuestGiverQuestDetails();
QuestGiverQuestDetails packet = new();
packet.QuestTitle = quest.LogTitle;
packet.LogDescription = quest.LogDescription;
@@ -507,7 +507,7 @@ namespace Game.Misc
public void SendQuestGiverOfferReward(Quest quest, ObjectGuid npcGUID, bool autoLaunched)
{
QuestGiverOfferRewardMessage packet = new QuestGiverOfferRewardMessage();
QuestGiverOfferRewardMessage packet = new();
packet.QuestTitle = quest.LogTitle;
packet.RewardText = quest.OfferRewardText;
@@ -534,7 +534,7 @@ namespace Game.Misc
ObjectManager.GetLocaleString(questOfferRewardLocale.RewardText, locale, ref packet.RewardText);
}
QuestGiverOfferReward offer = new QuestGiverOfferReward();
QuestGiverOfferReward offer = new();
quest.BuildQuestRewards(offer.Rewards, _session.GetPlayer());
offer.QuestGiverGUID = npcGUID;
@@ -575,7 +575,7 @@ namespace Game.Misc
return;
}
QuestGiverRequestItems packet = new QuestGiverRequestItems();
QuestGiverRequestItems packet = new();
packet.QuestTitle = quest.LogTitle;
packet.CompletionText = quest.RequestItemsText;
@@ -654,10 +654,10 @@ namespace Game.Misc
public uint GetGossipOptionAction(uint selection) { return _gossipMenu.GetMenuItemAction(selection); }
public bool IsGossipOptionCoded(uint selection) { return _gossipMenu.IsMenuItemCoded(selection); }
GossipMenu _gossipMenu = new GossipMenu();
QuestMenu _questMenu = new QuestMenu();
GossipMenu _gossipMenu = new();
QuestMenu _questMenu = new();
WorldSession _session;
InteractionData _interactionData = new InteractionData();
InteractionData _interactionData = new();
}
public class QuestMenu
@@ -667,7 +667,7 @@ namespace Game.Misc
if (Global.ObjectMgr.GetQuestTemplate(QuestId) == null)
return;
QuestMenuItem questMenuItem = new QuestMenuItem();
QuestMenuItem questMenuItem = new();
questMenuItem.QuestId = QuestId;
questMenuItem.QuestIcon = Icon;
@@ -704,7 +704,7 @@ namespace Game.Misc
return _questMenuItems.LookupByIndex(index);
}
List<QuestMenuItem> _questMenuItems = new List<QuestMenuItem>();
List<QuestMenuItem> _questMenuItems = new();
}
public struct QuestMenuItem
@@ -743,7 +743,7 @@ namespace Game.Misc
public class PageTextLocale
{
public StringArray Text = new StringArray((int)Locale.Total);
public StringArray Text = new((int)Locale.Total);
}
public class GossipMenuItems
@@ -761,7 +761,7 @@ namespace Game.Misc
public uint BoxMoney;
public string BoxText;
public uint BoxBroadcastTextId;
public List<Condition> Conditions = new List<Condition>();
public List<Condition> Conditions = new();
}
public class PointOfInterest
@@ -776,13 +776,13 @@ namespace Game.Misc
public class PointOfInterestLocale
{
public StringArray Name = new StringArray((int)Locale.Total);
public StringArray Name = new((int)Locale.Total);
}
public class GossipMenus
{
public uint MenuId;
public uint TextId;
public List<Condition> Conditions = new List<Condition>();
public List<Condition> Conditions = new();
}
}
+5 -5
View File
@@ -12,7 +12,7 @@ namespace Game.Entities
public uint MoneyCost;
public uint ReqSkillLine;
public uint ReqSkillRank;
public Array<uint> ReqAbility = new Array<uint>(3);
public Array<uint> ReqAbility = new(3);
public byte ReqLevel;
public bool IsCastable() { return Global.SpellMgr.GetSpellInfo(SpellId, Difficulty.None).HasEffect(SpellEffectName.LearnSpell); }
@@ -33,7 +33,7 @@ namespace Game.Entities
{
float reputationDiscount = player.GetReputationPriceDiscount(npc);
TrainerList trainerList = new TrainerList();
TrainerList trainerList = new();
trainerList.TrainerGUID = npc.GetGUID();
trainerList.TrainerType = (int)_type;
trainerList.TrainerID = (int)_id;
@@ -44,7 +44,7 @@ namespace Game.Entities
if (!player.IsSpellFitByClassAndRace(trainerSpell.SpellId))
continue;
TrainerListSpell trainerListSpell = new TrainerListSpell();
TrainerListSpell trainerListSpell = new();
trainerListSpell.SpellID = trainerSpell.SpellId;
trainerListSpell.MoneyCost = (uint)(trainerSpell.MoneyCost * reputationDiscount);
trainerListSpell.ReqSkillLine = trainerSpell.ReqSkillLine;
@@ -147,7 +147,7 @@ namespace Game.Entities
void SendTeachFailure(Creature npc, Player player, uint spellId, TrainerFailReason reason)
{
TrainerBuyFailed trainerBuyFailed = new TrainerBuyFailed();
TrainerBuyFailed trainerBuyFailed = new();
trainerBuyFailed.TrainerGUID = npc.GetGUID();
trainerBuyFailed.SpellID = spellId;
trainerBuyFailed.TrainerFailedReason = reason;
@@ -170,6 +170,6 @@ namespace Game.Entities
uint _id;
TrainerType _type;
List<TrainerSpell> _spells;
Array<string> _greeting = new Array<string>((int)Locale.Total);
Array<string> _greeting = new((int)Locale.Total);
}
}