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
+1 -2
View File
@@ -30,7 +30,6 @@ using Game.Network.Packets;
using Game.Spells;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
@@ -2670,7 +2669,7 @@ namespace Game.Entities
var nodeEntry = CliDB.TaxiNodesStorage.LookupByKey(nodeid);
if (nodeEntry != null && nodeEntry.ContinentID == GetMapId())
{
Contract.Assert(nodeEntry != null); // checked in m_taxi.LoadTaxiDestinationsFromString
Cypher.Assert(nodeEntry != null); // checked in m_taxi.LoadTaxiDestinationsFromString
mapId = nodeEntry.ContinentID;
Relocate(nodeEntry.Pos.X, nodeEntry.Pos.Y, nodeEntry.Pos.Z, 0.0f);
}
+1 -2
View File
@@ -19,7 +19,6 @@ using Framework.Constants;
using Game.Groups;
using Game.Maps;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Entities
{
@@ -165,7 +164,7 @@ namespace Game.Entities
public void SetPartyType(GroupCategory category, GroupType type)
{
Contract.Assert(category < GroupCategory.Max);
Cypher.Assert(category < GroupCategory.Max);
byte value = GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType);
value &= (byte)~((byte)0xFF << ((byte)category * 4));
value |= (byte)((byte)type << ((byte)category * 4));
+1 -2
View File
@@ -29,7 +29,6 @@ using Game.Network.Packets;
using Game.Spells;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
@@ -122,7 +121,7 @@ namespace Game.Entities
{
List<ItemPosCount> dest = new List<ItemPosCount>();
InventoryResult msg = CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, itemid, count);
Contract.Assert(msg == InventoryResult.Ok); // Already checked before
Cypher.Assert(msg == InventoryResult.Ok); // Already checked before
Item it = StoreNewItem(dest, itemid, true);
SendNewItem(it, count, true, false, true);
}
+4 -5
View File
@@ -27,7 +27,6 @@ using Game.Network.Packets;
using Game.Spells;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Entities
{
@@ -241,7 +240,7 @@ namespace Game.Entities
//we should obtain map from GetMap() in 99% of cases. Special case
//only for quests which cast teleport spells on player
Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId());
Contract.Assert(_map != null);
Cypher.Assert(_map != null);
GameObject gameObject = _map.GetGameObject(guid);
if (gameObject != null)
{
@@ -342,7 +341,7 @@ namespace Game.Entities
switch (guid.GetHigh())
{
case HighGuid.Player:
Contract.Assert(quest.HasFlag(QuestFlags.AutoComplete));
Cypher.Assert(quest.HasFlag(QuestFlags.AutoComplete));
return Global.ObjectMgr.GetQuestTemplate(nextQuestID);
case HighGuid.Creature:
case HighGuid.Pet:
@@ -360,7 +359,7 @@ namespace Game.Entities
//we should obtain map from GetMap() in 99% of cases. Special case
//only for quests which cast teleport spells on player
Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId());
Contract.Assert(_map != null);
Cypher.Assert(_map != null);
GameObject gameObject = _map.GetGameObject(guid);
if (gameObject != null)
objectQR = Global.ObjectMgr.GetGOQuestRelationBounds(gameObject.GetEntry());
@@ -2156,7 +2155,7 @@ namespace Game.Entities
public void KilledMonster(CreatureTemplate cInfo, ObjectGuid guid)
{
Contract.Assert(cInfo != null);
Cypher.Assert(cInfo != null);
if (cInfo.Entry != 0)
KilledMonsterCredit(cInfo.Entry, guid);
+9 -10
View File
@@ -37,7 +37,6 @@ using Game.PvP;
using Game.Spells;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
namespace Game.Entities
@@ -1091,7 +1090,7 @@ namespace Game.Entities
if (!charm.GetCharmerGUID().IsEmpty())
{
Log.outFatal(LogFilter.Player, "Charmed unit has charmer guid {0}", charm.GetCharmerGUID());
Contract.Assert(false);
Cypher.Assert(false);
}
SetCharm(charm, false);
@@ -1231,7 +1230,7 @@ namespace Game.Entities
return;
CurrencyTypesRecord currency = CliDB.CurrencyTypesStorage.LookupByKey(id);
Contract.Assert(currency != null);
Cypher.Assert(currency != null);
if (!ignoreMultipliers)
count *= (int)GetTotalAuraMultiplierByMiscValue(AuraType.ModCurrencyGain, (int)id);
@@ -2605,7 +2604,7 @@ namespace Game.Entities
return textId;
}
uint GetDefaultGossipMenuForSource(WorldObject source)
public static uint GetDefaultGossipMenuForSource(WorldObject source)
{
switch (source.GetTypeId())
{
@@ -3546,7 +3545,7 @@ namespace Game.Entities
public void SetResurrectRequestData(Unit caster, uint health, uint mana, uint appliedAura)
{
Contract.Assert(!IsResurrectRequested());
Cypher.Assert(!IsResurrectRequested());
_resurrectionData = new ResurrectionData();
_resurrectionData.GUID = caster.GetGUID();
_resurrectionData.Location.WorldRelocate(caster);
@@ -5099,9 +5098,9 @@ namespace Game.Entities
return GetCollisionHeight(false);
var displayInfo = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetNativeDisplayId());
Contract.Assert(displayInfo != null);
Cypher.Assert(displayInfo != null);
var modelData = CliDB.CreatureModelDataStorage.LookupByKey(displayInfo.ModelID);
Contract.Assert(modelData != null);
Cypher.Assert(modelData != null);
float scaleMod = GetObjectScale(); // 99% sure about this
@@ -5111,9 +5110,9 @@ namespace Game.Entities
{
//! Dismounting case - use basic default model data
var displayInfo = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetNativeDisplayId());
Contract.Assert(displayInfo != null);
Cypher.Assert(displayInfo != null);
var modelData = CliDB.CreatureModelDataStorage.LookupByKey(displayInfo.ModelID);
Contract.Assert(modelData != null);
Cypher.Assert(modelData != null);
return modelData.CollisionHeight;
}
@@ -7009,7 +7008,7 @@ namespace Game.Entities
//new
public uint DoRandomRoll(uint minimum, uint maximum)
{
Contract.Assert(maximum <= 10000);
Cypher.Assert(maximum <= 10000);
uint roll = RandomHelper.URand(minimum, maximum);