From 7f1b58ab241abba0a689ecab715bb3747e086ac9 Mon Sep 17 00:00:00 2001 From: FlaggAC <65846074+FlaggAC@users.noreply.github.com> Date: Sat, 24 Aug 2024 07:32:35 -0700 Subject: [PATCH] Change static readonly fields to const fields. (#4211) This will at least somewhat improve performance, as confirmed through microbenchmark testing. const fields are replaced with literal values in the Assembly's IL code, while static readonly fields may be optimized by the JIT, and is not guaranteed to happen. const fields may also lend themselves to stronger optimizations at runtime. --- Source/ACE.Common/DerethDateTime.cs | 40 +++++++-------- Source/ACE.Common/ThreadSafeRandom.cs | 2 +- Source/ACE.DatLoader/DatDatabase.cs | 2 +- Source/ACE.DatLoader/DatDirectoryHeader.cs | 2 +- Source/ACE.DatLoader/DatFile.cs | 2 +- .../WorldDatabaseWithEntityCache.cs | 2 +- Source/ACE.Entity/Position.cs | 6 +-- .../Command/Handlers/DeveloperFixCommands.cs | 4 +- Source/ACE.Server/Entity/Chess/ChessMatch.cs | 2 +- Source/ACE.Server/Entity/Cloak.cs | 4 +- Source/ACE.Server/Entity/Fellowship.cs | 2 +- Source/ACE.Server/Entity/LandblockMesh.cs | 8 +-- .../Entity/Mutations/MutationCache.cs | 2 +- .../Factories/Entity/ChanceTable.cs | 2 +- .../Factories/LootGenerationFactory.cs | 8 +-- .../Tables/Cantrips/ArmorCantrips.cs | 2 +- .../Tables/Cantrips/JewelryCantrips.cs | 2 +- .../Tables/Cantrips/MeleeCantrips.cs | 2 +- .../Tables/Cantrips/MissileCantrips.cs | 2 +- .../Factories/Tables/Cantrips/WandCantrips.cs | 2 +- .../Factories/Tables/Spells/ArmorSpells.cs | 2 +- .../Factories/Tables/Spells/GemSpells.cs | 2 +- .../Factories/Tables/Spells/JewelrySpells.cs | 2 +- .../Factories/Tables/Spells/MeleeSpells.cs | 2 +- .../Factories/Tables/Spells/MissileSpells.cs | 2 +- .../Factories/Tables/Spells/ScrollSpells.cs | 4 +- .../Factories/Tables/Spells/WandSpells.cs | 2 +- Source/ACE.Server/Managers/RecipeManager.cs | 2 +- .../GameAction/Actions/GameActionQueryAge.cs | 26 +++++----- .../GameEvent/Events/GameEventStartBarber.cs | 4 +- .../Network/Structure/AllegianceHierarchy.cs | 4 +- .../Network/Structure/AppraiseInfo.cs | 2 +- .../Network/Structure/RestrictionDB.cs | 4 +- .../Physics/Animation/MotionInterp.cs | 14 +++--- .../Physics/Animation/MovementParameters.cs | 12 ++--- Source/ACE.Server/Physics/Common/LandDefs.cs | 50 +++++++++---------- .../ACE.Server/Physics/Common/ObjectMaint.cs | 2 +- Source/ACE.Server/Physics/Common/Position.cs | 4 +- .../Physics/Managers/InterpolationManager.cs | 4 +- .../Physics/Managers/StickyManager.cs | 4 +- Source/ACE.Server/Physics/PhysicsGlobals.cs | 42 ++++++++-------- Source/ACE.Server/Physics/PhysicsObj.cs | 2 +- Source/ACE.Server/Physics/Sphere.cs | 4 +- Source/ACE.Server/WorldObjects/Corpse.cs | 2 +- .../ACE.Server/WorldObjects/Creature_Melee.cs | 8 +-- .../WorldObjects/Creature_Missile.cs | 10 ++-- Source/ACE.Server/WorldObjects/Healer.cs | 2 +- .../Managers/ConfirmationManager.cs | 2 +- .../WorldObjects/Monster_Awareness.cs | 4 +- .../ACE.Server/WorldObjects/Monster_Magic.cs | 6 +-- .../WorldObjects/Monster_Missile.cs | 2 +- .../WorldObjects/Monster_Navigation.cs | 14 +++--- Source/ACE.Server/WorldObjects/Pet.cs | 6 +-- Source/ACE.Server/WorldObjects/Player.cs | 4 +- .../ACE.Server/WorldObjects/Player_Combat.cs | 2 +- .../WorldObjects/Player_Commerce.cs | 2 +- .../WorldObjects/Player_Database.cs | 2 +- .../ACE.Server/WorldObjects/Player_Death.cs | 2 +- .../WorldObjects/Player_Location.cs | 2 +- .../ACE.Server/WorldObjects/Player_Magic.cs | 2 +- .../ACE.Server/WorldObjects/Player_Melee.cs | 8 +-- Source/ACE.Server/WorldObjects/Portal.cs | 2 +- .../ACE.Server/WorldObjects/SkillFormula.cs | 6 +-- Source/ACE.Server/WorldObjects/Vendor.cs | 2 +- Source/ACE.Server/WorldObjects/WorldObject.cs | 4 +- .../WorldObjects/WorldObject_Magic.cs | 6 +-- .../WorldObjects/WorldObject_Weapon.cs | 4 +- 67 files changed, 199 insertions(+), 199 deletions(-) diff --git a/Source/ACE.Common/DerethDateTime.cs b/Source/ACE.Common/DerethDateTime.cs index 28131eec85..51acc0e26e 100644 --- a/Source/ACE.Common/DerethDateTime.cs +++ b/Source/ACE.Common/DerethDateTime.cs @@ -8,29 +8,29 @@ namespace ACE.Common public class DerethDateTime { // Changing the four variables below will result in the Date and Time reported in ACClient no longer matching - private static int hoursInADay = 16; // A Derethian day has 16 hours - private static int daysInAMonth = 30; // A Derethian month has 30 days and does not vary like Earth months. - private static int monthsInAYear = 12; // A Derethian year has 12 months - private static double dayTicks = 7620; // A Derethain day has 7620 ticks per day + private const int hoursInADay = 16; // A Derethian day has 16 hours + private const int daysInAMonth = 30; // A Derethian month has 30 days and does not vary like Earth months. + private const int monthsInAYear = 12; // A Derethian year has 12 months + private const double dayTicks = 7620; // A Derethain day has 7620 ticks per day - private static double hourTicks = dayTicks / hoursInADay; - private static double minuteTicks = hourTicks / 60; - private static double secondTicks = minuteTicks / 60; + private const double hourTicks = dayTicks / hoursInADay; + private const double minuteTicks = hourTicks / 60; + private const double secondTicks = minuteTicks / 60; - private static double monthTicks = dayTicks * daysInAMonth; - private static double yearTicks = monthTicks * monthsInAYear; + private const double monthTicks = dayTicks * daysInAMonth; + private const double yearTicks = monthTicks * monthsInAYear; - private static double dayZeroTicks = 0; // Morningthaw 1, 10 P.Y. - Morntide-and-Half - private static double hourOneTicks = 210; // Morningthaw 1, 10 P.Y. - Midsong - private static double dayOneTicks = dayZeroTicks + hourOneTicks + (hourTicks * 8); // Morningthaw 2, 10 P.Y. - Darktide - private static double yearOneTicks = dayOneTicks + (dayTicks * 359); // Morningthaw 1, 11 P.Y. - Darktide - private static double yearZeroTicks = dayOneTicks + (dayTicks * 269); // Snowreap 1, 10 P.Y. - Darktide + private const double dayZeroTicks = 0; // Morningthaw 1, 10 P.Y. - Morntide-and-Half + private const double hourOneTicks = 210; // Morningthaw 1, 10 P.Y. - Midsong + private const double dayOneTicks = dayZeroTicks + hourOneTicks + (hourTicks * 8); // Morningthaw 2, 10 P.Y. - Darktide + private const double yearOneTicks = dayOneTicks + (dayTicks * 359); // Morningthaw 1, 11 P.Y. - Darktide + private const double yearZeroTicks = dayOneTicks + (dayTicks * 269); // Snowreap 1, 10 P.Y. - Darktide - private static DateTime dayZero_RealWorld = new DateTime(1999, 4, 1, 10, 30, 00); - private static DateTime dayOne_RealWorld = new DateTime(1999, 4, 2, 00, 00, 00); + private static readonly DateTime dayZero_RealWorld = new DateTime(1999, 4, 1, 10, 30, 00); + private static readonly DateTime dayOne_RealWorld = new DateTime(1999, 4, 2, 00, 00, 00); - private static DateTime retailDayOne_RealWorld = new DateTime(1999, 11, 2, 00, 00, 00); - private static DateTime retailDayLast_RealWorld = new DateTime(2017, 1, 31, 12, 00, 00); // Eastern Standard Time + private static readonly DateTime retailDayOne_RealWorld = new DateTime(1999, 11, 2, 00, 00, 00); + private static readonly DateTime retailDayLast_RealWorld = new DateTime(2017, 1, 31, 12, 00, 00); // Eastern Standard Time /// /// A instance set to the Derethian Date, Portal Year and Time when the worlds first opened. @@ -55,13 +55,13 @@ public class DerethDateTime /// /// Date: Morningthaw 1, 10 P.Y. | Time: Morntide-and-Half (0) /// - public static readonly double MinValue = 0; // Morningthaw 1, 10 P.Y. - Morntide-and-Half + public const double MinValue = 0; // Morningthaw 1, 10 P.Y. - Morntide-and-Half /// /// Any value higher than this results in acclient crashing upon connection to server. /// Date: Thistledown 2, 401 P.Y. | Time: Morntide-and-Half (1073741828) /// - public static readonly double MaxValue = (yearTicks * 391) + (monthTicks * 5) + (dayTicks * 1) + 4; // Thistledown 2, 401 P.Y. - Morntide-and-Half (1073741828) + public const double MaxValue = (yearTicks * 391) + (monthTicks * 5) + (dayTicks * 1) + 4; // Thistledown 2, 401 P.Y. - Morntide-and-Half (1073741828) /// /// Months of the Portal Year diff --git a/Source/ACE.Common/ThreadSafeRandom.cs b/Source/ACE.Common/ThreadSafeRandom.cs index b7673dba7a..fec221bcf6 100644 --- a/Source/ACE.Common/ThreadSafeRandom.cs +++ b/Source/ACE.Common/ThreadSafeRandom.cs @@ -38,7 +38,7 @@ public static double NextInterval(float qualityMod) /// /// The maximum possible double < 1.0 /// - private static readonly double maxExclusive = 0.9999999999999999; + private const double maxExclusive = 0.9999999999999999; public static double NextIntervalMax(float qualityMod) { diff --git a/Source/ACE.DatLoader/DatDatabase.cs b/Source/ACE.DatLoader/DatDatabase.cs index 79d43db575..875a6c9c3c 100644 --- a/Source/ACE.DatLoader/DatDatabase.cs +++ b/Source/ACE.DatLoader/DatDatabase.cs @@ -13,7 +13,7 @@ public class DatDatabase { private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private static readonly uint DAT_HEADER_OFFSET = 0x140; + private const uint DAT_HEADER_OFFSET = 0x140; public string FilePath { get; } diff --git a/Source/ACE.DatLoader/DatDirectoryHeader.cs b/Source/ACE.DatLoader/DatDirectoryHeader.cs index f96fbec2a3..cc480adfa9 100644 --- a/Source/ACE.DatLoader/DatDirectoryHeader.cs +++ b/Source/ACE.DatLoader/DatDirectoryHeader.cs @@ -4,7 +4,7 @@ namespace ACE.DatLoader { public class DatDirectoryHeader : IUnpackable { - internal static readonly uint ObjectSize = ((sizeof(uint) * 0x3E) + sizeof(uint) + (DatFile.ObjectSize * 0x3D)); + internal const uint ObjectSize = ((sizeof(uint) * 0x3E) + sizeof(uint) + (DatFile.ObjectSize * 0x3D)); public uint[] Branches { get; } = new uint[0x3E]; public uint EntryCount { get; private set; } diff --git a/Source/ACE.DatLoader/DatFile.cs b/Source/ACE.DatLoader/DatFile.cs index 8721c3445f..9271520e52 100644 --- a/Source/ACE.DatLoader/DatFile.cs +++ b/Source/ACE.DatLoader/DatFile.cs @@ -7,7 +7,7 @@ namespace ACE.DatLoader { public class DatFile : IUnpackable { - internal static readonly uint ObjectSize = (sizeof(uint) * 6); + internal const uint ObjectSize = (sizeof(uint) * 6); //public uint BitFlags { get; private set; } diff --git a/Source/ACE.Database/WorldDatabaseWithEntityCache.cs b/Source/ACE.Database/WorldDatabaseWithEntityCache.cs index 328f5e9ca7..92f15321d9 100644 --- a/Source/ACE.Database/WorldDatabaseWithEntityCache.cs +++ b/Source/ACE.Database/WorldDatabaseWithEntityCache.cs @@ -863,7 +863,7 @@ public void CacheAllTreasureMaterialBase() } } - private static readonly float NormalizeEpsilon = 0.00001f; + private const float NormalizeEpsilon = 0.00001f; private void TreasureMaterialBase_Normalize(Dictionary>> materialBase) { diff --git a/Source/ACE.Entity/Position.cs b/Source/ACE.Entity/Position.cs index 76372b804c..5c5c3ab68b 100644 --- a/Source/ACE.Entity/Position.cs +++ b/Source/ACE.Entity/Position.cs @@ -503,9 +503,9 @@ public string ToLOCString() return $"0x{LandblockId.Raw:X8} [{PositionX:F6} {PositionY:F6} {PositionZ:F6}] {RotationW:F6} {RotationX:F6} {RotationY:F6} {RotationZ:F6}"; } - public static readonly int BlockLength = 192; - public static readonly int CellSide = 8; - public static readonly int CellLength = 24; + public const int BlockLength = 192; + public const int CellSide = 8; + public const int CellLength = 24; public bool Equals(Position p) { diff --git a/Source/ACE.Server/Command/Handlers/DeveloperFixCommands.cs b/Source/ACE.Server/Command/Handlers/DeveloperFixCommands.cs index 142067bb5a..710ea4451d 100644 --- a/Source/ACE.Server/Command/Handlers/DeveloperFixCommands.cs +++ b/Source/ACE.Server/Command/Handlers/DeveloperFixCommands.cs @@ -1333,10 +1333,10 @@ public static Dictionary GetImbuedEffect() } // head / hands / feet - public static readonly int MaxArmorLevel_Extremity = 345; + public const int MaxArmorLevel_Extremity = 345; // everything else - public static readonly int MaxArmorLevel_NonExtremity = 315; + public const int MaxArmorLevel_NonExtremity = 315; public static int GetArmorLevel(int armorLevel, EquipMask equipMask, TinkerLog tinkerLog, int numTinkers, int imbuedEffect) { diff --git a/Source/ACE.Server/Entity/Chess/ChessMatch.cs b/Source/ACE.Server/Entity/Chess/ChessMatch.cs index b18e4b4ef2..815ad27a4e 100644 --- a/Source/ACE.Server/Entity/Chess/ChessMatch.cs +++ b/Source/ACE.Server/Entity/Chess/ChessMatch.cs @@ -711,7 +711,7 @@ public void SendGameOver(Player player, int winner) /// /// How quickly the rankings will raise / lower /// - public static readonly int RankFactor = 50; + public const int RankFactor = 50; /// /// Adjusts the chess ranks for 2 players after a match diff --git a/Source/ACE.Server/Entity/Cloak.cs b/Source/ACE.Server/Entity/Cloak.cs index bfc1f4f605..bcf472753d 100644 --- a/Source/ACE.Server/Entity/Cloak.cs +++ b/Source/ACE.Server/Entity/Cloak.cs @@ -77,7 +77,7 @@ private static float MaxProcBase200 } } - private static readonly float TwoThirds = 2.0f / 3.0f; + private const float TwoThirds = 2.0f / 3.0f; /// /// Rolls for a chance at procing a cloak spell @@ -197,7 +197,7 @@ public static bool IsCloak(WorldObject wo) /// /// The amount of damage reduced by a cloak proced with PropertyInt.CloakWeaveProc=2 /// - public static readonly int DamageReductionAmount = 200; + public const int DamageReductionAmount = 200; public static int GetDamageReductionAmount(WorldObject source) { diff --git a/Source/ACE.Server/Entity/Fellowship.cs b/Source/ACE.Server/Entity/Fellowship.cs index b31140cac7..4b7fc5bc92 100644 --- a/Source/ACE.Server/Entity/Fellowship.cs +++ b/Source/ACE.Server/Entity/Fellowship.cs @@ -630,7 +630,7 @@ internal double GetMemberSharePercent() return 1.0; } - public static readonly int MaxDistance = 600; + public const int MaxDistance = 600; /// /// Returns the amount to scale the XP for a fellow diff --git a/Source/ACE.Server/Entity/LandblockMesh.cs b/Source/ACE.Server/Entity/LandblockMesh.cs index 7b8b61434f..3adcf3bf3d 100644 --- a/Source/ACE.Server/Entity/LandblockMesh.cs +++ b/Source/ACE.Server/Entity/LandblockMesh.cs @@ -22,22 +22,22 @@ public class LandblockMesh: Mesh /// /// A landblock has this many cells squared /// - public static readonly int CellDim = 8; + public const int CellDim = 8; /// /// A landblock is this unit size squared /// - public static readonly int LandblockSize = 192; + public const int LandblockSize = 192; /// /// A landblock cell is this unit size squared /// - public static readonly int CellSize = LandblockSize / CellDim; + public const int CellSize = LandblockSize / CellDim; /// /// A landblock has this many vertices squared /// - public static readonly int VertexDim = CellDim + 1; + public const int VertexDim = CellDim + 1; /// /// LandHeightTable mapping non-linear heights diff --git a/Source/ACE.Server/Entity/Mutations/MutationCache.cs b/Source/ACE.Server/Entity/Mutations/MutationCache.cs index f652270964..dea1242221 100644 --- a/Source/ACE.Server/Entity/Mutations/MutationCache.cs +++ b/Source/ACE.Server/Entity/Mutations/MutationCache.cs @@ -512,7 +512,7 @@ public static string GetSecondOperator(MutationEffectType effectType) return null; } - private static readonly string prefix = "ACE.Server.Entity.Mutations."; + private const string prefix = "ACE.Server.Entity.Mutations."; private static List ReadScript(string filename) { diff --git a/Source/ACE.Server/Factories/Entity/ChanceTable.cs b/Source/ACE.Server/Factories/Entity/ChanceTable.cs index f481ea47b7..294e0626e5 100644 --- a/Source/ACE.Server/Factories/Entity/ChanceTable.cs +++ b/Source/ACE.Server/Factories/Entity/ChanceTable.cs @@ -10,7 +10,7 @@ namespace ACE.Server.Factories.Entity public class ChanceTable : List<(T result, float chance)> { private bool verified; - private static readonly decimal threshold = 0.0000001M; + private const decimal threshold = 0.0000001M; private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); diff --git a/Source/ACE.Server/Factories/LootGenerationFactory.cs b/Source/ACE.Server/Factories/LootGenerationFactory.cs index 7c1f15bda8..d33ff6c3c8 100644 --- a/Source/ACE.Server/Factories/LootGenerationFactory.cs +++ b/Source/ACE.Server/Factories/LootGenerationFactory.cs @@ -736,8 +736,8 @@ public static MaterialType RollGemType(int tier) return gemResult.MaterialType; } - public static readonly float WeaponBulk = 0.50f; - public static readonly float ArmorBulk = 0.25f; + public const float WeaponBulk = 0.50f; + public const float ArmorBulk = 0.25f; private static bool MutateBurden(WorldObject wo, TreasureDeath treasureDeath, bool isWeapon) { @@ -839,9 +839,9 @@ private static void MutateValue(WorldObject wo, int tier, TreasureRoll roll) } // increase for a wider variance in item value ranges - private static readonly float valueFactor = 1.0f / 3.0f; + private const float valueFactor = 1.0f / 3.0f; - private static readonly float valueNonFactor = 1.0f - valueFactor; + private const float valueNonFactor = 1.0f - valueFactor; private static void MutateValue_Generic(WorldObject wo, int tier) { diff --git a/Source/ACE.Server/Factories/Tables/Cantrips/ArmorCantrips.cs b/Source/ACE.Server/Factories/Tables/Cantrips/ArmorCantrips.cs index 062ad41131..4b6fa60aac 100644 --- a/Source/ACE.Server/Factories/Tables/Cantrips/ArmorCantrips.cs +++ b/Source/ACE.Server/Factories/Tables/Cantrips/ArmorCantrips.cs @@ -95,7 +95,7 @@ public static class ArmorCantrips SpellId.CANTRIPPIERCINGBANE1, }; - private static readonly int NumLevels = 4; + private const int NumLevels = 4; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Cantrips/JewelryCantrips.cs b/Source/ACE.Server/Factories/Tables/Cantrips/JewelryCantrips.cs index 20efcd450b..ea2d618a5f 100644 --- a/Source/ACE.Server/Factories/Tables/Cantrips/JewelryCantrips.cs +++ b/Source/ACE.Server/Factories/Tables/Cantrips/JewelryCantrips.cs @@ -73,7 +73,7 @@ public static class JewelryCantrips SpellId.CANTRIPPIERCINGWARD1, }; - private static readonly int NumLevels = 4; + private const int NumLevels = 4; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Cantrips/MeleeCantrips.cs b/Source/ACE.Server/Factories/Tables/Cantrips/MeleeCantrips.cs index 59f1cef126..cb608c4181 100644 --- a/Source/ACE.Server/Factories/Tables/Cantrips/MeleeCantrips.cs +++ b/Source/ACE.Server/Factories/Tables/Cantrips/MeleeCantrips.cs @@ -29,7 +29,7 @@ public static class MeleeCantrips SpellId.CantripSneakAttackProwess1, }; - private static readonly int NumLevels = 4; + private const int NumLevels = 4; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Cantrips/MissileCantrips.cs b/Source/ACE.Server/Factories/Tables/Cantrips/MissileCantrips.cs index 2e445498aa..a2d851017a 100644 --- a/Source/ACE.Server/Factories/Tables/Cantrips/MissileCantrips.cs +++ b/Source/ACE.Server/Factories/Tables/Cantrips/MissileCantrips.cs @@ -28,7 +28,7 @@ public static class MissileCantrips SpellId.CantripSneakAttackProwess1, }; - private static readonly int NumLevels = 4; + private const int NumLevels = 4; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Cantrips/WandCantrips.cs b/Source/ACE.Server/Factories/Tables/Cantrips/WandCantrips.cs index f396ed00bf..2b7a897092 100644 --- a/Source/ACE.Server/Factories/Tables/Cantrips/WandCantrips.cs +++ b/Source/ACE.Server/Factories/Tables/Cantrips/WandCantrips.cs @@ -32,7 +32,7 @@ public static class WandCantrips SpellId.CantripSpiritThirst1, }; - private static readonly int NumLevels = 4; + private const int NumLevels = 4; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Spells/ArmorSpells.cs b/Source/ACE.Server/Factories/Tables/Spells/ArmorSpells.cs index 4562ae9903..35de03fd49 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/ArmorSpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/ArmorSpells.cs @@ -103,7 +103,7 @@ public static class ArmorSpells SpellId.LightningBane1, }; - private static readonly int NumTiers = 8; + private const int NumTiers = 8; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Spells/GemSpells.cs b/Source/ACE.Server/Factories/Tables/Spells/GemSpells.cs index 8d09483f13..68573cca5a 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/GemSpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/GemSpells.cs @@ -87,7 +87,7 @@ public static class GemSpells SpellId.LightningProtectionSelf1, }; - private static readonly int NumTiers = 8; + private const int NumTiers = 8; // original api public static readonly SpellId[][] GemCreatureSpellMatrix = new SpellId[NumTiers][]; diff --git a/Source/ACE.Server/Factories/Tables/Spells/JewelrySpells.cs b/Source/ACE.Server/Factories/Tables/Spells/JewelrySpells.cs index e366d87141..4d621ff8f2 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/JewelrySpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/JewelrySpells.cs @@ -85,7 +85,7 @@ public static class JewelrySpells SpellId.LightningProtectionSelf1, }; - private static readonly int NumTiers = 8; + private const int NumTiers = 8; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Spells/MeleeSpells.cs b/Source/ACE.Server/Factories/Tables/Spells/MeleeSpells.cs index d0945d362d..5c40e0eab9 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/MeleeSpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/MeleeSpells.cs @@ -30,7 +30,7 @@ public static class MeleeSpells SpellId.SneakAttackMasterySelf1, }; - private static readonly int NumTiers = 8; + private const int NumTiers = 8; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Spells/MissileSpells.cs b/Source/ACE.Server/Factories/Tables/Spells/MissileSpells.cs index 39ca0210f6..348f256582 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/MissileSpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/MissileSpells.cs @@ -29,7 +29,7 @@ public static class MissileSpells SpellId.SneakAttackMasterySelf1, }; - private static readonly int NumTiers = 8; + private const int NumTiers = 8; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Factories/Tables/Spells/ScrollSpells.cs b/Source/ACE.Server/Factories/Tables/Spells/ScrollSpells.cs index c2b6718644..a91fcad2c5 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/ScrollSpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/ScrollSpells.cs @@ -346,9 +346,9 @@ public static class ScrollSpells SpellId.CurseWeakness1, }; - private static readonly int NumLevels = 7; + private const int NumLevels = 7; - private static readonly int MaxLevels = 8; + private const int MaxLevels = 8; private static readonly int NumSpells = creatureSpells.Count + lifeSpells.Count + itemSpells.Count + warSpells.Count + voidSpells.Count; diff --git a/Source/ACE.Server/Factories/Tables/Spells/WandSpells.cs b/Source/ACE.Server/Factories/Tables/Spells/WandSpells.cs index e3375554f2..40f60ff39b 100644 --- a/Source/ACE.Server/Factories/Tables/Spells/WandSpells.cs +++ b/Source/ACE.Server/Factories/Tables/Spells/WandSpells.cs @@ -34,7 +34,7 @@ public static class WandSpells SpellId.SneakAttackMasterySelf1, }; - private static readonly int NumTiers = 8; + private const int NumTiers = 8; // original api public static readonly SpellId[][] Table = new SpellId[spells.Count][]; diff --git a/Source/ACE.Server/Managers/RecipeManager.cs b/Source/ACE.Server/Managers/RecipeManager.cs index d9d57b645b..36554713c9 100644 --- a/Source/ACE.Server/Managers/RecipeManager.cs +++ b/Source/ACE.Server/Managers/RecipeManager.cs @@ -1479,7 +1479,7 @@ public static void ModifyDataID(Player player, RecipeModsDID didMod, WorldObject /// /// flag to use c# logic instead of mutate script logic /// - private static readonly bool useMutateNative = false; + private const bool useMutateNative = false; public static bool TryMutate(Player player, WorldObject source, WorldObject target, Recipe recipe, uint dataId, HashSet modified) { diff --git a/Source/ACE.Server/Network/GameAction/Actions/GameActionQueryAge.cs b/Source/ACE.Server/Network/GameAction/Actions/GameActionQueryAge.cs index 36e175026b..3247e2d0ea 100644 --- a/Source/ACE.Server/Network/GameAction/Actions/GameActionQueryAge.cs +++ b/Source/ACE.Server/Network/GameAction/Actions/GameActionQueryAge.cs @@ -17,19 +17,19 @@ public static void Handle(ClientMessage message, Session session) session.Network.EnqueueSend(new GameEventQueryAgeResponse(session, string.Empty, ageMsg)); } - private static readonly int SecondsPerMinute = 60; - private static readonly int MinutesPerHour = 60; - private static readonly int HoursPerDay = 24; - - private static readonly int DaysPerWeek = 7; - private static readonly int DaysPerMonth = 30; - private static readonly int DaysPerYear = 365; - - private static readonly int SecondsPerHour = SecondsPerMinute * MinutesPerHour; // 3600 - private static readonly int SecondsPerDay = SecondsPerHour * HoursPerDay; // 86400 - private static readonly int SecondsPerWeek = SecondsPerDay * DaysPerWeek; // 604800 - private static readonly int SecondsPerMonth = SecondsPerDay * DaysPerMonth; // 2592000 - private static readonly int SecondsPerYear = SecondsPerDay * DaysPerYear; // 31536000 + private const int SecondsPerMinute = 60; + private const int MinutesPerHour = 60; + private const int HoursPerDay = 24; + + private const int DaysPerWeek = 7; + private const int DaysPerMonth = 30; + private const int DaysPerYear = 365; + + private const int SecondsPerHour = SecondsPerMinute * MinutesPerHour; // 3600 + private const int SecondsPerDay = SecondsPerHour * HoursPerDay; // 86400 + private const int SecondsPerWeek = SecondsPerDay * DaysPerWeek; // 604800 + private const int SecondsPerMonth = SecondsPerDay * DaysPerMonth; // 2592000 + private const int SecondsPerYear = SecondsPerDay * DaysPerYear; // 31536000 public static string CalculateAgeMessage(int ageSeconds) { diff --git a/Source/ACE.Server/Network/GameEvent/Events/GameEventStartBarber.cs b/Source/ACE.Server/Network/GameEvent/Events/GameEventStartBarber.cs index 0c65e85c2a..c55a8d9383 100644 --- a/Source/ACE.Server/Network/GameEvent/Events/GameEventStartBarber.cs +++ b/Source/ACE.Server/Network/GameEvent/Events/GameEventStartBarber.cs @@ -2,8 +2,8 @@ namespace ACE.Server.Network.GameEvent.Events { public class GameEventStartBarber : GameEventMessage { - public static readonly uint EmpyreanMaleMotionDID = 0x0900020E; - public static readonly uint EmpyreanFemaleMotionDID = 0x0900020D; + public const uint EmpyreanMaleMotionDID = 0x0900020E; + public const uint EmpyreanFemaleMotionDID = 0x0900020D; public GameEventStartBarber(Session session) : base(GameEventType.StartBarber, GameMessageGroup.UIQueue, session, 68) diff --git a/Source/ACE.Server/Network/Structure/AllegianceHierarchy.cs b/Source/ACE.Server/Network/Structure/AllegianceHierarchy.cs index 61ef571692..18abb69159 100644 --- a/Source/ACE.Server/Network/Structure/AllegianceHierarchy.cs +++ b/Source/ACE.Server/Network/Structure/AllegianceHierarchy.cs @@ -163,8 +163,8 @@ public static void Write(this BinaryWriter writer, AllegianceHierarchy hierarchy // aside from RestrictionDB, this appears to be the only other place in the client that calls PHashTable/IntrusiveHashTable constructor directly // 256 is ignored, and 23 is used - private static readonly ushort headerNumBuckets = 256; - private static readonly ushort actualNumBuckets = 23; + private const ushort headerNumBuckets = 256; + private const ushort actualNumBuckets = 23; private static readonly GuidComparer guidComparer = new GuidComparer(actualNumBuckets); diff --git a/Source/ACE.Server/Network/Structure/AppraiseInfo.cs b/Source/ACE.Server/Network/Structure/AppraiseInfo.cs index 8d600995b4..a5df76a991 100644 --- a/Source/ACE.Server/Network/Structure/AppraiseInfo.cs +++ b/Source/ACE.Server/Network/Structure/AppraiseInfo.cs @@ -18,7 +18,7 @@ namespace ACE.Server.Network.Structure /// public class AppraiseInfo { - private static readonly uint EnchantmentMask = 0x80000000; + private const uint EnchantmentMask = 0x80000000; public IdentifyResponseFlags Flags; diff --git a/Source/ACE.Server/Network/Structure/RestrictionDB.cs b/Source/ACE.Server/Network/Structure/RestrictionDB.cs index d26ad5e83e..a7f1cf5e65 100644 --- a/Source/ACE.Server/Network/Structure/RestrictionDB.cs +++ b/Source/ACE.Server/Network/Structure/RestrictionDB.cs @@ -79,11 +79,11 @@ public static void Write(this BinaryWriter writer, RestrictionDB restrictions) writer.Write(restrictions.Table); } - private static readonly ushort headerNumBuckets = 768; // this # of buckets was sent over the wire in retail header + private const ushort headerNumBuckets = 768; // this # of buckets was sent over the wire in retail header // however, this value ends up being unused, and the "real" # of buckets originates // from a hardcoded value in g_bucketSizeArray in the client constant data - private static readonly ushort actualNumBuckets = 89; // in RestrictionDB constructor in acclient, + private const ushort actualNumBuckets = 89; // in RestrictionDB constructor in acclient, // client uses PHashTable for this (as opposed to the typical PackableHashTable) // which inits an IntrusiveHashTable with size 64 diff --git a/Source/ACE.Server/Physics/Animation/MotionInterp.cs b/Source/ACE.Server/Physics/Animation/MotionInterp.cs index c6435c701f..e58bd859da 100644 --- a/Source/ACE.Server/Physics/Animation/MotionInterp.cs +++ b/Source/ACE.Server/Physics/Animation/MotionInterp.cs @@ -23,13 +23,13 @@ public class MotionInterp public float MyRunRate; public LinkedList PendingMotions; - public static readonly float BackwardsFactor = 6.4999998e-1f; - public static readonly float MaxSidestepAnimRate = 3.0f; - public static readonly float RunAnimSpeed = 4.0f; - public static readonly float RunTurnFactor = 1.5f; - public static readonly float SidestepAnimSpeed = 1.25f; - public static readonly float SidestepFactor = 0.5f; - public static readonly float WalkAnimSpeed = 3.1199999f; + public const float BackwardsFactor = 6.4999998e-1f; + public const float MaxSidestepAnimRate = 3.0f; + public const float RunAnimSpeed = 4.0f; + public const float RunTurnFactor = 1.5f; + public const float SidestepAnimSpeed = 1.25f; + public const float SidestepFactor = 0.5f; + public const float WalkAnimSpeed = 3.1199999f; public MotionInterp() { } diff --git a/Source/ACE.Server/Physics/Animation/MovementParameters.cs b/Source/ACE.Server/Physics/Animation/MovementParameters.cs index 814badc8a8..7578b6a440 100644 --- a/Source/ACE.Server/Physics/Animation/MovementParameters.cs +++ b/Source/ACE.Server/Physics/Animation/MovementParameters.cs @@ -42,12 +42,12 @@ public MovementParamFlags Flags public HoldKey HoldKeyToApply; public int ActionStamp; - public static readonly float Default_DistanceToObject = 0.6f; - public static readonly float Default_FailDistance = float.MaxValue; - public static readonly float Default_MinDistance = 0.0f; - public static readonly float Default_Speed = 1.0f; - //public static readonly float Default_WalkRunThreshold = 15.0f; - public static readonly float Default_WalkRunThreshold = 1.0f; + public const float Default_DistanceToObject = 0.6f; + public const float Default_FailDistance = float.MaxValue; + public const float Default_MinDistance = 0.0f; + public const float Default_Speed = 1.0f; + //public const float Default_WalkRunThreshold = 15.0f; + public const float Default_WalkRunThreshold = 1.0f; public MovementParameters() { diff --git a/Source/ACE.Server/Physics/Common/LandDefs.cs b/Source/ACE.Server/Physics/Common/LandDefs.cs index f6a9ff6c6f..28392690e9 100644 --- a/Source/ACE.Server/Physics/Common/LandDefs.cs +++ b/Source/ACE.Server/Physics/Common/LandDefs.cs @@ -83,31 +83,31 @@ public enum TerrainType RoadType = 0x20 }; - public static readonly int BlockCellID = 0x0000FFFF; - public static readonly int FirstEnvCellID = 0x100; - public static readonly int LastEnvCellID = 0xFFFD; - public static readonly int FirstLandCellID = 1; - public static readonly int LastLandCellID = 64; - - public static readonly uint BlockMask = 0xFFFF0000; - public static readonly int BlockX_Mask = 0xFF00; - public static readonly int BlockY_Mask = 0x00FF; - public static readonly int CellID_Mask = 0x0000FFFF; - public static readonly int LandblockMask = 7; - - public static readonly int BlockPartShift = 16; - public static readonly int LandblockShift = 3; - public static readonly int MaxBlockShift = 8; - - public static readonly int BlockLength = 192; - public static readonly int CellLength = 24; - public static readonly int LandLength = 2040; - public static readonly int VertexDim = 9; - - public static readonly int BlockSide = 8; - public static readonly int VertexPerCell = 1; - public static readonly int HalfSquareLength = 12; - public static readonly int SquareLength = 24; + public const int BlockCellID = 0x0000FFFF; + public const int FirstEnvCellID = 0x100; + public const int LastEnvCellID = 0xFFFD; + public const int FirstLandCellID = 1; + public const int LastLandCellID = 64; + + public const uint BlockMask = 0xFFFF0000; + public const int BlockX_Mask = 0xFF00; + public const int BlockY_Mask = 0x00FF; + public const int CellID_Mask = 0x0000FFFF; + public const int LandblockMask = 7; + + public const int BlockPartShift = 16; + public const int LandblockShift = 3; + public const int MaxBlockShift = 8; + + public const int BlockLength = 192; + public const int CellLength = 24; + public const int LandLength = 2040; + public const int VertexDim = 9; + + public const int BlockSide = 8; + public const int VertexPerCell = 1; + public const int HalfSquareLength = 12; + public const int SquareLength = 24; public static List LandHeightTable; diff --git a/Source/ACE.Server/Physics/Common/ObjectMaint.cs b/Source/ACE.Server/Physics/Common/ObjectMaint.cs index e3c721a4ee..9d5387450d 100644 --- a/Source/ACE.Server/Physics/Common/ObjectMaint.cs +++ b/Source/ACE.Server/Physics/Common/ObjectMaint.cs @@ -18,7 +18,7 @@ public class ObjectMaint /// /// The client automatically removes known objects if they remain outside visibility for this amount of time /// - public static readonly float DestructionTime = 25.0f; + public const float DestructionTime = 25.0f; private static readonly ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); diff --git a/Source/ACE.Server/Physics/Common/Position.cs b/Source/ACE.Server/Physics/Common/Position.cs index d6378ec5a2..6bf07a54c4 100644 --- a/Source/ACE.Server/Physics/Common/Position.cs +++ b/Source/ACE.Server/Physics/Common/Position.cs @@ -136,8 +136,8 @@ public static float CylinderDistanceNoZ(float radius, Position pos, float otherR return offset.Length() - (radius + otherRadius); } - public static readonly float ThresholdMed = 1.0f / 3.0f; - public static readonly float ThresholdHigh = 2.0f / 3.0f; + public const float ThresholdMed = 1.0f / 3.0f; + public const float ThresholdHigh = 2.0f / 3.0f; public Quadrant DetermineQuadrant(float height, Position position) { diff --git a/Source/ACE.Server/Physics/Managers/InterpolationManager.cs b/Source/ACE.Server/Physics/Managers/InterpolationManager.cs index 6d00b95ecc..b976a211b7 100644 --- a/Source/ACE.Server/Physics/Managers/InterpolationManager.cs +++ b/Source/ACE.Server/Physics/Managers/InterpolationManager.cs @@ -15,8 +15,8 @@ public class InterpolationManager public int NodeFailCounter; public Position BlipToPosition; - public static readonly float LargeDistance = 999999.0f; - public static readonly float MaxInterpolatedVelocity = 7.5f; + public const float LargeDistance = 999999.0f; + public const float MaxInterpolatedVelocity = 7.5f; public static bool UseAdjustedSpeed = true; diff --git a/Source/ACE.Server/Physics/Managers/StickyManager.cs b/Source/ACE.Server/Physics/Managers/StickyManager.cs index d4742d6641..66e054826f 100644 --- a/Source/ACE.Server/Physics/Managers/StickyManager.cs +++ b/Source/ACE.Server/Physics/Managers/StickyManager.cs @@ -17,9 +17,9 @@ public class StickyManager public bool Initialized; public double StickyTimeoutTime; - public static readonly float StickyRadius = 0.3f; + public const float StickyRadius = 0.3f; - public static readonly float StickyTime = 1.0f; + public const float StickyTime = 1.0f; public StickyManager() { diff --git a/Source/ACE.Server/Physics/PhysicsGlobals.cs b/Source/ACE.Server/Physics/PhysicsGlobals.cs index ffd03450a2..db6d182d71 100644 --- a/Source/ACE.Server/Physics/PhysicsGlobals.cs +++ b/Source/ACE.Server/Physics/PhysicsGlobals.cs @@ -6,55 +6,55 @@ namespace ACE.Server.Physics { public class PhysicsGlobals { - public static readonly float EPSILON = 0.0002f; + public const float EPSILON = 0.0002f; - public static readonly float EpsilonSq = EPSILON * EPSILON; + public const float EpsilonSq = EPSILON * EPSILON; - public static readonly float Gravity = -9.8f; + public const float Gravity = -9.8f; - public static readonly float DefaultFriction = 0.95f; + public const float DefaultFriction = 0.95f; - public static readonly float DefaultElasticity = 0.05f; + public const float DefaultElasticity = 0.05f; - public static readonly float DefaultTranslucency = 0.0f; + public const float DefaultTranslucency = 0.0f; - public static readonly float DefaultMass = 1.0f; + public const float DefaultMass = 1.0f; - public static readonly float DefaultScale = 1.0f; + public const float DefaultScale = 1.0f; public static readonly PhysicsState DefaultState = PhysicsState.EdgeSlide | PhysicsState.LightingOn | PhysicsState.Gravity | PhysicsState.ReportCollisions; - public static readonly float MaxElasticity = 0.1f; + public const float MaxElasticity = 0.1f; - public static readonly float MaxVelocity = 50.0f; + public const float MaxVelocity = 50.0f; - public static readonly float MaxVelocitySquared = MaxVelocity * MaxVelocity; + public const float MaxVelocitySquared = MaxVelocity * MaxVelocity; - public static readonly float SmallVelocity = 0.25f; + public const float SmallVelocity = 0.25f; - public static readonly float SmallVelocitySquared = SmallVelocity * SmallVelocity; + public const float SmallVelocitySquared = SmallVelocity * SmallVelocity; - public static readonly float MinQuantum = 1.0f / 30.0f; // 0.0333... 30fps + public const float MinQuantum = 1.0f / 30.0f; // 0.0333... 30fps - //public static readonly float MaxQuantum = 0.2f; // 5fps // this is buggy with MoveToManager turning - public static readonly float MaxQuantum = 0.1f; // 10fps + //public const float MaxQuantum = 0.2f; // 5fps // this is buggy with MoveToManager turning + public const float MaxQuantum = 0.1f; // 10fps - public static readonly float HugeQuantum = 2.0f; // 0.5fps + public const float HugeQuantum = 2.0f; // 0.5fps /// /// The walkable allowance when landing on the ground /// - public static readonly float LandingZ = 0.0871557f; + public const float LandingZ = 0.0871557f; - public static readonly float FloorZ = 0.66417414618662751f; + public const float FloorZ = 0.66417414618662751f; - public static readonly float DummySphereRadius = 0.1f; + public const float DummySphereRadius = 0.1f; public static readonly Sphere DummySphere = new Sphere(new Vector3(0, 0, DummySphereRadius), DummySphereRadius); public static readonly Sphere DefaultSortingSphere; - public static readonly float DefaultStepHeight = 0.01f; + public const float DefaultStepHeight = 0.01f; } } diff --git a/Source/ACE.Server/Physics/PhysicsObj.cs b/Source/ACE.Server/Physics/PhysicsObj.cs index 642ea6118f..930aea489c 100644 --- a/Source/ACE.Server/Physics/PhysicsObj.cs +++ b/Source/ACE.Server/Physics/PhysicsObj.cs @@ -114,7 +114,7 @@ public string Name public ObjectMaint ObjMaint; public bool IsPlayer => ID >= 0x50000001 && ID <= 0x5FFFFFFF; - public static readonly int UpdateTimeLength = 9; + public const int UpdateTimeLength = 9; public bool IsSticky => PositionManager?.StickyManager != null && PositionManager.StickyManager.TargetID != 0; diff --git a/Source/ACE.Server/Physics/Sphere.cs b/Source/ACE.Server/Physics/Sphere.cs index 2fc4c5a93f..764cf43fd9 100644 --- a/Source/ACE.Server/Physics/Sphere.cs +++ b/Source/ACE.Server/Physics/Sphere.cs @@ -60,8 +60,8 @@ public Sphere(DatLoader.Entity.Sphere sphere) Radius = sphere.Radius; } - public static readonly float ThresholdMed = 1.0f / 3.0f; - public static readonly float ThresholdHigh = 2.0f / 3.0f; + public const float ThresholdMed = 1.0f / 3.0f; + public const float ThresholdHigh = 2.0f / 3.0f; public static Quadrant Attack(Position targetPos, float targetRadius, float targetHeight, Position attackPos, Vector2 left, Vector2 right, float attackRadius, float attackHeight) { diff --git a/Source/ACE.Server/WorldObjects/Corpse.cs b/Source/ACE.Server/WorldObjects/Corpse.cs index 154a69e5d2..8e6a999971 100644 --- a/Source/ACE.Server/WorldObjects/Corpse.cs +++ b/Source/ACE.Server/WorldObjects/Corpse.cs @@ -24,7 +24,7 @@ public partial class Corpse : Container /// /// The maximum number of seconds for an empty corpse to stick around /// - public static readonly double EmptyDecayTime = 15.0; + public const double EmptyDecayTime = 15.0; /// /// Flag indicates if a corpse is from a monster or a player diff --git a/Source/ACE.Server/WorldObjects/Creature_Melee.cs b/Source/ACE.Server/WorldObjects/Creature_Melee.cs index 7ca0062415..79d314638e 100644 --- a/Source/ACE.Server/WorldObjects/Creature_Melee.cs +++ b/Source/ACE.Server/WorldObjects/Creature_Melee.cs @@ -100,11 +100,11 @@ public int DistanceComparator(PhysicsObj a, PhysicsObj b) return dist1.CompareTo(dist2); } - public static readonly float CleaveRange = 5.0f; - public static readonly float CleaveRangeSq = CleaveRange * CleaveRange; - public static readonly float CleaveAngle = 180.0f; + public const float CleaveRange = 5.0f; + public const float CleaveRangeSq = CleaveRange * CleaveRange; + public const float CleaveAngle = 180.0f; - public static readonly float CleaveCylRange = 2.0f; + public const float CleaveCylRange = 2.0f; /// /// Performs a cleaving attack for two-handed weapons diff --git a/Source/ACE.Server/WorldObjects/Creature_Missile.cs b/Source/ACE.Server/WorldObjects/Creature_Missile.cs index 2eca0d8fac..bdf484c17a 100644 --- a/Source/ACE.Server/WorldObjects/Creature_Missile.cs +++ b/Source/ACE.Server/WorldObjects/Creature_Missile.cs @@ -142,7 +142,7 @@ public WorldObject LaunchProjectile(WorldObject weapon, WorldObject ammo, WorldO return proj; } - public static readonly float ProjSpawnHeight = 0.8454f; + public const float ProjSpawnHeight = 0.8454f; /// /// Returns the origin to spawn the projectile in the attacker local space @@ -205,7 +205,7 @@ private static float GetProjectileRadius(uint projectileWcid) } // lowest value found in data / for starter bows - public static readonly float DefaultProjectileSpeed = 20.0f; + public const float DefaultProjectileSpeed = 20.0f; public float GetProjectileSpeed() { @@ -399,9 +399,9 @@ public Sound GetLaunchMissileSound(WorldObject weapon) } } - public static readonly float MetersToYards = 1.094f; // 1.09361 - public static readonly float MissileRangeCap = 85.0f / MetersToYards; // 85 yards = ~77.697 meters w/ ac formula - public static readonly float DefaultMaxVelocity = 20.0f; // ? + public const float MetersToYards = 1.094f; // 1.09361 + public const float MissileRangeCap = 85.0f / MetersToYards; // 85 yards = ~77.697 meters w/ ac formula + public const float DefaultMaxVelocity = 20.0f; // ? public float GetMaxMissileRange() { diff --git a/Source/ACE.Server/WorldObjects/Healer.cs b/Source/ACE.Server/WorldObjects/Healer.cs index 51b34d574f..67a2a17e72 100644 --- a/Source/ACE.Server/WorldObjects/Healer.cs +++ b/Source/ACE.Server/WorldObjects/Healer.cs @@ -116,7 +116,7 @@ public override void HandleActionUseOnTarget(Player healer, WorldObject target) DoHealMotion(healer, targetPlayer, true); } - public static readonly float Healing_MaxMove = 5.0f; + public const float Healing_MaxMove = 5.0f; public void DoHealMotion(Player healer, Player target, bool success) { diff --git a/Source/ACE.Server/WorldObjects/Managers/ConfirmationManager.cs b/Source/ACE.Server/WorldObjects/Managers/ConfirmationManager.cs index 3b405a050e..e07c7fd85e 100644 --- a/Source/ACE.Server/WorldObjects/Managers/ConfirmationManager.cs +++ b/Source/ACE.Server/WorldObjects/Managers/ConfirmationManager.cs @@ -17,7 +17,7 @@ public class ConfirmationManager private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private static readonly double confirmationTimeout = 30; + private const double confirmationTimeout = 30; private UIntSequence contextSequence = new UIntSequence(); diff --git a/Source/ACE.Server/WorldObjects/Monster_Awareness.cs b/Source/ACE.Server/WorldObjects/Monster_Awareness.cs index b96296f98f..e1bbb77d68 100644 --- a/Source/ACE.Server/WorldObjects/Monster_Awareness.cs +++ b/Source/ACE.Server/WorldObjects/Monster_Awareness.cs @@ -374,12 +374,12 @@ public void CheckTargets_Inner() /// The most common value from retail /// Some other common values are in the range of 12-25 /// - public static readonly float VisualAwarenessRange_Default = 18.0f; + public const float VisualAwarenessRange_Default = 18.0f; /// /// The highest value found in the current database /// - public static readonly float VisualAwarenessRange_Highest = 75.0f; + public const float VisualAwarenessRange_Highest = 75.0f; public double? VisualAwarenessRange { diff --git a/Source/ACE.Server/WorldObjects/Monster_Magic.cs b/Source/ACE.Server/WorldObjects/Monster_Magic.cs index ff8ef7cf9d..fe890fc6a9 100644 --- a/Source/ACE.Server/WorldObjects/Monster_Magic.cs +++ b/Source/ACE.Server/WorldObjects/Monster_Magic.cs @@ -200,9 +200,9 @@ private bool UseMana() return true; } - private static readonly float PreCastSpeed = 2.0f; - private static readonly float PostCastSpeed = 1.0f; - private static readonly float PostCastSpeed_Ranged = 1.66f; // ?? + private const float PreCastSpeed = 2.0f; + private const float PostCastSpeed = 1.0f; + private const float PostCastSpeed_Ranged = 1.66f; // ?? /// /// Perform the first part of monster spell casting animation - spreading arms out diff --git a/Source/ACE.Server/WorldObjects/Monster_Missile.cs b/Source/ACE.Server/WorldObjects/Monster_Missile.cs index cbec7503d2..1d94620cdb 100644 --- a/Source/ACE.Server/WorldObjects/Monster_Missile.cs +++ b/Source/ACE.Server/WorldObjects/Monster_Missile.cs @@ -14,7 +14,7 @@ partial class Creature /// /// The delay between missile attacks (todo: find actual value) /// - public static readonly float MissileDelay = 1.0f; + public const float MissileDelay = 1.0f; /// /// Returns TRUE if monster has physical ranged attacks diff --git a/Source/ACE.Server/WorldObjects/Monster_Navigation.cs b/Source/ACE.Server/WorldObjects/Monster_Navigation.cs index a5b14f0163..b0e378998a 100644 --- a/Source/ACE.Server/WorldObjects/Monster_Navigation.cs +++ b/Source/ACE.Server/WorldObjects/Monster_Navigation.cs @@ -18,21 +18,21 @@ partial class Creature /// /// Return to home if target distance exceeds this range /// - public static readonly float MaxChaseRange = 96.0f; - public static readonly float MaxChaseRangeSq = MaxChaseRange * MaxChaseRange; + public const float MaxChaseRange = 96.0f; + public const float MaxChaseRangeSq = MaxChaseRange * MaxChaseRange; /// /// Determines if a monster is within melee range of target /// - //public static readonly float MaxMeleeRange = 1.5f; - public static readonly float MaxMeleeRange = 0.75f; - //public static readonly float MaxMeleeRange = 1.5f + 0.6f + 0.1f; // max melee range + distance from + buffer + //public const float MaxMeleeRange = 1.5f; + public const float MaxMeleeRange = 0.75f; + //public const float MaxMeleeRange = 1.5f + 0.6f + 0.1f; // max melee range + distance from + buffer /// /// The maximum range for a monster missile attack /// - //public static readonly float MaxMissileRange = 80.0f; - //public static readonly float MaxMissileRange = 40.0f; // for testing + //public const float MaxMissileRange = 80.0f; + //public const float MaxMissileRange = 40.0f; // for testing /// /// The distance per second from running animation diff --git a/Source/ACE.Server/WorldObjects/Pet.cs b/Source/ACE.Server/WorldObjects/Pet.cs index 7566395e89..3c94bd8b42 100644 --- a/Source/ACE.Server/WorldObjects/Pet.cs +++ b/Source/ACE.Server/WorldObjects/Pet.cs @@ -194,7 +194,7 @@ public void Tick(double currentUnixTime) SlowTick(currentUnixTime); } - private static readonly double slowTickSeconds = 1.0; + private const double slowTickSeconds = 1.0; private double nextSlowTickTime; /// @@ -225,8 +225,8 @@ public void SlowTick(double currentUnixTime) // if the passive pet is between min-max distance to owner, // it will turn and start running torwards its owner - private static readonly float MinDistance = 2.0f; - private static readonly float MaxDistance = 192.0f; + private const float MinDistance = 2.0f; + private const float MaxDistance = 192.0f; private void StartFollow() { diff --git a/Source/ACE.Server/WorldObjects/Player.cs b/Source/ACE.Server/WorldObjects/Player.cs index 01c299279f..76e8fae71e 100644 --- a/Source/ACE.Server/WorldObjects/Player.cs +++ b/Source/ACE.Server/WorldObjects/Player.cs @@ -69,8 +69,8 @@ public bool IsJumping public SquelchManager SquelchManager; - public static readonly float MaxRadarRange_Indoors = 25.0f; - public static readonly float MaxRadarRange_Outdoors = 75.0f; + public const float MaxRadarRange_Indoors = 25.0f; + public const float MaxRadarRange_Outdoors = 75.0f; public DateTime PrevObjSend; diff --git a/Source/ACE.Server/WorldObjects/Player_Combat.cs b/Source/ACE.Server/WorldObjects/Player_Combat.cs index afb138e7cc..bf43e2d9f7 100644 --- a/Source/ACE.Server/WorldObjects/Player_Combat.cs +++ b/Source/ACE.Server/WorldObjects/Player_Combat.cs @@ -729,7 +729,7 @@ public bool IsPKLiteDeath(uint? killerGuid) public CombatMode LastCombatMode; - public static readonly float UseTimeEpsilon = 0.05f; + public const float UseTimeEpsilon = 0.05f; /// /// This method processes the Game Action (F7B1) Change Combat Mode (0x0053) diff --git a/Source/ACE.Server/WorldObjects/Player_Commerce.cs b/Source/ACE.Server/WorldObjects/Player_Commerce.cs index 0cfe3d1870..2c2646d5b3 100644 --- a/Source/ACE.Server/WorldObjects/Player_Commerce.cs +++ b/Source/ACE.Server/WorldObjects/Player_Commerce.cs @@ -47,7 +47,7 @@ public void HandleActionBuyItem(uint vendorGuid, List items) SendUseDoneEvent(); } - private static readonly uint coinStackWcid = (uint)ACE.Entity.Enum.WeenieClassName.W_COINSTACK_CLASS; + private const uint coinStackWcid = (uint)ACE.Entity.Enum.WeenieClassName.W_COINSTACK_CLASS; /// /// Vendor has validated the transactions and sent a list of items for processing. diff --git a/Source/ACE.Server/WorldObjects/Player_Database.cs b/Source/ACE.Server/WorldObjects/Player_Database.cs index 0b40b67541..b37e894584 100644 --- a/Source/ACE.Server/WorldObjects/Player_Database.cs +++ b/Source/ACE.Server/WorldObjects/Player_Database.cs @@ -14,7 +14,7 @@ namespace ACE.Server.WorldObjects { partial class Player { - public static readonly long DefaultPlayerSaveIntervalSecs = 300; // default to 5 minutes + public const long DefaultPlayerSaveIntervalSecs = 300; // default to 5 minutes public DateTime CharacterLastRequestedDatabaseSave { get; protected set; } diff --git a/Source/ACE.Server/WorldObjects/Player_Death.cs b/Source/ACE.Server/WorldObjects/Player_Death.cs index 953fdb6565..fb438bb69c 100644 --- a/Source/ACE.Server/WorldObjects/Player_Death.cs +++ b/Source/ACE.Server/WorldObjects/Player_Death.cs @@ -618,7 +618,7 @@ public void DeathItemLog(List dropItems, Corpse corpse) /// /// The maximum # of items a player can drop /// - public static readonly int MaxItemsDropped = 14; + public const int MaxItemsDropped = 14; /// /// Rolls for the # of items to drop for a player death diff --git a/Source/ACE.Server/WorldObjects/Player_Location.cs b/Source/ACE.Server/WorldObjects/Player_Location.cs index f75fd31b2f..7765940114 100644 --- a/Source/ACE.Server/WorldObjects/Player_Location.cs +++ b/Source/ACE.Server/WorldObjects/Player_Location.cs @@ -792,7 +792,7 @@ public void NotifyLandblocks() CurrentLandblock?.SetActive(); } - public static readonly float RunFactor = 1.5f; + public const float RunFactor = 1.5f; /// /// Returns the amount of time for player to rotate by the # of degrees diff --git a/Source/ACE.Server/WorldObjects/Player_Magic.cs b/Source/ACE.Server/WorldObjects/Player_Magic.cs index 44c633e699..b42b54c088 100644 --- a/Source/ACE.Server/WorldObjects/Player_Magic.cs +++ b/Source/ACE.Server/WorldObjects/Player_Magic.cs @@ -687,7 +687,7 @@ public void DoCastGesture(Spell spell, WorldObject casterItem, ActionChain castC } // 20 from MoveToManager threshold? - public static readonly float MaxAngle = 5; + public const float MaxAngle = 5; public void DoCastSpell(MagicState _state, bool checkAngle = true) { diff --git a/Source/ACE.Server/WorldObjects/Player_Melee.cs b/Source/ACE.Server/WorldObjects/Player_Melee.cs index bd411cbacc..a5483c9b4d 100644 --- a/Source/ACE.Server/WorldObjects/Player_Melee.cs +++ b/Source/ACE.Server/WorldObjects/Player_Melee.cs @@ -163,9 +163,9 @@ public void HandleActionTargetedMeleeAttack(uint targetGuid, uint attackHeight, HandleActionTargetedMeleeAttack_Inner(target, attackSequence); } - public static readonly float MeleeDistance = 0.6f; - public static readonly float StickyDistance = 4.0f; - public static readonly float RepeatDistance = 16.0f; + public const float MeleeDistance = 0.6f; + public const float StickyDistance = 4.0f; + public const float RepeatDistance = 16.0f; public void HandleActionTargetedMeleeAttack_Inner(WorldObject target, int attackSequence) { @@ -429,7 +429,7 @@ public float DoSwingMotion(WorldObject target, out List<(float time, AttackHook return animLength; } - public static readonly float KickThreshold = 0.75f; + public const float KickThreshold = 0.75f; public MotionCommand PrevMotionCommand; diff --git a/Source/ACE.Server/WorldObjects/Portal.cs b/Source/ACE.Server/WorldObjects/Portal.cs index 76e0c9e164..1b7126b174 100644 --- a/Source/ACE.Server/WorldObjects/Portal.cs +++ b/Source/ACE.Server/WorldObjects/Portal.cs @@ -117,7 +117,7 @@ public override void OnCastSpell(WorldObject activator) /// If a player tries to use 2 portals in under this amount of time, /// they receive an error message /// - private static readonly float minTimeSinceLastPortal = 3.5f; + private const float minTimeSinceLastPortal = 3.5f; public override ActivationResult CheckUseRequirements(WorldObject activator) { diff --git a/Source/ACE.Server/WorldObjects/SkillFormula.cs b/Source/ACE.Server/WorldObjects/SkillFormula.cs index 974b8c49f0..55764c75fb 100644 --- a/Source/ACE.Server/WorldObjects/SkillFormula.cs +++ b/Source/ACE.Server/WorldObjects/SkillFormula.cs @@ -8,12 +8,12 @@ namespace ACE.Server.WorldObjects public class SkillFormula { // everything else: melee weapons (including finesse), thrown weapons, atlatls - public static readonly float DefaultMod = 0.011f; + public const float DefaultMod = 0.011f; // bows and crossbows - public static readonly float BowMod = 0.008f; + public const float BowMod = 0.008f; - public static readonly float ArmorMod = 200.0f / 3.0f; + public const float ArmorMod = 200.0f / 3.0f; public static float GetAttributeMod(int currentSkill, bool isBow = false) { diff --git a/Source/ACE.Server/WorldObjects/Vendor.cs b/Source/ACE.Server/WorldObjects/Vendor.cs index f2c8a88792..0ae968610a 100644 --- a/Source/ACE.Server/WorldObjects/Vendor.cs +++ b/Source/ACE.Server/WorldObjects/Vendor.cs @@ -319,7 +319,7 @@ public void DoVendorEmote(VendorType vendorType, WorldObject player) } } - private static readonly float closeInterval = 1.5f; + private const float closeInterval = 1.5f; /// /// After a player approaches a vendor, this is called every closeInterval seconds diff --git a/Source/ACE.Server/WorldObjects/WorldObject.cs b/Source/ACE.Server/WorldObjects/WorldObject.cs index cc02fe60b9..0ac00a8e7e 100644 --- a/Source/ACE.Server/WorldObjects/WorldObject.cs +++ b/Source/ACE.Server/WorldObjects/WorldObject.cs @@ -1015,8 +1015,8 @@ public Quadrant GetRelativeDir(WorldObject target) /// public bool IsLinkSpot => WeenieType == WeenieType.Generic && WeenieClassName.Equals("portaldestination"); - public static readonly float LocalBroadcastRange = 96.0f; - public static readonly float LocalBroadcastRangeSq = LocalBroadcastRange * LocalBroadcastRange; + public const float LocalBroadcastRange = 96.0f; + public const float LocalBroadcastRangeSq = LocalBroadcastRange * LocalBroadcastRange; public SetPosition ScatterPos { get; set; } diff --git a/Source/ACE.Server/WorldObjects/WorldObject_Magic.cs b/Source/ACE.Server/WorldObjects/WorldObject_Magic.cs index c5043be13c..42b65ffe74 100644 --- a/Source/ACE.Server/WorldObjects/WorldObject_Magic.cs +++ b/Source/ACE.Server/WorldObjects/WorldObject_Magic.cs @@ -1518,7 +1518,7 @@ public List CreateSpellProjectiles(Spell spell, WorldObject tar return LaunchSpellProjectiles(spell, target, spellType, weapon, isWeaponSpell, fromProc, origins, velocity, lifeProjectileDamage); } - public static readonly float ProjHeight = 2.0f / 3.0f; + public const float ProjHeight = 2.0f / 3.0f; public Vector3 CalculatePreOffset(Spell spell, ProjectileSpellType spellType, WorldObject target) { @@ -1682,7 +1682,7 @@ public static float GetSpreadAnglePerStep(Spell spell) public static readonly Quaternion OneEighty = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)Math.PI); - public static readonly float ProjHeightArc = 5.0f / 6.0f; + public const float ProjHeightArc = 5.0f / 6.0f; /// /// Calculates the spell projectile velocity in global space @@ -2195,7 +2195,7 @@ public void OnSpellsDeactivated() IsAffecting = false; } - private static readonly double defaultIgnoreSomeMagicProjectileDamage = 0.25; + private const double defaultIgnoreSomeMagicProjectileDamage = 0.25; public double? GetAbsorbMagicDamage() { diff --git a/Source/ACE.Server/WorldObjects/WorldObject_Weapon.cs b/Source/ACE.Server/WorldObjects/WorldObject_Weapon.cs index fb7a0ff5b4..fe9904d06d 100644 --- a/Source/ACE.Server/WorldObjects/WorldObject_Weapon.cs +++ b/Source/ACE.Server/WorldObjects/WorldObject_Weapon.cs @@ -374,7 +374,7 @@ public static float GetWeaponCritDamageMod(WorldObject weapon, Creature wielder, /// /// PvP damaged is halved, automatically displayed in the client /// - public static readonly float ElementalDamageBonusPvPReduction = 0.5f; + public const float ElementalDamageBonusPvPReduction = 0.5f; /// /// Returns a multiplicative elemental damage modifier for the magic caster weapon type @@ -1030,7 +1030,7 @@ public bool IsMasterable // - 1/3 - 2/3 sec. Power-up Time = High Backhand // - 2/3 sec+ Power-up Time = High Slash - public static readonly float ThrustThreshold = 0.33f; + public const float ThrustThreshold = 0.33f; /// /// Returns TRUE if this is a thrust/slash weapon,