From 032f9a55f37b1c4bdfeeff80099f046d4a2c3571 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 15 Nov 2021 16:11:20 -0500 Subject: [PATCH] Cleanup some warnings. --- Source/Framework/Collections/BitSet.cs | 2 +- .../Collections/LinkedListElement.cs | 4 +-- Source/Framework/Collections/MultiMap.cs | 12 ++++----- .../Framework/Configuration/ConfigManager.cs | 2 +- Source/Framework/Cryptography/RsaCrypt.cs | 2 +- Source/Framework/Cryptography/SRP6.cs | 2 +- Source/Framework/Cryptography/ShaHmac.cs | 4 +-- .../Database/AsyncCallbackProcessor.cs | 2 +- Source/Framework/Database/DB.cs | 8 +++--- Source/Framework/Database/DatabaseLoader.cs | 10 +++---- Source/Framework/Database/DatabaseUpdater.cs | 14 +++++----- Source/Framework/Database/MySqlBase.cs | 16 ++++++------ .../Framework/Database/PreparedStatement.cs | 2 +- Source/Framework/Database/QueryCallback.cs | 2 +- Source/Framework/Database/SQLQueryHolder.cs | 4 +-- Source/Framework/Database/SQLTransaction.cs | 6 ++--- Source/Framework/Dynamic/EventMap.cs | 4 +-- Source/Framework/Dynamic/EventSystem.cs | 2 +- Source/Framework/Dynamic/FlagArray.cs | 6 ++--- Source/Framework/Dynamic/TaskScheduler.cs | 6 ++--- Source/Framework/Framework.csproj | 1 - Source/Framework/GameMath/AxisAlignedBox.cs | 4 +-- .../Framework/GameMath/CollisionDetection.cs | 2 +- Source/Framework/GameMath/Matrix2.cs | 10 +++---- Source/Framework/GameMath/Matrix3.cs | 16 ++++++------ Source/Framework/GameMath/Matrix4.cs | 12 ++++----- Source/Framework/GameMath/Plane.cs | 6 ++--- Source/Framework/GameMath/Quaternion.cs | 26 +++++++++---------- Source/Framework/GameMath/Ray.cs | 2 +- Source/Framework/GameMath/Vector2.cs | 16 ++++++------ Source/Framework/GameMath/Vector3.cs | 22 ++++++++-------- Source/Framework/GameMath/Vector4.cs | 22 ++++++++-------- Source/Framework/IO/ByteBuffer.cs | 2 +- Source/Framework/IO/StringArguments.cs | 2 +- Source/Framework/IO/Zlib/Deflate.cs | 6 ++--- Source/Framework/IO/Zlib/Trees.cs | 6 ++--- Source/Framework/IO/Zlib/compress.cs | 2 +- Source/Framework/Logging/Appender.cs | 4 +-- Source/Framework/Logging/Logger.cs | 2 +- Source/Framework/Networking/NetworkThread.cs | 4 +-- Source/Framework/Realm/Realm.cs | 2 +- Source/Framework/Realm/RealmManager.cs | 20 +++++++------- .../RecastDetour/Detour/DetourNavMesh.cs | 2 +- .../Detour/DetourNavMeshBuilder.cs | 16 ++++++------ .../RecastDetour/Detour/DetourNavMeshQuery.cs | 16 ++++++------ Source/Framework/Singleton/Singleton.cs | 2 +- .../Threading/ProducerConsumerQueue.cs | 4 +-- Source/Framework/Util/Extensions.cs | 4 +-- Source/Game/AI/PlayerAI/PlayerAI.cs | 2 +- Source/Game/Entities/Object/WorldObject.cs | 2 +- Source/Game/Entities/SceneObject.cs | 2 +- Source/Game/Movement/MotionMaster.cs | 12 ++++----- Source/Game/Spells/Auras/AuraEffect.cs | 6 ++--- Source/Game/Spells/SpellEffects.cs | 2 +- Source/Scripts/Pets/DeathKnight.cs | 2 +- Source/Scripts/Smart/SmartAI.cs | 14 +++++----- Source/Scripts/Spells/DeathKnight.cs | 2 +- Source/Scripts/Spells/Generic.cs | 6 ++--- Source/Scripts/Spells/Holiday.cs | 4 +-- Source/Scripts/Spells/Items.cs | 8 +++--- Source/Scripts/Spells/Mage.cs | 4 +-- Source/Scripts/Spells/Priest.cs | 6 ++--- Source/Scripts/Spells/Quest.cs | 12 ++++----- Source/Scripts/Spells/Rogue.cs | 2 +- Source/Scripts/Spells/Warlock.cs | 8 +++--- Source/Scripts/Spells/Warrior.cs | 2 +- Source/Scripts/World/AreaTrigger.cs | 4 +-- Source/Scripts/World/GameObject.cs | 2 +- Source/Scripts/World/ItemScripts.cs | 4 +-- Source/Scripts/World/NpcSpecial.cs | 18 ++++++------- 70 files changed, 233 insertions(+), 234 deletions(-) diff --git a/Source/Framework/Collections/BitSet.cs b/Source/Framework/Collections/BitSet.cs index d84f774c5..4d191c564 100644 --- a/Source/Framework/Collections/BitSet.cs +++ b/Source/Framework/Collections/BitSet.cs @@ -293,7 +293,7 @@ namespace System.Collections public Object Clone() { - BitSet bitArray = new BitSet(_mArray); + BitSet bitArray = new(_mArray); bitArray._version = _version; bitArray._mLength = _mLength; return bitArray; diff --git a/Source/Framework/Collections/LinkedListElement.cs b/Source/Framework/Collections/LinkedListElement.cs index dbcc6c77f..775838519 100644 --- a/Source/Framework/Collections/LinkedListElement.cs +++ b/Source/Framework/Collections/LinkedListElement.cs @@ -66,8 +66,8 @@ namespace Framework.Collections public class LinkedListHead { - LinkedListElement _iFirst = new LinkedListElement(); - LinkedListElement _iLast = new LinkedListElement(); + LinkedListElement _iFirst = new(); + LinkedListElement _iLast = new(); uint _iSize; public LinkedListHead() diff --git a/Source/Framework/Collections/MultiMap.cs b/Source/Framework/Collections/MultiMap.cs index 4af610d5b..2753df576 100644 --- a/Source/Framework/Collections/MultiMap.cs +++ b/Source/Framework/Collections/MultiMap.cs @@ -181,7 +181,7 @@ namespace System.Collections.Generic { get { - List retVal = new List(); + List retVal = new(); foreach (var item in _interalStorage) { retVal.AddRange(item.Value); @@ -194,7 +194,7 @@ namespace System.Collections.Generic { get { - List> retVal = new List>(); + List> retVal = new(); foreach (var pair in _interalStorage) { foreach (var value in pair.Value) @@ -259,7 +259,7 @@ namespace System.Collections.Generic return new MultiMapEnumerator(this); } - private Dictionary> _interalStorage = new Dictionary>(); + private Dictionary> _interalStorage = new(); } public sealed class SortedMultiMap : IMultiMap, IDictionary @@ -424,7 +424,7 @@ namespace System.Collections.Generic { get { - List retVal = new List(); + List retVal = new(); foreach (var item in _interalStorage) { retVal.AddRange(item.Value); @@ -437,7 +437,7 @@ namespace System.Collections.Generic { get { - List> retVal = new List>(); + List> retVal = new(); foreach (var pair in _interalStorage) { foreach (var value in pair.Value) @@ -502,6 +502,6 @@ namespace System.Collections.Generic return new SortedMultiMapEnumerator(this); } - private SortedDictionary> _interalStorage = new SortedDictionary>(); + private SortedDictionary> _interalStorage = new(); } } diff --git a/Source/Framework/Configuration/ConfigManager.cs b/Source/Framework/Configuration/ConfigManager.cs index f14d9d69a..0bf352d68 100644 --- a/Source/Framework/Configuration/ConfigManager.cs +++ b/Source/Framework/Configuration/ConfigManager.cs @@ -79,6 +79,6 @@ namespace Framework.Configuration return _configList.Where(p => p.Key.Contains(name)).Select(p => p.Key); } - static Dictionary _configList = new Dictionary(); + static Dictionary _configList = new(); } } diff --git a/Source/Framework/Cryptography/RsaCrypt.cs b/Source/Framework/Cryptography/RsaCrypt.cs index 1666c50cb..78927ce8d 100644 --- a/Source/Framework/Cryptography/RsaCrypt.cs +++ b/Source/Framework/Cryptography/RsaCrypt.cs @@ -31,7 +31,7 @@ namespace Framework.Cryptography public class RsaStore { - public static RSAParameters RSAParameters = new RSAParameters() + public static RSAParameters RSAParameters = new() { Modulus = new byte[] { 0xee, 0xb3, 0xdc, 0xd4, 0xd3, 0xc3, 0xb4, 0x54, 0x51, 0xce, 0x66, 0x5b, 0xcb, 0x32, 0xb8, 0xf0, 0xf7, 0x92, 0x53, 0xc6, 0x19, 0xf2, 0x0c, 0x85, 0x2f, 0x8a, 0x26, 0xa9, 0x7a, 0x45, 0x9f, 0x60, 0xc4, 0xeb, 0xcd, 0xea, 0x7f, 0x8d, 0x59, 0xd8, 0x57, 0xb2, 0x60, 0x7b, 0x09, 0x4c, 0x9b, 0x68, 0xb8, 0xc7, 0xed, 0xef, 0x1e, 0x80, 0x0d, 0xe6, 0x6b, 0x37, 0x5b, 0x53, 0x90, 0xeb, 0x18, 0x13, 0x0d, 0x7f, 0x43, 0x64, 0x83, 0xda, 0x98, 0xe6, 0xac, 0xc2, 0x30, 0xa2, 0x82, 0xa5, 0xc6, 0xcb, 0xc7, 0xfb, 0x86, 0x9f, 0x9f, 0xa9, 0x02, 0x6a, 0x03, 0x49, 0xc5, 0x38, 0xfb, 0xc0, 0xc8, 0x55, 0xcc, 0xc0, 0xce, 0x25, 0x91, 0xbe, 0x85, 0xcf, 0xd1, 0xd1, 0x37, 0xce, 0xcc, 0x83, 0xd2, 0xea, 0x30, 0x80, 0x07, 0x7b, 0x80, 0x9f, 0x9d, 0x44, 0x54, 0x22, 0x29, 0xbe, 0x86, 0xda, 0xdb, 0x48, 0xc5, 0xa9, 0xf9, 0x13, 0x36, 0x95, 0x23, 0x76, 0xf1, 0x0e, 0xdc, 0x84, 0x0d, 0x94, 0x02, 0x12, 0xa8, 0x97, 0xf3, 0x3b, 0x14, 0xee, 0xaa, 0x6f, 0x98, 0x05, 0x27, 0x4e, 0x1f, 0xa3, 0x60, 0xa5, 0xa9, 0xda, 0xd8, 0x17, 0xdf, 0x33, 0xcb, 0xe2, 0x13, 0x54, 0x8b, 0x18, 0xb0, 0xca, 0xb9, 0xbb, 0x88, 0x64, 0x06, 0xdf, 0x75, 0xa6, 0xd7, 0x61, 0x00, 0xbb, 0xb0, 0x5a, 0x0e, 0x7a, 0xd4, 0x77, 0x08, 0x4d, 0x15, 0xe2, 0x10, 0x83, 0xb0, 0x04, 0xaa, 0x9e, 0x8b, 0x77, 0xa9, 0x06, 0x89, 0x5d, 0x08, 0x5d, 0x0f, 0xb8, 0x2e, 0x6b, 0xc1, 0xcb, 0x64, 0xcf, 0x6e, 0x5c, 0xdb, 0x4f, 0x58, 0x65, 0x08, 0x51, 0xfb, 0x0d, 0x48, 0x1a, 0x6f, 0xb6, 0x3d, 0x1f, 0x0b, 0xdd, 0xfe, 0x1b, 0x1d, 0xf0, 0xbf, 0xb0, 0x27, 0x6b, 0xf5, 0x8e, 0xbc, 0xc7, 0x40, 0x01, 0xff, 0xa7, 0x0b, 0x80, 0xd6, 0x5f }, Exponent = new byte[] { 0x01, 0x00, 0x01 }, diff --git a/Source/Framework/Cryptography/SRP6.cs b/Source/Framework/Cryptography/SRP6.cs index c5aeafa04..92cf38faf 100644 --- a/Source/Framework/Cryptography/SRP6.cs +++ b/Source/Framework/Cryptography/SRP6.cs @@ -30,7 +30,7 @@ namespace Framework.Cryptography static SRP6() { - _sha1 = new SHA1Managed(); + _sha1 = SHA1.Create(); _g = new BigInteger(7); _N = new BigInteger(new byte[] { diff --git a/Source/Framework/Cryptography/ShaHmac.cs b/Source/Framework/Cryptography/ShaHmac.cs index b23db3192..7e7372d9c 100644 --- a/Source/Framework/Cryptography/ShaHmac.cs +++ b/Source/Framework/Cryptography/ShaHmac.cs @@ -26,7 +26,7 @@ namespace Framework.Cryptography { public Sha256() { - sha = new SHA256Managed(); + sha = SHA256.Create(); sha.Initialize(); } @@ -69,7 +69,7 @@ namespace Framework.Cryptography public class HmacHash : HMACSHA1 { - public HmacHash(byte[] key) : base(key, true) + public HmacHash(byte[] key) : base(key) { Initialize(); } diff --git a/Source/Framework/Database/AsyncCallbackProcessor.cs b/Source/Framework/Database/AsyncCallbackProcessor.cs index 2f90c0ea2..71f8b631c 100644 --- a/Source/Framework/Database/AsyncCallbackProcessor.cs +++ b/Source/Framework/Database/AsyncCallbackProcessor.cs @@ -26,7 +26,7 @@ namespace Framework.Database public class AsyncCallbackProcessor where T : ISqlCallback { - List _callbacks = new List(); + List _callbacks = new(); public T AddCallback(T query) { diff --git a/Source/Framework/Database/DB.cs b/Source/Framework/Database/DB.cs index 565e9befb..e0d43865e 100644 --- a/Source/Framework/Database/DB.cs +++ b/Source/Framework/Database/DB.cs @@ -19,9 +19,9 @@ namespace Framework.Database { public static class DB { - public static LoginDatabase Login = new LoginDatabase(); - public static CharacterDatabase Characters = new CharacterDatabase(); - public static WorldDatabase World = new WorldDatabase(); - public static HotfixDatabase Hotfix = new HotfixDatabase(); + public static LoginDatabase Login = new(); + public static CharacterDatabase Characters = new(); + public static WorldDatabase World = new(); + public static HotfixDatabase Hotfix = new(); } } diff --git a/Source/Framework/Database/DatabaseLoader.cs b/Source/Framework/Database/DatabaseLoader.cs index 5141ccdb0..01910dbff 100644 --- a/Source/Framework/Database/DatabaseLoader.cs +++ b/Source/Framework/Database/DatabaseLoader.cs @@ -35,7 +35,7 @@ namespace Framework.Database bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags); _open.Add(() => { - MySqlConnectionInfo connectionObject = new MySqlConnectionInfo + MySqlConnectionInfo connectionObject = new() { Host = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Host", ""), Port = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Port", ""), @@ -161,10 +161,10 @@ namespace Framework.Database bool _autoSetup; DatabaseTypeFlags _updateFlags; - List> _open = new List>(); - List> _populate = new List>(); - List> _update = new List>(); - List> _prepare = new List>(); + List> _open = new(); + List> _populate = new(); + List> _update = new(); + List> _prepare = new(); } public enum DatabaseTypeFlags diff --git a/Source/Framework/Database/DatabaseUpdater.cs b/Source/Framework/Database/DatabaseUpdater.cs index 27231fd56..4600f9bfe 100644 --- a/Source/Framework/Database/DatabaseUpdater.cs +++ b/Source/Framework/Database/DatabaseUpdater.cs @@ -91,7 +91,7 @@ namespace Framework.Database bool redundancyChecks = ConfigMgr.GetDefaultValue("Updates.Redundancy", true); bool archivedRedundancy = ConfigMgr.GetDefaultValue("Updates.Redundancy", true); - UpdateResult result = new UpdateResult(); + UpdateResult result = new(); // Count updates foreach (var entry in appliedFiles) @@ -193,7 +193,7 @@ namespace Framework.Database } uint speed = 0; - AppliedFileEntry file = new AppliedFileEntry(availableQuery.GetFileName(), hash, availableQuery.state, 0); + AppliedFileEntry file = new(availableQuery.GetFileName(), hash, availableQuery.state, 0); switch (mode) { @@ -320,7 +320,7 @@ namespace Framework.Database List GetFileList() { - List fileList = new List(); + List fileList = new(); SQLResult result = _database.Query("SELECT `path`, `state` FROM `updates_include`"); if (result.IsEmpty()) @@ -350,7 +350,7 @@ namespace Framework.Database Dictionary ReceiveAppliedFiles() { - Dictionary map = new Dictionary(); + Dictionary map = new(); SQLResult result = _database.Query("SELECT `name`, `hash`, `state`, UNIX_TIMESTAMP(`timestamp`) FROM `updates` ORDER BY `name` ASC"); if (result.IsEmpty()) @@ -358,7 +358,7 @@ namespace Framework.Database do { - AppliedFileEntry entry = new AppliedFileEntry(result.Read(0), result.Read(1), result.Read(2).ToEnum(), result.Read(3)); + AppliedFileEntry entry = new(result.Read(0), result.Read(1), result.Read(2).ToEnum(), result.Read(3)); map.Add(entry.Name, entry); } while (result.NextRow()); @@ -368,7 +368,7 @@ namespace Framework.Database IEnumerable GetFilesFromDirectory(string directory, State state) { - Queue queue = new Queue(); + Queue queue = new(); queue.Enqueue(directory); while (queue.Count > 0) { @@ -395,7 +395,7 @@ namespace Framework.Database string CalculateHash(string fileName) { - using (SHA1 sha1 = new SHA1Managed()) + using (SHA1 sha1 = SHA1.Create()) { string text = File.ReadAllText(fileName).Replace("\r", ""); return sha1.ComputeHash(Encoding.UTF8.GetBytes(text)).ToHexString(); diff --git a/Source/Framework/Database/MySqlBase.cs b/Source/Framework/Database/MySqlBase.cs index 828bb2d60..9a2a41121 100644 --- a/Source/Framework/Database/MySqlBase.cs +++ b/Source/Framework/Database/MySqlBase.cs @@ -48,8 +48,8 @@ namespace Framework.Database public abstract class MySqlBase { - Dictionary _preparedQueries = new Dictionary(); - ProducerConsumerQueue _queue = new ProducerConsumerQueue(); + Dictionary _preparedQueries = new(); + ProducerConsumerQueue _queue = new(); MySqlConnectionInfo _connectionInfo; DatabaseUpdater _updater; @@ -115,7 +115,7 @@ namespace Framework.Database public void Execute(PreparedStatement stmt) { - PreparedStatementTask task = new PreparedStatementTask(stmt); + PreparedStatementTask task = new(stmt); _queue.Push(task); } @@ -155,7 +155,7 @@ namespace Framework.Database public QueryCallback AsyncQuery(PreparedStatement stmt) { - PreparedStatementTask task = new PreparedStatementTask(stmt, true); + PreparedStatementTask task = new(stmt, true); // Store future result before enqueueing - task might get already processed and deleted before returning from this method Task result = task.GetFuture(); _queue.Push(task); @@ -164,7 +164,7 @@ namespace Framework.Database public Task> DelayQueryHolder(SQLQueryHolder holder) { - SQLQueryHolderTask task = new SQLQueryHolderTask(holder); + SQLQueryHolderTask task = new(holder); // Store future result before enqueueing - task might get already processed and deleted before returning from this method Task> result = task.GetFuture(); _queue.Push(task); @@ -178,7 +178,7 @@ namespace Framework.Database public void PrepareStatement(T statement, string sql) { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); int index = 0; for (var i = 0; i < sql.Length; i++) { @@ -257,7 +257,7 @@ namespace Framework.Database public TransactionCallback AsyncCommitTransaction(SQLTransaction transaction) { - TransactionWithResultTask task = new TransactionWithResultTask(transaction); + TransactionWithResultTask task = new(transaction); Task result = task.GetFuture(); _queue.Push(task); return new TransactionCallback(result); @@ -304,7 +304,7 @@ namespace Framework.Database if (ex.InnerException is MySqlException) code = (MySqlErrorCode)((MySqlException)ex.InnerException).Number; - StringBuilder stringBuilder = new StringBuilder($"SqlException: MySqlErrorCode: {code} Message: {ex.Message} SqlQuery: {query} "); + StringBuilder stringBuilder = new($"SqlException: MySqlErrorCode: {code} Message: {ex.Message} SqlQuery: {query} "); if (parameters != null) { stringBuilder.Append("Parameters: "); diff --git a/Source/Framework/Database/PreparedStatement.cs b/Source/Framework/Database/PreparedStatement.cs index ed32b6b9f..b5a5f92d3 100644 --- a/Source/Framework/Database/PreparedStatement.cs +++ b/Source/Framework/Database/PreparedStatement.cs @@ -23,7 +23,7 @@ namespace Framework.Database public class PreparedStatement { public string CommandText; - public Dictionary Parameters = new Dictionary(); + public Dictionary Parameters = new(); public PreparedStatement(string commandText) { diff --git a/Source/Framework/Database/QueryCallback.cs b/Source/Framework/Database/QueryCallback.cs index 440a40a1d..7bd3d395a 100644 --- a/Source/Framework/Database/QueryCallback.cs +++ b/Source/Framework/Database/QueryCallback.cs @@ -83,7 +83,7 @@ namespace Framework.Database } Task _result; - Queue _callbacks = new Queue(); + Queue _callbacks = new(); } struct QueryCallbackData diff --git a/Source/Framework/Database/SQLQueryHolder.cs b/Source/Framework/Database/SQLQueryHolder.cs index 7eca14453..b82c0997a 100644 --- a/Source/Framework/Database/SQLQueryHolder.cs +++ b/Source/Framework/Database/SQLQueryHolder.cs @@ -22,8 +22,8 @@ namespace Framework.Database { public class SQLQueryHolder { - public Dictionary m_queries = new Dictionary(); - Dictionary _results = new Dictionary(); + public Dictionary m_queries = new(); + Dictionary _results = new(); public void SetQuery(T index, string sql, params object[] args) { diff --git a/Source/Framework/Database/SQLTransaction.cs b/Source/Framework/Database/SQLTransaction.cs index 89b9565ed..f39a2f248 100644 --- a/Source/Framework/Database/SQLTransaction.cs +++ b/Source/Framework/Database/SQLTransaction.cs @@ -33,7 +33,7 @@ namespace Framework.Database public void Append(PreparedStatement stmt) { - MySqlCommand cmd = new MySqlCommand(stmt.CommandText); + MySqlCommand cmd = new(stmt.CommandText); foreach (var parameter in stmt.Parameters) cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value); @@ -80,7 +80,7 @@ namespace Framework.Database } SQLTransaction m_trans; - public static object _deadlockLock = new object(); + public static object _deadlockLock = new(); } class TransactionWithResultTask : TransactionTask @@ -119,7 +119,7 @@ namespace Framework.Database public Task GetFuture() { return m_result.Task; } - TaskCompletionSource m_result = new TaskCompletionSource(); + TaskCompletionSource m_result = new(); } public class TransactionCallback : ISqlCallback diff --git a/Source/Framework/Dynamic/EventMap.cs b/Source/Framework/Dynamic/EventMap.cs index 1ed188efa..416750258 100644 --- a/Source/Framework/Dynamic/EventMap.cs +++ b/Source/Framework/Dynamic/EventMap.cs @@ -282,7 +282,7 @@ namespace Framework.Dynamic { if (group == 0 || group > 8 || Empty()) return; - MultiMap delayed = new MultiMap(); + MultiMap delayed = new(); foreach (var pair in _eventMap.KeyValueList) { @@ -411,6 +411,6 @@ namespace Framework.Dynamic /// - Bit 24 - 31: Phase /// - Pattern: 0xPPGGEEEE /// - SortedMultiMap _eventMap = new SortedMultiMap(); + SortedMultiMap _eventMap = new(); } } diff --git a/Source/Framework/Dynamic/EventSystem.cs b/Source/Framework/Dynamic/EventSystem.cs index 077a8087c..58ed592c6 100644 --- a/Source/Framework/Dynamic/EventSystem.cs +++ b/Source/Framework/Dynamic/EventSystem.cs @@ -120,7 +120,7 @@ namespace Framework.Dynamic public SortedMultiMap GetEvents() { return m_events; } ulong m_time; - SortedMultiMap m_events = new SortedMultiMap(); + SortedMultiMap m_events = new(); } public class BasicEvent diff --git a/Source/Framework/Dynamic/FlagArray.cs b/Source/Framework/Dynamic/FlagArray.cs index bf690f58a..cb453b9d4 100644 --- a/Source/Framework/Dynamic/FlagArray.cs +++ b/Source/Framework/Dynamic/FlagArray.cs @@ -75,21 +75,21 @@ namespace Framework.Dynamic public static FlagArray128 operator &(FlagArray128 left, FlagArray128 right) { - FlagArray128 fl = new FlagArray128(); + FlagArray128 fl = new(); for (var i = 0; i < left._values.Length; ++i) fl[i] = left._values[i] & right._values[i]; return fl; } public static FlagArray128 operator |(FlagArray128 left, FlagArray128 right) { - FlagArray128 fl = new FlagArray128(); + FlagArray128 fl = new(); for (var i = 0; i < left._values.Length; ++i) fl[i] = left._values[i] | right._values[i]; return fl; } public static FlagArray128 operator ^(FlagArray128 left, FlagArray128 right) { - FlagArray128 fl = new FlagArray128(); + FlagArray128 fl = new(); for (var i = 0; i < left._values.Length; ++i) fl[i] = left._values[i] ^ right._values[i]; return fl; diff --git a/Source/Framework/Dynamic/TaskScheduler.cs b/Source/Framework/Dynamic/TaskScheduler.cs index ff2084551..8b6e17b56 100644 --- a/Source/Framework/Dynamic/TaskScheduler.cs +++ b/Source/Framework/Dynamic/TaskScheduler.cs @@ -361,7 +361,7 @@ namespace Framework.Dynamic // Perfect forward the context to the handler // Use weak references to catch destruction before callbacks. - TaskContext context = new TaskContext(_task_holder.Pop(), this); + TaskContext context = new(_task_holder.Pop(), this); // Invoke the context context.Invoke(); @@ -479,7 +479,7 @@ namespace Framework.Dynamic public void ModifyIf(Func filter) { - List cache = new List(); + List cache = new(); foreach (var task in container.Where(filter)) { if (filter(task)) @@ -498,7 +498,7 @@ namespace Framework.Dynamic return container.Empty(); } - SortedSet container = new SortedSet(); + SortedSet container = new(); } public class TaskContext diff --git a/Source/Framework/Framework.csproj b/Source/Framework/Framework.csproj index 5d5158458..71fcceaf0 100644 --- a/Source/Framework/Framework.csproj +++ b/Source/Framework/Framework.csproj @@ -7,7 +7,6 @@ - diff --git a/Source/Framework/GameMath/AxisAlignedBox.cs b/Source/Framework/GameMath/AxisAlignedBox.cs index 6d92f49bc..5d0c7d4e1 100644 --- a/Source/Framework/GameMath/AxisAlignedBox.cs +++ b/Source/Framework/GameMath/AxisAlignedBox.cs @@ -251,7 +251,7 @@ namespace Framework.GameMath public Vector3 corner(int index) { // default constructor inits all components to 0 - Vector3 v = new Vector3(); + Vector3 v = new(); switch (index) { @@ -312,7 +312,7 @@ namespace Framework.GameMath public static AxisAlignedBox operator +(AxisAlignedBox box, Vector3 v) { - AxisAlignedBox outt = new AxisAlignedBox(); + AxisAlignedBox outt = new(); outt.Lo = box.Lo + v; outt.Hi = box.Hi + v; return outt; diff --git a/Source/Framework/GameMath/CollisionDetection.cs b/Source/Framework/GameMath/CollisionDetection.cs index 3ca2ba649..ee6c2ebff 100644 --- a/Source/Framework/GameMath/CollisionDetection.cs +++ b/Source/Framework/GameMath/CollisionDetection.cs @@ -38,7 +38,7 @@ namespace Framework.GameMath Inside = true; Vector3 MinB = box.Lo; Vector3 MaxB = box.Hi; - Vector3 MaxT = new Vector3(-1.0f, -1.0f, -1.0f); + Vector3 MaxT = new(-1.0f, -1.0f, -1.0f); // Find candidate planes. for (int i = 0; i < 3; ++i) diff --git a/Source/Framework/GameMath/Matrix2.cs b/Source/Framework/GameMath/Matrix2.cs index a5d0ac203..fe004950a 100644 --- a/Source/Framework/GameMath/Matrix2.cs +++ b/Source/Framework/GameMath/Matrix2.cs @@ -95,11 +95,11 @@ namespace Framework.GameMath /// /// 4-dimentional single-precision floating point zero matrix. /// - public static readonly Matrix2 Zero = new Matrix2(0, 0, 0, 0); + public static readonly Matrix2 Zero = new(0, 0, 0, 0); /// /// 4-dimentional single-precision floating point identity matrix. /// - public static readonly Matrix2 Identity = new Matrix2(1, 0, 0, 1); + public static readonly Matrix2 Identity = new(1, 0, 0, 1); #endregion #region Public Properties @@ -186,7 +186,7 @@ namespace Framework.GameMath /// public static Matrix2 Parse(string value) { - Regex r = new Regex(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); + Regex r = new(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); Match m = r.Match(value); if (m.Success) { @@ -219,7 +219,7 @@ namespace Framework.GameMath /// public static bool TryParse(string value, out Matrix2 result) { - Regex r = new Regex(regularExp, RegexOptions.Singleline); + Regex r = new(regularExp, RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -409,7 +409,7 @@ namespace Framework.GameMath /// A new instance containing the transposed matrix. public static Matrix2 Transpose(Matrix2 m) { - Matrix2 t = new Matrix2(m); + Matrix2 t = new(m); t.Transpose(); return t; } diff --git a/Source/Framework/GameMath/Matrix3.cs b/Source/Framework/GameMath/Matrix3.cs index da5a33b03..da8724f95 100644 --- a/Source/Framework/GameMath/Matrix3.cs +++ b/Source/Framework/GameMath/Matrix3.cs @@ -102,11 +102,11 @@ namespace Framework.GameMath /// /// 4-dimentional single-precision floating point zero matrix. /// - public static readonly Matrix3 Zero = new Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0); + public static readonly Matrix3 Zero = new(0, 0, 0, 0, 0, 0, 0, 0, 0); /// /// 4-dimentional single-precision floating point identity matrix. /// - public static readonly Matrix3 Identity = new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1); + public static readonly Matrix3 Identity = new(1, 0, 0, 0, 1, 0, 0, 0, 1); #endregion #region Public Properties @@ -241,7 +241,7 @@ namespace Framework.GameMath /// public static Matrix3 Parse(string value) { - Regex r = new Regex(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); + Regex r = new(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); Match m = r.Match(value); if (m.Success) { @@ -280,7 +280,7 @@ namespace Framework.GameMath /// public static bool TryParse(string value, out Matrix3 result) { - Regex r = new Regex(regularExp, RegexOptions.Singleline); + Regex r = new(regularExp, RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -519,7 +519,7 @@ namespace Framework.GameMath /// A new instance containing the transposed matrix. public static Matrix3 Transpose(Matrix3 m) { - Matrix3 t = new Matrix3(m); + Matrix3 t = new(m); t.Transpose(); return t; } @@ -530,15 +530,15 @@ namespace Framework.GameMath fCos = (float)Math.Cos(fYAngle); fSin = (float)Math.Sin(fYAngle); - Matrix3 kZMat = new Matrix3(fCos, -fSin, 0.0f, fSin, fCos, 0.0f, 0.0f, 0.0f, 1.0f); + Matrix3 kZMat = new(fCos, -fSin, 0.0f, fSin, fCos, 0.0f, 0.0f, 0.0f, 1.0f); fCos = (float)Math.Cos(fPAngle); fSin = (float)Math.Sin(fPAngle); - Matrix3 kYMat = new Matrix3(fCos, 0.0f, fSin, 0.0f, 1.0f, 0.0f, -fSin, 0.0f, fCos); + Matrix3 kYMat = new(fCos, 0.0f, fSin, 0.0f, 1.0f, 0.0f, -fSin, 0.0f, fCos); fCos = (float)Math.Cos(fRAngle); fSin = (float)Math.Sin(fRAngle); - Matrix3 kXMat = new Matrix3(1.0f, 0.0f, 0.0f, 0.0f, fCos, -fSin, 0.0f, fSin, fCos); + Matrix3 kXMat = new(1.0f, 0.0f, 0.0f, 0.0f, fCos, -fSin, 0.0f, fSin, fCos); return (kZMat * (kYMat * kXMat)); } diff --git a/Source/Framework/GameMath/Matrix4.cs b/Source/Framework/GameMath/Matrix4.cs index 358bd4087..d472abf0c 100644 --- a/Source/Framework/GameMath/Matrix4.cs +++ b/Source/Framework/GameMath/Matrix4.cs @@ -109,11 +109,11 @@ namespace Framework.GameMath /// /// 4-dimentional single-precision floating point zero matrix. /// - public static readonly Matrix4 Zero = new Matrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + public static readonly Matrix4 Zero = new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); /// /// 4-dimentional single-precision floating point identity matrix. /// - public static readonly Matrix4 Identity = new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + public static readonly Matrix4 Identity = new(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); #endregion #region Public Properties @@ -313,7 +313,7 @@ namespace Framework.GameMath /// public static Matrix4 Parse(string value) { - Regex r = new Regex(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); + Regex r = new(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); Match m = r.Match(value); if (m.Success) { @@ -360,7 +360,7 @@ namespace Framework.GameMath /// public static bool TryParse(string value, out Matrix4 result) { - Regex r = new Regex(regularExp, RegexOptions.Singleline); + Regex r = new(regularExp, RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -661,7 +661,7 @@ namespace Framework.GameMath /// A new instance containing the transposed matrix. public static Matrix4 Transpose(Matrix4 m) { - Matrix4 t = new Matrix4(m); + Matrix4 t = new(m); t.Transpose(); return t; } @@ -840,7 +840,7 @@ namespace Framework.GameMath /// A new instance containing the result. public static Vector4 operator *(Matrix4 matrix, Vector4 vector) { - Vector4 result = new Vector4(); + Vector4 result = new(); for (int r = 0; r < 4; ++r) { for (int c = 0; c < 4; ++c) diff --git a/Source/Framework/GameMath/Plane.cs b/Source/Framework/GameMath/Plane.cs index 0cdbdc3f7..4c832f498 100644 --- a/Source/Framework/GameMath/Plane.cs +++ b/Source/Framework/GameMath/Plane.cs @@ -119,15 +119,15 @@ namespace Framework.GameMath /// /// Plane on the X axis. /// - public static readonly Plane XPlane = new Plane(Vector3.XAxis, Vector3.Zero); + public static readonly Plane XPlane = new(Vector3.XAxis, Vector3.Zero); /// /// Plane on the Y axis. /// - public static readonly Plane YPlane = new Plane(Vector3.YAxis, Vector3.Zero); + public static readonly Plane YPlane = new(Vector3.YAxis, Vector3.Zero); /// /// Plane on the Z axis. /// - public static readonly Plane ZPlane = new Plane(Vector3.ZAxis, Vector3.Zero); + public static readonly Plane ZPlane = new(Vector3.ZAxis, Vector3.Zero); #endregion #region Public Properties diff --git a/Source/Framework/GameMath/Quaternion.cs b/Source/Framework/GameMath/Quaternion.cs index c64bb2fbe..f466918e0 100644 --- a/Source/Framework/GameMath/Quaternion.cs +++ b/Source/Framework/GameMath/Quaternion.cs @@ -134,27 +134,27 @@ namespace Framework.GameMath /// /// Double-precision floating point zero quaternion. /// - public static readonly Quaternion Zero = new Quaternion(0, 0, 0, 0); + public static readonly Quaternion Zero = new(0, 0, 0, 0); /// /// Double-precision floating point identity quaternion. /// - public static readonly Quaternion Identity = new Quaternion(0, 0, 0, 1); + public static readonly Quaternion Identity = new(0, 0, 0, 1); /// /// Double-precision floating point X-Axis quaternion. /// - public static readonly Quaternion XAxis = new Quaternion(1, 0, 0, 0); + public static readonly Quaternion XAxis = new(1, 0, 0, 0); /// /// Double-precision floating point Y-Axis quaternion. /// - public static readonly Quaternion YAxis = new Quaternion(0, 1, 0, 0); + public static readonly Quaternion YAxis = new(0, 1, 0, 0); /// /// Double-precision floating point Z-Axis quaternion. /// - public static readonly Quaternion ZAxis = new Quaternion(0, 0, 1, 0); + public static readonly Quaternion ZAxis = new(0, 0, 1, 0); /// /// Double-precision floating point W-Axis quaternion. /// - public static readonly Quaternion WAxis = new Quaternion(0, 0, 0, 1); + public static readonly Quaternion WAxis = new(0, 0, 0, 1); #endregion #region Public Properties @@ -261,7 +261,7 @@ namespace Framework.GameMath /// A that represents the vector specified by the parameter. public static Quaternion Parse(string value) { - Regex r = new Regex(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.None); + Regex r = new(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.None); Match m = r.Match(value); if (m.Success) { @@ -289,7 +289,7 @@ namespace Framework.GameMath /// if value was converted successfully; otherwise, . public static bool TryParse(string value, out Quaternion result) { - Regex r = new Regex(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.None); + Regex r = new(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.None); Match m = r.Match(value); if (m.Success) { @@ -365,7 +365,7 @@ namespace Framework.GameMath /// A new containing the result. public static Quaternion Multiply(Quaternion left, Quaternion right) { - Quaternion result = new Quaternion(); + Quaternion result = new(); result.X = left.W * right.X + left.X * right.W + left.Y * right.Z - left.Z * right.Y; result.Y = left.W * right.Y + left.Y * right.W + left.Z * right.X - left.X * right.Z; result.Z = left.W * right.Z + left.Z * right.W + left.X * right.Y - left.Y * right.X; @@ -394,7 +394,7 @@ namespace Framework.GameMath /// A instance to hold the result. public static Quaternion Multiply(Quaternion quaternion, float scalar) { - Quaternion result = new Quaternion(quaternion); + Quaternion result = new(quaternion); result.X *= scalar; result.Y *= scalar; result.Z *= scalar; @@ -429,7 +429,7 @@ namespace Framework.GameMath throw new DivideByZeroException("Dividing quaternion by zero"); } - Quaternion result = new Quaternion(quaternion); + Quaternion result = new(quaternion); result.X /= scalar; result.Y /= scalar; result.Z /= scalar; @@ -508,7 +508,7 @@ namespace Framework.GameMath /// The quaternion's logarithm. public static Quaternion Log(Quaternion quaternion) { - Quaternion result = new Quaternion(0, 0, 0, 0); + Quaternion result = new(0, 0, 0, 0); if (Math.Abs(quaternion.W) < 1.0) { @@ -539,7 +539,7 @@ namespace Framework.GameMath /// The quaternion's exponent. public Quaternion Exp(Quaternion quaternion) { - Quaternion result = new Quaternion(0, 0, 0, 0); + Quaternion result = new(0, 0, 0, 0); float angle = (float)System.Math.Sqrt(quaternion.X * quaternion.X + quaternion.Y * quaternion.Y + quaternion.Z * quaternion.Z); float sin = (float)System.Math.Sin(angle); diff --git a/Source/Framework/GameMath/Ray.cs b/Source/Framework/GameMath/Ray.cs index 3763847f0..9d880dace 100644 --- a/Source/Framework/GameMath/Ray.cs +++ b/Source/Framework/GameMath/Ray.cs @@ -105,7 +105,7 @@ namespace Framework.GameMath /// A that represents the vector specified by the parameter. public static Ray Parse(string s) { - Regex r = new Regex(@"\((?\([^\)]*\)), (?\([^\)]*\))\)", RegexOptions.None); + Regex r = new(@"\((?\([^\)]*\)), (?\([^\)]*\))\)", RegexOptions.None); Match m = r.Match(s); if (m.Success) { diff --git a/Source/Framework/GameMath/Vector2.cs b/Source/Framework/GameMath/Vector2.cs index 05bb1c061..d34f8cde8 100644 --- a/Source/Framework/GameMath/Vector2.cs +++ b/Source/Framework/GameMath/Vector2.cs @@ -88,15 +88,15 @@ namespace Framework.GameMath /// /// 4-Dimentional single-precision floating point zero vector. /// - public static readonly Vector2 Zero = new Vector2(0.0f, 0.0f); + public static readonly Vector2 Zero = new(0.0f, 0.0f); /// /// 4-Dimentional single-precision floating point X-Axis vector. /// - public static readonly Vector2 XAxis = new Vector2(1.0f, 0.0f); + public static readonly Vector2 XAxis = new(1.0f, 0.0f); /// /// 4-Dimentional single-precision floating point Y-Axis vector. /// - public static readonly Vector2 YAxis = new Vector2(0.0f, 1.0f); + public static readonly Vector2 YAxis = new(0.0f, 1.0f); #endregion #region Public properties @@ -147,7 +147,7 @@ namespace Framework.GameMath /// A that represents the vector specified by the parameter. public static Vector2 Parse(string value) { - Regex r = new Regex(@"\((?.*),(?.*)\)", RegexOptions.Singleline); + Regex r = new(@"\((?.*),(?.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -173,7 +173,7 @@ namespace Framework.GameMath /// if value was converted successfully; otherwise, . public static bool TryParse(string value, out Vector2 result) { - Regex r = new Regex(@"\((?.*),(?.*)\)", RegexOptions.Singleline); + Regex r = new(@"\((?.*),(?.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -831,7 +831,7 @@ namespace Framework.GameMath /// A of single-precision floating point values. public static explicit operator List(Vector2 vector) { - List list = new List(); + List list = new(); list.Add(vector.X); list.Add(vector.Y); @@ -844,7 +844,7 @@ namespace Framework.GameMath /// A of single-precision floating point values. public static explicit operator LinkedList(Vector2 vector) { - LinkedList list = new LinkedList(); + LinkedList list = new(); list.AddLast(vector.X); list.AddLast(vector.Y); @@ -938,7 +938,7 @@ namespace Framework.GameMath public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { StandardValuesCollection svc = - new StandardValuesCollection(new object[3] { Vector2.Zero, Vector2.XAxis, Vector2.YAxis }); + new(new object[3] { Vector2.Zero, Vector2.XAxis, Vector2.YAxis }); return svc; } diff --git a/Source/Framework/GameMath/Vector3.cs b/Source/Framework/GameMath/Vector3.cs index 99b9cf0cb..3131dfe90 100644 --- a/Source/Framework/GameMath/Vector3.cs +++ b/Source/Framework/GameMath/Vector3.cs @@ -88,23 +88,23 @@ namespace Framework.GameMath /// /// 4-Dimentional single-precision floating point zero vector. /// - public static readonly Vector3 Zero = new Vector3(0.0f, 0.0f, 0.0f); + public static readonly Vector3 Zero = new(0.0f, 0.0f, 0.0f); - public static readonly Vector3 One = new Vector3(1.0f, 1.0f, 1.0f); + public static readonly Vector3 One = new(1.0f, 1.0f, 1.0f); - public static readonly Vector3 Inf = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); + public static readonly Vector3 Inf = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); /// /// 4-Dimentional single-precision floating point X-Axis vector. /// - public static readonly Vector3 XAxis = new Vector3(1.0f, 0.0f, 0.0f); + public static readonly Vector3 XAxis = new(1.0f, 0.0f, 0.0f); /// /// 4-Dimentional single-precision floating point Y-Axis vector. /// - public static readonly Vector3 YAxis = new Vector3(0.0f, 1.0f, 0.0f); + public static readonly Vector3 YAxis = new(0.0f, 1.0f, 0.0f); /// /// 4-Dimentional single-precision floating point Y-Axis vector. /// - public static readonly Vector3 ZAxis = new Vector3(0.0f, 0.0f, 1.0f); + public static readonly Vector3 ZAxis = new(0.0f, 0.0f, 1.0f); #endregion #region Public properties @@ -152,7 +152,7 @@ namespace Framework.GameMath /// A that represents the vector specified by the parameter. public static Vector3 Parse(string value) { - Regex r = new Regex(@"\((?.*),(?.*),(?.*)\)", RegexOptions.Singleline); + Regex r = new(@"\((?.*),(?.*),(?.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -179,7 +179,7 @@ namespace Framework.GameMath /// if value was converted successfully; otherwise, . public static bool TryParse(string value, out Vector3 result) { - Regex r = new Regex(@"\((?.*),(?.*),(?.*)\)", RegexOptions.Singleline); + Regex r = new(@"\((?.*),(?.*),(?.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -901,7 +901,7 @@ namespace Framework.GameMath /// A of single-precision floating point values. public static explicit operator List(Vector3 vector) { - List list = new List(3); + List list = new(3); list.Add(vector.X); list.Add(vector.Y); list.Add(vector.Z); @@ -915,7 +915,7 @@ namespace Framework.GameMath /// A of single-precision floating point values. public static explicit operator LinkedList(Vector3 vector) { - LinkedList list = new LinkedList(); + LinkedList list = new(); list.AddLast(vector.X); list.AddLast(vector.Y); list.AddLast(vector.Z); @@ -1089,7 +1089,7 @@ namespace Framework.GameMath public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { StandardValuesCollection svc = - new StandardValuesCollection(new object[4] { Vector3.Zero, Vector3.XAxis, Vector3.YAxis, Vector3.ZAxis }); + new(new object[4] { Vector3.Zero, Vector3.XAxis, Vector3.YAxis, Vector3.ZAxis }); return svc; } diff --git a/Source/Framework/GameMath/Vector4.cs b/Source/Framework/GameMath/Vector4.cs index f38794169..380734a8c 100644 --- a/Source/Framework/GameMath/Vector4.cs +++ b/Source/Framework/GameMath/Vector4.cs @@ -100,23 +100,23 @@ namespace Framework.GameMath /// /// 4-Dimentional single-precision floating point zero vector. /// - public static readonly Vector4 Zero = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); + public static readonly Vector4 Zero = new(0.0f, 0.0f, 0.0f, 0.0f); /// /// 4-Dimentional single-precision floating point X-Axis vector. /// - public static readonly Vector4 XAxis = new Vector4(1.0f, 0.0f, 0.0f, 0.0f); + public static readonly Vector4 XAxis = new(1.0f, 0.0f, 0.0f, 0.0f); /// /// 4-Dimentional single-precision floating point Y-Axis vector. /// - public static readonly Vector4 YAxis = new Vector4(0.0f, 1.0f, 0.0f, 0.0f); + public static readonly Vector4 YAxis = new(0.0f, 1.0f, 0.0f, 0.0f); /// /// 4-Dimentional single-precision floating point Y-Axis vector. /// - public static readonly Vector4 ZAxis = new Vector4(0.0f, 0.0f, 1.0f, 0.0f); + public static readonly Vector4 ZAxis = new(0.0f, 0.0f, 1.0f, 0.0f); /// /// 4-Dimentional single-precision floating point Y-Axis vector. /// - public static readonly Vector4 WAxis = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); + public static readonly Vector4 WAxis = new(0.0f, 0.0f, 0.0f, 1.0f); #endregion #region Public properties @@ -185,7 +185,7 @@ namespace Framework.GameMath /// A that represents the vector specified by the parameter. public static Vector4 Parse(string value) { - Regex r = new Regex(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.Singleline); + Regex r = new(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -213,7 +213,7 @@ namespace Framework.GameMath /// if value was converted successfully; otherwise, . public static bool TryParse(string value, out Vector4 result) { - Regex r = new Regex(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.Singleline); + Regex r = new(@"\((?.*),(?.*),(?.*),(?.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { @@ -806,7 +806,7 @@ namespace Framework.GameMath public static Vector4 operator *(Vector4 vector, Matrix4 M) { - Vector4 result = new Vector4(); + Vector4 result = new(); for (int i = 0; i < 4; ++i) { result[i] = 0.0f; @@ -914,7 +914,7 @@ namespace Framework.GameMath /// A of single-precision floating point values. public static explicit operator List(Vector4 vector) { - List list = new List(4); + List list = new(4); list.Add(vector.X); list.Add(vector.Y); list.Add(vector.Z); @@ -929,7 +929,7 @@ namespace Framework.GameMath /// A of single-precision floating point values. public static explicit operator LinkedList(Vector4 vector) { - LinkedList list = new LinkedList(); + LinkedList list = new(); list.AddLast(vector.X); list.AddLast(vector.Y); list.AddLast(vector.Z); @@ -1025,7 +1025,7 @@ namespace Framework.GameMath public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { StandardValuesCollection svc = - new StandardValuesCollection(new object[5] { Vector4.Zero, Vector4.XAxis, Vector4.YAxis, Vector4.ZAxis, Vector4.WAxis }); + new(new object[5] { Vector4.Zero, Vector4.XAxis, Vector4.YAxis, Vector4.ZAxis, Vector4.WAxis }); return svc; } diff --git a/Source/Framework/IO/ByteBuffer.cs b/Source/Framework/IO/ByteBuffer.cs index 2a2055b44..35f380edd 100644 --- a/Source/Framework/IO/ByteBuffer.cs +++ b/Source/Framework/IO/ByteBuffer.cs @@ -107,7 +107,7 @@ namespace Framework.IO public string ReadCString() { ResetBitPos(); - StringBuilder tmpString = new StringBuilder(); + StringBuilder tmpString = new(); char tmpChar = readStream.ReadChar(); char tmpEndChar = Convert.ToChar(Encoding.UTF8.GetString(new byte[] { 0 })); diff --git a/Source/Framework/IO/StringArguments.cs b/Source/Framework/IO/StringArguments.cs index 86e756b78..7d1b80a69 100644 --- a/Source/Framework/IO/StringArguments.cs +++ b/Source/Framework/IO/StringArguments.cs @@ -263,7 +263,7 @@ namespace Framework.IO bool Match(string pattern, out Match m) { - Regex r = new Regex(pattern); + Regex r = new(pattern); m = r.Match(activestring); return m.Success; } diff --git a/Source/Framework/IO/Zlib/Deflate.cs b/Source/Framework/IO/Zlib/Deflate.cs index 1572d9286..d9502a791 100644 --- a/Source/Framework/IO/Zlib/Deflate.cs +++ b/Source/Framework/IO/Zlib/Deflate.cs @@ -217,9 +217,9 @@ namespace Framework.IO public ct_data[] dyn_dtree=new ct_data[2*D_CODES+1]; // distance tree public ct_data[] bl_tree=new ct_data[2*BL_CODES+1]; // Huffman tree for bit lengths - public tree_desc l_desc=new tree_desc(); // desc. for literal tree - public tree_desc d_desc=new tree_desc(); // desc. for distance tree - public tree_desc bl_desc=new tree_desc(); // desc. for bit length tree + public tree_desc l_desc=new(); // desc. for literal tree + public tree_desc d_desc=new(); // desc. for distance tree + public tree_desc bl_desc=new(); // desc. for bit length tree // number of codes at each bit length for an optimal tree public ushort[] bl_count=new ushort[MAX_BITS+1]; diff --git a/Source/Framework/IO/Zlib/Trees.cs b/Source/Framework/IO/Zlib/Trees.cs index f0a6afad4..d96ec5e8b 100644 --- a/Source/Framework/IO/Zlib/Trees.cs +++ b/Source/Framework/IO/Zlib/Trees.cs @@ -240,9 +240,9 @@ namespace Framework.IO } } - private static readonly static_tree_desc static_l_desc=new static_tree_desc(static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS); - private static readonly static_tree_desc static_d_desc=new static_tree_desc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); - private static readonly static_tree_desc static_bl_desc=new static_tree_desc(null, extra_blbits, 0, BL_CODES, MAX_BL_BITS); + private static readonly static_tree_desc static_l_desc=new(static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS); + private static readonly static_tree_desc static_d_desc=new(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); + private static readonly static_tree_desc static_bl_desc=new(null, extra_blbits, 0, BL_CODES, MAX_BL_BITS); // =========================================================================== // Local (static) routines in this file. diff --git a/Source/Framework/IO/Zlib/compress.cs b/Source/Framework/IO/Zlib/compress.cs index b1aace5f0..21cf32f5a 100644 --- a/Source/Framework/IO/Zlib/compress.cs +++ b/Source/Framework/IO/Zlib/compress.cs @@ -26,7 +26,7 @@ namespace Framework.IO { public static byte[] Compress(byte[] data) { - ByteBuffer buffer = new ByteBuffer(); + ByteBuffer buffer = new(); buffer.WriteUInt8(0x78); buffer.WriteUInt8(0x9c); diff --git a/Source/Framework/Logging/Appender.cs b/Source/Framework/Logging/Appender.cs index 934f4f5b8..92e09940c 100644 --- a/Source/Framework/Logging/Appender.cs +++ b/Source/Framework/Logging/Appender.cs @@ -125,7 +125,7 @@ class FileAppender : Appender, IDisposable string _logDir; bool _dynamicName; FileStream _logStream; - object locker = new object(); + object locker = new(); } class DBAppender : Appender @@ -177,7 +177,7 @@ abstract class Appender if (_level == LogLevel.Disabled || (_level != LogLevel.Fatal && _level > message.level)) return; - StringBuilder ss = new StringBuilder(); + StringBuilder ss = new(); if (_flags.HasAnyFlag(AppenderFlags.PrefixTimestamp)) ss.AppendFormat("{0:MM/dd/yyyy HH:mm:ss} ", message.mtime); diff --git a/Source/Framework/Logging/Logger.cs b/Source/Framework/Logging/Logger.cs index aaba36713..ea32751db 100644 --- a/Source/Framework/Logging/Logger.cs +++ b/Source/Framework/Logging/Logger.cs @@ -61,5 +61,5 @@ class Logger string name; LogLevel level; - Dictionary appenders = new Dictionary(); + Dictionary appenders = new(); } diff --git a/Source/Framework/Networking/NetworkThread.cs b/Source/Framework/Networking/NetworkThread.cs index e34e737e3..29cf20b1d 100644 --- a/Source/Framework/Networking/NetworkThread.cs +++ b/Source/Framework/Networking/NetworkThread.cs @@ -27,8 +27,8 @@ namespace Framework.Networking Thread _thread; - List _Sockets = new List(); - List _newSockets = new List(); + List _Sockets = new(); + List _newSockets = new(); public void Stop() { diff --git a/Source/Framework/Realm/Realm.cs b/Source/Framework/Realm/Realm.cs index 72ce9349f..bbed7a46a 100644 --- a/Source/Framework/Realm/Realm.cs +++ b/Source/Framework/Realm/Realm.cs @@ -55,7 +55,7 @@ public class Realm : IEquatable realmIp = ExternalAddress; } - IPEndPoint endpoint = new IPEndPoint(realmIp, Port); + IPEndPoint endpoint = new(realmIp, Port); // Return external IP return endpoint; diff --git a/Source/Framework/Realm/RealmManager.cs b/Source/Framework/Realm/RealmManager.cs index c2dab5453..df9910693 100644 --- a/Source/Framework/Realm/RealmManager.cs +++ b/Source/Framework/Realm/RealmManager.cs @@ -51,7 +51,7 @@ public class RealmManager : Singleton { do { - RealmBuildInfo build = new RealmBuildInfo(); + RealmBuildInfo build = new(); build.MajorVersion = result.Read(0); build.MinorVersion = result.Read(1); build.BugfixVersion = result.Read(2); @@ -92,7 +92,7 @@ public class RealmManager : Singleton { PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_REALMLIST); SQLResult result = DB.Login.Query(stmt); - Dictionary existingRealms = new Dictionary(); + Dictionary existingRealms = new(); foreach (var p in _realms) existingRealms[p.Key] = p.Value.Name; @@ -192,7 +192,7 @@ public class RealmManager : Singleton realmEntry.PopulationState = Math.Max((int)realm.PopulationLevel, 1); realmEntry.CfgCategoriesID = realm.Timezone; - ClientVersion version = new ClientVersion(); + ClientVersion version = new(); RealmBuildInfo buildInfo = GetBuildInfo(realm.Build); if (buildInfo != null) { @@ -235,7 +235,7 @@ public class RealmManager : Singleton if (realm.Value.Build != build) flag |= RealmFlags.VersionMismatch; - RealmListUpdate realmListUpdate = new RealmListUpdate(); + RealmListUpdate realmListUpdate = new(); realmListUpdate.Update.WowRealmAddress = (int)realm.Value.Id.GetAddress(); realmListUpdate.Update.CfgTimezonesID = 1; realmListUpdate.Update.PopulationState = (realm.Value.Flags.HasAnyFlag(RealmFlags.Offline) ? 0 : Math.Max((int)realm.Value.PopulationLevel, 1)); @@ -279,8 +279,8 @@ public class RealmManager : Singleton if (realm.Flags.HasAnyFlag(RealmFlags.Offline) || realm.Build != build) return BattlenetRpcErrorCode.UserServerNotPermittedOnRealm; - RealmListServerIPAddresses serverAddresses = new RealmListServerIPAddresses(); - AddressFamily addressFamily = new AddressFamily(); + RealmListServerIPAddresses serverAddresses = new(); + AddressFamily addressFamily = new(); addressFamily.Id = 1; var address = new Address(); @@ -302,7 +302,7 @@ public class RealmManager : Singleton stmt.AddValue(4, accountName); DB.Login.DirectExecute(stmt); - Bgs.Protocol.Attribute attribute = new Bgs.Protocol.Attribute(); + Bgs.Protocol.Attribute attribute = new(); attribute.Name = "Param_RealmJoinTicket"; attribute.Value = new Bgs.Protocol.Variant(); attribute.Value.BlobValue = Google.Protobuf.ByteString.CopyFrom(accountName, System.Text.Encoding.UTF8); @@ -328,9 +328,9 @@ public class RealmManager : Singleton public ICollection GetRealms() { return _realms.Values; } List GetSubRegions() { return _subRegions; } - List _builds = new List(); - ConcurrentDictionary _realms = new ConcurrentDictionary(); - List _subRegions = new List(); + List _builds = new(); + ConcurrentDictionary _realms = new(); + List _subRegions = new(); Timer _updateTimer; } diff --git a/Source/Framework/RecastDetour/Detour/DetourNavMesh.cs b/Source/Framework/RecastDetour/Detour/DetourNavMesh.cs index 00c4e1804..02c3143f1 100644 --- a/Source/Framework/RecastDetour/Detour/DetourNavMesh.cs +++ b/Source/Framework/RecastDetour/Detour/DetourNavMesh.cs @@ -354,7 +354,7 @@ public static partial class Detour if (header.version != DT_NAVMESH_VERSION) return DT_FAILURE | DT_WRONG_VERSION; - dtNavMeshParams navMeshParams = new dtNavMeshParams(); + dtNavMeshParams navMeshParams = new(); dtVcopy(navMeshParams.orig, header.bmin); navMeshParams.tileWidth = header.bmax[0] - header.bmin[0]; navMeshParams.tileHeight = header.bmax[2] - header.bmin[2]; diff --git a/Source/Framework/RecastDetour/Detour/DetourNavMeshBuilder.cs b/Source/Framework/RecastDetour/Detour/DetourNavMeshBuilder.cs index 2d7681219..85036e242 100644 --- a/Source/Framework/RecastDetour/Detour/DetourNavMeshBuilder.cs +++ b/Source/Framework/RecastDetour/Detour/DetourNavMeshBuilder.cs @@ -133,7 +133,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); bytes.AddRange(BitConverter.GetBytes(firstLink)); for (int i = 0; i < DT_VERTS_PER_POLYGON; ++i) @@ -196,7 +196,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); bytes.AddRange(BitConverter.GetBytes(vertBase)); bytes.AddRange(BitConverter.GetBytes(triBase)); @@ -232,7 +232,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); bytes.AddRange(BitConverter.GetBytes(polyRef)); bytes.AddRange(BitConverter.GetBytes(next)); @@ -270,7 +270,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); for (int j = 0; j < bmin.Length; ++j) { bytes.AddRange(BitConverter.GetBytes(bmin[j])); @@ -326,7 +326,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); for (int i = 0; i < 6; ++i) { bytes.AddRange(BitConverter.GetBytes(pos[i])); @@ -412,7 +412,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); bytes.AddRange(BitConverter.GetBytes(magic)); bytes.AddRange(BitConverter.GetBytes(version)); @@ -537,7 +537,7 @@ public static partial class Detour public byte[] ToBytes() { - List bytes = new List(); + List bytes = new(); bytes.AddRange(header.ToBytes()); for (int i = 0; i < polys.Length; ++i) @@ -645,7 +645,7 @@ public static partial class Detour /// public dtNavMeshParams Clone() { - dtNavMeshParams copy = new dtNavMeshParams(); + dtNavMeshParams copy = new(); for (int i = 0; i < orig.Length; ++i) { copy.orig[i] = orig[i]; diff --git a/Source/Framework/RecastDetour/Detour/DetourNavMeshQuery.cs b/Source/Framework/RecastDetour/Detour/DetourNavMeshQuery.cs index 75b7ec7e3..0dbf56011 100644 --- a/Source/Framework/RecastDetour/Detour/DetourNavMeshQuery.cs +++ b/Source/Framework/RecastDetour/Detour/DetourNavMeshQuery.cs @@ -222,7 +222,7 @@ public static partial class Detour raycastLimitSqr = 0f; } } - private dtQueryData m_query = new dtQueryData(); //< Sliced query state. + private dtQueryData m_query = new(); //< Sliced query state. private dtNodePool m_tinyNodePool; //< Pointer to small node pool. private dtNodePool m_nodePool; //< Pointer to node pool. @@ -884,7 +884,7 @@ public static partial class Detour nearestRef = 0; - dtFindNearestPolyQuery query = new dtFindNearestPolyQuery(this, center); + dtFindNearestPolyQuery query = new(this, center); dtStatus status = queryPolygons(center, halfExtents, filter, query); if (dtStatusFailed(status)) @@ -1430,7 +1430,7 @@ public static partial class Detour return DT_FAILURE; } - dtRaycastHit rayHit = new dtRaycastHit(); + dtRaycastHit rayHit = new(); rayHit.maxPath = 0; int iter = 0; @@ -2579,7 +2579,7 @@ public static partial class Detour public dtStatus raycast(dtPolyRef startRef, float[] startPos, float[] endPos, dtQueryFilter filter, ref float t, float[] hitNormal, dtPolyRef[] path, ref uint pathCount, int maxPath) { - dtRaycastHit hit = new dtRaycastHit(); + dtRaycastHit hit = new(); hit.path = path; hit.maxPath = maxPath; @@ -2670,16 +2670,16 @@ public static partial class Detour dtStatus status = DT_SUCCESS; - dtMeshTile prevTile = new dtMeshTile(); + dtMeshTile prevTile = new(); dtMeshTile nextTile; - dtPoly prevPoly = new dtPoly(); + dtPoly prevPoly = new(); dtPoly nextPoly; dtPolyRef curRef; // The API input has been checked already, skip checking internal data. curRef = startRef; - dtMeshTile tile = new dtMeshTile(); - dtPoly poly = new dtPoly(); + dtMeshTile tile = new(); + dtPoly poly = new(); m_nav.getTileAndPolyByRefUnsafe(curRef, ref tile, ref poly); nextTile = prevTile = tile; nextPoly = prevPoly = poly; diff --git a/Source/Framework/Singleton/Singleton.cs b/Source/Framework/Singleton/Singleton.cs index 6bb2b69db..4ce8e592b 100644 --- a/Source/Framework/Singleton/Singleton.cs +++ b/Source/Framework/Singleton/Singleton.cs @@ -21,7 +21,7 @@ using System.Reflection; public class Singleton where T : class { private static volatile T instance; - private static object syncRoot = new object(); + private static object syncRoot = new(); public static T Instance { diff --git a/Source/Framework/Threading/ProducerConsumerQueue.cs b/Source/Framework/Threading/ProducerConsumerQueue.cs index f7468fea2..8a77973e8 100644 --- a/Source/Framework/Threading/ProducerConsumerQueue.cs +++ b/Source/Framework/Threading/ProducerConsumerQueue.cs @@ -22,8 +22,8 @@ namespace Framework.Threading { public class ProducerConsumerQueue { - object _queueLock = new object(); - Queue _queue = new Queue(); + object _queueLock = new(); + Queue _queue = new(); volatile bool _shutdown; public ProducerConsumerQueue() diff --git a/Source/Framework/Util/Extensions.cs b/Source/Framework/Util/Extensions.cs index 19d8f2e9b..d682e0bb9 100644 --- a/Source/Framework/Util/Extensions.cs +++ b/Source/Framework/Util/Extensions.cs @@ -157,7 +157,7 @@ namespace System public static List DeserializeObjects(this ICollection data) { - List list = new List(); + List list = new(); if (data.Count == 0) return list; @@ -261,7 +261,7 @@ namespace System public static string ReadCString(this BinaryReader reader) { byte num; - List temp = new List(); + List temp = new(); while ((num = reader.ReadByte()) != 0) temp.Add(num); diff --git a/Source/Game/AI/PlayerAI/PlayerAI.cs b/Source/Game/AI/PlayerAI/PlayerAI.cs index 885fc2b42..3b7d1ada6 100644 --- a/Source/Game/AI/PlayerAI/PlayerAI.cs +++ b/Source/Game/AI/PlayerAI/PlayerAI.cs @@ -606,7 +606,7 @@ namespace Game.AI if (spellInfo == null) return; - Spell spell = new Spell(me, spellInfo, TriggerCastFlags.CastDirectly); + Spell spell = new(me, spellInfo, TriggerCastFlags.CastDirectly); if (spell.CheckPetCast(victim) != SpellCastResult.SpellCastOk) return; diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index 00a6e4142..d9fe7a01f 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -2232,7 +2232,7 @@ namespace Game.Entities return; } - Spell spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId); + Spell spell = new(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId); foreach (var pair in args.SpellValueOverrides) spell.SetSpellValue(pair.Key, pair.Value); diff --git a/Source/Game/Entities/SceneObject.cs b/Source/Game/Entities/SceneObject.cs index 5b27ac630..c580f04e0 100644 --- a/Source/Game/Entities/SceneObject.cs +++ b/Source/Game/Entities/SceneObject.cs @@ -95,7 +95,7 @@ namespace Game.Entities ulong lowGuid = creator.GetMap().GenerateLowGuid(HighGuid.SceneObject); - SceneObject sceneObject = new SceneObject(); + SceneObject sceneObject = new(); if (!sceneObject.Create(lowGuid, SceneType.Normal, sceneId, sceneTemplate != null ? sceneTemplate.ScenePackageId : 0, creator.GetMap(), creator, pos, privateObjectOwner)) { sceneObject.Dispose(); diff --git a/Source/Game/Movement/MotionMaster.cs b/Source/Game/Movement/MotionMaster.cs index c182a30f4..19cc950f7 100644 --- a/Source/Game/Movement/MotionMaster.cs +++ b/Source/Game/Movement/MotionMaster.cs @@ -625,14 +625,14 @@ namespace Game.Movement if (_owner.IsTypeId(TypeId.Player)) { - PointMovementGenerator movement = new PointMovementGenerator(id, x, y, z, generatePath, speed, null, target, spellEffectExtraData); + PointMovementGenerator movement = new(id, x, y, z, generatePath, speed, null, target, spellEffectExtraData); movement.Priority = MovementGeneratorPriority.Highest; movement.BaseUnitState = UnitState.Charging; Add(movement); } else { - PointMovementGenerator movement = new PointMovementGenerator(id, x, y, z, generatePath, speed, null, target, spellEffectExtraData); + PointMovementGenerator movement = new(id, x, y, z, generatePath, speed, null, target, spellEffectExtraData); movement.Priority = MovementGeneratorPriority.Highest; movement.BaseUnitState = UnitState.Charging; Add(movement); @@ -680,7 +680,7 @@ namespace Game.Movement if (spellEffectExtraData != null) init.SetSpellEffectExtraData(spellEffectExtraData); - GenericMovementGenerator movement = new GenericMovementGenerator(init, MovementGeneratorType.Effect, 0); + GenericMovementGenerator movement = new(init, MovementGeneratorType.Effect, 0); movement.Priority = MovementGeneratorPriority.Highest; Add(movement); } @@ -730,7 +730,7 @@ namespace Game.Movement arrivalSpellTargetGuid = arrivalCast.Target; } - GenericMovementGenerator movement = new GenericMovementGenerator(init, MovementGeneratorType.Effect, id, arrivalSpellId, arrivalSpellTargetGuid); + GenericMovementGenerator movement = new(init, MovementGeneratorType.Effect, id, arrivalSpellId, arrivalSpellTargetGuid); movement.Priority = MovementGeneratorPriority.Highest; movement.BaseUnitState = UnitState.Jumping; Add(movement); @@ -849,7 +849,7 @@ namespace Game.Movement init.MoveTo(_owner.GetPositionX(), _owner.GetPositionY(), tz + _owner.GetHoverOffset(), false); init.SetFall(); - GenericMovementGenerator movement = new GenericMovementGenerator(init, MovementGeneratorType.Effect, id); + GenericMovementGenerator movement = new(init, MovementGeneratorType.Effect, id); movement.Priority = MovementGeneratorPriority.Highest; Add(movement); } @@ -943,7 +943,7 @@ namespace Game.Movement return; } - GenericMovementGenerator movement = new GenericMovementGenerator(init, type, id); + GenericMovementGenerator movement = new(init, type, id); movement.Priority = priority; Add(movement); } diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index fd5b0094e..e645c2ab2 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -256,7 +256,7 @@ namespace Game.Spells case AuraType.AddPctModifier: if (m_spellmod == null) { - SpellModifierByClassMask spellmod = new SpellModifierByClassMask(GetBase()); + SpellModifierByClassMask spellmod = new(GetBase()); spellmod.op = (SpellModOp)GetMiscValue(); spellmod.type = GetAuraType() == AuraType.AddPctModifier ? SpellModType.Pct : SpellModType.Flat; @@ -269,7 +269,7 @@ namespace Game.Spells case AuraType.AddFlatModifierBySpellLabel: if (m_spellmod == null) { - SpellFlatModifierByLabel spellmod = new SpellFlatModifierByLabel(GetBase()); + SpellFlatModifierByLabel spellmod = new(GetBase()); spellmod.op = (SpellModOp)GetMiscValue(); spellmod.type = SpellModType.LabelFlat; @@ -283,7 +283,7 @@ namespace Game.Spells case AuraType.AddPctModifierBySpellLabel: if (m_spellmod == null) { - SpellPctModifierByLabel spellmod = new SpellPctModifierByLabel(GetBase()); + SpellPctModifierByLabel spellmod = new(GetBase()); spellmod.op = (SpellModOp)GetMiscValue(); spellmod.type = SpellModType.LabelPct; diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 7396fd2b4..ce1c0a484 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -694,7 +694,7 @@ namespace Game.Spells } // Init dest coordinates - WorldLocation targetDest = new WorldLocation(destTarget); + WorldLocation targetDest = new(destTarget); if (targetDest.GetMapId() == 0xFFFFFFFF) targetDest.SetMapId(unitTarget.GetMapId()); diff --git a/Source/Scripts/Pets/DeathKnight.cs b/Source/Scripts/Pets/DeathKnight.cs index ec8da43e5..89591aeb7 100644 --- a/Source/Scripts/Pets/DeathKnight.cs +++ b/Source/Scripts/Pets/DeathKnight.cs @@ -49,7 +49,7 @@ namespace Scripts.Pets return; // Find victim of Summon Gargoyle spell - List targets = new List(); + List targets = new(); var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); var searcher = new UnitListSearcher(me, targets, u_check); Cell.VisitAllObjects(me, searcher, 30.0f); diff --git a/Source/Scripts/Smart/SmartAI.cs b/Source/Scripts/Smart/SmartAI.cs index ab8ee41ff..17616c46a 100644 --- a/Source/Scripts/Smart/SmartAI.cs +++ b/Source/Scripts/Smart/SmartAI.cs @@ -35,7 +35,7 @@ namespace Scripts.Smart return false; Log.outDebug(LogFilter.ScriptsAi, "AreaTrigger {0} is using SmartTrigger script", trigger.Id); - SmartScript script = new SmartScript(); + SmartScript script = new(); script.OnInitialize(trigger); script.ProcessEventsFor(SmartEvents.AreatriggerOntrigger, player, trigger.Id); return true; @@ -60,28 +60,28 @@ namespace Scripts.Smart public override void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) { - SmartScript smartScript = new SmartScript(); + SmartScript smartScript = new(); smartScript.OnInitialize(sceneTemplate); smartScript.ProcessEventsFor(SmartEvents.SceneStart, player); } public override void OnSceneTriggerEvent(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName) { - SmartScript smartScript = new SmartScript(); + SmartScript smartScript = new(); smartScript.OnInitialize(sceneTemplate); smartScript.ProcessEventsFor(SmartEvents.SceneTrigger, player, 0, 0, false, null, null, triggerName); } public override void OnSceneCancel(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) { - SmartScript smartScript = new SmartScript(); + SmartScript smartScript = new(); smartScript.OnInitialize(sceneTemplate); smartScript.ProcessEventsFor(SmartEvents.SceneCancel, player); } public override void OnSceneComplete(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) { - SmartScript smartScript = new SmartScript(); + SmartScript smartScript = new(); smartScript.OnInitialize(sceneTemplate); smartScript.ProcessEventsFor(SmartEvents.SceneComplete, player); } @@ -95,7 +95,7 @@ namespace Scripts.Smart // Called when a quest status change public override void OnQuestStatusChange(Player player, Quest quest, QuestStatus oldStatus, QuestStatus newStatus) { - SmartScript smartScript = new SmartScript(); + SmartScript smartScript = new(); smartScript.OnInitialize(quest); switch (newStatus) { @@ -123,7 +123,7 @@ namespace Scripts.Smart ushort slot = player.FindQuestSlot(quest.Id); if (slot < SharedConst.MaxQuestLogSize && player.IsQuestObjectiveComplete(slot, quest, objective)) { - SmartScript smartScript = new SmartScript(); + SmartScript smartScript = new(); smartScript.OnInitialize(quest); smartScript.ProcessEventsFor(SmartEvents.QuestObjCompletion, player, objective.Id); } diff --git a/Source/Scripts/Spells/DeathKnight.cs b/Source/Scripts/Spells/DeathKnight.cs index 47d2175a0..e43b3d149 100644 --- a/Source/Scripts/Spells/DeathKnight.cs +++ b/Source/Scripts/Spells/DeathKnight.cs @@ -268,7 +268,7 @@ namespace Scripts.Spells.DeathKnight return; int amount = (int)damageInfo.GetDamage() / 2; - SpellNonMeleeDamage log = new SpellNonMeleeDamage(drw, drw.GetVictim(), spellInfo, new SpellCastVisual(spellInfo.GetSpellXSpellVisualId(drw), 0), spellInfo.GetSchoolMask()); + SpellNonMeleeDamage log = new(drw, drw.GetVictim(), spellInfo, new SpellCastVisual(spellInfo.GetSpellXSpellVisualId(drw), 0), spellInfo.GetSchoolMask()); log.damage = (uint)amount; Unit.DealDamage(drw, drw.GetVictim(), (uint)amount, null, DamageEffectType.SpellDirect, spellInfo.GetSchoolMask(), spellInfo, true); drw.SendSpellNonMeleeDamageLog(log); diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index 4ae9d21b5..cc48d9aed 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -2270,7 +2270,7 @@ namespace Scripts.Spells.Generic if (player.GetLastPetNumber() != 0) { PetType newPetType = (player.GetClass() == Class.Hunter) ? PetType.Hunter : PetType.Summon; - Pet newPet = new Pet(player, newPetType); + Pet newPet = new(player, newPetType); if (newPet.LoadPetFromDB(player, 0, player.GetLastPetNumber(), true)) { // revive the pet if it is dead @@ -2723,7 +2723,7 @@ namespace Scripts.Spells.Generic Unit target = GetHitUnit(); if (target) { - SpiritHealerConfirm spiritHealerConfirm = new SpiritHealerConfirm(); + SpiritHealerConfirm spiritHealerConfirm = new(); spiritHealerConfirm.Unit = target.GetGUID(); originalCaster.SendPacket(spiritHealerConfirm); } @@ -2972,7 +2972,7 @@ namespace Scripts.Spells.Generic [Script] class spell_gen_turkey_marker : AuraScript { - readonly List _applyTimes = new List(); + readonly List _applyTimes = new(); void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { diff --git a/Source/Scripts/Spells/Holiday.cs b/Source/Scripts/Spells/Holiday.cs index ff1cc92a1..49ea7bf30 100644 --- a/Source/Scripts/Spells/Holiday.cs +++ b/Source/Scripts/Spells/Holiday.cs @@ -189,8 +189,8 @@ namespace Scripts.Spells.Holiday bool foundSomeone = false; // For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123) // required by achievement and "hearts" visual - List playerList = new List(); - AnyPlayerInObjectRangeCheck checker = new AnyPlayerInObjectRangeCheck(target, SharedConst.InteractionDistance * 2); + List playerList = new(); + AnyPlayerInObjectRangeCheck checker = new(target, SharedConst.InteractionDistance * 2); var searcher = new PlayerListSearcher(target, playerList, checker); Cell.VisitWorldObjects(target, searcher, SharedConst.InteractionDistance * 2); foreach (Player player in playerList) diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Items.cs index ba4e28421..0d2a61c85 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Items.cs @@ -1139,7 +1139,7 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - List possibleSpells = new List(); + List possibleSpells = new(); switch (caster.GetClass()) { case Class.Warlock: @@ -2165,7 +2165,7 @@ namespace Scripts.Spells.Items { SpellCastResult CheckRequirement() { - List ghouls = new List(); + List ghouls = new(); GetCaster().GetAllMinionsByEntry(ghouls, CreatureIds.Ghoul); if (ghouls.Count >= CreatureIds.MaxGhouls) { @@ -3530,7 +3530,7 @@ namespace Scripts.Spells.Items { void SecondaryEffect() { - List availableElixirs = new List() + List availableElixirs = new() { // Battle Elixirs 33720, // Onslaught Elixir (28102) @@ -3599,7 +3599,7 @@ namespace Scripts.Spells.Items { void SecondaryEffect() { - List availableElixirs = new List() + List availableElixirs = new() { 43185, // Runic Healing Potion (33447) 53750, // Crazy Alchemist's Potion (40077) diff --git a/Source/Scripts/Spells/Mage.cs b/Source/Scripts/Spells/Mage.cs index bf226adfe..41d65a530 100644 --- a/Source/Scripts/Spells/Mage.cs +++ b/Source/Scripts/Spells/Mage.cs @@ -524,7 +524,7 @@ namespace Scripts.Spells.Mage [Script] // Ice Lance - 30455 class spell_mage_ice_lance : SpellScript { - List _orderedTargets = new List(); + List _orderedTargets = new(); public override bool Validate(SpellInfo spellInfo) { @@ -788,7 +788,7 @@ namespace Scripts.Spells.Mage void Apply(AuraEffect aurEff, AuraEffectHandleModes mode) { - List minions = new List(); + List minions = new(); GetTarget().GetAllMinionsByEntry(minions, (uint)Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon, GetCastDifficulty()).GetEffect(0).MiscValue); // Get the last summoned RoF, save it and despawn older ones diff --git a/Source/Scripts/Spells/Priest.cs b/Source/Scripts/Spells/Priest.cs index 6e3885849..94af1fe6c 100644 --- a/Source/Scripts/Spells/Priest.cs +++ b/Source/Scripts/Spells/Priest.cs @@ -111,7 +111,7 @@ namespace Scripts.Spells.Priest [Script] // 81749 - Atonement public class spell_pri_atonement : AuraScript { - List _appliedAtonements = new List(); + List _appliedAtonements = new(); public override bool Validate(SpellInfo spellInfo) { @@ -372,7 +372,7 @@ namespace Scripts.Spells.Priest { Position destPos = GetHitDest().GetPosition(); - SpellCastTargets targets = new SpellCastTargets(); + SpellCastTargets targets = new(); targets.SetDst(destPos); targets.SetUnitTarget(GetCaster()); GetHitUnit().CastSpell(targets, (uint)GetEffectValue(), new CastSpellExtraArgs(GetCastDifficulty())); @@ -1002,7 +1002,7 @@ namespace Scripts.Spells.Priest } else { - CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.CastDifficulty = GetCastDifficulty(); GetCaster().CastSpell(destPos, SpellIds.AngelicFeatherAreatrigger, args); } diff --git a/Source/Scripts/Spells/Quest.cs b/Source/Scripts/Spells/Quest.cs index bb4b09120..b50510b0c 100644 --- a/Source/Scripts/Spells/Quest.cs +++ b/Source/Scripts/Spells/Quest.cs @@ -1295,9 +1295,9 @@ namespace Scripts.Spells.Quest { Unit caster = GetCaster(); // Check for player that is in 65 y range - List playerList = new List(); - AnyPlayerInObjectRangeCheck checker = new AnyPlayerInObjectRangeCheck(caster, 65.0f); - PlayerListSearcher searcher = new PlayerListSearcher(caster, playerList, checker); + List playerList = new(); + AnyPlayerInObjectRangeCheck checker = new(caster, 65.0f); + PlayerListSearcher searcher = new(caster, playerList, checker); Cell.VisitWorldObjects(caster, searcher, 65.0f); foreach (Player player in playerList) { @@ -1366,7 +1366,7 @@ namespace Scripts.Spells.Quest void SetDest(ref SpellDestination dest) { // Adjust effect summon position - Position offset = new Position(0.0f, 0.0f, 20.0f, 0.0f); + Position offset = new(0.0f, 0.0f, 20.0f, 0.0f); dest.RelocateOffset(offset); } @@ -1426,7 +1426,7 @@ namespace Scripts.Spells.Quest void SetDest(ref SpellDestination dest) { // Adjust effect summon position - Position offset = new Position(0.0f, 0.0f, 20.0f, 0.0f); + Position offset = new(0.0f, 0.0f, 20.0f, 0.0f); dest.RelocateOffset(offset); } @@ -1443,7 +1443,7 @@ namespace Scripts.Spells.Quest void SetDest(ref SpellDestination dest) { // Adjust effect summon position - Position offset = new Position(0.0f, 0.0f, 2.5f, 0.0f); + Position offset = new(0.0f, 0.0f, 2.5f, 0.0f); dest.RelocateOffset(offset); } diff --git a/Source/Scripts/Spells/Rogue.cs b/Source/Scripts/Spells/Rogue.cs index 686ca80eb..b9e3ba9f2 100644 --- a/Source/Scripts/Spells/Rogue.cs +++ b/Source/Scripts/Spells/Rogue.cs @@ -109,7 +109,7 @@ namespace Scripts.Spells.Rogue _targets.Add(target.GetGUID()); } - List _targets = new List(); + List _targets = new(); } [Script] // 2098 - Eviscerate diff --git a/Source/Scripts/Spells/Warlock.cs b/Source/Scripts/Spells/Warlock.cs index 3fd4c9b42..1101400ec 100644 --- a/Source/Scripts/Spells/Warlock.cs +++ b/Source/Scripts/Spells/Warlock.cs @@ -278,7 +278,7 @@ namespace Scripts.Spells.Warlock if (modOwner) modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.PowerCost0, ref damage); - SpellNonMeleeDamage damageInfo = new SpellNonMeleeDamage(caster, caster, GetSpellInfo(), GetAura().GetSpellVisual(), GetSpellInfo().SchoolMask, GetAura().GetCastId()); + SpellNonMeleeDamage damageInfo = new(caster, caster, GetSpellInfo(), GetAura().GetSpellVisual(), GetSpellInfo().SchoolMask, GetAura().GetCastId()); damageInfo.periodicLog = true; damageInfo.damage = damage; caster.DealSpellDamage(damageInfo, false); @@ -473,7 +473,7 @@ namespace Scripts.Spells.Warlock public List GetDotList() { return _dotList; } public Unit GetOriginalSwapSource() { return _swapCaster; } public void SetOriginalSwapSource(Unit victim) { _swapCaster = victim; } - List _dotList = new List(); + List _dotList = new(); Unit _swapCaster; } @@ -547,7 +547,7 @@ namespace Scripts.Spells.Warlock GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapModCost, true); bool hasGlyph = GetCaster().HasAura(SpellIds.GlyphOfSoulSwap); - List dotList = new List(); + List dotList = new(); Unit swapSource = null; Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride); if (swapOverride != null) @@ -671,7 +671,7 @@ namespace Scripts.Spells.Warlock void HandleDummyTick(AuraEffect aurEff) { List rainOfFireAreaTriggers = GetTarget().GetAreaTriggers(SpellIds.RainOfFire); - List targetsInRainOfFire = new List(); + List targetsInRainOfFire = new(); foreach (AreaTrigger rainOfFireAreaTrigger in rainOfFireAreaTriggers) { diff --git a/Source/Scripts/Spells/Warrior.cs b/Source/Scripts/Spells/Warrior.cs index d56c26e5f..0f026140f 100644 --- a/Source/Scripts/Spells/Warrior.cs +++ b/Source/Scripts/Spells/Warrior.cs @@ -196,7 +196,7 @@ namespace Scripts.Spells.Warrior { float range = GetSpellInfo().GetMaxRange(true, GetCaster()) * 1.5f; - PathGenerator generatedPath = new PathGenerator(GetCaster()); + PathGenerator generatedPath = new(GetCaster()); generatedPath.SetPathLengthLimit(range); bool result = generatedPath.CalculatePath(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, true); diff --git a/Source/Scripts/World/AreaTrigger.cs b/Source/Scripts/World/AreaTrigger.cs index c982398dc..0b2dec181 100644 --- a/Source/Scripts/World/AreaTrigger.cs +++ b/Source/Scripts/World/AreaTrigger.cs @@ -139,8 +139,8 @@ namespace Scripts.World.Areatriggers public const uint TypeWaypoint = 0; public const uint DataStart = 0; - public static Position StormforgedMonitorPosition = new Position(6963.95f, 45.65f, 818.71f, 4.948f); - public static Position StormforgedEradictorPosition = new Position(6983.18f, 7.15f, 806.33f, 2.228f); + public static Position StormforgedMonitorPosition = new(6963.95f, 45.65f, 818.71f, 4.948f); + public static Position StormforgedEradictorPosition = new(6983.18f, 7.15f, 806.33f, 2.228f); } [Script] diff --git a/Source/Scripts/World/GameObject.cs b/Source/Scripts/World/GameObject.cs index 0a7bf4ac0..7d53a64a2 100644 --- a/Source/Scripts/World/GameObject.cs +++ b/Source/Scripts/World/GameObject.cs @@ -981,7 +981,7 @@ namespace Scripts.World.GameObjects me.UseDoorOrButton(); if (player.GetQuestStatus(QuestIds.MissingFriends) == QuestStatus.Incomplete) { - List childrenList = new List(); + List childrenList = new(); me.GetCreatureListWithEntryInGrid(childrenList, CreatureIds.CaptiveChild, SharedConst.InteractionDistance); foreach (Creature creature in childrenList) { diff --git a/Source/Scripts/World/ItemScripts.cs b/Source/Scripts/World/ItemScripts.cs index 830acf6b6..644de7685 100644 --- a/Source/Scripts/World/ItemScripts.cs +++ b/Source/Scripts/World/ItemScripts.cs @@ -188,7 +188,7 @@ namespace Scripts.World.ItemScripts public override bool OnExpire(Player player, ItemTemplate pItemProto) { - List dest = new List(); + List dest = new(); InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, 39883, 1); // Cracked Egg if (msg == InventoryResult.Ok) player.StoreNewItem(dest, 39883, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(39883)); @@ -204,7 +204,7 @@ namespace Scripts.World.ItemScripts public override bool OnExpire(Player player, ItemTemplate pItemProto) { - List dest = new List(); + List dest = new(); InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, 44718, 1); // Ripe Disgusting Jar if (msg == InventoryResult.Ok) player.StoreNewItem(dest, 44718, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(44718)); diff --git a/Source/Scripts/World/NpcSpecial.cs b/Source/Scripts/World/NpcSpecial.cs index f6a475c23..5c4761f62 100644 --- a/Source/Scripts/World/NpcSpecial.cs +++ b/Source/Scripts/World/NpcSpecial.cs @@ -234,7 +234,7 @@ namespace Scripts.World.NpcSpecial public const uint StuffingServer = 61795; public const uint TurkeyServer = 61796; public const uint SweetPotatoesServer = 61797; - public static Dictionary ChairSpells = new Dictionary() + public static Dictionary ChairSpells = new() { { CreatureIds.TheCranberryChair, CranberryServer }, { CreatureIds.ThePieChair, PieServer }, @@ -409,7 +409,7 @@ namespace Scripts.World.NpcSpecial }; //alliance run to where - public static Position DoctorAllianceRunTo = new Position(-3742.96f, -4531.52f, 11.91f); + public static Position DoctorAllianceRunTo = new(-3742.96f, -4531.52f, 11.91f); public static Position[] DoctorHordeCoords = { @@ -422,7 +422,7 @@ namespace Scripts.World.NpcSpecial }; //horde run to where - public static Position DoctorHordeRunTo = new Position(-1016.44f, -3508.48f, 62.96f); + public static Position DoctorHordeRunTo = new(-1016.44f, -3508.48f, 62.96f); public static uint[] AllianceSoldierId = { @@ -445,7 +445,7 @@ namespace Scripts.World.NpcSpecial public const uint AnimGoLaunchFirework = 3; public const uint ZoneMoonglade = 493; - public static Position omenSummonPos = new Position(7558.993f, -2839.999f, 450.0214f, 4.46f); + public static Position omenSummonPos = new(7558.993f, -2839.999f, 450.0214f, 4.46f); public const uint AuraDurationTimeLeft = 5000; @@ -761,7 +761,7 @@ namespace Scripts.World.NpcSpecial ObjectGuid DoSearchForTargets(ObjectGuid lastTargetGUID) { - List targets = new List(); + List targets = new(); me.GetCreatureListWithEntryInGrid(targets, CreatureIds.TorchTossingTargetBunny, 60.0f); targets.RemoveAll(creature => creature.GetGUID() == lastTargetGUID); @@ -854,7 +854,7 @@ namespace Scripts.World.NpcSpecial bool checkNearbyPlayers() { // Returns true if no nearby player has aura "Test Ribbon Pole Channel". - List players = new List(); + List players = new(); var check = new UnitAuraCheck(true, SpellIds.RibbonDanceCosmetic); var searcher = new PlayerListSearcher(me, players, check); Cell.VisitWorldObjects(me, searcher, 10.0f); @@ -1055,8 +1055,8 @@ namespace Scripts.World.NpcSpecial bool Event; - List Patients = new List(); - List Coordinates = new List(); + List Patients = new(); + List Coordinates = new(); } [Script] @@ -2319,7 +2319,7 @@ namespace Scripts.World.NpcSpecial break; } - MoveSplineInit init = new MoveSplineInit(who); + MoveSplineInit init = new(who); init.DisableTransportPathTransformations(); init.MoveTo(x, y, z, false); init.SetFacing(o);