Core/Errors: Stop using System.Diagnostics.Contracts, Its just closing the server without error or warning. We now log the error and then throw a exception

This commit is contained in:
hondacrx
2018-06-15 12:34:56 -04:00
parent 1289bc3ed1
commit 7aa494d5dd
86 changed files with 520 additions and 558 deletions
+3 -4
View File
@@ -21,7 +21,6 @@ using Game.Entities;
using Game.Maps;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Text;
namespace Game.Conditions
@@ -36,7 +35,7 @@ namespace Game.Conditions
public bool Meets(ConditionSourceInfo sourceInfo)
{
Contract.Assert(ConditionTarget < SharedConst.MaxConditionTargets);
Cypher.Assert(ConditionTarget < SharedConst.MaxConditionTargets);
WorldObject obj = sourceInfo.mConditionTargets[ConditionTarget];
// object not present, return false
if (obj == null)
@@ -62,7 +61,7 @@ namespace Game.Conditions
if (player != null)
{
// don't allow 0 items (it's checked during table load)
Contract.Assert(ConditionValue2 != 0);
Cypher.Assert(ConditionValue2 != 0);
bool checkBank = ConditionValue3 != 0 ? true : false;
condMeets = player.HasItemCount(ConditionValue1, ConditionValue2, checkBank);
}
@@ -486,7 +485,7 @@ namespace Game.Conditions
mask |= GridMapTypeMask.Player;
break;
default:
Contract.Assert(false, "Condition.GetSearcherTypeMaskForCondition - missing condition handling!");
Cypher.Assert(false, "Condition.GetSearcherTypeMaskForCondition - missing condition handling!");
break;
}
return mask;
+4 -5
View File
@@ -25,7 +25,6 @@ using Game.Loots;
using Game.Spells;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
namespace Game
@@ -43,7 +42,7 @@ namespace Game
foreach (var i in conditions)
{
// no point of having not loaded conditions in list
Contract.Assert(i.isLoaded(), "ConditionMgr.GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
Cypher.Assert(i.isLoaded(), "ConditionMgr.GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
// group not filled yet, fill with widest mask possible
if (!elseGroupSearcherTypeMasks.ContainsKey(i.ElseGroup))
elseGroupSearcherTypeMasks[i.ElseGroup] = GridMapTypeMask.All;
@@ -54,7 +53,7 @@ namespace Game
if (i.ReferenceId != 0) // handle reference
{
var refe = ConditionReferenceStore.LookupByKey(i.ReferenceId);
Contract.Assert(refe.Empty(), "ConditionMgr.GetSearcherTypeMaskForConditionList - incorrect reference");
Cypher.Assert(refe.Empty(), "ConditionMgr.GetSearcherTypeMaskForConditionList - incorrect reference");
elseGroupSearcherTypeMasks[i.ElseGroup] &= GetSearcherTypeMaskForConditionList(refe);
}
else // handle normal condition
@@ -579,7 +578,7 @@ namespace Game
{
uint conditionEffMask = cond.SourceGroup;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)cond.SourceEntry);
Contract.Assert(spellInfo != null);
Cypher.Assert(spellInfo != null);
List<uint> sharedMasks = new List<uint>();
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
{
@@ -1644,7 +1643,7 @@ namespace Game
static bool PlayerConditionLogic(uint logic, bool[] results)
{
Contract.Assert(results.Length < 16, "Logic array size must be equal to or less than 16");
Cypher.Assert(results.Length < 16, "Logic array size must be equal to or less than 16");
for (var i = 0; i < results.Length; ++i)
{
+1 -2
View File
@@ -22,7 +22,6 @@ using Game.DataStorage;
using Game.Entities;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game
{
@@ -288,7 +287,7 @@ namespace Game
public bool IsDisabledFor(DisableType type, uint entry, Unit unit, byte flags = 0)
{
Contract.Assert(type < DisableType.Max);
Cypher.Assert(type < DisableType.Max);
if (!m_DisableMap.ContainsKey(type) || m_DisableMap[type].Empty())
return false;