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:
@@ -28,7 +28,7 @@ using System.Collections.Concurrent;
|
||||
|
||||
namespace Game.Maps
|
||||
{
|
||||
public abstract class Notifier
|
||||
public class Notifier
|
||||
{
|
||||
public virtual void Visit(IList<WorldObject> objs) { }
|
||||
public virtual void Visit(IList<Creature> objs) { }
|
||||
|
||||
@@ -23,7 +23,6 @@ using Game.Groups;
|
||||
using Game.Scenarios;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game.Maps
|
||||
@@ -426,7 +425,7 @@ namespace Game.Maps
|
||||
InstanceBind bind = player.GetBoundInstance(pair.Value.GetMapId(), pair.Value.GetDifficultyID());
|
||||
if (bind != null)
|
||||
{
|
||||
Contract.Assert(bind.save == pair.Value);
|
||||
Cypher.Assert(bind.save == pair.Value);
|
||||
if (bind.perm && bind.extendState != 0) // permanent and not already expired
|
||||
{
|
||||
// actual promotion in DB already happened in caller
|
||||
@@ -602,7 +601,7 @@ namespace Game.Maps
|
||||
void SetResetTimeFor(uint mapid, Difficulty d, long t)
|
||||
{
|
||||
var key = MathFunctions.MakePair64(mapid, (uint)d);
|
||||
Contract.Assert(m_resetTimeByMapDifficulty.ContainsKey(key));
|
||||
Cypher.Assert(m_resetTimeByMapDifficulty.ContainsKey(key));
|
||||
m_resetTimeByMapDifficulty[key] = t;
|
||||
}
|
||||
|
||||
@@ -662,7 +661,7 @@ namespace Game.Maps
|
||||
Map map = Global.MapMgr.FindMap(GetMapId(), m_instanceid);
|
||||
if (map != null)
|
||||
{
|
||||
Contract.Assert(map.IsDungeon());
|
||||
Cypher.Assert(map.IsDungeon());
|
||||
InstanceScript instanceScript = ((InstanceMap)map).GetInstanceScript();
|
||||
if (instanceScript != null)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@ using Game.Groups;
|
||||
using Game.Network.Packets;
|
||||
using Game.Scenarios;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
|
||||
namespace Game.Maps
|
||||
@@ -157,7 +156,7 @@ namespace Game.Maps
|
||||
{
|
||||
foreach (var data in objectData)
|
||||
{
|
||||
Contract.Assert(!objectInfo.ContainsKey(data.entry));
|
||||
Cypher.Assert(!objectInfo.ContainsKey(data.entry));
|
||||
objectInfo[data.entry] = data.type;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +215,7 @@ namespace Game.Maps
|
||||
|
||||
public BossInfo GetBossInfo(uint id)
|
||||
{
|
||||
Contract.Assert(id < bosses.Count);
|
||||
Cypher.Assert(id < bosses.Count);
|
||||
return bosses[id];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ using Game.Garrisons;
|
||||
using Game.Groups;
|
||||
using Game.Scenarios;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game.Maps
|
||||
@@ -181,13 +180,13 @@ namespace Game.Maps
|
||||
if (entry == null)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "CreateInstance: no record for map {0}", GetId());
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
}
|
||||
InstanceTemplate iTemplate = Global.ObjectMgr.GetInstanceTemplate(GetId());
|
||||
if (iTemplate == null)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "CreateInstance: no instance template for map {0}", GetId());
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
}
|
||||
|
||||
// some instances only have one difficulty
|
||||
@@ -196,7 +195,7 @@ namespace Game.Maps
|
||||
Log.outDebug(LogFilter.Maps, "MapInstanced.CreateInstance: {0} map instance {1} for {2} created with difficulty {3}", save != null ? "" : "new ", InstanceId, GetId(), difficulty);
|
||||
|
||||
InstanceMap map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
|
||||
Contract.Assert(map.IsDungeon());
|
||||
Cypher.Assert(map.IsDungeon());
|
||||
|
||||
map.LoadRespawnTimes();
|
||||
map.LoadCorpseData();
|
||||
@@ -222,7 +221,7 @@ namespace Game.Maps
|
||||
Log.outDebug(LogFilter.Maps, "MapInstanced.CreateBattleground: map bg {0} for {1} created.", InstanceId, GetId());
|
||||
|
||||
BattlegroundMap map = new BattlegroundMap(GetId(), (uint)GetGridExpiry(), InstanceId, this, Difficulty.None);
|
||||
Contract.Assert(map.IsBattlegroundOrArena());
|
||||
Cypher.Assert(map.IsBattlegroundOrArena());
|
||||
map.SetBG(bg);
|
||||
bg.SetBgMap(map);
|
||||
|
||||
@@ -236,7 +235,7 @@ namespace Game.Maps
|
||||
lock (_mapLock)
|
||||
{
|
||||
GarrisonMap map = new GarrisonMap(GetId(), GetGridExpiry(), instanceId, this, owner.GetGUID());
|
||||
Contract.Assert(map.IsGarrison());
|
||||
Cypher.Assert(map.IsGarrison());
|
||||
|
||||
m_InstancedMaps[instanceId] = map;
|
||||
return map;
|
||||
|
||||
@@ -19,7 +19,6 @@ using Framework.Constants;
|
||||
using Game.DataStorage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -116,7 +115,7 @@ namespace Game
|
||||
|
||||
// get this mmap data
|
||||
MMapData mmap = loadedMMaps[mapId];
|
||||
Contract.Assert(mmap.navMesh != null);
|
||||
Cypher.Assert(mmap.navMesh != null);
|
||||
|
||||
// check if we already have this tile loaded
|
||||
uint packedGridPos = packTileID(x, y);
|
||||
@@ -247,7 +246,7 @@ namespace Game
|
||||
// if the grid is later reloaded, dtNavMesh.addTile will return error but no extra memory is used
|
||||
// we cannot recover from this error - assert out
|
||||
Log.outError(LogFilter.Maps, "MMAP:unloadMap: Could not unload {0:D4}{1:D2}{2:D2}.mmtile from navmesh", mapId, x, y);
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+20
-21
@@ -30,7 +30,6 @@ using Game.Scenarios;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -93,7 +92,7 @@ namespace Game.Maps
|
||||
for (var i = 0; i < i_worldObjects.Count; ++i)
|
||||
{
|
||||
WorldObject obj = i_worldObjects[i];
|
||||
Contract.Assert(obj.IsWorldObject());
|
||||
Cypher.Assert(obj.IsWorldObject());
|
||||
obj.RemoveFromWorld();
|
||||
obj.ResetMap();
|
||||
}
|
||||
@@ -334,7 +333,7 @@ namespace Game.Maps
|
||||
|
||||
Log.outDebug(LogFilter.Maps, "Switch object {0} from grid[{1}, {2}] {3}", obj.GetGUID(), cell.GetGridX(), cell.GetGridY(), on);
|
||||
Grid ngrid = getGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Contract.Assert(ngrid != null);
|
||||
Cypher.Assert(ngrid != null);
|
||||
|
||||
RemoveFromGrid(obj, cell);
|
||||
|
||||
@@ -462,7 +461,7 @@ namespace Game.Maps
|
||||
EnsureGridLoadedForActiveObject(cell, player);
|
||||
AddToGrid(player, cell);
|
||||
|
||||
Contract.Assert(player.GetMap() == this);
|
||||
Cypher.Assert(player.GetMap() == this);
|
||||
player.SetMap(this);
|
||||
player.AddToWorld();
|
||||
|
||||
@@ -986,7 +985,7 @@ namespace Game.Maps
|
||||
Cell integrity_check = new Cell(dynObj.GetPositionX(), dynObj.GetPositionY());
|
||||
Cell old_cell = dynObj.GetCurrentCell();
|
||||
|
||||
Contract.Assert(integrity_check == old_cell);
|
||||
Cypher.Assert(integrity_check == old_cell);
|
||||
|
||||
Cell new_cell = new Cell(x, y);
|
||||
|
||||
@@ -1013,7 +1012,7 @@ namespace Game.Maps
|
||||
old_cell = dynObj.GetCurrentCell();
|
||||
integrity_check = new Cell(dynObj.GetPositionX(), dynObj.GetPositionY());
|
||||
|
||||
Contract.Assert(integrity_check == old_cell);
|
||||
Cypher.Assert(integrity_check == old_cell);
|
||||
}
|
||||
|
||||
public void AreaTriggerRelocation(AreaTrigger at, float x, float y, float z, float orientation)
|
||||
@@ -1021,7 +1020,7 @@ namespace Game.Maps
|
||||
Cell integrity_check = new Cell(at.GetPositionX(), at.GetPositionY());
|
||||
Cell old_cell = at.GetCurrentCell();
|
||||
|
||||
Contract.Assert(integrity_check == old_cell);
|
||||
Cypher.Assert(integrity_check == old_cell);
|
||||
Cell new_cell = new Cell(x, y);
|
||||
|
||||
if (getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
@@ -1045,7 +1044,7 @@ namespace Game.Maps
|
||||
|
||||
old_cell = at.GetCurrentCell();
|
||||
integrity_check = new Cell(at.GetPositionX(), at.GetPositionY());
|
||||
Contract.Assert(integrity_check == old_cell);
|
||||
Cypher.Assert(integrity_check == old_cell);
|
||||
}
|
||||
|
||||
void AddCreatureToMoveList(Creature c, float x, float y, float z, float ang)
|
||||
@@ -1595,7 +1594,7 @@ namespace Game.Maps
|
||||
grid.VisitAllGrids(visitor);
|
||||
}
|
||||
|
||||
Contract.Assert(i_objectsToRemove.Empty());
|
||||
Cypher.Assert(i_objectsToRemove.Empty());
|
||||
setGrid(null, x, y);
|
||||
|
||||
uint gx = (MapConst.MaxGrids - 1) - x;
|
||||
@@ -2221,7 +2220,7 @@ namespace Game.Maps
|
||||
while (!_updateObjects.Empty())
|
||||
{
|
||||
WorldObject obj = _updateObjects[0];
|
||||
Contract.Assert(obj.IsInWorld);
|
||||
Cypher.Assert(obj.IsInWorld);
|
||||
_updateObjects.RemoveAt(0);
|
||||
obj.BuildUpdate(update_players);
|
||||
}
|
||||
@@ -2265,7 +2264,7 @@ namespace Game.Maps
|
||||
|
||||
public void AddObjectToRemoveList(WorldObject obj)
|
||||
{
|
||||
Contract.Assert(obj.GetMapId() == GetId() && obj.GetInstanceId() == GetInstanceId());
|
||||
Cypher.Assert(obj.GetMapId() == GetId() && obj.GetInstanceId() == GetInstanceId());
|
||||
|
||||
obj.CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
|
||||
|
||||
@@ -2274,7 +2273,7 @@ namespace Game.Maps
|
||||
|
||||
public void AddObjectToSwitchList(WorldObject obj, bool on)
|
||||
{
|
||||
Contract.Assert(obj.GetMapId() == GetId() && obj.GetInstanceId() == GetInstanceId());
|
||||
Cypher.Assert(obj.GetMapId() == GetId() && obj.GetInstanceId() == GetInstanceId());
|
||||
// i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses
|
||||
// the contained objects only if GetTypeId() == TYPEID_UNIT , so we can return in all other cases
|
||||
if (!obj.IsTypeId(TypeId.Unit) && !obj.IsTypeId(TypeId.GameObject))
|
||||
@@ -2285,7 +2284,7 @@ namespace Game.Maps
|
||||
else if (i_objectsToSwitch[obj] != on)
|
||||
i_objectsToSwitch.Remove(obj);
|
||||
else
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
}
|
||||
|
||||
void RemoveAllObjectsInRemoveList()
|
||||
@@ -2678,7 +2677,7 @@ namespace Game.Maps
|
||||
|
||||
void RemoveCorpse(Corpse corpse)
|
||||
{
|
||||
Contract.Assert(corpse);
|
||||
Cypher.Assert(corpse);
|
||||
|
||||
corpse.DestroyForNearbyPlayers();
|
||||
if (corpse.GetCurrentCell() != null)
|
||||
@@ -3368,7 +3367,7 @@ namespace Game.Maps
|
||||
|
||||
public ulong GenerateLowGuid(HighGuid high)
|
||||
{
|
||||
//Contract.Assert(!ObjectGuid.IsMapSpecific(high), "Only map specific guid can be generated in Map context");
|
||||
//Cypher.Assert(!ObjectGuid.IsMapSpecific(high), "Only map specific guid can be generated in Map context");
|
||||
|
||||
return GetGuidSequenceGenerator(high).Generate();
|
||||
}
|
||||
@@ -4402,7 +4401,7 @@ namespace Game.Maps
|
||||
if (player.GetMap() == this)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "InstanceMap:CannotEnter - player {0} ({1}) already in map {2}, {3}, {4}!", player.GetName(), player.GetGUID().ToString(), GetId(), GetInstanceId(), GetSpawnMode());
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
return EnterState.CannotEnterAlreadyInMap;
|
||||
}
|
||||
|
||||
@@ -4456,7 +4455,7 @@ namespace Game.Maps
|
||||
mapSave = Global.InstanceSaveMgr.AddInstanceSave(GetId(), GetInstanceId(), GetSpawnMode(), 0, 0, true);
|
||||
}
|
||||
|
||||
Contract.Assert(mapSave != null);
|
||||
Cypher.Assert(mapSave != null);
|
||||
|
||||
// check for existing instance binds
|
||||
InstanceBind playerBind = player.GetBoundInstance(GetId(), GetSpawnMode());
|
||||
@@ -4497,7 +4496,7 @@ namespace Game.Maps
|
||||
GetMapName(), groupBind.save.GetMapId(), groupBind.save.GetInstanceId(),
|
||||
groupBind.save.GetDifficultyID(), groupBind.save.GetPlayerCount(),
|
||||
groupBind.save.GetGroupCount(), groupBind.save.CanReset());
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
return false;
|
||||
}
|
||||
// bind to the group or keep using the group save
|
||||
@@ -4544,7 +4543,7 @@ namespace Game.Maps
|
||||
player.BindToInstance(mapSave, false);
|
||||
else
|
||||
// cannot jump to a different instance without resetting it
|
||||
Contract.Assert(playerBind.save == mapSave);
|
||||
Cypher.Assert(playerBind.save == mapSave);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4753,7 +4752,7 @@ namespace Game.Maps
|
||||
|
||||
public override void UnloadAll()
|
||||
{
|
||||
Contract.Assert(!HavePlayers());
|
||||
Cypher.Assert(!HavePlayers());
|
||||
|
||||
if (m_resetAfterUnload)
|
||||
{
|
||||
@@ -4849,7 +4848,7 @@ namespace Game.Maps
|
||||
if (player.GetMap() == this)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "BGMap:CannotEnter - player {0} is already in map!", player.GetGUID().ToString());
|
||||
Contract.Assert(false);
|
||||
Cypher.Assert(false);
|
||||
return EnterState.CannotEnterAlreadyInMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ using Game.Groups;
|
||||
using Game.Maps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game.Entities
|
||||
@@ -60,7 +59,7 @@ namespace Game.Entities
|
||||
if (map == null)
|
||||
{
|
||||
var entry = CliDB.MapStorage.LookupByKey(id);
|
||||
Contract.Assert(entry != null);
|
||||
Cypher.Assert(entry != null);
|
||||
if (entry.ParentMapID != -1)
|
||||
{
|
||||
CreateBaseMap((uint)entry.ParentMapID);
|
||||
@@ -73,7 +72,7 @@ namespace Game.Entities
|
||||
lock(_mapsLock)
|
||||
map = CreateBaseMap_i(entry);
|
||||
}
|
||||
Contract.Assert(map != null);
|
||||
Cypher.Assert(map != null);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ using Game.Entities;
|
||||
using Game.Movement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game.Maps
|
||||
@@ -161,12 +160,12 @@ namespace Game.Maps
|
||||
}
|
||||
}
|
||||
|
||||
Contract.Assert(!keyFrames.Empty());
|
||||
Cypher.Assert(!keyFrames.Empty());
|
||||
|
||||
if (transport.mapsUsed.Count > 1)
|
||||
{
|
||||
foreach (var mapId in transport.mapsUsed)
|
||||
Contract.Assert(!CliDB.MapStorage.LookupByKey(mapId).Instanceable());
|
||||
Cypher.Assert(!CliDB.MapStorage.LookupByKey(mapId).Instanceable());
|
||||
|
||||
transport.inInstance = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user