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
+2 -1
View File
@@ -20,6 +20,7 @@ using Framework.Configuration;
using Framework.Database; using Framework.Database;
using Framework.Networking; using Framework.Networking;
using System; using System;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Timers; using System.Timers;
@@ -41,7 +42,7 @@ namespace BNetServer
Environment.Exit(-1); Environment.Exit(-1);
}; };
if (!ConfigMgr.Load(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".conf")) if (!ConfigMgr.Load(Process.GetCurrentProcess().ProcessName + ".conf"))
ExitNow(); ExitNow();
// Initialize the database connection // Initialize the database connection
+2 -19
View File
@@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System.Diagnostics.Contracts;
namespace System.Collections namespace System.Collections
{ {
@@ -27,7 +26,6 @@ namespace System.Collections
{ {
throw new ArgumentOutOfRangeException("length"); throw new ArgumentOutOfRangeException("length");
} }
Contract.EndContractBlock();
_mArray = new uint[GetArrayLength(length, BitsPerInt32)]; _mArray = new uint[GetArrayLength(length, BitsPerInt32)];
_mLength = length; _mLength = length;
@@ -47,7 +45,7 @@ namespace System.Collections
{ {
throw new ArgumentNullException("values"); throw new ArgumentNullException("values");
} }
Contract.EndContractBlock();
// this value is chosen to prevent overflow when computing m_length // this value is chosen to prevent overflow when computing m_length
if (values.Length > UInt32.MaxValue / BitsPerInt32) if (values.Length > UInt32.MaxValue / BitsPerInt32)
{ {
@@ -68,7 +66,6 @@ namespace System.Collections
{ {
throw new ArgumentNullException("bits"); throw new ArgumentNullException("bits");
} }
Contract.EndContractBlock();
int arrayLength = GetArrayLength(bits._mLength, BitsPerInt32); int arrayLength = GetArrayLength(bits._mLength, BitsPerInt32);
_mArray = new uint[arrayLength]; _mArray = new uint[arrayLength];
@@ -97,7 +94,6 @@ namespace System.Collections
{ {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
Contract.EndContractBlock();
return (Convert.ToInt64(_mArray[index / 32]) & (1 << (index % 32))) != 0; return (Convert.ToInt64(_mArray[index / 32]) & (1 << (index % 32))) != 0;
} }
@@ -108,7 +104,6 @@ namespace System.Collections
{ {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException("index");
} }
Contract.EndContractBlock();
if (value) if (value)
{ {
@@ -140,7 +135,6 @@ namespace System.Collections
throw new ArgumentNullException("value"); throw new ArgumentNullException("value");
if (Length != value.Length) if (Length != value.Length)
throw new ArgumentException(); throw new ArgumentException();
Contract.EndContractBlock();
int ints = GetArrayLength(_mLength, BitsPerInt32); int ints = GetArrayLength(_mLength, BitsPerInt32);
for (int i = 0; i < ints; i++) for (int i = 0; i < ints; i++)
@@ -158,7 +152,6 @@ namespace System.Collections
throw new ArgumentNullException("value"); throw new ArgumentNullException("value");
if (Length != value.Length) if (Length != value.Length)
throw new ArgumentException(); throw new ArgumentException();
Contract.EndContractBlock();
int ints = GetArrayLength(_mLength, BitsPerInt32); int ints = GetArrayLength(_mLength, BitsPerInt32);
for (int i = 0; i < ints; i++) for (int i = 0; i < ints; i++)
@@ -176,7 +169,6 @@ namespace System.Collections
throw new ArgumentNullException("value"); throw new ArgumentNullException("value");
if (Length != value.Length) if (Length != value.Length)
throw new ArgumentException(); throw new ArgumentException();
Contract.EndContractBlock();
int ints = GetArrayLength(_mLength, BitsPerInt32); int ints = GetArrayLength(_mLength, BitsPerInt32);
for (int i = 0; i < ints; i++) for (int i = 0; i < ints; i++)
@@ -204,7 +196,6 @@ namespace System.Collections
{ {
get get
{ {
Contract.Ensures(Contract.Result<int>() >= 0);
return _mLength; return _mLength;
} }
set set
@@ -213,7 +204,6 @@ namespace System.Collections
{ {
throw new ArgumentOutOfRangeException("value"); throw new ArgumentOutOfRangeException("value");
} }
Contract.EndContractBlock();
int newints = GetArrayLength(value, BitsPerInt32); int newints = GetArrayLength(value, BitsPerInt32);
if (newints > _mArray.Length || newints + ShrinkThreshold < _mArray.Length) if (newints > _mArray.Length || newints + ShrinkThreshold < _mArray.Length)
@@ -255,8 +245,6 @@ namespace System.Collections
if (array.Rank != 1) if (array.Rank != 1)
throw new ArgumentException(); throw new ArgumentException();
Contract.EndContractBlock();
if (array is uint[]) if (array is uint[])
{ {
Array.Copy(_mArray, 0, array, index, GetArrayLength(_mLength, BitsPerInt32)); Array.Copy(_mArray, 0, array, index, GetArrayLength(_mLength, BitsPerInt32));
@@ -288,17 +276,12 @@ namespace System.Collections
{ {
get get
{ {
Contract.Ensures(Contract.Result<int>() >= 0);
return _mLength; return _mLength;
} }
} }
public Object Clone() public Object Clone()
{ {
Contract.Ensures(Contract.Result<Object>() != null);
Contract.Ensures(((BitArray)Contract.Result<Object>()).Length == this.Length);
BitSet bitArray = new BitSet(_mArray); BitSet bitArray = new BitSet(_mArray);
bitArray._version = _version; bitArray._version = _version;
bitArray._mLength = _mLength; bitArray._mLength = _mLength;
@@ -345,7 +328,7 @@ namespace System.Collections
private static int GetArrayLength(int n, int div) private static int GetArrayLength(int n, int div)
{ {
Contract.Assert(div > 0, "GetArrayLength: div arg must be greater than 0"); Cypher.Assert(div > 0, "GetArrayLength: div arg must be greater than 0");
return n > 0 ? (((n - 1) / div) + 1) : 0; return n > 0 ? (((n - 1) / div) + 1) : 0;
} }
+1 -2
View File
@@ -17,7 +17,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Framework.Database namespace Framework.Database
@@ -68,7 +67,7 @@ namespace Framework.Database
bool hasNext = _result != null; bool hasNext = _result != null;
if (_callbacks.Count == 0) if (_callbacks.Count == 0)
{ {
Contract.Assert(!hasNext); Cypher.Assert(!hasNext);
return QueryCallbackStatus.Completed; return QueryCallbackStatus.Completed;
} }
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2012-2018 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Runtime.CompilerServices;
public class Cypher
{
public static void Assert(bool value, string message = "", [CallerMemberName]string memberName = "")
{
if (!value)
{
if (!message.IsEmpty())
Log.outFatal(LogFilter.Server, message);
throw new Exception(memberName);
}
}
}
+18 -1
View File
@@ -1,4 +1,21 @@
using System; /*
* Copyright (C) 2012-2018 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
+2 -3
View File
@@ -16,7 +16,6 @@
*/ */
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Framework.Dynamic namespace Framework.Dynamic
@@ -112,13 +111,13 @@ namespace Framework.Dynamic
public void ScheduleAbort() public void ScheduleAbort()
{ {
Contract.Assert(IsRunning(), "Tried to scheduled the abortion of an event twice!"); Cypher.Assert(IsRunning(), "Tried to scheduled the abortion of an event twice!");
m_abortState = AbortState.Scheduled; m_abortState = AbortState.Scheduled;
} }
public void SetAborted() public void SetAborted()
{ {
Contract.Assert(!IsAborted(), "Tried to abort an already aborted event!"); Cypher.Assert(!IsAborted(), "Tried to abort an already aborted event!");
m_abortState = AbortState.Aborted; m_abortState = AbortState.Aborted;
} }
+1 -2
View File
@@ -16,7 +16,6 @@
*/ */
using Framework.Collections; using Framework.Collections;
using System.Diagnostics.Contracts;
namespace Framework.Dynamic namespace Framework.Dynamic
{ {
@@ -42,7 +41,7 @@ namespace Framework.Dynamic
// Create new link // Create new link
public void link(TO toObj, FROM fromObj) public void link(TO toObj, FROM fromObj)
{ {
Contract.Assert(fromObj != null); // fromObj MUST not be NULL Cypher.Assert(fromObj != null); // fromObj MUST not be NULL
if (isValid()) if (isValid())
unlink(); unlink();
if (toObj != null) if (toObj != null)
+1 -2
View File
@@ -17,7 +17,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Framework.Dynamic namespace Framework.Dynamic
@@ -622,7 +621,7 @@ namespace Framework.Dynamic
{ {
// This was adapted to TC to prevent static analysis tools from complaining. // This was adapted to TC to prevent static analysis tools from complaining.
// If you encounter this assertion check if you repeat a TaskContext more then 1 time! // If you encounter this assertion check if you repeat a TaskContext more then 1 time!
Contract.Assert(!_consumed, "Bad task logic, task context was consumed already!"); Cypher.Assert(!_consumed, "Bad task logic, task context was consumed already!");
} }
/// <summary> /// <summary>
-2
View File
@@ -16,7 +16,6 @@
*/ */
using System; using System;
using System.Diagnostics.Contracts;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Framework.IO namespace Framework.IO
@@ -47,7 +46,6 @@ namespace Framework.IO
if (!MoveNext(delimiters)) if (!MoveNext(delimiters))
return ""; return "";
Contract.Assume(Current != null);
return Current; return Current;
} }
+1 -2
View File
@@ -16,7 +16,6 @@
*/ */
using System; using System;
using System.Diagnostics.Contracts;
using System.Net.Sockets; using System.Net.Sockets;
namespace Framework.Networking namespace Framework.Networking
@@ -25,7 +24,7 @@ namespace Framework.Networking
{ {
public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1) public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1)
{ {
Contract.Assert(threadCount > 0); Cypher.Assert(threadCount > 0);
Acceptor = new AsyncAcceptor(); Acceptor = new AsyncAcceptor();
if (!Acceptor.Start(bindIp, port)) if (!Acceptor.Start(bindIp, port))
+2 -2
View File
@@ -207,7 +207,7 @@ public static class MathFunctions
return val1 <= val2; return val1 <= val2;
default: default:
// incorrect parameter // incorrect parameter
//Contract.Assert(false); Cypher.Assert(false);
return false; return false;
} }
@@ -228,7 +228,7 @@ public static class MathFunctions
return val1 <= val2; return val1 <= val2;
default: default:
// incorrect parameter // incorrect parameter
//Contract.Assert(false); Cypher.Assert(false);
return false; return false;
} }
} }
+1 -2
View File
@@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Diagnostics.Contracts;
public class RandomHelper public class RandomHelper
{ {
@@ -70,7 +69,7 @@ public class RandomHelper
} }
public static float FRand(float min, float max) public static float FRand(float min, float max)
{ {
Contract.Assert(max >= min); Cypher.Assert(max >= min);
return (float)(rand.NextDouble() * (max - min) + min); return (float)(rand.NextDouble() * (max - min) + min);
} }
+1 -2
View File
@@ -21,7 +21,6 @@ using Game.Entities;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.AI namespace Game.AI
@@ -472,7 +471,7 @@ namespace Game.AI
_caster = caster; _caster = caster;
_spellInfo = Global.SpellMgr.GetSpellInfo(spellId); _spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
Contract.Assert(_spellInfo != null); Cypher.Assert(_spellInfo != null);
} }
public bool Check(Unit target) public bool Check(Unit target)
+1 -2
View File
@@ -17,7 +17,6 @@
using Framework.Database; using Framework.Database;
using System; using System;
using System.Diagnostics.Contracts;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@@ -46,7 +45,7 @@ namespace Game
DB.Login.DirectExecute(stmt); DB.Login.DirectExecute(stmt);
uint newAccountId = GetId(email); uint newAccountId = GetId(email);
Contract.Assert(newAccountId != 0); Cypher.Assert(newAccountId != 0);
if (withGameAccount) if (withGameAccount)
{ {
+2 -3
View File
@@ -27,7 +27,6 @@ using Game.Network;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -586,7 +585,7 @@ namespace Game.Achievements
uint timeElapsed = 0; uint timeElapsed = 0;
if (criteria.Entry.StartTimer != 0) if (criteria.Entry.StartTimer != 0)
{ {
Contract.Assert(trees != null); Cypher.Assert(trees != null);
foreach (CriteriaTree tree in trees) foreach (CriteriaTree tree in trees)
{ {
@@ -1554,7 +1553,7 @@ namespace Game.Achievements
uint questObjectiveCriterias = 0; uint questObjectiveCriterias = 0;
foreach (CriteriaRecord criteriaEntry in CliDB.CriteriaStorage.Values) foreach (CriteriaRecord criteriaEntry in CliDB.CriteriaStorage.Values)
{ {
Contract.Assert(criteriaEntry.Type < CriteriaTypes.TotalTypes, Cypher.Assert(criteriaEntry.Type < CriteriaTypes.TotalTypes,
$"CRITERIA_TYPE_TOTAL must be greater than or equal to {criteriaEntry.Type + 1} but is currently equal to {CriteriaTypes.TotalTypes}"); $"CRITERIA_TYPE_TOTAL must be greater than or equal to {criteriaEntry.Type + 1} but is currently equal to {CriteriaTypes.TotalTypes}");
var treeList = _criteriaTreeByCriteria.LookupByKey(criteriaEntry.Id); var treeList = _criteriaTreeByCriteria.LookupByKey(criteriaEntry.Id);
+3 -4
View File
@@ -24,7 +24,6 @@ using Game.Mails;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game namespace Game
{ {
@@ -327,8 +326,8 @@ namespace Game
public void AddAItem(Item it) public void AddAItem(Item it)
{ {
Contract.Assert(it); Cypher.Assert(it);
Contract.Assert(!mAitems.ContainsKey(it.GetGUID().GetCounter())); Cypher.Assert(!mAitems.ContainsKey(it.GetGUID().GetCounter()));
mAitems[it.GetGUID().GetCounter()] = it; mAitems[it.GetGUID().GetCounter()] = it;
} }
@@ -419,7 +418,7 @@ namespace Game
{ {
public void AddAuction(AuctionEntry auction) public void AddAuction(AuctionEntry auction)
{ {
Contract.Assert(auction != null); Cypher.Assert(auction != null);
AuctionsMap[auction.Id] = auction; AuctionsMap[auction.Id] = auction;
Global.ScriptMgr.OnAuctionAdd(this, auction); Global.ScriptMgr.OnAuctionAdd(this, auction);
+1 -2
View File
@@ -25,7 +25,6 @@ using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.BattleFields namespace Game.BattleFields
@@ -1078,7 +1077,7 @@ namespace Game.BattleFields
public bool SetCapturePointData(GameObject capturePoint) public bool SetCapturePointData(GameObject capturePoint)
{ {
Contract.Assert(capturePoint); Cypher.Assert(capturePoint);
Log.outError(LogFilter.Battlefield, "Creating capture point {0}", capturePoint.GetEntry()); Log.outError(LogFilter.Battlefield, "Creating capture point {0}", capturePoint.GetEntry());
@@ -21,7 +21,6 @@ using Game.Entities;
using Game.Network.Packets; using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.BattleFields namespace Game.BattleFields
{ {
@@ -1591,7 +1590,7 @@ namespace Game.BattleFields
public override void ChangeTeam(uint oldteam) public override void ChangeTeam(uint oldteam)
{ {
Contract.Assert(m_Workshop != null); Cypher.Assert(m_Workshop != null);
m_Workshop.GiveControlTo(m_team, false); m_Workshop.GiveControlTo(m_team, false);
} }
uint GetTeam() { return m_team; } uint GetTeam() { return m_team; }
+3 -4
View File
@@ -29,7 +29,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.BattleGrounds namespace Game.BattleGrounds
@@ -520,13 +519,13 @@ namespace Game.BattleGrounds
public BattlegroundMap GetBgMap() public BattlegroundMap GetBgMap()
{ {
Contract.Assert(m_Map); Cypher.Assert(m_Map);
return m_Map; return m_Map;
} }
public void SetTeamStartPosition(int teamIndex, Position pos) public void SetTeamStartPosition(int teamIndex, Position pos)
{ {
Contract.Assert(teamIndex < TeamId.Neutral); Cypher.Assert(teamIndex < TeamId.Neutral);
StartPosition[teamIndex] = pos; StartPosition[teamIndex] = pos;
} }
@@ -1892,7 +1891,7 @@ namespace Game.BattleGrounds
public Position GetTeamStartPosition(int teamIndex) public Position GetTeamStartPosition(int teamIndex)
{ {
Contract.Assert(teamIndex < TeamId.Neutral); Cypher.Assert(teamIndex < TeamId.Neutral);
return StartPosition[teamIndex]; return StartPosition[teamIndex];
} }
@@ -17,7 +17,6 @@
using Framework.Constants; using Framework.Constants;
using Game.Entities; using Game.Entities;
using System.Diagnostics.Contracts;
using Game.Network.Packets; using Game.Network.Packets;
namespace Game.BattleGrounds namespace Game.BattleGrounds
@@ -53,7 +52,7 @@ namespace Game.BattleGrounds
HealingDone += value; HealingDone += value;
break; break;
default: default:
Contract.Assert(false, "Not implemented Battleground score type!"); Cypher.Assert(false, "Not implemented Battleground score type!");
break; break;
} }
} }
@@ -21,7 +21,6 @@ using Game.Entities;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.BattleGrounds.Zones namespace Game.BattleGrounds.Zones
{ {
+1 -2
View File
@@ -24,7 +24,6 @@ using Game.Maps;
using Game.SupportSystem; using Game.SupportSystem;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Chat.Commands namespace Game.Chat.Commands
{ {
@@ -419,7 +418,7 @@ namespace Game.Chat.Commands
// update to parent zone if exist (client map show only zones without parents) // update to parent zone if exist (client map show only zones without parents)
AreaTableRecord zoneEntry = areaEntry.ParentAreaID != 0 ? CliDB.AreaTableStorage.LookupByKey(areaEntry.ParentAreaID) : areaEntry; AreaTableRecord zoneEntry = areaEntry.ParentAreaID != 0 ? CliDB.AreaTableStorage.LookupByKey(areaEntry.ParentAreaID) : areaEntry;
Contract.Assert(zoneEntry != null); Cypher.Assert(zoneEntry != null);
Map map = Global.MapMgr.CreateBaseMap(zoneEntry.ContinentID); Map map = Global.MapMgr.CreateBaseMap(zoneEntry.ContinentID);
+1 -2
View File
@@ -17,7 +17,6 @@
using Framework.GameMath; using Framework.GameMath;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Collision namespace Game.Collision
{ {
@@ -68,7 +67,7 @@ namespace Game.Collision
bool result = false; bool result = false;
float maxDist = (endPos - startPos).magnitude(); float maxDist = (endPos - startPos).magnitude();
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too // valid map coords should *never ever* produce float overflow, but this would produce NaNs too
Contract.Assert(maxDist < float.MaxValue); Cypher.Assert(maxDist < float.MaxValue);
// prevent NaN values which can cause BIH intersection to enter infinite loop // prevent NaN values which can cause BIH intersection to enter infinite loop
if (maxDist < 1e-10f) if (maxDist < 1e-10f)
{ {
@@ -19,7 +19,6 @@ using Framework.Constants;
using Framework.GameMath; using Framework.GameMath;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Collision namespace Game.Collision
{ {
@@ -221,7 +220,7 @@ namespace Game.Collision
if (instanceTree.GetLocationInfo(pos, info)) if (instanceTree.GetLocationInfo(pos, info))
{ {
floor = info.ground_Z; floor = info.ground_Z;
Contract.Assert(floor < float.MaxValue); Cypher.Assert(floor < float.MaxValue);
type = info.hitModel.GetLiquidType(); // entry from LiquidType.dbc type = info.hitModel.GetLiquidType(); // entry from LiquidType.dbc
if (reqLiquidType != 0 && !Convert.ToBoolean(Global.DB2Mgr.GetLiquidFlags(type) & reqLiquidType)) if (reqLiquidType != 0 && !Convert.ToBoolean(Global.DB2Mgr.GetLiquidFlags(type) & reqLiquidType))
return false; return false;
+2 -3
View File
@@ -19,7 +19,6 @@ using Framework.Constants;
using Framework.GameMath; using Framework.GameMath;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO; using System.IO;
namespace Game.Collision namespace Game.Collision
@@ -328,7 +327,7 @@ namespace Game.Collision
bool result = false; bool result = false;
float maxDist = (pPos2 - pPos1).magnitude(); float maxDist = (pPos2 - pPos1).magnitude();
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too // valid map coords should *never ever* produce float overflow, but this would produce NaNs too
Contract.Assert(maxDist < float.MaxValue); Cypher.Assert(maxDist < float.MaxValue);
// prevent NaN values which can cause BIH intersection to enter infinite loop // prevent NaN values which can cause BIH intersection to enter infinite loop
if (maxDist < 1e-10f) if (maxDist < 1e-10f)
{ {
@@ -375,7 +374,7 @@ namespace Game.Collision
return false; return false;
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too // valid map coords should *never ever* produce float overflow, but this would produce NaNs too
Contract.Assert(maxDist < float.MaxValue); Cypher.Assert(maxDist < float.MaxValue);
// prevent NaN values which can cause BIH intersection to enter infinite loop // prevent NaN values which can cause BIH intersection to enter infinite loop
if (maxDist < 1e-10f) if (maxDist < 1e-10f)
return true; return true;
+1 -2
View File
@@ -18,7 +18,6 @@
using Framework.GameMath; using Framework.GameMath;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Collections.Concurrent; using System.Collections.Concurrent;
namespace Game.Collision namespace Game.Collision
@@ -102,7 +101,7 @@ namespace Game.Collision
Node getGrid(int x, int y) Node getGrid(int x, int y)
{ {
Contract.Assert(x < CELL_NUMBER && y < CELL_NUMBER); Cypher.Assert(x < CELL_NUMBER && y < CELL_NUMBER);
if (nodes[x][y] == null) if (nodes[x][y] == null)
nodes[x][y] = new Node(); nodes[x][y] = new Node();
return nodes[x][y]; return nodes[x][y];
+2 -3
View File
@@ -19,7 +19,6 @@ using Framework.Constants;
using Game.Entities; using Game.Entities;
using Game.Spells; using Game.Spells;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Combat namespace Game.Combat
@@ -313,7 +312,7 @@ namespace Game.Combat
if (threatSpell != null && threatSpell.HasAttribute(SpellAttr1.NoThreat)) if (threatSpell != null && threatSpell.HasAttribute(SpellAttr1.NoThreat))
return false; return false;
Contract.Assert(hatingUnit.IsTypeId(TypeId.Unit)); Cypher.Assert(hatingUnit.IsTypeId(TypeId.Unit));
return true; return true;
} }
@@ -395,7 +394,7 @@ namespace Game.Combat
currentRef = threatList[i]; currentRef = threatList[i];
Unit target = currentRef.getTarget(); Unit target = currentRef.getTarget();
Contract.Assert(target); // if the ref has status online the target must be there ! Cypher.Assert(target); // if the ref has status online the target must be there !
// some units are prefered in comparison to others // some units are prefered in comparison to others
if (!noPriorityTargetFound && (target.IsImmunedToDamage(attacker.GetMeleeDamageSchoolMask()) || target.HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags.TakeDamage))) if (!noPriorityTargetFound && (target.IsImmunedToDamage(attacker.GetMeleeDamageSchoolMask()) || target.HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags.TakeDamage)))
+3 -4
View File
@@ -21,7 +21,6 @@ using Game.Entities;
using Game.Maps; using Game.Maps;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Text; using System.Text;
namespace Game.Conditions namespace Game.Conditions
@@ -36,7 +35,7 @@ namespace Game.Conditions
public bool Meets(ConditionSourceInfo sourceInfo) public bool Meets(ConditionSourceInfo sourceInfo)
{ {
Contract.Assert(ConditionTarget < SharedConst.MaxConditionTargets); Cypher.Assert(ConditionTarget < SharedConst.MaxConditionTargets);
WorldObject obj = sourceInfo.mConditionTargets[ConditionTarget]; WorldObject obj = sourceInfo.mConditionTargets[ConditionTarget];
// object not present, return false // object not present, return false
if (obj == null) if (obj == null)
@@ -62,7 +61,7 @@ namespace Game.Conditions
if (player != null) if (player != null)
{ {
// don't allow 0 items (it's checked during table load) // 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; bool checkBank = ConditionValue3 != 0 ? true : false;
condMeets = player.HasItemCount(ConditionValue1, ConditionValue2, checkBank); condMeets = player.HasItemCount(ConditionValue1, ConditionValue2, checkBank);
} }
@@ -486,7 +485,7 @@ namespace Game.Conditions
mask |= GridMapTypeMask.Player; mask |= GridMapTypeMask.Player;
break; break;
default: default:
Contract.Assert(false, "Condition.GetSearcherTypeMaskForCondition - missing condition handling!"); Cypher.Assert(false, "Condition.GetSearcherTypeMaskForCondition - missing condition handling!");
break; break;
} }
return mask; return mask;
+4 -5
View File
@@ -25,7 +25,6 @@ using Game.Loots;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game namespace Game
@@ -43,7 +42,7 @@ namespace Game
foreach (var i in conditions) foreach (var i in conditions)
{ {
// no point of having not loaded conditions in list // 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 // group not filled yet, fill with widest mask possible
if (!elseGroupSearcherTypeMasks.ContainsKey(i.ElseGroup)) if (!elseGroupSearcherTypeMasks.ContainsKey(i.ElseGroup))
elseGroupSearcherTypeMasks[i.ElseGroup] = GridMapTypeMask.All; elseGroupSearcherTypeMasks[i.ElseGroup] = GridMapTypeMask.All;
@@ -54,7 +53,7 @@ namespace Game
if (i.ReferenceId != 0) // handle reference if (i.ReferenceId != 0) // handle reference
{ {
var refe = ConditionReferenceStore.LookupByKey(i.ReferenceId); 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); elseGroupSearcherTypeMasks[i.ElseGroup] &= GetSearcherTypeMaskForConditionList(refe);
} }
else // handle normal condition else // handle normal condition
@@ -579,7 +578,7 @@ namespace Game
{ {
uint conditionEffMask = cond.SourceGroup; uint conditionEffMask = cond.SourceGroup;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)cond.SourceEntry); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)cond.SourceEntry);
Contract.Assert(spellInfo != null); Cypher.Assert(spellInfo != null);
List<uint> sharedMasks = new List<uint>(); List<uint> sharedMasks = new List<uint>();
for (byte i = 0; i < SpellConst.MaxEffects; ++i) for (byte i = 0; i < SpellConst.MaxEffects; ++i)
{ {
@@ -1644,7 +1643,7 @@ namespace Game
static bool PlayerConditionLogic(uint logic, bool[] results) 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) for (var i = 0; i < results.Length; ++i)
{ {
+1 -2
View File
@@ -22,7 +22,6 @@ using Game.DataStorage;
using Game.Entities; using Game.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game namespace Game
{ {
@@ -288,7 +287,7 @@ namespace Game
public bool IsDisabledFor(DisableType type, uint entry, Unit unit, byte flags = 0) 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()) if (!m_DisableMap.ContainsKey(type) || m_DisableMap[type].Empty())
return false; return false;
+7 -9
View File
@@ -20,7 +20,6 @@ using Framework.Database;
using Framework.GameMath; using Framework.GameMath;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -73,8 +72,8 @@ namespace Game.DataStorage
CharBaseSectionVariation[] sectionToBase = new CharBaseSectionVariation[(int)CharSectionType.Max]; CharBaseSectionVariation[] sectionToBase = new CharBaseSectionVariation[(int)CharSectionType.Max];
foreach (CharBaseSectionRecord charBaseSection in CliDB.CharBaseSectionStorage.Values) foreach (CharBaseSectionRecord charBaseSection in CliDB.CharBaseSectionStorage.Values)
{ {
Contract.Assert(charBaseSection.ResolutionVariationEnum < (byte)CharSectionType.Max, $"SECTION_TYPE_MAX ({(byte)CharSectionType.Max}) must be equal to or greater than {charBaseSection.ResolutionVariationEnum + 1}"); Cypher.Assert(charBaseSection.ResolutionVariationEnum < (byte)CharSectionType.Max, $"SECTION_TYPE_MAX ({(byte)CharSectionType.Max}) must be equal to or greater than {charBaseSection.ResolutionVariationEnum + 1}");
Contract.Assert(charBaseSection.VariationEnum < CharBaseSectionVariation.Max, $"CharBaseSectionVariation.Max {(byte)CharBaseSectionVariation.Max} must be equal to or greater than {charBaseSection.VariationEnum + 1}"); Cypher.Assert(charBaseSection.VariationEnum < CharBaseSectionVariation.Max, $"CharBaseSectionVariation.Max {(byte)CharBaseSectionVariation.Max} must be equal to or greater than {charBaseSection.VariationEnum + 1}");
sectionToBase[charBaseSection.ResolutionVariationEnum] = charBaseSection.VariationEnum; sectionToBase[charBaseSection.ResolutionVariationEnum] = charBaseSection.VariationEnum;
} }
@@ -84,7 +83,7 @@ namespace Game.DataStorage
MultiMap<Tuple<byte, byte, CharBaseSectionVariation>, Tuple<byte, byte>> addedSections = new MultiMap<Tuple<byte, byte, CharBaseSectionVariation>, Tuple<byte, byte>>(); MultiMap<Tuple<byte, byte, CharBaseSectionVariation>, Tuple<byte, byte>> addedSections = new MultiMap<Tuple<byte, byte, CharBaseSectionVariation>, Tuple<byte, byte>>();
foreach (CharSectionsRecord charSection in CliDB.CharSectionsStorage.Values) foreach (CharSectionsRecord charSection in CliDB.CharSectionsStorage.Values)
{ {
Contract.Assert(charSection.BaseSection < (byte)CharSectionType.Max, $"SECTION_TYPE_MAX ({(byte)CharSectionType.Max}) must be equal to or greater than {charSection.BaseSection + 1}"); Cypher.Assert(charSection.BaseSection < (byte)CharSectionType.Max, $"SECTION_TYPE_MAX ({(byte)CharSectionType.Max}) must be equal to or greater than {charSection.BaseSection + 1}");
Tuple<byte, byte, CharBaseSectionVariation> sectionKey = Tuple.Create(charSection.RaceID, charSection.SexID, sectionToBase[charSection.BaseSection]); Tuple<byte, byte, CharBaseSectionVariation> sectionKey = Tuple.Create(charSection.RaceID, charSection.SexID, sectionToBase[charSection.BaseSection]);
Tuple<byte, byte> sectionCombination = Tuple.Create(charSection.VariationIndex, charSection.ColorIndex); Tuple<byte, byte> sectionCombination = Tuple.Create(charSection.VariationIndex, charSection.ColorIndex);
@@ -299,7 +298,7 @@ namespace Game.DataStorage
foreach (var namesProfanity in CliDB.NamesProfanityStorage.Values) foreach (var namesProfanity in CliDB.NamesProfanityStorage.Values)
{ {
Contract.Assert(namesProfanity.Language < (int)LocaleConstant.Total || namesProfanity.Language == -1); Cypher.Assert(namesProfanity.Language < (int)LocaleConstant.Total || namesProfanity.Language == -1);
if (namesProfanity.Language != -1) if (namesProfanity.Language != -1)
_nameValidators[namesProfanity.Language].Add(new Regex(namesProfanity.Name, RegexOptions.IgnoreCase | RegexOptions.Compiled)); _nameValidators[namesProfanity.Language].Add(new Regex(namesProfanity.Name, RegexOptions.IgnoreCase | RegexOptions.Compiled));
else else
@@ -321,7 +320,7 @@ namespace Game.DataStorage
foreach (var namesReserved in CliDB.NamesReservedLocaleStorage.Values) foreach (var namesReserved in CliDB.NamesReservedLocaleStorage.Values)
{ {
Contract.Assert(!Convert.ToBoolean(namesReserved.LocaleMask & ~((1 << (int)LocaleConstant.Total) - 1))); Cypher.Assert(!Convert.ToBoolean(namesReserved.LocaleMask & ~((1 << (int)LocaleConstant.Total) - 1)));
for (int i = 0; i < (int)LocaleConstant.Total; ++i) for (int i = 0; i < (int)LocaleConstant.Total; ++i)
{ {
if (i == (int)LocaleConstant.None) if (i == (int)LocaleConstant.None)
@@ -343,7 +342,7 @@ namespace Game.DataStorage
foreach (PowerTypeRecord powerType in CliDB.PowerTypeStorage.Values) foreach (PowerTypeRecord powerType in CliDB.PowerTypeStorage.Values)
{ {
Contract.Assert(powerType.PowerTypeEnum < PowerType.Max); Cypher.Assert(powerType.PowerTypeEnum < PowerType.Max);
_powerTypes[powerType.PowerTypeEnum] = powerType; _powerTypes[powerType.PowerTypeEnum] = powerType;
} }
@@ -1116,7 +1115,7 @@ namespace Game.DataStorage
public string GetNameGenEntry(uint race, uint gender) public string GetNameGenEntry(uint race, uint gender)
{ {
Contract.Assert(gender < (int)Gender.None); Cypher.Assert(gender < (int)Gender.None);
var listNameGen = _nameGenData.LookupByKey(race); var listNameGen = _nameGenData.LookupByKey(race);
if (listNameGen == null) if (listNameGen == null)
return ""; return "";
@@ -1443,7 +1442,6 @@ namespace Game.DataStorage
{ {
newPos = new Vector2(); newPos = new Vector2();
//Contract.Assert(newMapId != 0 || newPos != );
WorldMapTransformsRecord transformation = null; WorldMapTransformsRecord transformation = null;
foreach (WorldMapTransformsRecord transform in CliDB.WorldMapTransformsStorage.Values) foreach (WorldMapTransformsRecord transform in CliDB.WorldMapTransformsStorage.Values)
{ {
+5 -6
View File
@@ -24,7 +24,6 @@ using Game.Groups;
using Game.Maps; using Game.Maps;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Game.Network.Packets; using Game.Network.Packets;
@@ -757,8 +756,8 @@ namespace Game.DungeonFinding
if (it2.Value.lockStatus == LfgLockStatusType.RaidLocked && isContinue) if (it2.Value.lockStatus == LfgLockStatusType.RaidLocked && isContinue)
{ {
LFGDungeonData dungeon = GetLFGDungeon(dungeonId); LFGDungeonData dungeon = GetLFGDungeon(dungeonId);
Contract.Assert(dungeon != null); Cypher.Assert(dungeon != null);
Contract.Assert(player); Cypher.Assert(player);
InstanceBind playerBind = player.GetBoundInstance(dungeon.map, dungeon.difficulty); InstanceBind playerBind = player.GetBoundInstance(dungeon.map, dungeon.difficulty);
if (playerBind != null) if (playerBind != null)
{ {
@@ -873,7 +872,7 @@ namespace Game.DungeonFinding
// Set the dungeon difficulty // Set the dungeon difficulty
LFGDungeonData dungeon = GetLFGDungeon(proposal.dungeonId); LFGDungeonData dungeon = GetLFGDungeon(proposal.dungeonId);
Contract.Assert(dungeon != null); Cypher.Assert(dungeon != null);
Group grp = !proposal.group.IsEmpty() ? Global.GroupMgr.GetGroupByGUID(proposal.group) : null; Group grp = !proposal.group.IsEmpty() ? Global.GroupMgr.GetGroupByGUID(proposal.group) : null;
foreach (var pguid in players) foreach (var pguid in players)
@@ -1431,7 +1430,7 @@ namespace Game.DungeonFinding
public bool IsVoteKickActive(ObjectGuid gguid) public bool IsVoteKickActive(ObjectGuid gguid)
{ {
Contract.Assert(gguid.IsParty()); Cypher.Assert(gguid.IsParty());
bool active = GroupsStore[gguid].IsVoteKickActive(); bool active = GroupsStore[gguid].IsVoteKickActive();
Log.outInfo(LogFilter.Lfg, "Group: {0}, Active: {1}", gguid.ToString(), active); Log.outInfo(LogFilter.Lfg, "Group: {0}, Active: {1}", gguid.ToString(), active);
@@ -1591,7 +1590,7 @@ namespace Game.DungeonFinding
void SetVoteKick(ObjectGuid gguid, bool active) void SetVoteKick(ObjectGuid gguid, bool active)
{ {
Contract.Assert(gguid.IsParty()); Cypher.Assert(gguid.IsParty());
var data = GroupsStore[gguid]; var data = GroupsStore[gguid];
Log.outInfo(LogFilter.Lfg, "Group: {0}, New state: {1}, Previous: {2}", gguid.ToString(), active, data.IsVoteKickActive()); Log.outInfo(LogFilter.Lfg, "Group: {0}, New state: {1}, Previous: {2}", gguid.ToString(), active, data.IsVoteKickActive());
+1 -2
View File
@@ -27,7 +27,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -662,7 +661,7 @@ namespace Game.Entities
return false; return false;
} }
Contract.Assert(i_disabledAI == null, "The disabled AI wasn't cleared!"); Cypher.Assert(i_disabledAI == null, "The disabled AI wasn't cleared!");
i_AI = null; i_AI = null;
+1 -2
View File
@@ -23,7 +23,6 @@ using Game.DataStorage;
using Game.Entities; using Game.Entities;
using Game.Network.Packets; using Game.Network.Packets;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Misc namespace Game.Misc
@@ -32,7 +31,7 @@ namespace Game.Misc
{ {
public uint AddMenuItem(int optionIndex, GossipOptionIcon icon, string message, uint sender, uint action, string boxMessage, uint boxMoney, bool coded = false) public uint AddMenuItem(int optionIndex, GossipOptionIcon icon, string message, uint sender, uint action, string boxMessage, uint boxMoney, bool coded = false)
{ {
Contract.Assert(_menuItems.Count <= SharedConst.MaxGossipMenuItems); Cypher.Assert(_menuItems.Count <= SharedConst.MaxGossipMenuItems);
// Find a free new id - script case // Find a free new id - script case
if (optionIndex == -1) if (optionIndex == -1)
+11 -12
View File
@@ -17,7 +17,6 @@
using Framework.Constants; using Framework.Constants;
using Game.Spells; using Game.Spells;
using System.Diagnostics.Contracts;
namespace Game.Entities namespace Game.Entities
{ {
@@ -36,9 +35,9 @@ namespace Game.Entities
public override void Dispose() public override void Dispose()
{ {
// make sure all references were properly removed // make sure all references were properly removed
Contract.Assert(_aura == null); Cypher.Assert(_aura == null);
Contract.Assert(!_caster); Cypher.Assert(!_caster);
Contract.Assert(!_isViewpoint); Cypher.Assert(!_isViewpoint);
_removedAura = null; _removedAura = null;
base.Dispose(); base.Dispose();
@@ -129,8 +128,8 @@ namespace Game.Entities
public override void Update(uint diff) public override void Update(uint diff)
{ {
// caster has to be always available and in the same map // caster has to be always available and in the same map
Contract.Assert(_caster != null); Cypher.Assert(_caster != null);
Contract.Assert(_caster.GetMap() == GetMap()); Cypher.Assert(_caster.GetMap() == GetMap());
bool expired = false; bool expired = false;
@@ -189,13 +188,13 @@ namespace Game.Entities
public void SetAura(Aura aura) public void SetAura(Aura aura)
{ {
Contract.Assert(_aura == null && aura != null); Cypher.Assert(_aura == null && aura != null);
_aura = aura; _aura = aura;
} }
void RemoveAura() void RemoveAura()
{ {
Contract.Assert(_aura != null && _removedAura == null); Cypher.Assert(_aura != null && _removedAura == null);
_removedAura = _aura; _removedAura = _aura;
_aura = null; _aura = null;
if (!_removedAura.IsRemoved()) if (!_removedAura.IsRemoved())
@@ -224,16 +223,16 @@ namespace Game.Entities
void BindToCaster() void BindToCaster()
{ {
Contract.Assert(_caster == null); Cypher.Assert(_caster == null);
_caster = Global.ObjAccessor.GetUnit(this, GetCasterGUID()); _caster = Global.ObjAccessor.GetUnit(this, GetCasterGUID());
Contract.Assert(_caster != null); Cypher.Assert(_caster != null);
Contract.Assert(_caster.GetMap() == GetMap()); Cypher.Assert(_caster.GetMap() == GetMap());
_caster._RegisterDynObject(this); _caster._RegisterDynObject(this);
} }
void UnbindFromCaster() void UnbindFromCaster()
{ {
Contract.Assert(_caster != null); Cypher.Assert(_caster != null);
_caster._UnregisterDynObject(this); _caster._UnregisterDynObject(this);
_caster = null; _caster = null;
} }
@@ -30,7 +30,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -100,7 +99,7 @@ namespace Game.Entities
if (owner) if (owner)
{ {
owner.RemoveGameObject(this, false); owner.RemoveGameObject(this, false);
Contract.Assert(GetOwnerGUID().IsEmpty()); Cypher.Assert(GetOwnerGUID().IsEmpty());
return; return;
} }
@@ -182,7 +181,7 @@ namespace Game.Entities
bool Create(uint entry, Map map, Position pos, Quaternion rotation, uint animProgress, GameObjectState goState, uint artKit) bool Create(uint entry, Map map, Position pos, Quaternion rotation, uint animProgress, GameObjectState goState, uint artKit)
{ {
Contract.Assert(map); Cypher.Assert(map);
SetMap(map); SetMap(map);
Relocate(pos); Relocate(pos);
@@ -2143,7 +2142,7 @@ namespace Game.Entities
public void SetDestructibleState(GameObjectDestructibleState state, Player eventInvoker = null, bool setHealth = false) public void SetDestructibleState(GameObjectDestructibleState state, Player eventInvoker = null, bool setHealth = false)
{ {
// the user calling this must know he is already operating on destructible gameobject // the user calling this must know he is already operating on destructible gameobject
Contract.Assert(GetGoType() == GameObjectTypes.DestructibleBuilding); Cypher.Assert(GetGoType() == GameObjectTypes.DestructibleBuilding);
switch (state) switch (state)
{ {
@@ -2278,7 +2277,7 @@ namespace Game.Entities
public virtual uint GetTransportPeriod() public virtual uint GetTransportPeriod()
{ {
Contract.Assert(GetGoInfo().type == GameObjectTypes.Transport); Cypher.Assert(GetGoInfo().type == GameObjectTypes.Transport);
if (m_goValue.Transport.AnimationInfo.Path != null) if (m_goValue.Transport.AnimationInfo.Path != null)
return m_goValue.Transport.AnimationInfo.TotalTime; return m_goValue.Transport.AnimationInfo.TotalTime;
@@ -2290,8 +2289,8 @@ namespace Game.Entities
if (GetGoState() == state) if (GetGoState() == state)
return; return;
Contract.Assert(GetGoInfo().type == GameObjectTypes.Transport); Cypher.Assert(GetGoInfo().type == GameObjectTypes.Transport);
Contract.Assert(state >= GameObjectState.TransportActive); Cypher.Assert(state >= GameObjectState.TransportActive);
if (state == GameObjectState.TransportActive) if (state == GameObjectState.TransportActive)
{ {
m_goValue.Transport.StateUpdateTimer = 0; m_goValue.Transport.StateUpdateTimer = 0;
@@ -2302,7 +2301,7 @@ namespace Game.Entities
} }
else else
{ {
Contract.Assert(stopFrame < m_goValue.Transport.StopFrames.Count); Cypher.Assert(stopFrame < m_goValue.Transport.StopFrames.Count);
m_goValue.Transport.PathProgress = Time.GetMSTime() + m_goValue.Transport.StopFrames[(int)stopFrame]; m_goValue.Transport.PathProgress = Time.GetMSTime() + m_goValue.Transport.StopFrames[(int)stopFrame];
SetGoState((GameObjectState)((int)GameObjectState.TransportStopped + stopFrame)); SetGoState((GameObjectState)((int)GameObjectState.TransportStopped + stopFrame));
} }
@@ -2631,7 +2630,7 @@ namespace Game.Entities
// Owner already found and different than expected owner - remove object from old owner // Owner already found and different than expected owner - remove object from old owner
if (!owner.IsEmpty() && !GetOwnerGUID().IsEmpty() && GetOwnerGUID() != owner) if (!owner.IsEmpty() && !GetOwnerGUID().IsEmpty() && GetOwnerGUID() != owner)
{ {
Contract.Assert(false); Cypher.Assert(false);
} }
m_spawnedByDefault = false; // all object with owner is despawned after delay m_spawnedByDefault = false; // all object with owner is despawned after delay
SetGuidValue(GameObjectFields.CreatedBy, owner); SetGuidValue(GameObjectFields.CreatedBy, owner);
+6 -7
View File
@@ -26,7 +26,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@@ -759,7 +758,7 @@ namespace Game.Entities
if (item.IsInUpdateQueue()) if (item.IsInUpdateQueue())
return; return;
Contract.Assert(player != null); Cypher.Assert(player != null);
if (player.GetGUID() != item.GetOwnerGUID()) if (player.GetGUID() != item.GetOwnerGUID())
{ {
@@ -779,7 +778,7 @@ namespace Game.Entities
if (!item.IsInUpdateQueue()) if (!item.IsInUpdateQueue())
return; return;
Contract.Assert(player != null); Cypher.Assert(player != null);
if (player.GetGUID() != item.GetOwnerGUID()) if (player.GetGUID() != item.GetOwnerGUID())
{ {
@@ -2054,7 +2053,7 @@ namespace Game.Entities
public int GetItemStatValue(uint index, Player owner) public int GetItemStatValue(uint index, Player owner)
{ {
Contract.Assert(index < ItemConst.MaxStats); Cypher.Assert(index < ItemConst.MaxStats);
uint itemLevel = GetItemLevel(owner); uint itemLevel = GetItemLevel(owner);
uint randomPropPoints = ItemEnchantment.GetRandomPropertyPoints(itemLevel, GetQuality(), GetTemplate().GetInventoryType(), GetTemplate().GetSubClass()); uint randomPropPoints = ItemEnchantment.GetRandomPropertyPoints(itemLevel, GetQuality(), GetTemplate().GetInventoryType(), GetTemplate().GetSubClass());
if (randomPropPoints != 0) if (randomPropPoints != 0)
@@ -2550,7 +2549,7 @@ namespace Game.Entities
if (eff.EquippedItemCount == 0) //all items of a set were removed if (eff.EquippedItemCount == 0) //all items of a set were removed
{ {
Contract.Assert(eff == player.ItemSetEff[setindex]); Cypher.Assert(eff == player.ItemSetEff[setindex]);
player.ItemSetEff[setindex] = null; player.ItemSetEff[setindex] = null;
} }
} }
@@ -2632,12 +2631,12 @@ namespace Game.Entities
public ItemQuality GetQuality() { return _bonusData.Quality; } public ItemQuality GetQuality() { return _bonusData.Quality; }
public int GetItemStatType(uint index) public int GetItemStatType(uint index)
{ {
Contract.Assert(index < ItemConst.MaxStats); Cypher.Assert(index < ItemConst.MaxStats);
return _bonusData.ItemStatType[index]; return _bonusData.ItemStatType[index];
} }
public SocketColor GetSocketColor(uint index) public SocketColor GetSocketColor(uint index)
{ {
Contract.Assert(index < ItemConst.MaxGemSockets); Cypher.Assert(index < ItemConst.MaxGemSockets);
return _bonusData.socketColor[index]; return _bonusData.socketColor[index];
} }
public uint GetAppearanceModId() { return GetUInt32Value(ItemFields.AppearanceModId); } public uint GetAppearanceModId() { return GetUInt32Value(ItemFields.AppearanceModId); }
+5 -6
View File
@@ -20,7 +20,6 @@ using Game.DataStorage;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Entities namespace Game.Entities
{ {
@@ -275,22 +274,22 @@ namespace Game.Entities
public uint GetContainerSlots() { return ExtendedData.ContainerSlots; } public uint GetContainerSlots() { return ExtendedData.ContainerSlots; }
public int GetItemStatType(uint index) public int GetItemStatType(uint index)
{ {
Contract.Assert(index < ItemConst.MaxStats); Cypher.Assert(index < ItemConst.MaxStats);
return ExtendedData.StatModifierBonusStat[index]; return ExtendedData.StatModifierBonusStat[index];
} }
public int GetItemStatValue(uint index) public int GetItemStatValue(uint index)
{ {
Contract.Assert(index < ItemConst.MaxStats); Cypher.Assert(index < ItemConst.MaxStats);
return ExtendedData.ItemStatValue[index]; return ExtendedData.ItemStatValue[index];
} }
public int GetItemStatAllocation(uint index) public int GetItemStatAllocation(uint index)
{ {
Contract.Assert(index < ItemConst.MaxStats); Cypher.Assert(index < ItemConst.MaxStats);
return ExtendedData.StatPercentEditor[index]; return ExtendedData.StatPercentEditor[index];
} }
public float GetItemStatSocketCostMultiplier(uint index) public float GetItemStatSocketCostMultiplier(uint index)
{ {
Contract.Assert(index < ItemConst.MaxStats); Cypher.Assert(index < ItemConst.MaxStats);
return ExtendedData.StatPercentageOfSocket[index]; return ExtendedData.StatPercentageOfSocket[index];
} }
public uint GetScalingStatDistribution() { return ExtendedData.ScalingStatDistributionID; } public uint GetScalingStatDistribution() { return ExtendedData.ScalingStatDistributionID; }
@@ -310,7 +309,7 @@ namespace Game.Entities
public uint GetTotemCategory() { return ExtendedData.TotemCategoryID; } public uint GetTotemCategory() { return ExtendedData.TotemCategoryID; }
public SocketColor GetSocketColor(uint index) public SocketColor GetSocketColor(uint index)
{ {
Contract.Assert(index < ItemConst.MaxGemSockets); Cypher.Assert(index < ItemConst.MaxGemSockets);
return (SocketColor)ExtendedData.SocketType[index]; return (SocketColor)ExtendedData.SocketType[index];
} }
public uint GetSocketBonus() { return ExtendedData.SocketMatchEnchantmentId; } public uint GetSocketBonus() { return ExtendedData.SocketMatchEnchantmentId; }
+3 -4
View File
@@ -23,7 +23,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -39,7 +38,7 @@ namespace Game.Entities
{ {
m_petType = type; m_petType = type;
Contract.Assert(GetOwner().IsTypeId(TypeId.Player)); Cypher.Assert(GetOwner().IsTypeId(TypeId.Player));
m_unitTypeMask |= UnitTypeMask.Pet; m_unitTypeMask |= UnitTypeMask.Pet;
if (type == PetType.Hunter) if (type == PetType.Hunter)
@@ -663,7 +662,7 @@ namespace Game.Entities
public bool CreateBaseAtCreature(Creature creature) public bool CreateBaseAtCreature(Creature creature)
{ {
Contract.Assert(creature); Cypher.Assert(creature);
if (!CreateBaseAtTamed(creature.GetCreatureTemplate(), creature.GetMap())) if (!CreateBaseAtTamed(creature.GetCreatureTemplate(), creature.GetMap()))
return false; return false;
@@ -1336,7 +1335,7 @@ namespace Game.Entities
public bool Create(ulong guidlow, Map map, uint Entry) public bool Create(ulong guidlow, Map map, uint Entry)
{ {
Contract.Assert(map); Cypher.Assert(map);
SetMap(map); SetMap(map);
_Create(ObjectGuid.Create(HighGuid.Pet, map.GetId(), Entry, guidlow)); _Create(ObjectGuid.Create(HighGuid.Pet, map.GetId(), Entry, guidlow));
+1 -2
View File
@@ -30,7 +30,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -2670,7 +2669,7 @@ namespace Game.Entities
var nodeEntry = CliDB.TaxiNodesStorage.LookupByKey(nodeid); var nodeEntry = CliDB.TaxiNodesStorage.LookupByKey(nodeid);
if (nodeEntry != null && nodeEntry.ContinentID == GetMapId()) 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; mapId = nodeEntry.ContinentID;
Relocate(nodeEntry.Pos.X, nodeEntry.Pos.Y, nodeEntry.Pos.Z, 0.0f); 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.Groups;
using Game.Maps; using Game.Maps;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Entities namespace Game.Entities
{ {
@@ -165,7 +164,7 @@ namespace Game.Entities
public void SetPartyType(GroupCategory category, GroupType type) public void SetPartyType(GroupCategory category, GroupType type)
{ {
Contract.Assert(category < GroupCategory.Max); Cypher.Assert(category < GroupCategory.Max);
byte value = GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType); byte value = GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType);
value &= (byte)~((byte)0xFF << ((byte)category * 4)); value &= (byte)~((byte)0xFF << ((byte)category * 4));
value |= (byte)((byte)type << ((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 Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -122,7 +121,7 @@ namespace Game.Entities
{ {
List<ItemPosCount> dest = new List<ItemPosCount>(); List<ItemPosCount> dest = new List<ItemPosCount>();
InventoryResult msg = CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, itemid, count); 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); Item it = StoreNewItem(dest, itemid, true);
SendNewItem(it, count, true, false, true); SendNewItem(it, count, true, false, true);
} }
+4 -5
View File
@@ -27,7 +27,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Entities namespace Game.Entities
{ {
@@ -241,7 +240,7 @@ namespace Game.Entities
//we should obtain map from GetMap() in 99% of cases. Special case //we should obtain map from GetMap() in 99% of cases. Special case
//only for quests which cast teleport spells on player //only for quests which cast teleport spells on player
Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId()); Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId());
Contract.Assert(_map != null); Cypher.Assert(_map != null);
GameObject gameObject = _map.GetGameObject(guid); GameObject gameObject = _map.GetGameObject(guid);
if (gameObject != null) if (gameObject != null)
{ {
@@ -342,7 +341,7 @@ namespace Game.Entities
switch (guid.GetHigh()) switch (guid.GetHigh())
{ {
case HighGuid.Player: case HighGuid.Player:
Contract.Assert(quest.HasFlag(QuestFlags.AutoComplete)); Cypher.Assert(quest.HasFlag(QuestFlags.AutoComplete));
return Global.ObjectMgr.GetQuestTemplate(nextQuestID); return Global.ObjectMgr.GetQuestTemplate(nextQuestID);
case HighGuid.Creature: case HighGuid.Creature:
case HighGuid.Pet: case HighGuid.Pet:
@@ -360,7 +359,7 @@ namespace Game.Entities
//we should obtain map from GetMap() in 99% of cases. Special case //we should obtain map from GetMap() in 99% of cases. Special case
//only for quests which cast teleport spells on player //only for quests which cast teleport spells on player
Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId()); Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId());
Contract.Assert(_map != null); Cypher.Assert(_map != null);
GameObject gameObject = _map.GetGameObject(guid); GameObject gameObject = _map.GetGameObject(guid);
if (gameObject != null) if (gameObject != null)
objectQR = Global.ObjectMgr.GetGOQuestRelationBounds(gameObject.GetEntry()); objectQR = Global.ObjectMgr.GetGOQuestRelationBounds(gameObject.GetEntry());
@@ -2156,7 +2155,7 @@ namespace Game.Entities
public void KilledMonster(CreatureTemplate cInfo, ObjectGuid guid) public void KilledMonster(CreatureTemplate cInfo, ObjectGuid guid)
{ {
Contract.Assert(cInfo != null); Cypher.Assert(cInfo != null);
if (cInfo.Entry != 0) if (cInfo.Entry != 0)
KilledMonsterCredit(cInfo.Entry, guid); KilledMonsterCredit(cInfo.Entry, guid);
+9 -10
View File
@@ -37,7 +37,6 @@ using Game.PvP;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -1091,7 +1090,7 @@ namespace Game.Entities
if (!charm.GetCharmerGUID().IsEmpty()) if (!charm.GetCharmerGUID().IsEmpty())
{ {
Log.outFatal(LogFilter.Player, "Charmed unit has charmer guid {0}", charm.GetCharmerGUID()); Log.outFatal(LogFilter.Player, "Charmed unit has charmer guid {0}", charm.GetCharmerGUID());
Contract.Assert(false); Cypher.Assert(false);
} }
SetCharm(charm, false); SetCharm(charm, false);
@@ -1231,7 +1230,7 @@ namespace Game.Entities
return; return;
CurrencyTypesRecord currency = CliDB.CurrencyTypesStorage.LookupByKey(id); CurrencyTypesRecord currency = CliDB.CurrencyTypesStorage.LookupByKey(id);
Contract.Assert(currency != null); Cypher.Assert(currency != null);
if (!ignoreMultipliers) if (!ignoreMultipliers)
count *= (int)GetTotalAuraMultiplierByMiscValue(AuraType.ModCurrencyGain, (int)id); count *= (int)GetTotalAuraMultiplierByMiscValue(AuraType.ModCurrencyGain, (int)id);
@@ -2605,7 +2604,7 @@ namespace Game.Entities
return textId; return textId;
} }
uint GetDefaultGossipMenuForSource(WorldObject source) public static uint GetDefaultGossipMenuForSource(WorldObject source)
{ {
switch (source.GetTypeId()) switch (source.GetTypeId())
{ {
@@ -3546,7 +3545,7 @@ namespace Game.Entities
public void SetResurrectRequestData(Unit caster, uint health, uint mana, uint appliedAura) public void SetResurrectRequestData(Unit caster, uint health, uint mana, uint appliedAura)
{ {
Contract.Assert(!IsResurrectRequested()); Cypher.Assert(!IsResurrectRequested());
_resurrectionData = new ResurrectionData(); _resurrectionData = new ResurrectionData();
_resurrectionData.GUID = caster.GetGUID(); _resurrectionData.GUID = caster.GetGUID();
_resurrectionData.Location.WorldRelocate(caster); _resurrectionData.Location.WorldRelocate(caster);
@@ -5099,9 +5098,9 @@ namespace Game.Entities
return GetCollisionHeight(false); return GetCollisionHeight(false);
var displayInfo = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetNativeDisplayId()); var displayInfo = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetNativeDisplayId());
Contract.Assert(displayInfo != null); Cypher.Assert(displayInfo != null);
var modelData = CliDB.CreatureModelDataStorage.LookupByKey(displayInfo.ModelID); var modelData = CliDB.CreatureModelDataStorage.LookupByKey(displayInfo.ModelID);
Contract.Assert(modelData != null); Cypher.Assert(modelData != null);
float scaleMod = GetObjectScale(); // 99% sure about this float scaleMod = GetObjectScale(); // 99% sure about this
@@ -5111,9 +5110,9 @@ namespace Game.Entities
{ {
//! Dismounting case - use basic default model data //! Dismounting case - use basic default model data
var displayInfo = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetNativeDisplayId()); var displayInfo = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetNativeDisplayId());
Contract.Assert(displayInfo != null); Cypher.Assert(displayInfo != null);
var modelData = CliDB.CreatureModelDataStorage.LookupByKey(displayInfo.ModelID); var modelData = CliDB.CreatureModelDataStorage.LookupByKey(displayInfo.ModelID);
Contract.Assert(modelData != null); Cypher.Assert(modelData != null);
return modelData.CollisionHeight; return modelData.CollisionHeight;
} }
@@ -7009,7 +7008,7 @@ namespace Game.Entities
//new //new
public uint DoRandomRoll(uint minimum, uint maximum) public uint DoRandomRoll(uint minimum, uint maximum)
{ {
Contract.Assert(maximum <= 10000); Cypher.Assert(maximum <= 10000);
uint roll = RandomHelper.URand(minimum, maximum); uint roll = RandomHelper.URand(minimum, maximum);
+11 -10
View File
@@ -18,8 +18,8 @@
using Framework.Constants; using Framework.Constants;
using Framework.Dynamic; using Framework.Dynamic;
using Game.DataStorage; using Game.DataStorage;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Entities namespace Game.Entities
{ {
@@ -175,7 +175,7 @@ namespace Game.Entities
public virtual void InitStats(uint duration) public virtual void InitStats(uint duration)
{ {
Contract.Assert(!IsPet()); Cypher.Assert(!IsPet());
m_timer = duration; m_timer = duration;
m_lifetime = duration; m_lifetime = duration;
@@ -250,11 +250,11 @@ namespace Game.Entities
return; return;
} }
Contract.Assert(!IsPet()); Cypher.Assert(!IsPet());
if (IsPet()) if (IsPet())
{ {
ToPet().Remove(PetSaveMode.NotInSlot); ToPet().Remove(PetSaveMode.NotInSlot);
Contract.Assert(!IsInWorld); Cypher.Assert(!IsInWorld);
return; return;
} }
@@ -313,9 +313,11 @@ namespace Game.Entities
: base(properties, owner, isWorldObject) : base(properties, owner, isWorldObject)
{ {
m_owner = owner; m_owner = owner;
Contract.Assert(m_owner); Cypher.Assert(m_owner);
m_unitTypeMask |= UnitTypeMask.Minion; m_unitTypeMask |= UnitTypeMask.Minion;
m_followAngle = SharedConst.PetFollowAngle; m_followAngle = SharedConst.PetFollowAngle;
/// @todo: Find correct way
InitCharmInfo();
} }
public override void InitStats(uint duration) public override void InitStats(uint duration)
@@ -411,7 +413,7 @@ namespace Game.Entities
public bool InitStatsForLevel(uint petlevel) public bool InitStatsForLevel(uint petlevel)
{ {
CreatureTemplate cinfo = GetCreatureTemplate(); CreatureTemplate cinfo = GetCreatureTemplate();
Contract.Assert(cinfo != null); Cypher.Assert(cinfo != null);
SetLevel(petlevel); SetLevel(petlevel);
@@ -966,10 +968,9 @@ namespace Game.Entities
public class Puppet : Minion public class Puppet : Minion
{ {
public Puppet(SummonPropertiesRecord properties, Unit owner) public Puppet(SummonPropertiesRecord properties, Unit owner) : base(properties, owner, false)
: base(properties, owner, false)
{ {
Contract.Assert(owner.IsTypeId(TypeId.Player)); Cypher.Assert(owner.IsTypeId(TypeId.Player));
m_unitTypeMask |= UnitTypeMask.Puppet; m_unitTypeMask |= UnitTypeMask.Puppet;
} }
@@ -985,7 +986,7 @@ namespace Game.Entities
{ {
base.InitSummon(); base.InitSummon();
if (!SetCharmedBy(GetOwner(), CharmType.Possess)) if (!SetCharmedBy(GetOwner(), CharmType.Possess))
Contract.Assert(false); Cypher.Assert(false);
} }
public override void Update(uint diff) public override void Update(uint diff)
+1 -2
View File
@@ -21,7 +21,6 @@ using Game.DataStorage;
using Game.Maps; using Game.Maps;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -72,7 +71,7 @@ namespace Game.Entities
public override void Dispose() public override void Dispose()
{ {
Contract.Assert(_passengers.Empty()); Cypher.Assert(_passengers.Empty());
UnloadStaticPassengers(); UnloadStaticPassengers();
base.Dispose(); base.Dispose();
} }
+5 -6
View File
@@ -28,7 +28,6 @@ using Game.PvP;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -168,7 +167,7 @@ namespace Game.Entities
public void TauntApply(Unit taunter) public void TauntApply(Unit taunter)
{ {
Contract.Assert(IsTypeId(TypeId.Unit)); Cypher.Assert(IsTypeId(TypeId.Unit));
if (!taunter || (taunter.IsTypeId(TypeId.Player) && taunter.ToPlayer().IsGameMaster())) if (!taunter || (taunter.IsTypeId(TypeId.Player) && taunter.ToPlayer().IsGameMaster()))
return; return;
@@ -192,7 +191,7 @@ namespace Game.Entities
public void TauntFadeOut(Unit taunter) public void TauntFadeOut(Unit taunter)
{ {
Contract.Assert(IsTypeId(TypeId.Unit)); Cypher.Assert(IsTypeId(TypeId.Unit));
if (!taunter || (taunter.IsTypeId(TypeId.Player) && taunter.ToPlayer().IsGameMaster())) if (!taunter || (taunter.IsTypeId(TypeId.Player) && taunter.ToPlayer().IsGameMaster()))
return; return;
@@ -1091,7 +1090,7 @@ namespace Game.Entities
{ {
Player he = duel_wasMounted ? victim.GetCharmer().ToPlayer() : victim.ToPlayer(); Player he = duel_wasMounted ? victim.GetCharmer().ToPlayer() : victim.ToPlayer();
Contract.Assert(he && he.duel != null); Cypher.Assert(he && he.duel != null);
if (duel_wasMounted) // In this case victim==mount if (duel_wasMounted) // In this case victim==mount
victim.SetHealth(1); victim.SetHealth(1);
@@ -2882,7 +2881,7 @@ namespace Game.Entities
// function based on function Unit.CanAttack from 13850 client // function based on function Unit.CanAttack from 13850 client
public bool _IsValidAttackTarget(Unit target, SpellInfo bySpell, WorldObject obj = null) public bool _IsValidAttackTarget(Unit target, SpellInfo bySpell, WorldObject obj = null)
{ {
Contract.Assert(target != null); Cypher.Assert(target != null);
// can't attack self // can't attack self
if (this == target) if (this == target)
@@ -3019,7 +3018,7 @@ namespace Game.Entities
// function based on function Unit.CanAssist from 13850 client // function based on function Unit.CanAssist from 13850 client
public bool _IsValidAssistTarget(Unit target, SpellInfo bySpell) public bool _IsValidAssistTarget(Unit target, SpellInfo bySpell)
{ {
Contract.Assert(target != null); Cypher.Assert(target != null);
// can assist to self // can assist to self
if (this == target) if (this == target)
+12 -11
View File
@@ -20,7 +20,6 @@ using Game.AI;
using Game.Network.Packets; using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -163,7 +162,8 @@ namespace Game.Entities
minion.SetOwnerGUID(GetGUID()); minion.SetOwnerGUID(GetGUID());
m_Controlled.Add(minion); if (!m_Controlled.Contains(minion))
m_Controlled.Add(minion);
if (IsTypeId(TypeId.Player)) if (IsTypeId(TypeId.Player))
{ {
@@ -269,12 +269,12 @@ namespace Game.Entities
if (GetGUID() == unit.GetCharmerGUID()) if (GetGUID() == unit.GetCharmerGUID())
continue; continue;
Contract.Assert(unit.GetOwnerGUID() == GetGUID()); Cypher.Assert(unit.GetOwnerGUID() == GetGUID());
if (unit.GetOwnerGUID() != GetGUID()) if (unit.GetOwnerGUID() != GetGUID())
{ {
Contract.Assert(false); Cypher.Assert(false);
} }
Contract.Assert(unit.IsTypeId(TypeId.Unit)); Cypher.Assert(unit.IsTypeId(TypeId.Unit));
if (!unit.HasUnitTypeMask(UnitTypeMask.Guardian)) if (!unit.HasUnitTypeMask(UnitTypeMask.Guardian))
continue; continue;
@@ -308,8 +308,8 @@ namespace Game.Entities
if (charmer.IsTypeId(TypeId.Player)) if (charmer.IsTypeId(TypeId.Player))
charmer.RemoveAurasByType(AuraType.Mounted); charmer.RemoveAurasByType(AuraType.Mounted);
Contract.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player)); Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
Contract.Assert((type == CharmType.Vehicle) == IsVehicle()); Cypher.Assert((type == CharmType.Vehicle) == IsVehicle());
Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type); Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type);
@@ -505,8 +505,8 @@ namespace Game.Entities
if (!charmer) if (!charmer)
return; return;
Contract.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player)); Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
Contract.Assert(type != CharmType.Vehicle || (IsTypeId(TypeId.Unit) && IsVehicle())); Cypher.Assert(type != CharmType.Vehicle || (IsTypeId(TypeId.Unit) && IsVehicle()));
charmer.SetCharm(this, false); charmer.SetCharm(this, false);
@@ -574,7 +574,7 @@ namespace Game.Entities
} }
} }
void RemoveAllMinionsByEntry(uint entry) public void RemoveAllMinionsByEntry(uint entry)
{ {
for (var i = 0; i < m_Controlled.Count; ++i) for (var i = 0; i < m_Controlled.Count; ++i)
{ {
@@ -612,7 +612,8 @@ namespace Game.Entities
if (_isWalkingBeforeCharm) if (_isWalkingBeforeCharm)
charm.SetWalk(false); charm.SetWalk(false);
m_Controlled.Add(charm); if (!m_Controlled.Contains(charm))
m_Controlled.Add(charm);
} }
else else
{ {
+21 -22
View File
@@ -22,7 +22,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -1787,7 +1786,7 @@ namespace Game.Entities
{ {
foreach (AuraApplication aurApp in procAuras) foreach (AuraApplication aurApp in procAuras)
{ {
Contract.Assert(aurApp.GetTarget() == this); Cypher.Assert(aurApp.GetTarget() == this);
uint procEffectMask = aurApp.GetBase().IsProcTriggeredOnEvent(aurApp, eventInfo, now); uint procEffectMask = aurApp.GetBase().IsProcTriggeredOnEvent(aurApp, eventInfo, now);
if (procEffectMask != 0) if (procEffectMask != 0)
{ {
@@ -1890,7 +1889,7 @@ namespace Game.Entities
++m_procDeep; ++m_procDeep;
else else
{ {
Contract.Assert(m_procDeep != 0); Cypher.Assert(m_procDeep != 0);
--m_procDeep; --m_procDeep;
} }
} }
@@ -1989,7 +1988,7 @@ namespace Game.Entities
} }
public void SetCurrentCastSpell(Spell pSpell) public void SetCurrentCastSpell(Spell pSpell)
{ {
Contract.Assert(pSpell != null); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells Cypher.Assert(pSpell != null); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells
CurrentSpellTypes CSpellType = pSpell.GetCurrentContainer(); CurrentSpellTypes CSpellType = pSpell.GetCurrentContainer();
@@ -2789,7 +2788,7 @@ namespace Game.Entities
} }
public void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true) public void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true)
{ {
Contract.Assert(spellType < CurrentSpellTypes.Max); Cypher.Assert(spellType < CurrentSpellTypes.Max);
Log.outDebug(LogFilter.Unit, "Interrupt spell for unit {0}", GetEntry()); Log.outDebug(LogFilter.Unit, "Interrupt spell for unit {0}", GetEntry());
Spell spell = m_currentSpells.LookupByKey(spellType); Spell spell = m_currentSpells.LookupByKey(spellType);
@@ -3375,7 +3374,7 @@ namespace Game.Entities
{ {
Aura aura = keyValuePair.Value; Aura aura = keyValuePair.Value;
Contract.Assert(!aura.IsRemoved()); Cypher.Assert(!aura.IsRemoved());
m_ownedAuras.Remove(keyValuePair); m_ownedAuras.Remove(keyValuePair);
m_removedAuras.Add(aura); m_removedAuras.Add(aura);
@@ -3402,7 +3401,7 @@ namespace Game.Entities
if (auraToRemove.IsRemoved()) if (auraToRemove.IsRemoved())
return; return;
Contract.Assert(auraToRemove.GetOwner() == this); Cypher.Assert(auraToRemove.GetOwner() == this);
if (removeMode == AuraRemoveMode.None) if (removeMode == AuraRemoveMode.None)
{ {
@@ -3423,7 +3422,7 @@ namespace Game.Entities
} }
} }
Contract.Assert(false); Cypher.Assert(false);
} }
public void RemoveAurasDueToSpell(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default) public void RemoveAurasDueToSpell(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
@@ -3612,7 +3611,7 @@ namespace Game.Entities
{ {
Aura aura = m_modAuras[auraType][i].GetBase(); Aura aura = m_modAuras[auraType][i].GetBase();
AuraApplication aurApp = aura.GetApplicationOfTarget(GetGUID()); AuraApplication aurApp = aura.GetApplicationOfTarget(GetGUID());
Contract.Assert(aurApp != null); Cypher.Assert(aurApp != null);
if (check(aurApp)) if (check(aurApp))
{ {
@@ -3833,16 +3832,16 @@ namespace Game.Entities
public void _UnapplyAura(KeyValuePair<uint, AuraApplication> pair, AuraRemoveMode removeMode) public void _UnapplyAura(KeyValuePair<uint, AuraApplication> pair, AuraRemoveMode removeMode)
{ {
AuraApplication aurApp = pair.Value; AuraApplication aurApp = pair.Value;
Contract.Assert(aurApp != null); Cypher.Assert(aurApp != null);
Contract.Assert(!aurApp.HasRemoveMode()); Cypher.Assert(!aurApp.HasRemoveMode());
Contract.Assert(aurApp.GetTarget() == this); Cypher.Assert(aurApp.GetTarget() == this);
aurApp.SetRemoveMode(removeMode); aurApp.SetRemoveMode(removeMode);
Aura aura = aurApp.GetBase(); Aura aura = aurApp.GetBase();
Log.outDebug(LogFilter.Spells, "Aura {0} now is remove mode {1}", aura.GetId(), removeMode); Log.outDebug(LogFilter.Spells, "Aura {0} now is remove mode {1}", aura.GetId(), removeMode);
// dead loop is killing the server probably // dead loop is killing the server probably
Contract.Assert(m_removedAurasCount < 0xFFFFFFFF); Cypher.Assert(m_removedAurasCount < 0xFFFFFFFF);
++m_removedAurasCount; ++m_removedAurasCount;
@@ -3889,7 +3888,7 @@ namespace Game.Entities
} }
// all effect mustn't be applied // all effect mustn't be applied
Contract.Assert(aurApp.GetEffectMask() == 0); Cypher.Assert(aurApp.GetEffectMask() == 0);
// Remove totem at next update if totem loses its aura // Remove totem at next update if totem loses its aura
if (aurApp.GetRemoveMode() == AuraRemoveMode.Expire && IsTypeId(TypeId.Unit) && IsTotem()) if (aurApp.GetRemoveMode() == AuraRemoveMode.Expire && IsTypeId(TypeId.Unit) && IsTotem())
@@ -3908,7 +3907,7 @@ namespace Game.Entities
public void _UnapplyAura(AuraApplication aurApp, AuraRemoveMode removeMode) public void _UnapplyAura(AuraApplication aurApp, AuraRemoveMode removeMode)
{ {
// aura can be removed from unit only if it's applied on it, shouldn't happen // aura can be removed from unit only if it's applied on it, shouldn't happen
Contract.Assert(aurApp.GetBase().GetApplicationOfTarget(GetGUID()) == aurApp); Cypher.Assert(aurApp.GetBase().GetApplicationOfTarget(GetGUID()) == aurApp);
uint spellId = aurApp.GetBase().GetId(); uint spellId = aurApp.GetBase().GetId();
var range = m_appliedAuras.LookupByKey(spellId); var range = m_appliedAuras.LookupByKey(spellId);
@@ -3921,7 +3920,7 @@ namespace Game.Entities
return; return;
} }
} }
Contract.Assert(false); Cypher.Assert(false);
} }
public AuraEffect GetAuraEffect(uint spellId, uint effIndex, ObjectGuid casterGUID = default(ObjectGuid)) public AuraEffect GetAuraEffect(uint spellId, uint effIndex, ObjectGuid casterGUID = default(ObjectGuid))
@@ -4009,10 +4008,10 @@ namespace Game.Entities
public void _ApplyAuraEffect(Aura aura, uint effIndex) public void _ApplyAuraEffect(Aura aura, uint effIndex)
{ {
Contract.Assert(aura != null); Cypher.Assert(aura != null);
Contract.Assert(aura.HasEffect(effIndex)); Cypher.Assert(aura.HasEffect(effIndex));
AuraApplication aurApp = aura.GetApplicationOfTarget(GetGUID()); AuraApplication aurApp = aura.GetApplicationOfTarget(GetGUID());
Contract.Assert(aurApp != null); Cypher.Assert(aurApp != null);
if (aurApp.GetEffectMask() == 0) if (aurApp.GetEffectMask() == 0)
_ApplyAura(aurApp, (uint)(1 << (int)effIndex)); _ApplyAura(aurApp, (uint)(1 << (int)effIndex));
else else
@@ -4058,7 +4057,7 @@ namespace Game.Entities
} }
public void _AddAura(UnitAura aura, Unit caster) public void _AddAura(UnitAura aura, Unit caster)
{ {
Contract.Assert(!m_cleanupDone); Cypher.Assert(!m_cleanupDone);
m_ownedAuras.Add(aura.GetId(), aura); m_ownedAuras.Add(aura.GetId(), aura);
_RemoveNoStackAurasDueToAura(aura); _RemoveNoStackAurasDueToAura(aura);
@@ -4073,7 +4072,7 @@ namespace Game.Entities
// @HACK: Player is not in world during loading auras. // @HACK: Player is not in world during loading auras.
//Single target auras are not saved or loaded from database //Single target auras are not saved or loaded from database
//but may be created as a result of aura links (player mounts with passengers) //but may be created as a result of aura links (player mounts with passengers)
Contract.Assert((IsInWorld && !IsDuringRemoveFromWorld()) || (aura.GetCasterGUID() == GetGUID()) || (IsLoading() && aura.HasEffectType(AuraType.ControlVehicle))); Cypher.Assert((IsInWorld && !IsDuringRemoveFromWorld()) || (aura.GetCasterGUID() == GetGUID()) || (IsLoading() && aura.HasEffectType(AuraType.ControlVehicle)));
// register single target aura // register single target aura
caster.m_scAuras.Add(aura); caster.m_scAuras.Add(aura);
@@ -4090,7 +4089,7 @@ namespace Game.Entities
} }
public Aura _TryStackingOrRefreshingExistingAura(SpellInfo newAura, uint effMask, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1) public Aura _TryStackingOrRefreshingExistingAura(SpellInfo newAura, uint effMask, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{ {
Contract.Assert(!casterGUID.IsEmpty() || caster); Cypher.Assert(!casterGUID.IsEmpty() || caster);
// Check if these can stack anyway // Check if these can stack anyway
if (casterGUID.IsEmpty() && !newAura.IsStackableOnOneSlotWithDifferentCasters()) if (casterGUID.IsEmpty() && !newAura.IsStackableOnOneSlotWithDifferentCasters())
+8 -9
View File
@@ -30,7 +30,6 @@ using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -139,7 +138,7 @@ namespace Game.Entities
// If this is set during update SetCantProc(false) call is missing somewhere in the code // If this is set during update SetCantProc(false) call is missing somewhere in the code
// Having this would prevent spells from being proced, so let's crash // Having this would prevent spells from being proced, so let's crash
Contract.Assert(m_procDeep == 0); Cypher.Assert(m_procDeep == 0);
if (CanHaveThreatList() && GetThreatManager().isNeedUpdateToClient(diff)) if (CanHaveThreatList() && GetThreatManager().isNeedUpdateToClient(diff))
SendThreatListUpdate(); SendThreatListUpdate();
@@ -811,7 +810,7 @@ namespace Game.Entities
public void _EnterVehicle(Vehicle vehicle, sbyte seatId, AuraApplication aurApp) public void _EnterVehicle(Vehicle vehicle, sbyte seatId, AuraApplication aurApp)
{ {
// Must be called only from aura handler // Must be called only from aura handler
Contract.Assert(aurApp != null); Cypher.Assert(aurApp != null);
if (!IsAlive() || GetVehicleKit() == vehicle || vehicle.GetBase().IsOnVehicle(this)) if (!IsAlive() || GetVehicleKit() == vehicle || vehicle.GetBase().IsOnVehicle(this))
return; return;
@@ -840,7 +839,7 @@ namespace Game.Entities
} }
} }
Contract.Assert(!m_vehicle); Cypher.Assert(!m_vehicle);
vehicle.AddPassenger(this, seatId); vehicle.AddPassenger(this, seatId);
} }
@@ -866,12 +865,12 @@ namespace Game.Entities
continue; continue;
// Make sure there is only one ride vehicle aura on target cast by the unit changing seat // Make sure there is only one ride vehicle aura on target cast by the unit changing seat
Contract.Assert(rideVehicleEffect == null); Cypher.Assert(rideVehicleEffect == null);
rideVehicleEffect = eff; rideVehicleEffect = eff;
} }
// Unit riding a vehicle must always have control vehicle aura on target // Unit riding a vehicle must always have control vehicle aura on target
Contract.Assert(rideVehicleEffect != null); Cypher.Assert(rideVehicleEffect != null);
rideVehicleEffect.ChangeAmount((seatId < 0 ? GetTransSeat() : seatId) + 1); rideVehicleEffect.ChangeAmount((seatId < 0 ? GetTransSeat() : seatId) + 1);
} }
@@ -1764,12 +1763,12 @@ namespace Game.Entities
public AuraApplication _CreateAuraApplication(Aura aura, uint effMask) public AuraApplication _CreateAuraApplication(Aura aura, uint effMask)
{ {
// can't apply aura on unit which is going to be deleted - to not create a memory leak // can't apply aura on unit which is going to be deleted - to not create a memory leak
Contract.Assert(!m_cleanupDone); Cypher.Assert(!m_cleanupDone);
// aura musn't be removed // aura musn't be removed
Contract.Assert(!aura.IsRemoved()); Cypher.Assert(!aura.IsRemoved());
// aura mustn't be already applied on target // aura mustn't be already applied on target
Contract.Assert(!aura.IsAppliedOnTarget(GetGUID()), "Unit._CreateAuraApplication: aura musn't be applied on target"); Cypher.Assert(!aura.IsAppliedOnTarget(GetGUID()), "Unit._CreateAuraApplication: aura musn't be applied on target");
SpellInfo aurSpellInfo = aura.GetSpellInfo(); SpellInfo aurSpellInfo = aura.GetSpellInfo();
uint aurId = aurSpellInfo.Id; uint aurId = aurSpellInfo.Id;
+13 -14
View File
@@ -22,7 +22,6 @@ using Game.DataStorage;
using Game.Movement; using Game.Movement;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -64,9 +63,9 @@ namespace Game.Entities
public void Dispose() public void Dispose()
{ {
// @Uninstall must be called before this. // @Uninstall must be called before this.
Contract.Assert(_status == Status.UnInstalling); Cypher.Assert(_status == Status.UnInstalling);
foreach (var pair in Seats) foreach (var pair in Seats)
Contract.Assert(pair.Value.IsEmpty()); Cypher.Assert(pair.Value.IsEmpty());
} }
public void Install() public void Install()
@@ -254,7 +253,7 @@ namespace Game.Entities
Log.outDebug(LogFilter.Vehicle, "Vehicle ({0}, Entry {1}): installing accessory (Entry: {2}) on seat: {3}", _me.GetGUID().ToString(), GetCreatureEntry(), entry, seatId); Log.outDebug(LogFilter.Vehicle, "Vehicle ({0}, Entry {1}): installing accessory (Entry: {2}) on seat: {3}", _me.GetGUID().ToString(), GetCreatureEntry(), entry, seatId);
TempSummon accessory = _me.SummonCreature(entry, _me, (TempSummonType)type, summonTime); TempSummon accessory = _me.SummonCreature(entry, _me, (TempSummonType)type, summonTime);
Contract.Assert(accessory); Cypher.Assert(accessory);
if (minion) if (minion)
accessory.AddUnitTypeMask(UnitTypeMask.Accessory); accessory.AddUnitTypeMask(UnitTypeMask.Accessory);
@@ -319,11 +318,11 @@ namespace Game.Entities
if (!seat.Value.IsEmpty()) if (!seat.Value.IsEmpty())
{ {
Unit passenger = Global.ObjAccessor.GetUnit(GetBase(), seat.Value.Passenger.Guid); Unit passenger = Global.ObjAccessor.GetUnit(GetBase(), seat.Value.Passenger.Guid);
Contract.Assert(passenger != null); Cypher.Assert(passenger != null);
passenger.ExitVehicle(); passenger.ExitVehicle();
} }
Contract.Assert(seat.Value.IsEmpty()); Cypher.Assert(seat.Value.IsEmpty());
} }
return true; return true;
@@ -335,7 +334,7 @@ namespace Game.Entities
return null; return null;
var seat = GetSeatKeyValuePairForPassenger(unit); var seat = GetSeatKeyValuePairForPassenger(unit);
Contract.Assert(seat.Value != null); Cypher.Assert(seat.Value != null);
Log.outDebug( LogFilter.Vehicle, "Unit {0} exit vehicle entry {1} id {2} dbguid {3} seat {4}", Log.outDebug( LogFilter.Vehicle, "Unit {0} exit vehicle entry {1} id {2} dbguid {3} seat {4}",
unit.GetName(), _me.GetEntry(), _vehicleInfo.Id, _me.GetGUID().ToString(), seat.Key); unit.GetName(), _me.GetEntry(), _vehicleInfo.Id, _me.GetGUID().ToString(), seat.Key);
@@ -371,7 +370,7 @@ namespace Game.Entities
public void RelocatePassengers() public void RelocatePassengers()
{ {
Contract.Assert(_me.GetMap() != null); Cypher.Assert(_me.GetMap() != null);
List<Tuple<Unit, Position>> seatRelocation = new List<Tuple<Unit, Position>>(); List<Tuple<Unit, Position>> seatRelocation = new List<Tuple<Unit, Position>>();
@@ -381,7 +380,7 @@ namespace Game.Entities
Unit passenger = Global.ObjAccessor.GetUnit(GetBase(), pair.Value.Passenger.Guid); Unit passenger = Global.ObjAccessor.GetUnit(GetBase(), pair.Value.Passenger.Guid);
if (passenger != null) if (passenger != null)
{ {
Contract.Assert(passenger.IsInWorld); Cypher.Assert(passenger.IsInWorld);
float px, py, pz, po; float px, py, pz, po;
passenger.m_movementInfo.transport.pos.GetPosition(out px, out py, out pz, out po); passenger.m_movementInfo.transport.pos.GetPosition(out px, out py, out pz, out po);
@@ -543,9 +542,9 @@ namespace Game.Entities
public override bool Execute(ulong e_time, uint p_time) public override bool Execute(ulong e_time, uint p_time)
{ {
Contract.Assert(Passenger.IsInWorld); Cypher.Assert(Passenger.IsInWorld);
Contract.Assert(Target != null && Target.GetBase().IsInWorld); Cypher.Assert(Target != null && Target.GetBase().IsInWorld);
Contract.Assert(Target.GetBase().HasAuraTypeWithCaster(AuraType.ControlVehicle, Passenger.GetGUID())); Cypher.Assert(Target.GetBase().HasAuraTypeWithCaster(AuraType.ControlVehicle, Passenger.GetGUID()));
Target.RemovePendingEventsForSeat(Seat.Key); Target.RemovePendingEventsForSeat(Seat.Key);
Target.RemovePendingEventsForPassenger(Passenger); Target.RemovePendingEventsForPassenger(Passenger);
@@ -555,7 +554,7 @@ namespace Game.Entities
Seat.Value.Passenger.IsUnselectable = Passenger.HasFlag(UnitFields.Flags, UnitFlags.NotSelectable); Seat.Value.Passenger.IsUnselectable = Passenger.HasFlag(UnitFields.Flags, UnitFlags.NotSelectable);
if (Seat.Value.SeatInfo.CanEnterOrExit()) if (Seat.Value.SeatInfo.CanEnterOrExit())
{ {
Contract.Assert(Target.UsableSeatNum != 0); Cypher.Assert(Target.UsableSeatNum != 0);
--Target.UsableSeatNum; --Target.UsableSeatNum;
if (Target.UsableSeatNum == 0) if (Target.UsableSeatNum == 0)
{ {
@@ -596,7 +595,7 @@ namespace Game.Entities
if (Target.GetBase().IsTypeId(TypeId.Unit) && Passenger.IsTypeId(TypeId.Player) && if (Target.GetBase().IsTypeId(TypeId.Unit) && Passenger.IsTypeId(TypeId.Player) &&
Seat.Value.SeatInfo.Flags.HasAnyFlag(VehicleSeatFlags.CanControl)) Seat.Value.SeatInfo.Flags.HasAnyFlag(VehicleSeatFlags.CanControl))
Contract.Assert(Target.GetBase().SetCharmedBy(Passenger, CharmType.Vehicle)); // SMSG_CLIENT_CONTROL Cypher.Assert(Target.GetBase().SetCharmedBy(Passenger, CharmType.Vehicle)); // SMSG_CLIENT_CONTROL
Passenger.SendClearTarget(); // SMSG_BREAK_TARGET Passenger.SendClearTarget(); // SMSG_BREAK_TARGET
Passenger.SetControlled(true, UnitState.Root); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures) Passenger.SetControlled(true, UnitState.Root); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
+1 -2
View File
@@ -21,7 +21,6 @@ using Game.DataStorage;
using Game.Entities; using Game.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Garrisons namespace Game.Garrisons
@@ -173,7 +172,7 @@ namespace Game.Garrisons
//todo check this method, might be slow..... //todo check this method, might be slow.....
public List<GarrAbilityRecord> RollFollowerAbilities(uint garrFollowerId, GarrFollowerRecord follower, uint quality, uint faction, bool initial) public List<GarrAbilityRecord> RollFollowerAbilities(uint garrFollowerId, GarrFollowerRecord follower, uint quality, uint faction, bool initial)
{ {
Contract.Assert(faction< 2); Cypher.Assert(faction< 2);
bool hasForcedExclusiveTrait = false; bool hasForcedExclusiveTrait = false;
List<GarrAbilityRecord> result = new List<GarrAbilityRecord>(); List<GarrAbilityRecord> result = new List<GarrAbilityRecord>();
+1 -2
View File
@@ -25,7 +25,6 @@ using Game.Maps;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Garrisons namespace Game.Garrisons
{ {
@@ -426,7 +425,7 @@ namespace Game.Garrisons
{ {
// Restore previous level building // Restore previous level building
uint restored = Global.GarrisonMgr.GetPreviousLevelBuilding(constructing.BuildingType, constructing.UpgradeLevel); uint restored = Global.GarrisonMgr.GetPreviousLevelBuilding(constructing.BuildingType, constructing.UpgradeLevel);
Contract.Assert(restored != 0); Cypher.Assert(restored != 0);
GarrisonPlaceBuildingResult placeBuildingResult = new GarrisonPlaceBuildingResult(); GarrisonPlaceBuildingResult placeBuildingResult = new GarrisonPlaceBuildingResult();
placeBuildingResult.GarrTypeID = GarrisonType.Garrison; placeBuildingResult.GarrTypeID = GarrisonType.Garrison;
+2 -3
View File
@@ -29,7 +29,6 @@ using Game.Scripting;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Framework.Dynamic; using Framework.Dynamic;
@@ -3017,7 +3016,7 @@ namespace Game
{ {
if (spellEffect != null && spellEffect.IsEffect(SpellEffectName.LearnSpell)) if (spellEffect != null && spellEffect.IsEffect(SpellEffectName.LearnSpell))
{ {
Contract.Assert(spell.LearnedSpellId == spell.SpellId, $"Only one learned spell is currently supported - spell {spell.SpellId} already teaches {spell.LearnedSpellId} but it tried to overwrite it with {spellEffect.TriggerSpell}"); Cypher.Assert(spell.LearnedSpellId == spell.SpellId, $"Only one learned spell is currently supported - spell {spell.SpellId} already teaches {spell.LearnedSpellId} but it tried to overwrite it with {spellEffect.TriggerSpell}");
spell.LearnedSpellId = spellEffect.TriggerSpell; spell.LearnedSpellId = spellEffect.TriggerSpell;
break; break;
} }
@@ -9267,7 +9266,7 @@ namespace Game
} }
public ObjectGuidGenerator GetGenerator(HighGuid high) public ObjectGuidGenerator GetGenerator(HighGuid high)
{ {
Contract.Assert(ObjectGuid.IsGlobal(high) || ObjectGuid.IsRealmSpecific(high), "Only global guid can be generated in ObjectMgr context"); Cypher.Assert(ObjectGuid.IsGlobal(high) || ObjectGuid.IsRealmSpecific(high), "Only global guid can be generated in ObjectMgr context");
return GetGuidSequenceGenerator(high); return GetGuidSequenceGenerator(high);
} }
+2 -3
View File
@@ -27,7 +27,6 @@ using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Groups namespace Game.Groups
@@ -113,7 +112,7 @@ namespace Game.Groups
ConvertLeaderInstancesToGroup(leader, this, false); ConvertLeaderInstancesToGroup(leader, this, false);
Contract.Assert(AddMember(leader)); // If the leader can't be added to a new group because it appears full, something is clearly wrong. Cypher.Assert(AddMember(leader)); // If the leader can't be added to a new group because it appears full, something is clearly wrong.
} }
else if (!AddMember(leader)) else if (!AddMember(leader))
return false; return false;
@@ -898,7 +897,7 @@ namespace Game.Groups
// notify group members which player is the allowed looter for the given creature // notify group members which player is the allowed looter for the given creature
public void SendLooter(Creature creature, Player groupLooter) public void SendLooter(Creature creature, Player groupLooter)
{ {
Contract.Assert(creature); Cypher.Assert(creature);
LootList lootList = new LootList(); LootList lootList = new LootList();
lootList.Owner = creature.GetGUID(); lootList.Owner = creature.GetGUID();
+11 -12
View File
@@ -25,7 +25,6 @@ using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Guilds namespace Game.Guilds
@@ -2087,7 +2086,7 @@ namespace Game.Guilds
void _SendBankContentUpdate(MoveItemData pSrc, MoveItemData pDest) void _SendBankContentUpdate(MoveItemData pSrc, MoveItemData pDest)
{ {
Contract.Assert(pSrc.IsBank() || pDest.IsBank()); Cypher.Assert(pSrc.IsBank() || pDest.IsBank());
byte tabId = 0; byte tabId = 0;
List<byte> slots = new List<byte>(); List<byte> slots = new List<byte>();
@@ -2249,7 +2248,7 @@ namespace Game.Guilds
void SendGuildRanksUpdate(ObjectGuid setterGuid, ObjectGuid targetGuid, uint rank) void SendGuildRanksUpdate(ObjectGuid setterGuid, ObjectGuid targetGuid, uint rank)
{ {
Member member = GetMember(targetGuid); Member member = GetMember(targetGuid);
Contract.Assert(member != null); Cypher.Assert(member != null);
GuildSendRankChange rankChange = new GuildSendRankChange(); GuildSendRankChange rankChange = new GuildSendRankChange();
rankChange.Officer = setterGuid; rankChange.Officer = setterGuid;
@@ -3468,7 +3467,7 @@ namespace Game.Guilds
public virtual bool CheckItem(ref uint splitedAmount) public virtual bool CheckItem(ref uint splitedAmount)
{ {
Contract.Assert(m_pItem != null); Cypher.Assert(m_pItem != null);
if (splitedAmount > m_pItem.GetCount()) if (splitedAmount > m_pItem.GetCount())
return false; return false;
if (splitedAmount == m_pItem.GetCount()) if (splitedAmount == m_pItem.GetCount())
@@ -3487,7 +3486,7 @@ namespace Game.Guilds
public bool CloneItem(uint count) public bool CloneItem(uint count)
{ {
Contract.Assert(m_pItem != null); Cypher.Assert(m_pItem != null);
m_pClonedItem = m_pItem.CloneItem(count); m_pClonedItem = m_pItem.CloneItem(count);
if (m_pClonedItem == null) if (m_pClonedItem == null)
{ {
@@ -3499,7 +3498,7 @@ namespace Game.Guilds
public virtual void LogAction(MoveItemData pFrom) public virtual void LogAction(MoveItemData pFrom)
{ {
Contract.Assert(pFrom.GetItem() != null); Cypher.Assert(pFrom.GetItem() != null);
Global.ScriptMgr.OnGuildItemMove(m_pGuild, m_pPlayer, pFrom.GetItem(), Global.ScriptMgr.OnGuildItemMove(m_pGuild, m_pPlayer, pFrom.GetItem(),
pFrom.IsBank(), pFrom.GetContainer(), pFrom.GetSlotId(), pFrom.IsBank(), pFrom.GetContainer(), pFrom.GetSlotId(),
@@ -3588,7 +3587,7 @@ namespace Game.Guilds
public override Item StoreItem(SQLTransaction trans, Item pItem) public override Item StoreItem(SQLTransaction trans, Item pItem)
{ {
Contract.Assert(pItem != null); Cypher.Assert(pItem != null);
m_pPlayer.MoveItemToInventory(m_vec, pItem, true); m_pPlayer.MoveItemToInventory(m_vec, pItem, true);
m_pPlayer.SaveInventoryAndGoldToDB(trans); m_pPlayer.SaveInventoryAndGoldToDB(trans);
return pItem; return pItem;
@@ -3596,7 +3595,7 @@ namespace Game.Guilds
public override void LogBankEvent(SQLTransaction trans, MoveItemData pFrom, uint count) public override void LogBankEvent(SQLTransaction trans, MoveItemData pFrom, uint count)
{ {
Contract.Assert(pFrom != null); Cypher.Assert(pFrom != null);
// Bank . Char // Bank . Char
m_pGuild._LogBankEvent(trans, GuildBankEventLogTypes.WithdrawItem, pFrom.GetContainer(), m_pPlayer.GetGUID().GetCounter(), m_pGuild._LogBankEvent(trans, GuildBankEventLogTypes.WithdrawItem, pFrom.GetContainer(), m_pPlayer.GetGUID().GetCounter(),
pFrom.GetItem().GetEntry(), (ushort)count); pFrom.GetItem().GetEntry(), (ushort)count);
@@ -3622,7 +3621,7 @@ namespace Game.Guilds
} }
public override bool HasStoreRights(MoveItemData pOther) public override bool HasStoreRights(MoveItemData pOther)
{ {
Contract.Assert(pOther != null); Cypher.Assert(pOther != null);
// Do not check rights if item is being swapped within the same bank tab // Do not check rights if item is being swapped within the same bank tab
if (pOther.IsBank() && pOther.GetContainer() == m_container) if (pOther.IsBank() && pOther.GetContainer() == m_container)
return true; return true;
@@ -3631,7 +3630,7 @@ namespace Game.Guilds
public override bool HasWithdrawRights(MoveItemData pOther) public override bool HasWithdrawRights(MoveItemData pOther)
{ {
Contract.Assert(pOther != null); Cypher.Assert(pOther != null);
// Do not check rights if item is being swapped within the same bank tab // Do not check rights if item is being swapped within the same bank tab
if (pOther.IsBank() && pOther.GetContainer() == m_container) if (pOther.IsBank() && pOther.GetContainer() == m_container)
return true; return true;
@@ -3646,7 +3645,7 @@ namespace Game.Guilds
public override void RemoveItem(SQLTransaction trans, MoveItemData pOther, uint splitedAmount = 0) public override void RemoveItem(SQLTransaction trans, MoveItemData pOther, uint splitedAmount = 0)
{ {
Contract.Assert(m_pItem != null); Cypher.Assert(m_pItem != null);
if (splitedAmount != 0) if (splitedAmount != 0)
{ {
m_pItem.SetCount(m_pItem.GetCount() - splitedAmount); m_pItem.SetCount(m_pItem.GetCount() - splitedAmount);
@@ -3684,7 +3683,7 @@ namespace Game.Guilds
public override void LogBankEvent(SQLTransaction trans, MoveItemData pFrom, uint count) public override void LogBankEvent(SQLTransaction trans, MoveItemData pFrom, uint count)
{ {
Contract.Assert(pFrom.GetItem() != null); Cypher.Assert(pFrom.GetItem() != null);
if (pFrom.IsBank()) if (pFrom.IsBank())
// Bank . Bank // Bank . Bank
m_pGuild._LogBankEvent(trans, GuildBankEventLogTypes.MoveItem, pFrom.GetContainer(), m_pPlayer.GetGUID().GetCounter(), m_pGuild._LogBankEvent(trans, GuildBankEventLogTypes.MoveItem, pFrom.GetContainer(), m_pPlayer.GetGUID().GetCounter(),
+1 -2
View File
@@ -21,7 +21,6 @@ using Game.Entities;
using Game.Network; using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Diagnostics.Contracts;
namespace Game namespace Game
{ {
@@ -52,7 +51,7 @@ namespace Game
if (vehicle) if (vehicle)
{ {
VehicleSeatRecord seat = vehicle.GetSeatForPassenger(GetPlayer()); VehicleSeatRecord seat = vehicle.GetSeatForPassenger(GetPlayer());
Contract.Assert(seat != null); Cypher.Assert(seat != null);
if (!seat.Flags.HasAnyFlag(VehicleSeatFlags.CanAttack)) if (!seat.Flags.HasAnyFlag(VehicleSeatFlags.CanAttack))
{ {
SendAttackStop(enemy); SendAttackStop(enemy);
+2 -3
View File
@@ -20,7 +20,6 @@ using Game.Entities;
using Game.Groups; using Game.Groups;
using Game.Network; using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System.Diagnostics.Contracts;
namespace Game namespace Game
{ {
@@ -204,7 +203,7 @@ namespace Game
} }
// If we're about to create a group there really should be a leader present // If we're about to create a group there really should be a leader present
Contract.Assert(leader); Cypher.Assert(leader);
group.RemoveInvite(leader); group.RemoveInvite(leader);
group.Create(leader); group.Create(leader);
Global.GroupMgr.AddGroup(group); Global.GroupMgr.AddGroup(group);
@@ -253,7 +252,7 @@ namespace Game
Group grp = GetPlayer().GetGroup(); Group grp = GetPlayer().GetGroup();
// grp is checked already above in CanUninviteFromGroup() // grp is checked already above in CanUninviteFromGroup()
Contract.Assert(grp); Cypher.Assert(grp);
if (grp.IsMember(packet.TargetGUID)) if (grp.IsMember(packet.TargetGUID))
{ {
+1 -2
View File
@@ -22,7 +22,6 @@ using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using Game.Spells; using Game.Spells;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game namespace Game
{ {
@@ -231,7 +230,7 @@ namespace Game
GetPlayer().StopCastingCharm(); GetPlayer().StopCastingCharm();
else if (pet.GetOwnerGUID() == GetPlayer().GetGUID()) else if (pet.GetOwnerGUID() == GetPlayer().GetGUID())
{ {
Contract.Assert(pet.IsTypeId(TypeId.Unit)); Cypher.Assert(pet.IsTypeId(TypeId.Unit));
if (pet.IsPet()) if (pet.IsPet())
{ {
if (pet.ToPet().getPetType() == PetType.Hunter) if (pet.ToPet().getPetType() == PetType.Hunter)
+1 -2
View File
@@ -20,7 +20,6 @@ using Game.DataStorage;
using Game.Entities; using Game.Entities;
using Game.Network; using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System.Diagnostics.Contracts;
namespace Game namespace Game
{ {
@@ -185,7 +184,7 @@ namespace Game
} }
VehicleSeatRecord seat = vehicle.GetSeatForPassenger(unit); VehicleSeatRecord seat = vehicle.GetSeatForPassenger(unit);
Contract.Assert(seat != null); Cypher.Assert(seat != null);
if (seat.IsEjectable()) if (seat.IsEjectable())
unit.ExitVehicle(); unit.ExitVehicle();
else else
+1 -1
View File
@@ -28,7 +28,7 @@ using System.Collections.Concurrent;
namespace Game.Maps namespace Game.Maps
{ {
public abstract class Notifier public class Notifier
{ {
public virtual void Visit(IList<WorldObject> objs) { } public virtual void Visit(IList<WorldObject> objs) { }
public virtual void Visit(IList<Creature> objs) { } public virtual void Visit(IList<Creature> objs) { }
@@ -23,7 +23,6 @@ using Game.Groups;
using Game.Scenarios; using Game.Scenarios;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Maps namespace Game.Maps
@@ -426,7 +425,7 @@ namespace Game.Maps
InstanceBind bind = player.GetBoundInstance(pair.Value.GetMapId(), pair.Value.GetDifficultyID()); InstanceBind bind = player.GetBoundInstance(pair.Value.GetMapId(), pair.Value.GetDifficultyID());
if (bind != null) 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 if (bind.perm && bind.extendState != 0) // permanent and not already expired
{ {
// actual promotion in DB already happened in caller // actual promotion in DB already happened in caller
@@ -602,7 +601,7 @@ namespace Game.Maps
void SetResetTimeFor(uint mapid, Difficulty d, long t) void SetResetTimeFor(uint mapid, Difficulty d, long t)
{ {
var key = MathFunctions.MakePair64(mapid, (uint)d); var key = MathFunctions.MakePair64(mapid, (uint)d);
Contract.Assert(m_resetTimeByMapDifficulty.ContainsKey(key)); Cypher.Assert(m_resetTimeByMapDifficulty.ContainsKey(key));
m_resetTimeByMapDifficulty[key] = t; m_resetTimeByMapDifficulty[key] = t;
} }
@@ -662,7 +661,7 @@ namespace Game.Maps
Map map = Global.MapMgr.FindMap(GetMapId(), m_instanceid); Map map = Global.MapMgr.FindMap(GetMapId(), m_instanceid);
if (map != null) if (map != null)
{ {
Contract.Assert(map.IsDungeon()); Cypher.Assert(map.IsDungeon());
InstanceScript instanceScript = ((InstanceMap)map).GetInstanceScript(); InstanceScript instanceScript = ((InstanceMap)map).GetInstanceScript();
if (instanceScript != null) if (instanceScript != null)
{ {
+2 -3
View File
@@ -23,7 +23,6 @@ using Game.Groups;
using Game.Network.Packets; using Game.Network.Packets;
using Game.Scenarios; using Game.Scenarios;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Text; using System.Text;
namespace Game.Maps namespace Game.Maps
@@ -157,7 +156,7 @@ namespace Game.Maps
{ {
foreach (var data in objectData) foreach (var data in objectData)
{ {
Contract.Assert(!objectInfo.ContainsKey(data.entry)); Cypher.Assert(!objectInfo.ContainsKey(data.entry));
objectInfo[data.entry] = data.type; objectInfo[data.entry] = data.type;
} }
} }
@@ -216,7 +215,7 @@ namespace Game.Maps
public BossInfo GetBossInfo(uint id) public BossInfo GetBossInfo(uint id)
{ {
Contract.Assert(id < bosses.Count); Cypher.Assert(id < bosses.Count);
return bosses[id]; return bosses[id];
} }
+5 -6
View File
@@ -23,7 +23,6 @@ using Game.Garrisons;
using Game.Groups; using Game.Groups;
using Game.Scenarios; using Game.Scenarios;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Maps namespace Game.Maps
@@ -181,13 +180,13 @@ namespace Game.Maps
if (entry == null) if (entry == null)
{ {
Log.outError(LogFilter.Maps, "CreateInstance: no record for map {0}", GetId()); Log.outError(LogFilter.Maps, "CreateInstance: no record for map {0}", GetId());
Contract.Assert(false); Cypher.Assert(false);
} }
InstanceTemplate iTemplate = Global.ObjectMgr.GetInstanceTemplate(GetId()); InstanceTemplate iTemplate = Global.ObjectMgr.GetInstanceTemplate(GetId());
if (iTemplate == null) if (iTemplate == null)
{ {
Log.outError(LogFilter.Maps, "CreateInstance: no instance template for map {0}", GetId()); Log.outError(LogFilter.Maps, "CreateInstance: no instance template for map {0}", GetId());
Contract.Assert(false); Cypher.Assert(false);
} }
// some instances only have one difficulty // 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); 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); InstanceMap map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
Contract.Assert(map.IsDungeon()); Cypher.Assert(map.IsDungeon());
map.LoadRespawnTimes(); map.LoadRespawnTimes();
map.LoadCorpseData(); map.LoadCorpseData();
@@ -222,7 +221,7 @@ namespace Game.Maps
Log.outDebug(LogFilter.Maps, "MapInstanced.CreateBattleground: map bg {0} for {1} created.", InstanceId, GetId()); 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); BattlegroundMap map = new BattlegroundMap(GetId(), (uint)GetGridExpiry(), InstanceId, this, Difficulty.None);
Contract.Assert(map.IsBattlegroundOrArena()); Cypher.Assert(map.IsBattlegroundOrArena());
map.SetBG(bg); map.SetBG(bg);
bg.SetBgMap(map); bg.SetBgMap(map);
@@ -236,7 +235,7 @@ namespace Game.Maps
lock (_mapLock) lock (_mapLock)
{ {
GarrisonMap map = new GarrisonMap(GetId(), GetGridExpiry(), instanceId, this, owner.GetGUID()); GarrisonMap map = new GarrisonMap(GetId(), GetGridExpiry(), instanceId, this, owner.GetGUID());
Contract.Assert(map.IsGarrison()); Cypher.Assert(map.IsGarrison());
m_InstancedMaps[instanceId] = map; m_InstancedMaps[instanceId] = map;
return map; return map;
+2 -3
View File
@@ -19,7 +19,6 @@ using Framework.Constants;
using Game.DataStorage; using Game.DataStorage;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -116,7 +115,7 @@ namespace Game
// get this mmap data // get this mmap data
MMapData mmap = loadedMMaps[mapId]; MMapData mmap = loadedMMaps[mapId];
Contract.Assert(mmap.navMesh != null); Cypher.Assert(mmap.navMesh != null);
// check if we already have this tile loaded // check if we already have this tile loaded
uint packedGridPos = packTileID(x, y); 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 // 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 // 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); 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 else
{ {
+20 -21
View File
@@ -30,7 +30,6 @@ using Game.Scenarios;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -93,7 +92,7 @@ namespace Game.Maps
for (var i = 0; i < i_worldObjects.Count; ++i) for (var i = 0; i < i_worldObjects.Count; ++i)
{ {
WorldObject obj = i_worldObjects[i]; WorldObject obj = i_worldObjects[i];
Contract.Assert(obj.IsWorldObject()); Cypher.Assert(obj.IsWorldObject());
obj.RemoveFromWorld(); obj.RemoveFromWorld();
obj.ResetMap(); 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); 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()); Grid ngrid = getGrid(cell.GetGridX(), cell.GetGridY());
Contract.Assert(ngrid != null); Cypher.Assert(ngrid != null);
RemoveFromGrid(obj, cell); RemoveFromGrid(obj, cell);
@@ -462,7 +461,7 @@ namespace Game.Maps
EnsureGridLoadedForActiveObject(cell, player); EnsureGridLoadedForActiveObject(cell, player);
AddToGrid(player, cell); AddToGrid(player, cell);
Contract.Assert(player.GetMap() == this); Cypher.Assert(player.GetMap() == this);
player.SetMap(this); player.SetMap(this);
player.AddToWorld(); player.AddToWorld();
@@ -986,7 +985,7 @@ namespace Game.Maps
Cell integrity_check = new Cell(dynObj.GetPositionX(), dynObj.GetPositionY()); Cell integrity_check = new Cell(dynObj.GetPositionX(), dynObj.GetPositionY());
Cell old_cell = dynObj.GetCurrentCell(); Cell old_cell = dynObj.GetCurrentCell();
Contract.Assert(integrity_check == old_cell); Cypher.Assert(integrity_check == old_cell);
Cell new_cell = new Cell(x, y); Cell new_cell = new Cell(x, y);
@@ -1013,7 +1012,7 @@ namespace Game.Maps
old_cell = dynObj.GetCurrentCell(); old_cell = dynObj.GetCurrentCell();
integrity_check = new Cell(dynObj.GetPositionX(), dynObj.GetPositionY()); 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) 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 integrity_check = new Cell(at.GetPositionX(), at.GetPositionY());
Cell old_cell = at.GetCurrentCell(); Cell old_cell = at.GetCurrentCell();
Contract.Assert(integrity_check == old_cell); Cypher.Assert(integrity_check == old_cell);
Cell new_cell = new Cell(x, y); Cell new_cell = new Cell(x, y);
if (getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null) if (getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
@@ -1045,7 +1044,7 @@ namespace Game.Maps
old_cell = at.GetCurrentCell(); old_cell = at.GetCurrentCell();
integrity_check = new Cell(at.GetPositionX(), at.GetPositionY()); 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) void AddCreatureToMoveList(Creature c, float x, float y, float z, float ang)
@@ -1595,7 +1594,7 @@ namespace Game.Maps
grid.VisitAllGrids(visitor); grid.VisitAllGrids(visitor);
} }
Contract.Assert(i_objectsToRemove.Empty()); Cypher.Assert(i_objectsToRemove.Empty());
setGrid(null, x, y); setGrid(null, x, y);
uint gx = (MapConst.MaxGrids - 1) - x; uint gx = (MapConst.MaxGrids - 1) - x;
@@ -2221,7 +2220,7 @@ namespace Game.Maps
while (!_updateObjects.Empty()) while (!_updateObjects.Empty())
{ {
WorldObject obj = _updateObjects[0]; WorldObject obj = _updateObjects[0];
Contract.Assert(obj.IsInWorld); Cypher.Assert(obj.IsInWorld);
_updateObjects.RemoveAt(0); _updateObjects.RemoveAt(0);
obj.BuildUpdate(update_players); obj.BuildUpdate(update_players);
} }
@@ -2265,7 +2264,7 @@ namespace Game.Maps
public void AddObjectToRemoveList(WorldObject obj) 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 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) 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 // 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 // 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)) if (!obj.IsTypeId(TypeId.Unit) && !obj.IsTypeId(TypeId.GameObject))
@@ -2285,7 +2284,7 @@ namespace Game.Maps
else if (i_objectsToSwitch[obj] != on) else if (i_objectsToSwitch[obj] != on)
i_objectsToSwitch.Remove(obj); i_objectsToSwitch.Remove(obj);
else else
Contract.Assert(false); Cypher.Assert(false);
} }
void RemoveAllObjectsInRemoveList() void RemoveAllObjectsInRemoveList()
@@ -2678,7 +2677,7 @@ namespace Game.Maps
void RemoveCorpse(Corpse corpse) void RemoveCorpse(Corpse corpse)
{ {
Contract.Assert(corpse); Cypher.Assert(corpse);
corpse.DestroyForNearbyPlayers(); corpse.DestroyForNearbyPlayers();
if (corpse.GetCurrentCell() != null) if (corpse.GetCurrentCell() != null)
@@ -3368,7 +3367,7 @@ namespace Game.Maps
public ulong GenerateLowGuid(HighGuid high) 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(); return GetGuidSequenceGenerator(high).Generate();
} }
@@ -4402,7 +4401,7 @@ namespace Game.Maps
if (player.GetMap() == this) 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()); 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; return EnterState.CannotEnterAlreadyInMap;
} }
@@ -4456,7 +4455,7 @@ namespace Game.Maps
mapSave = Global.InstanceSaveMgr.AddInstanceSave(GetId(), GetInstanceId(), GetSpawnMode(), 0, 0, true); mapSave = Global.InstanceSaveMgr.AddInstanceSave(GetId(), GetInstanceId(), GetSpawnMode(), 0, 0, true);
} }
Contract.Assert(mapSave != null); Cypher.Assert(mapSave != null);
// check for existing instance binds // check for existing instance binds
InstanceBind playerBind = player.GetBoundInstance(GetId(), GetSpawnMode()); InstanceBind playerBind = player.GetBoundInstance(GetId(), GetSpawnMode());
@@ -4497,7 +4496,7 @@ namespace Game.Maps
GetMapName(), groupBind.save.GetMapId(), groupBind.save.GetInstanceId(), GetMapName(), groupBind.save.GetMapId(), groupBind.save.GetInstanceId(),
groupBind.save.GetDifficultyID(), groupBind.save.GetPlayerCount(), groupBind.save.GetDifficultyID(), groupBind.save.GetPlayerCount(),
groupBind.save.GetGroupCount(), groupBind.save.CanReset()); groupBind.save.GetGroupCount(), groupBind.save.CanReset());
Contract.Assert(false); Cypher.Assert(false);
return false; return false;
} }
// bind to the group or keep using the group save // bind to the group or keep using the group save
@@ -4544,7 +4543,7 @@ namespace Game.Maps
player.BindToInstance(mapSave, false); player.BindToInstance(mapSave, false);
else else
// cannot jump to a different instance without resetting it // 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() public override void UnloadAll()
{ {
Contract.Assert(!HavePlayers()); Cypher.Assert(!HavePlayers());
if (m_resetAfterUnload) if (m_resetAfterUnload)
{ {
@@ -4849,7 +4848,7 @@ namespace Game.Maps
if (player.GetMap() == this) if (player.GetMap() == this)
{ {
Log.outError(LogFilter.Maps, "BGMap:CannotEnter - player {0} is already in map!", player.GetGUID().ToString()); Log.outError(LogFilter.Maps, "BGMap:CannotEnter - player {0} is already in map!", player.GetGUID().ToString());
Contract.Assert(false); Cypher.Assert(false);
return EnterState.CannotEnterAlreadyInMap; return EnterState.CannotEnterAlreadyInMap;
} }
+2 -3
View File
@@ -21,7 +21,6 @@ using Game.Groups;
using Game.Maps; using Game.Maps;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Entities namespace Game.Entities
@@ -60,7 +59,7 @@ namespace Game.Entities
if (map == null) if (map == null)
{ {
var entry = CliDB.MapStorage.LookupByKey(id); var entry = CliDB.MapStorage.LookupByKey(id);
Contract.Assert(entry != null); Cypher.Assert(entry != null);
if (entry.ParentMapID != -1) if (entry.ParentMapID != -1)
{ {
CreateBaseMap((uint)entry.ParentMapID); CreateBaseMap((uint)entry.ParentMapID);
@@ -73,7 +72,7 @@ namespace Game.Entities
lock(_mapsLock) lock(_mapsLock)
map = CreateBaseMap_i(entry); map = CreateBaseMap_i(entry);
} }
Contract.Assert(map != null); Cypher.Assert(map != null);
return map; return map;
} }
+2 -3
View File
@@ -23,7 +23,6 @@ using Game.Entities;
using Game.Movement; using Game.Movement;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Maps namespace Game.Maps
@@ -161,12 +160,12 @@ namespace Game.Maps
} }
} }
Contract.Assert(!keyFrames.Empty()); Cypher.Assert(!keyFrames.Empty());
if (transport.mapsUsed.Count > 1) if (transport.mapsUsed.Count > 1)
{ {
foreach (var mapId in transport.mapsUsed) foreach (var mapId in transport.mapsUsed)
Contract.Assert(!CliDB.MapStorage.LookupByKey(mapId).Instanceable()); Cypher.Assert(!CliDB.MapStorage.LookupByKey(mapId).Instanceable());
transport.inInstance = false; transport.inInstance = false;
} }
@@ -20,7 +20,6 @@ using Framework.GameMath;
using Game.Entities; using Game.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Movement namespace Game.Movement
@@ -49,7 +48,7 @@ namespace Game.Movement
uint SendPathSpline(Unit me, List<Vector3> wp) uint SendPathSpline(Unit me, List<Vector3> wp)
{ {
int numWp = wp.Count; int numWp = wp.Count;
Contract.Assert(numWp > 1, "Every path must have source & destination"); Cypher.Assert(numWp > 1, "Every path must have source & destination");
MoveSplineInit init = new MoveSplineInit(me); MoveSplineInit init = new MoveSplineInit(me);
if (numWp > 2) if (numWp > 2)
init.MovebyPath(wp.ToArray()); init.MovebyPath(wp.ToArray());
@@ -61,7 +60,7 @@ namespace Game.Movement
void SendSplineFor(Unit me, int index, uint toNext) void SendSplineFor(Unit me, int index, uint toNext)
{ {
Contract.Assert(index < _chainSize); Cypher.Assert(index < _chainSize);
Log.outDebug(LogFilter.Movement, "{0}: Sending spline for {1}.", me.GetGUID().ToString(), index); Log.outDebug(LogFilter.Movement, "{0}: Sending spline for {1}.", me.GetGUID().ToString(), index);
SplineChainLink thisLink = _chain[index]; SplineChainLink thisLink = _chain[index];
@@ -278,6 +278,7 @@ namespace Game.Movement
return true; return true;
} }
void LoadPath(Creature creature) void LoadPath(Creature creature)
{ {
if (loadedFromDB) if (loadedFromDB)
@@ -298,6 +299,7 @@ namespace Game.Movement
if (!Stopped()) if (!Stopped())
StartMoveNow(creature); StartMoveNow(creature);
} }
void OnArrived(Creature creature) void OnArrived(Creature creature)
{ {
if (path == null || path.nodes.Empty()) if (path == null || path.nodes.Empty())
+3 -4
View File
@@ -22,7 +22,6 @@ using Game.DataStorage;
using Game.Entities; using Game.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Movement namespace Game.Movement
{ {
@@ -78,7 +77,7 @@ namespace Game.Movement
if (_owner.HasUnitState(UnitState.Root | UnitState.Stunned)) if (_owner.HasUnitState(UnitState.Root | UnitState.Stunned))
return; return;
Contract.Assert(!empty()); Cypher.Assert(!empty());
_cleanFlag |= MMCleanFlag.Update; _cleanFlag |= MMCleanFlag.Update;
bool isMoveGenUpdateSuccess = top().Update(_owner, diff); bool isMoveGenUpdateSuccess = top().Update(_owner, diff);
@@ -157,7 +156,7 @@ namespace Game.Movement
public IMovementGenerator GetMotionSlot(int slot) public IMovementGenerator GetMotionSlot(int slot)
{ {
Contract.Assert(slot >= 0); Cypher.Assert(slot >= 0);
return _slot[slot]; return _slot[slot];
} }
@@ -744,7 +743,7 @@ namespace Game.Movement
public IMovementGenerator top() public IMovementGenerator top()
{ {
Contract.Assert(!empty()); Cypher.Assert(!empty());
return _slot[_top]; return _slot[_top];
} }
+1 -2
View File
@@ -16,7 +16,6 @@
*/ */
using System; using System;
using System.Diagnostics.Contracts;
namespace Game.Network namespace Game.Network
{ {
@@ -24,7 +23,7 @@ namespace Game.Network
{ {
public void Insert(int index, int value) public void Insert(int index, int value)
{ {
Contract.Assert(index < 0x20); Cypher.Assert(index < 0x20);
_mask |= 1u << index; _mask |= 1u << index;
if (_contents.Length <= index) if (_contents.Length <= index)
@@ -23,7 +23,6 @@ using Framework.IO;
using Game.Entities; using Game.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Network.Packets namespace Game.Network.Packets
{ {
@@ -583,7 +582,7 @@ namespace Game.Network.Packets
public override void Write() public override void Write()
{ {
Contract.Assert(UndeleteInfo != null); Cypher.Assert(UndeleteInfo != null);
_worldPacket.WriteInt32(UndeleteInfo.ClientToken); _worldPacket.WriteInt32(UndeleteInfo.ClientToken);
_worldPacket.WriteUInt32(Result); _worldPacket.WriteUInt32(Result);
_worldPacket.WritePackedGuid(UndeleteInfo.CharacterGuid); _worldPacket.WritePackedGuid(UndeleteInfo.CharacterGuid);
+1 -2
View File
@@ -23,7 +23,6 @@ using Framework.IO;
using Game.Entities; using Game.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Game.Network.Packets namespace Game.Network.Packets
{ {
@@ -621,7 +620,7 @@ namespace Game.Network.Packets
if (player) if (player)
{ {
Contract.Assert(player.GetGUID() == guid); Cypher.Assert(player.GetGUID() == guid);
AccountID = player.GetSession().GetAccountGUID(); AccountID = player.GetSession().GetAccountGUID();
BnetAccountID = player.GetSession().GetBattlenetAccountGUID(); BnetAccountID = player.GetSession().GetBattlenetAccountGUID();
+2 -3
View File
@@ -27,7 +27,6 @@ using Game.Network;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.PvP namespace Game.PvP
@@ -297,9 +296,9 @@ namespace Game.PvP
public void SetMapFromZone(uint zone) public void SetMapFromZone(uint zone)
{ {
AreaTableRecord areaTable = CliDB.AreaTableStorage.LookupByKey(zone); AreaTableRecord areaTable = CliDB.AreaTableStorage.LookupByKey(zone);
Contract.Assert(areaTable != null); Cypher.Assert(areaTable != null);
Map map = Global.MapMgr.CreateBaseMap(areaTable.ContinentID); Map map = Global.MapMgr.CreateBaseMap(areaTable.ContinentID);
Contract.Assert(!map.Instanceable()); Cypher.Assert(!map.Instanceable());
m_map = map; m_map = map;
} }
+132 -133
View File
@@ -33,7 +33,6 @@ using Game.Spells;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -584,8 +583,8 @@ namespace Game.Scripting
} }
public void OnGainCalculation(uint gain, Player player, Unit unit) public void OnGainCalculation(uint gain, Player player, Unit unit)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(unit != null); Cypher.Assert(unit != null);
ForEach<FormulaScript>(p => p.OnGainCalculation(gain, player, unit)); ForEach<FormulaScript>(p => p.OnGainCalculation(gain, player, unit));
} }
@@ -597,7 +596,7 @@ namespace Game.Scripting
//MapScript //MapScript
public void OnCreateMap(Map map) public void OnCreateMap(Map map)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
var record = map.GetEntry(); var record = map.GetEntry();
if (record != null && record.IsWorldMap()) if (record != null && record.IsWorldMap())
@@ -611,7 +610,7 @@ namespace Game.Scripting
} }
public void OnDestroyMap(Map map) public void OnDestroyMap(Map map)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
var record = map.GetEntry(); var record = map.GetEntry();
if (record != null && record.IsWorldMap()) if (record != null && record.IsWorldMap())
@@ -625,8 +624,8 @@ namespace Game.Scripting
} }
public void OnLoadGridMap(Map map, GridMap gmap, uint gx, uint gy) public void OnLoadGridMap(Map map, GridMap gmap, uint gx, uint gy)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
Contract.Assert(gmap != null); Cypher.Assert(gmap != null);
var record = map.GetEntry(); var record = map.GetEntry();
if (record != null && record.IsWorldMap()) if (record != null && record.IsWorldMap())
@@ -641,8 +640,8 @@ namespace Game.Scripting
} }
public void OnUnloadGridMap(Map map, GridMap gmap, uint gx, uint gy) public void OnUnloadGridMap(Map map, GridMap gmap, uint gx, uint gy)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
Contract.Assert(gmap != null); Cypher.Assert(gmap != null);
var record = map.GetEntry(); var record = map.GetEntry();
if (record != null && record.IsWorldMap()) if (record != null && record.IsWorldMap())
@@ -656,8 +655,8 @@ namespace Game.Scripting
} }
public void OnPlayerEnterMap(Map map, Player player) public void OnPlayerEnterMap(Map map, Player player)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
Contract.Assert(player != null); Cypher.Assert(player != null);
ForEach<PlayerScript>(p => p.OnMapChanged(player)); ForEach<PlayerScript>(p => p.OnMapChanged(player));
@@ -674,7 +673,7 @@ namespace Game.Scripting
} }
public void OnPlayerLeaveMap(Map map, Player player) public void OnPlayerLeaveMap(Map map, Player player)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
var record = map.GetEntry(); var record = map.GetEntry();
if (record != null && record.IsWorldMap()) if (record != null && record.IsWorldMap())
@@ -688,7 +687,7 @@ namespace Game.Scripting
} }
public void OnMapUpdate(Map map, uint diff) public void OnMapUpdate(Map map, uint diff)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
var record = map.GetEntry(); var record = map.GetEntry();
if (record != null && record.IsWorldMap()) if (record != null && record.IsWorldMap())
@@ -704,7 +703,7 @@ namespace Game.Scripting
//InstanceMapScript //InstanceMapScript
public InstanceScript CreateInstanceData(InstanceMap map) public InstanceScript CreateInstanceData(InstanceMap map)
{ {
Contract.Assert(map != null); Cypher.Assert(map != null);
return RunScriptRet<InstanceMapScript, InstanceScript>(p => p.GetInstanceScript(map), map.GetScriptId(), null); return RunScriptRet<InstanceMapScript, InstanceScript>(p => p.GetInstanceScript(map), map.GetScriptId(), null);
} }
@@ -712,30 +711,30 @@ namespace Game.Scripting
//ItemScript //ItemScript
public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Item target) public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Item target)
{ {
Contract.Assert(caster != null); Cypher.Assert(caster != null);
Contract.Assert(target != null); Cypher.Assert(target != null);
return RunScriptRet<ItemScript>(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId()); return RunScriptRet<ItemScript>(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId());
} }
public bool OnQuestAccept(Player player, Item item, Quest quest) public bool OnQuestAccept(Player player, Item item, Quest quest)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(item != null); Cypher.Assert(item != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<ItemScript>(p => p.OnQuestAccept(player, item, quest), item.GetScriptId()); return RunScriptRet<ItemScript>(p => p.OnQuestAccept(player, item, quest), item.GetScriptId());
} }
public bool OnItemUse(Player player, Item item, SpellCastTargets targets, ObjectGuid castId) public bool OnItemUse(Player player, Item item, SpellCastTargets targets, ObjectGuid castId)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(item); Cypher.Assert(item);
return RunScriptRet<ItemScript>(p => p.OnUse(player, item, targets, castId), item.GetScriptId()); return RunScriptRet<ItemScript>(p => p.OnUse(player, item, targets, castId), item.GetScriptId());
} }
public bool OnItemExpire(Player player, ItemTemplate proto) public bool OnItemExpire(Player player, ItemTemplate proto)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(proto != null); Cypher.Assert(proto != null);
return RunScriptRet<ItemScript>(p => p.OnExpire(player, proto), proto.ScriptId); return RunScriptRet<ItemScript>(p => p.OnExpire(player, proto), proto.ScriptId);
} }
@@ -743,76 +742,76 @@ namespace Game.Scripting
//CreatureScript //CreatureScript
public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Creature target) public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Creature target)
{ {
Contract.Assert(caster); Cypher.Assert(caster);
Contract.Assert(target); Cypher.Assert(target);
return RunScriptRet<CreatureScript>(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId());
} }
public bool OnGossipHello(Player player, Creature creature) public bool OnGossipHello(Player player, Creature creature)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(creature); Cypher.Assert(creature);
return RunScriptRet<CreatureScript>(p => p.OnGossipHello(player, creature), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnGossipHello(player, creature), creature.GetScriptId());
} }
public bool OnGossipSelect(Player player, Creature creature, uint sender, uint action) public bool OnGossipSelect(Player player, Creature creature, uint sender, uint action)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
return RunScriptRet<CreatureScript>(p => p.OnGossipSelect(player, creature, sender, action), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnGossipSelect(player, creature, sender, action), creature.GetScriptId());
} }
public bool OnGossipSelectCode(Player player, Creature creature, uint sender, uint action, string code) public bool OnGossipSelectCode(Player player, Creature creature, uint sender, uint action, string code)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
Contract.Assert(code != null); Cypher.Assert(code != null);
return RunScriptRet<CreatureScript>(p => p.OnGossipSelectCode(player, creature, sender, action, code), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnGossipSelectCode(player, creature, sender, action, code), creature.GetScriptId());
} }
public bool OnQuestAccept(Player player, Creature creature, Quest quest) public bool OnQuestAccept(Player player, Creature creature, Quest quest)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestAccept(player, creature, quest), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnQuestAccept(player, creature, quest), creature.GetScriptId());
} }
public bool OnQuestSelect(Player player, Creature creature, Quest quest) public bool OnQuestSelect(Player player, Creature creature, Quest quest)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestSelect(player, creature, quest), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnQuestSelect(player, creature, quest), creature.GetScriptId());
} }
public bool OnQuestComplete(Player player, Creature creature, Quest quest) public bool OnQuestComplete(Player player, Creature creature, Quest quest)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestComplete(player, creature, quest), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnQuestComplete(player, creature, quest), creature.GetScriptId());
} }
public bool OnQuestReward(Player player, Creature creature, Quest quest, uint opt) public bool OnQuestReward(Player player, Creature creature, Quest quest, uint opt)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestReward(player, creature, quest, opt), creature.GetScriptId()); return RunScriptRet<CreatureScript>(p => p.OnQuestReward(player, creature, quest, opt), creature.GetScriptId());
} }
public uint GetDialogStatus(Player player, Creature creature) public uint GetDialogStatus(Player player, Creature creature)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
player.PlayerTalkClass.ClearMenus(); player.PlayerTalkClass.ClearMenus();
return RunScriptRet<CreatureScript, uint>(p => p.GetDialogStatus(player, creature), creature.GetScriptId(), (uint)QuestGiverStatus.ScriptedNoStatus); return RunScriptRet<CreatureScript, uint>(p => p.GetDialogStatus(player, creature), creature.GetScriptId(), (uint)QuestGiverStatus.ScriptedNoStatus);
} }
public bool CanSpawn(ulong spawnId, uint entry, CreatureTemplate actTemplate, CreatureData cData, Map map) public bool CanSpawn(ulong spawnId, uint entry, CreatureTemplate actTemplate, CreatureData cData, Map map)
{ {
Contract.Assert(actTemplate != null); Cypher.Assert(actTemplate != null);
CreatureTemplate baseTemplate = Global.ObjectMgr.GetCreatureTemplate(entry); CreatureTemplate baseTemplate = Global.ObjectMgr.GetCreatureTemplate(entry);
if (baseTemplate == null) if (baseTemplate == null)
@@ -821,13 +820,13 @@ namespace Game.Scripting
} }
public CreatureAI GetCreatureAI(Creature creature) public CreatureAI GetCreatureAI(Creature creature)
{ {
Contract.Assert(creature != null); Cypher.Assert(creature != null);
return RunScriptRet<CreatureScript, CreatureAI>(p => p.GetAI(creature), creature.GetScriptId()); return RunScriptRet<CreatureScript, CreatureAI>(p => p.GetAI(creature), creature.GetScriptId());
} }
public void OnCreatureUpdate(Creature creature, uint diff) public void OnCreatureUpdate(Creature creature, uint diff)
{ {
Contract.Assert(creature != null); Cypher.Assert(creature != null);
RunScript<CreatureScript>(p => p.OnUpdate(creature, diff), creature.GetScriptId()); RunScript<CreatureScript>(p => p.OnUpdate(creature, diff), creature.GetScriptId());
} }
@@ -835,90 +834,90 @@ namespace Game.Scripting
//GameObjectScript //GameObjectScript
public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, GameObject target) public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, GameObject target)
{ {
Contract.Assert(caster != null); Cypher.Assert(caster != null);
Contract.Assert(target != null); Cypher.Assert(target != null);
return RunScriptRet<GameObjectScript>(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId()); return RunScriptRet<GameObjectScript>(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId());
} }
public bool OnGossipHello(Player player, GameObject go) public bool OnGossipHello(Player player, GameObject go)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(go != null); Cypher.Assert(go != null);
player.PlayerTalkClass.ClearMenus(); player.PlayerTalkClass.ClearMenus();
return RunScriptRet<GameObjectScript>(p => p.OnGossipHello(player, go), go.GetScriptId()); return RunScriptRet<GameObjectScript>(p => p.OnGossipHello(player, go), go.GetScriptId());
} }
public bool OnGossipSelect(Player player, GameObject go, uint sender, uint action) public bool OnGossipSelect(Player player, GameObject go, uint sender, uint action)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(go != null); Cypher.Assert(go != null);
return RunScriptRet<GameObjectScript>(p => p.OnGossipSelect(player, go, sender, action), go.GetScriptId()); return RunScriptRet<GameObjectScript>(p => p.OnGossipSelect(player, go, sender, action), go.GetScriptId());
} }
public bool OnGossipSelectCode(Player player, GameObject go, uint sender, uint action, string code) public bool OnGossipSelectCode(Player player, GameObject go, uint sender, uint action, string code)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(go != null); Cypher.Assert(go != null);
Contract.Assert(code != null); Cypher.Assert(code != null);
return RunScriptRet<GameObjectScript>(p => p.OnGossipSelectCode(player, go, sender, action, code), go.GetScriptId()); return RunScriptRet<GameObjectScript>(p => p.OnGossipSelectCode(player, go, sender, action, code), go.GetScriptId());
} }
public bool OnQuestAccept(Player player, GameObject go, Quest quest) public bool OnQuestAccept(Player player, GameObject go, Quest quest)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(go != null); Cypher.Assert(go != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<GameObjectScript>(p => p.OnQuestAccept(player, go, quest), go.GetScriptId()); return RunScriptRet<GameObjectScript>(p => p.OnQuestAccept(player, go, quest), go.GetScriptId());
} }
public bool OnQuestReward(Player player, GameObject go, Quest quest, uint opt) public bool OnQuestReward(Player player, GameObject go, Quest quest, uint opt)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(go != null); Cypher.Assert(go != null);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
return RunScriptRet<GameObjectScript>(p => p.OnQuestReward(player, go, quest, opt), go.GetScriptId()); return RunScriptRet<GameObjectScript>(p => p.OnQuestReward(player, go, quest, opt), go.GetScriptId());
} }
public uint GetDialogStatus(Player player, GameObject go) public uint GetDialogStatus(Player player, GameObject go)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(go != null); Cypher.Assert(go != null);
return RunScriptRet<GameObjectScript, uint>(p => p.GetDialogStatus(player, go), go.GetScriptId(), (uint)QuestGiverStatus.ScriptedNoStatus); return RunScriptRet<GameObjectScript, uint>(p => p.GetDialogStatus(player, go), go.GetScriptId(), (uint)QuestGiverStatus.ScriptedNoStatus);
} }
public void OnGameObjectDestroyed(GameObject go, Player player) public void OnGameObjectDestroyed(GameObject go, Player player)
{ {
Contract.Assert(go != null); Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnDestroyed(go, player), go.GetScriptId()); RunScript<GameObjectScript>(p => p.OnDestroyed(go, player), go.GetScriptId());
} }
public void OnGameObjectDamaged(GameObject go, Player player) public void OnGameObjectDamaged(GameObject go, Player player)
{ {
Contract.Assert(go != null); Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnDamaged(go, player), go.GetScriptId()); RunScript<GameObjectScript>(p => p.OnDamaged(go, player), go.GetScriptId());
} }
public void OnGameObjectLootStateChanged(GameObject go, uint state, Unit unit) public void OnGameObjectLootStateChanged(GameObject go, uint state, Unit unit)
{ {
Contract.Assert(go != null); Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnLootStateChanged(go, state, unit), go.GetScriptId()); RunScript<GameObjectScript>(p => p.OnLootStateChanged(go, state, unit), go.GetScriptId());
} }
public void OnGameObjectStateChanged(GameObject go, GameObjectState state) public void OnGameObjectStateChanged(GameObject go, GameObjectState state)
{ {
Contract.Assert(go != null); Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnGameObjectStateChanged(go, state), go.GetScriptId()); RunScript<GameObjectScript>(p => p.OnGameObjectStateChanged(go, state), go.GetScriptId());
} }
public void OnGameObjectUpdate(GameObject go, uint diff) public void OnGameObjectUpdate(GameObject go, uint diff)
{ {
Contract.Assert(go != null); Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnUpdate(go, diff), go.GetScriptId()); RunScript<GameObjectScript>(p => p.OnUpdate(go, diff), go.GetScriptId());
} }
public GameObjectAI GetGameObjectAI(GameObject go) public GameObjectAI GetGameObjectAI(GameObject go)
{ {
Contract.Assert(go != null); Cypher.Assert(go != null);
return RunScriptRet<GameObjectScript, GameObjectAI>(p => p.GetAI(go), go.GetScriptId()); return RunScriptRet<GameObjectScript, GameObjectAI>(p => p.GetAI(go), go.GetScriptId());
} }
@@ -926,8 +925,8 @@ namespace Game.Scripting
//AreaTriggerScript //AreaTriggerScript
public bool OnAreaTrigger(Player player, AreaTriggerRecord trigger, bool entered) public bool OnAreaTrigger(Player player, AreaTriggerRecord trigger, bool entered)
{ {
Contract.Assert(player != null); Cypher.Assert(player != null);
Contract.Assert(trigger != null); Cypher.Assert(trigger != null);
return RunScriptRet<AreaTriggerScript>(p => p.OnTrigger(player, trigger, entered), Global.ObjectMgr.GetAreaTriggerScriptId(trigger.Id)); return RunScriptRet<AreaTriggerScript>(p => p.OnTrigger(player, trigger, entered), Global.ObjectMgr.GetAreaTriggerScriptId(trigger.Id));
} }
@@ -936,59 +935,59 @@ namespace Game.Scripting
public Battleground CreateBattleground(BattlegroundTypeId typeId) public Battleground CreateBattleground(BattlegroundTypeId typeId)
{ {
// @todo Implement script-side Battlegrounds. // @todo Implement script-side Battlegrounds.
Contract.Assert(false); Cypher.Assert(false);
return null; return null;
} }
// OutdoorPvPScript // OutdoorPvPScript
public OutdoorPvP CreateOutdoorPvP(OutdoorPvPData data) public OutdoorPvP CreateOutdoorPvP(OutdoorPvPData data)
{ {
Contract.Assert(data != null); Cypher.Assert(data != null);
return RunScriptRet<OutdoorPvPScript, OutdoorPvP>(p => p.GetOutdoorPvP(), data.ScriptId, null); return RunScriptRet<OutdoorPvPScript, OutdoorPvP>(p => p.GetOutdoorPvP(), data.ScriptId, null);
} }
// WeatherScript // WeatherScript
public void OnWeatherChange(Weather weather, WeatherState state, float grade) public void OnWeatherChange(Weather weather, WeatherState state, float grade)
{ {
Contract.Assert(weather != null); Cypher.Assert(weather != null);
RunScript<WeatherScript>(p => p.OnChange(weather, state, grade), weather.GetScriptId()); RunScript<WeatherScript>(p => p.OnChange(weather, state, grade), weather.GetScriptId());
} }
public void OnWeatherUpdate(Weather weather, uint diff) public void OnWeatherUpdate(Weather weather, uint diff)
{ {
Contract.Assert(weather != null); Cypher.Assert(weather != null);
RunScript<WeatherScript>(p => p.OnUpdate(weather, diff), weather.GetScriptId()); RunScript<WeatherScript>(p => p.OnUpdate(weather, diff), weather.GetScriptId());
} }
// AuctionHouseScript // AuctionHouseScript
public void OnAuctionAdd(AuctionHouseObject ah, AuctionEntry entry) public void OnAuctionAdd(AuctionHouseObject ah, AuctionEntry entry)
{ {
Contract.Assert(ah != null); Cypher.Assert(ah != null);
Contract.Assert(entry != null); Cypher.Assert(entry != null);
ForEach<AuctionHouseScript>(p => p.OnAuctionAdd(ah, entry)); ForEach<AuctionHouseScript>(p => p.OnAuctionAdd(ah, entry));
} }
public void OnAuctionRemove(AuctionHouseObject ah, AuctionEntry entry) public void OnAuctionRemove(AuctionHouseObject ah, AuctionEntry entry)
{ {
Contract.Assert(ah != null); Cypher.Assert(ah != null);
Contract.Assert(entry != null); Cypher.Assert(entry != null);
ForEach<AuctionHouseScript>(p => p.OnAuctionRemove(ah, entry)); ForEach<AuctionHouseScript>(p => p.OnAuctionRemove(ah, entry));
} }
public void OnAuctionSuccessful(AuctionHouseObject ah, AuctionEntry entry) public void OnAuctionSuccessful(AuctionHouseObject ah, AuctionEntry entry)
{ {
Contract.Assert(ah != null); Cypher.Assert(ah != null);
Contract.Assert(entry != null); Cypher.Assert(entry != null);
ForEach<AuctionHouseScript>(p => p.OnAuctionSuccessful(ah, entry)); ForEach<AuctionHouseScript>(p => p.OnAuctionSuccessful(ah, entry));
} }
public void OnAuctionExpire(AuctionHouseObject ah, AuctionEntry entry) public void OnAuctionExpire(AuctionHouseObject ah, AuctionEntry entry)
{ {
Contract.Assert(ah != null); Cypher.Assert(ah != null);
Contract.Assert(entry != null); Cypher.Assert(entry != null);
ForEach<AuctionHouseScript>(p => p.OnAuctionExpire(ah, entry)); ForEach<AuctionHouseScript>(p => p.OnAuctionExpire(ah, entry));
} }
// ConditionScript // ConditionScript
public bool OnConditionCheck(Condition condition, ConditionSourceInfo sourceInfo) public bool OnConditionCheck(Condition condition, ConditionSourceInfo sourceInfo)
{ {
Contract.Assert(condition != null); Cypher.Assert(condition != null);
return RunScriptRet<ConditionScript>(p => p.OnConditionCheck(condition, sourceInfo), condition.ScriptId, true); return RunScriptRet<ConditionScript>(p => p.OnConditionCheck(condition, sourceInfo), condition.ScriptId, true);
} }
@@ -996,46 +995,46 @@ namespace Game.Scripting
// VehicleScript // VehicleScript
public void OnInstall(Vehicle veh) public void OnInstall(Vehicle veh)
{ {
Contract.Assert(veh != null); Cypher.Assert(veh != null);
Contract.Assert(veh.GetBase().IsTypeId(TypeId.Unit)); Cypher.Assert(veh.GetBase().IsTypeId(TypeId.Unit));
RunScript<VehicleScript>(p => p.OnInstall(veh), veh.GetBase().ToCreature().GetScriptId()); RunScript<VehicleScript>(p => p.OnInstall(veh), veh.GetBase().ToCreature().GetScriptId());
} }
public void OnUninstall(Vehicle veh) public void OnUninstall(Vehicle veh)
{ {
Contract.Assert(veh != null); Cypher.Assert(veh != null);
Contract.Assert(veh.GetBase().IsTypeId(TypeId.Unit)); Cypher.Assert(veh.GetBase().IsTypeId(TypeId.Unit));
RunScript<VehicleScript>(p => p.OnUninstall(veh), veh.GetBase().ToCreature().GetScriptId()); RunScript<VehicleScript>(p => p.OnUninstall(veh), veh.GetBase().ToCreature().GetScriptId());
} }
public void OnReset(Vehicle veh) public void OnReset(Vehicle veh)
{ {
Contract.Assert(veh != null); Cypher.Assert(veh != null);
Contract.Assert(veh.GetBase().IsTypeId(TypeId.Unit)); Cypher.Assert(veh.GetBase().IsTypeId(TypeId.Unit));
RunScript<VehicleScript>(p => p.OnReset(veh), veh.GetBase().ToCreature().GetScriptId()); RunScript<VehicleScript>(p => p.OnReset(veh), veh.GetBase().ToCreature().GetScriptId());
} }
public void OnInstallAccessory(Vehicle veh, Creature accessory) public void OnInstallAccessory(Vehicle veh, Creature accessory)
{ {
Contract.Assert(veh != null); Cypher.Assert(veh != null);
Contract.Assert(veh.GetBase().IsTypeId(TypeId.Unit)); Cypher.Assert(veh.GetBase().IsTypeId(TypeId.Unit));
Contract.Assert(accessory != null); Cypher.Assert(accessory != null);
RunScript<VehicleScript>(p => p.OnInstallAccessory(veh, accessory), veh.GetBase().ToCreature().GetScriptId()); RunScript<VehicleScript>(p => p.OnInstallAccessory(veh, accessory), veh.GetBase().ToCreature().GetScriptId());
} }
public void OnAddPassenger(Vehicle veh, Unit passenger, sbyte seatId) public void OnAddPassenger(Vehicle veh, Unit passenger, sbyte seatId)
{ {
Contract.Assert(veh != null); Cypher.Assert(veh != null);
Contract.Assert(veh.GetBase().IsTypeId(TypeId.Unit)); Cypher.Assert(veh.GetBase().IsTypeId(TypeId.Unit));
Contract.Assert(passenger != null); Cypher.Assert(passenger != null);
RunScript<VehicleScript>(p => p.OnAddPassenger(veh, passenger, seatId), veh.GetBase().ToCreature().GetScriptId()); RunScript<VehicleScript>(p => p.OnAddPassenger(veh, passenger, seatId), veh.GetBase().ToCreature().GetScriptId());
} }
public void OnRemovePassenger(Vehicle veh, Unit passenger) public void OnRemovePassenger(Vehicle veh, Unit passenger)
{ {
Contract.Assert(veh != null); Cypher.Assert(veh != null);
Contract.Assert(veh.GetBase().IsTypeId(TypeId.Unit)); Cypher.Assert(veh.GetBase().IsTypeId(TypeId.Unit));
Contract.Assert(passenger != null); Cypher.Assert(passenger != null);
RunScript<VehicleScript>(p => p.OnRemovePassenger(veh, passenger), veh.GetBase().ToCreature().GetScriptId()); RunScript<VehicleScript>(p => p.OnRemovePassenger(veh, passenger), veh.GetBase().ToCreature().GetScriptId());
} }
@@ -1043,7 +1042,7 @@ namespace Game.Scripting
// DynamicObjectScript // DynamicObjectScript
public void OnDynamicObjectUpdate(DynamicObject dynobj, uint diff) public void OnDynamicObjectUpdate(DynamicObject dynobj, uint diff)
{ {
Contract.Assert(dynobj != null); Cypher.Assert(dynobj != null);
ForEach<DynamicObjectScript>(p => p.OnUpdate(dynobj, diff)); ForEach<DynamicObjectScript>(p => p.OnUpdate(dynobj, diff));
} }
@@ -1051,28 +1050,28 @@ namespace Game.Scripting
// TransportScript // TransportScript
public void OnAddPassenger(Transport transport, Player player) public void OnAddPassenger(Transport transport, Player player)
{ {
Contract.Assert(transport != null); Cypher.Assert(transport != null);
Contract.Assert(player != null); Cypher.Assert(player != null);
RunScript<TransportScript>(p => p.OnAddPassenger(transport, player), transport.GetScriptId()); RunScript<TransportScript>(p => p.OnAddPassenger(transport, player), transport.GetScriptId());
} }
public void OnAddCreaturePassenger(Transport transport, Creature creature) public void OnAddCreaturePassenger(Transport transport, Creature creature)
{ {
Contract.Assert(transport != null); Cypher.Assert(transport != null);
Contract.Assert(creature != null); Cypher.Assert(creature != null);
RunScript<TransportScript>(p => p.OnAddCreaturePassenger(transport, creature), transport.GetScriptId()); RunScript<TransportScript>(p => p.OnAddCreaturePassenger(transport, creature), transport.GetScriptId());
} }
public void OnRemovePassenger(Transport transport, Player player) public void OnRemovePassenger(Transport transport, Player player)
{ {
Contract.Assert(transport != null); Cypher.Assert(transport != null);
Contract.Assert(player != null); Cypher.Assert(player != null);
RunScript<TransportScript>(p => p.OnRemovePassenger(transport, player), transport.GetScriptId()); RunScript<TransportScript>(p => p.OnRemovePassenger(transport, player), transport.GetScriptId());
} }
public void OnTransportUpdate(Transport transport, uint diff) public void OnTransportUpdate(Transport transport, uint diff)
{ {
Contract.Assert(transport != null); Cypher.Assert(transport != null);
RunScript<TransportScript>(p => p.OnUpdate(transport, diff), transport.GetScriptId()); RunScript<TransportScript>(p => p.OnUpdate(transport, diff), transport.GetScriptId());
} }
@@ -1084,7 +1083,7 @@ namespace Game.Scripting
// AchievementCriteriaScript // AchievementCriteriaScript
public bool OnCriteriaCheck(uint ScriptId, Player source, Unit target) public bool OnCriteriaCheck(uint ScriptId, Player source, Unit target)
{ {
Contract.Assert(source != null); Cypher.Assert(source != null);
// target can be NULL. // target can be NULL.
return RunScriptRet<AchievementCriteriaScript>(p => p.OnCheck(source, target), ScriptId); return RunScriptRet<AchievementCriteriaScript>(p => p.OnCheck(source, target), ScriptId);
@@ -1261,27 +1260,27 @@ namespace Game.Scripting
// GroupScript // GroupScript
public void OnGroupAddMember(Group group, ObjectGuid guid) public void OnGroupAddMember(Group group, ObjectGuid guid)
{ {
Contract.Assert(group); Cypher.Assert(group);
ForEach<GroupScript>(p => p.OnAddMember(group, guid)); ForEach<GroupScript>(p => p.OnAddMember(group, guid));
} }
public void OnGroupInviteMember(Group group, ObjectGuid guid) public void OnGroupInviteMember(Group group, ObjectGuid guid)
{ {
Contract.Assert(group); Cypher.Assert(group);
ForEach<GroupScript>(p => p.OnInviteMember(group, guid)); ForEach<GroupScript>(p => p.OnInviteMember(group, guid));
} }
public void OnGroupRemoveMember(Group group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, string reason) public void OnGroupRemoveMember(Group group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, string reason)
{ {
Contract.Assert(group); Cypher.Assert(group);
ForEach<GroupScript>(p => p.OnRemoveMember(group, guid, method, kicker, reason)); ForEach<GroupScript>(p => p.OnRemoveMember(group, guid, method, kicker, reason));
} }
public void OnGroupChangeLeader(Group group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) public void OnGroupChangeLeader(Group group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid)
{ {
Contract.Assert(group); Cypher.Assert(group);
ForEach<GroupScript>(p => p.OnChangeLeader(group, newLeaderGuid, oldLeaderGuid)); ForEach<GroupScript>(p => p.OnChangeLeader(group, newLeaderGuid, oldLeaderGuid));
} }
public void OnGroupDisband(Group group) public void OnGroupDisband(Group group)
{ {
Contract.Assert(group); Cypher.Assert(group);
ForEach<GroupScript>(p => p.OnDisband(group)); ForEach<GroupScript>(p => p.OnDisband(group));
} }
@@ -1320,7 +1319,7 @@ namespace Game.Scripting
// AreaTriggerEntityScript // AreaTriggerEntityScript
public AreaTriggerAI GetAreaTriggerAI(AreaTrigger areaTrigger) public AreaTriggerAI GetAreaTriggerAI(AreaTrigger areaTrigger)
{ {
Contract.Assert(areaTrigger); Cypher.Assert(areaTrigger);
return RunScriptRet<AreaTriggerEntityScript, AreaTriggerAI>(p => p.GetAI(areaTrigger), areaTrigger.GetScriptId(), null); return RunScriptRet<AreaTriggerEntityScript, AreaTriggerAI>(p => p.GetAI(areaTrigger), areaTrigger.GetScriptId(), null);
} }
@@ -1328,7 +1327,7 @@ namespace Game.Scripting
// ConversationScript // ConversationScript
public void OnConversationCreate(Conversation conversation, Unit creator) public void OnConversationCreate(Conversation conversation, Unit creator)
{ {
Contract.Assert(conversation != null); Cypher.Assert(conversation != null);
RunScript<ConversationScript>(script => script.OnConversationCreate(conversation, creator), conversation.GetScriptId()); RunScript<ConversationScript>(script => script.OnConversationCreate(conversation, creator), conversation.GetScriptId());
} }
@@ -1336,29 +1335,29 @@ namespace Game.Scripting
//SceneScript //SceneScript
public void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) public void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(sceneTemplate != null); Cypher.Assert(sceneTemplate != null);
RunScript<SceneScript>(script => script.OnSceneStart(player, sceneInstanceID, sceneTemplate), sceneTemplate.ScriptId); RunScript<SceneScript>(script => script.OnSceneStart(player, sceneInstanceID, sceneTemplate), sceneTemplate.ScriptId);
} }
public void OnSceneTrigger(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName) public void OnSceneTrigger(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(sceneTemplate != null); Cypher.Assert(sceneTemplate != null);
RunScript<SceneScript>(script => script.OnSceneTriggerEvent(player, sceneInstanceID, sceneTemplate, triggerName), sceneTemplate.ScriptId); RunScript<SceneScript>(script => script.OnSceneTriggerEvent(player, sceneInstanceID, sceneTemplate, triggerName), sceneTemplate.ScriptId);
} }
public void OnSceneCancel(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) public void OnSceneCancel(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(sceneTemplate != null); Cypher.Assert(sceneTemplate != null);
RunScript<SceneScript>(script => script.OnSceneCancel(player, sceneInstanceID, sceneTemplate), sceneTemplate.ScriptId); RunScript<SceneScript>(script => script.OnSceneCancel(player, sceneInstanceID, sceneTemplate), sceneTemplate.ScriptId);
} }
public void OnSceneComplete(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) public void OnSceneComplete(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(sceneTemplate != null); Cypher.Assert(sceneTemplate != null);
RunScript<SceneScript>(script => script.OnSceneComplete(player, sceneInstanceID, sceneTemplate), sceneTemplate.ScriptId); RunScript<SceneScript>(script => script.OnSceneComplete(player, sceneInstanceID, sceneTemplate), sceneTemplate.ScriptId);
} }
@@ -1366,15 +1365,15 @@ namespace Game.Scripting
//QuestScript //QuestScript
public void OnQuestStatusChange(Player player, Quest quest, QuestStatus oldStatus, QuestStatus newStatus) public void OnQuestStatusChange(Player player, Quest quest, QuestStatus oldStatus, QuestStatus newStatus)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
RunScript<QuestScript>(script => script.OnQuestStatusChange(player, quest, oldStatus, newStatus), quest.ScriptId); RunScript<QuestScript>(script => script.OnQuestStatusChange(player, quest, oldStatus, newStatus), quest.ScriptId);
} }
public void OnQuestObjectiveChange(Player player, Quest quest, QuestObjective objective, int oldAmount, int newAmount) public void OnQuestObjectiveChange(Player player, Quest quest, QuestObjective objective, int oldAmount, int newAmount)
{ {
Contract.Assert(player); Cypher.Assert(player);
Contract.Assert(quest != null); Cypher.Assert(quest != null);
RunScript<QuestScript>(script => script.OnQuestObjectiveChange(player, quest, objective, oldAmount, newAmount), quest.ScriptId); RunScript<QuestScript>(script => script.OnQuestObjectiveChange(player, quest, objective, oldAmount, newAmount), quest.ScriptId);
} }
@@ -1416,7 +1415,7 @@ namespace Game.Scripting
} }
public void AddScript<T>(T script) where T : ScriptObject public void AddScript<T>(T script) where T : ScriptObject
{ {
Contract.Assert(script != null); Cypher.Assert(script != null);
if (!ScriptStorage.ContainsKey(typeof(T))) if (!ScriptStorage.ContainsKey(typeof(T)))
ScriptStorage[typeof(T)] = new ScriptRegistry<T>(); ScriptStorage[typeof(T)] = new ScriptRegistry<T>();
@@ -1456,7 +1455,7 @@ namespace Game.Scripting
{ {
public void AddScript(TValue script) public void AddScript(TValue script)
{ {
Contract.Assert(script != null); Cypher.Assert(script != null);
if (!script.IsDatabaseBound()) if (!script.IsDatabaseBound())
{ {
@@ -1493,7 +1492,7 @@ namespace Game.Scripting
// If the script is already assigned . delete it! // If the script is already assigned . delete it!
Log.outError(LogFilter.Scripts, "Script '{0}' already assigned with the same script name, so the script can't work.", script.GetName()); Log.outError(LogFilter.Scripts, "Script '{0}' already assigned with the same script name, so the script can't work.", script.GetName());
Contract.Assert(false); // Error that should be fixed ASAP. Cypher.Assert(false); // Error that should be fixed ASAP.
} }
} }
else else
+1 -2
View File
@@ -31,7 +31,6 @@ using Game.Spells;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game namespace Game
@@ -124,7 +123,7 @@ namespace Game
void AddSession_(WorldSession s) void AddSession_(WorldSession s)
{ {
Contract.Assert(s != null); Cypher.Assert(s != null);
//NOTE - Still there is race condition in WorldSession* being used in the Sockets //NOTE - Still there is race condition in WorldSession* being used in the Sockets
+47 -48
View File
@@ -24,7 +24,6 @@ using Game.Network.Packets;
using Game.Scripting; using Game.Scripting;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Spells namespace Game.Spells
@@ -75,7 +74,7 @@ namespace Game.Spells
_effectsToApply = effMask; _effectsToApply = effMask;
_needClientUpdate = false; _needClientUpdate = false;
Contract.Assert(GetTarget() != null && GetBase() != null); Cypher.Assert(GetTarget() != null && GetBase() != null);
// Try find slot for aura // Try find slot for aura
byte slot = 0; byte slot = 0;
@@ -165,20 +164,20 @@ namespace Game.Spells
Log.outError(LogFilter.Spells, "Aura {0} has no effect at effectIndex {1} but _HandleEffect was called", GetBase().GetSpellInfo().Id, effIndex); Log.outError(LogFilter.Spells, "Aura {0} has no effect at effectIndex {1} but _HandleEffect was called", GetBase().GetSpellInfo().Id, effIndex);
return; return;
} }
Contract.Assert(aurEff != null); Cypher.Assert(aurEff != null);
Contract.Assert(HasEffect(effIndex) == (!apply)); Cypher.Assert(HasEffect(effIndex) == (!apply));
Contract.Assert(Convert.ToBoolean((1 << (int)effIndex) & _effectsToApply)); Cypher.Assert(Convert.ToBoolean((1 << (int)effIndex) & _effectsToApply));
Log.outDebug(LogFilter.Spells, "AuraApplication._HandleEffect: {0}, apply: {1}: amount: {2}", aurEff.GetAuraType(), apply, aurEff.GetAmount()); Log.outDebug(LogFilter.Spells, "AuraApplication._HandleEffect: {0}, apply: {1}: amount: {2}", aurEff.GetAuraType(), apply, aurEff.GetAmount());
if (apply) if (apply)
{ {
Contract.Assert(!Convert.ToBoolean(_effectMask & (1 << (int)effIndex))); Cypher.Assert(!Convert.ToBoolean(_effectMask & (1 << (int)effIndex)));
_effectMask |= (uint)(1 << (int)effIndex); _effectMask |= (uint)(1 << (int)effIndex);
aurEff.HandleEffect(this, AuraEffectHandleModes.Real, true); aurEff.HandleEffect(this, AuraEffectHandleModes.Real, true);
} }
else else
{ {
Contract.Assert(Convert.ToBoolean(_effectMask & (1 << (int)effIndex))); Cypher.Assert(Convert.ToBoolean(_effectMask & (1 << (int)effIndex)));
_effectMask &= ~(uint)(1 << (int)effIndex); _effectMask &= ~(uint)(1 << (int)effIndex);
aurEff.HandleEffect(this, AuraEffectHandleModes.Real, false); aurEff.HandleEffect(this, AuraEffectHandleModes.Real, false);
} }
@@ -196,7 +195,7 @@ namespace Game.Spells
public void BuildUpdatePacket(ref AuraInfo auraInfo, bool remove) public void BuildUpdatePacket(ref AuraInfo auraInfo, bool remove)
{ {
Contract.Assert(_target.HasVisibleAura(this) != remove); Cypher.Assert(_target.HasVisibleAura(this) != remove);
auraInfo.Slot = GetSlot(); auraInfo.Slot = GetSlot();
if (remove) if (remove)
@@ -264,7 +263,7 @@ namespace Game.Spells
public uint GetEffectMask() { return _effectMask; } public uint GetEffectMask() { return _effectMask; }
public bool HasEffect(uint effect) public bool HasEffect(uint effect)
{ {
Contract.Assert(effect < SpellConst.MaxEffects); Cypher.Assert(effect < SpellConst.MaxEffects);
return Convert.ToBoolean(_effectMask & (1 << (int)effect)); return Convert.ToBoolean(_effectMask & (1 << (int)effect));
} }
public bool IsPositive() { return _flags.HasAnyFlag(AuraFlags.Positive); } public bool IsPositive() { return _flags.HasAnyFlag(AuraFlags.Positive); }
@@ -363,10 +362,10 @@ namespace Game.Spells
public virtual void _ApplyForTarget(Unit target, Unit caster, AuraApplication auraApp) public virtual void _ApplyForTarget(Unit target, Unit caster, AuraApplication auraApp)
{ {
Contract.Assert(target != null); Cypher.Assert(target != null);
Contract.Assert(auraApp != null); Cypher.Assert(auraApp != null);
// aura mustn't be already applied on target // aura mustn't be already applied on target
//Contract.Assert(!IsAppliedOnTarget(target.GetGUID()) && "Aura._ApplyForTarget: aura musn't be already applied on target"); //Cypher.Assert(!IsAppliedOnTarget(target.GetGUID()) && "Aura._ApplyForTarget: aura musn't be already applied on target");
m_applications[target.GetGUID()] = auraApp; m_applications[target.GetGUID()] = auraApp;
@@ -382,9 +381,9 @@ namespace Game.Spells
} }
public virtual void _UnapplyForTarget(Unit target, Unit caster, AuraApplication auraApp) public virtual void _UnapplyForTarget(Unit target, Unit caster, AuraApplication auraApp)
{ {
Contract.Assert(target != null); Cypher.Assert(target != null);
Contract.Assert(auraApp.HasRemoveMode()); Cypher.Assert(auraApp.HasRemoveMode());
Contract.Assert(auraApp != null); Cypher.Assert(auraApp != null);
var app = m_applications.LookupByKey(target.GetGUID()); var app = m_applications.LookupByKey(target.GetGUID());
@@ -393,11 +392,11 @@ namespace Game.Spells
{ {
Log.outError(LogFilter.Spells, "Aura._UnapplyForTarget, target: {0}, caster: {1}, spell: {2} was not found in owners application map!", Log.outError(LogFilter.Spells, "Aura._UnapplyForTarget, target: {0}, caster: {1}, spell: {2} was not found in owners application map!",
target.GetGUID().ToString(), caster ? caster.GetGUID().ToString() : "", auraApp.GetBase().GetSpellInfo().Id); target.GetGUID().ToString(), caster ? caster.GetGUID().ToString() : "", auraApp.GetBase().GetSpellInfo().Id);
Contract.Assert(false); Cypher.Assert(false);
} }
// aura has to be already applied // aura has to be already applied
Contract.Assert(app == auraApp); Cypher.Assert(app == auraApp);
m_applications.Remove(target.GetGUID()); m_applications.Remove(target.GetGUID());
m_removedApplications.Add(auraApp); m_removedApplications.Add(auraApp);
@@ -412,7 +411,7 @@ namespace Game.Spells
// and marks aura as removed // and marks aura as removed
public void _Remove(AuraRemoveMode removeMode) public void _Remove(AuraRemoveMode removeMode)
{ {
Contract.Assert(!m_isRemoved); Cypher.Assert(!m_isRemoved);
m_isRemoved = true; m_isRemoved = true;
foreach (var pair in m_applications.ToList()) foreach (var pair in m_applications.ToList())
{ {
@@ -482,7 +481,7 @@ namespace Game.Spells
else else
{ {
// ok, we have one unit twice in target map (impossible, but...) // ok, we have one unit twice in target map (impossible, but...)
Contract.Assert(false); Cypher.Assert(false);
} }
} }
@@ -564,7 +563,7 @@ namespace Game.Spells
if (aurApp != null) if (aurApp != null)
{ {
// owner has to be in world, or effect has to be applied to self // owner has to be in world, or effect has to be applied to self
Contract.Assert((!m_owner.IsInWorld && m_owner == pair.Key) || m_owner.IsInMap(pair.Key)); Cypher.Assert((!m_owner.IsInWorld && m_owner == pair.Key) || m_owner.IsInMap(pair.Key));
pair.Key._ApplyAura(aurApp, pair.Value); pair.Key._ApplyAura(aurApp, pair.Value);
} }
} }
@@ -587,7 +586,7 @@ namespace Game.Spells
if (GetApplicationOfTarget(unit.GetGUID()) != null) if (GetApplicationOfTarget(unit.GetGUID()) != null)
{ {
// owner has to be in world, or effect has to be applied to self // owner has to be in world, or effect has to be applied to self
Contract.Assert((!GetOwner().IsInWorld && GetOwner() == unit) || GetOwner().IsInMap(unit)); Cypher.Assert((!GetOwner().IsInWorld && GetOwner() == unit) || GetOwner().IsInMap(unit));
unit._ApplyAuraEffect(this, effIndex); unit._ApplyAuraEffect(this, effIndex);
} }
} }
@@ -595,7 +594,7 @@ namespace Game.Spells
public void UpdateOwner(uint diff, WorldObject owner) public void UpdateOwner(uint diff, WorldObject owner)
{ {
Contract.Assert(owner == m_owner); Cypher.Assert(owner == m_owner);
Unit caster = GetCaster(); Unit caster = GetCaster();
// Apply spellmods for channeled auras // Apply spellmods for channeled auras
@@ -994,9 +993,9 @@ namespace Game.Spells
public void UnregisterSingleTarget() public void UnregisterSingleTarget()
{ {
Contract.Assert(m_isSingleTarget); Cypher.Assert(m_isSingleTarget);
Unit caster = GetCaster(); Unit caster = GetCaster();
Contract.Assert(caster != null); Cypher.Assert(caster != null);
caster.GetSingleCastAuras().Remove(this); caster.GetSingleCastAuras().Remove(this);
SetIsSingleTarget(false); SetIsSingleTarget(false);
} }
@@ -1076,7 +1075,7 @@ namespace Game.Spells
public void RecalculateAmountOfEffects() public void RecalculateAmountOfEffects()
{ {
Contract.Assert(!IsRemoved()); Cypher.Assert(!IsRemoved());
Unit caster = GetCaster(); Unit caster = GetCaster();
foreach (AuraEffect effect in GetAuraEffects()) foreach (AuraEffect effect in GetAuraEffects())
if (effect != null && !IsRemoved()) if (effect != null && !IsRemoved())
@@ -1085,7 +1084,7 @@ namespace Game.Spells
public void HandleAllEffects(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) public void HandleAllEffects(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{ {
Contract.Assert(!IsRemoved()); Cypher.Assert(!IsRemoved());
foreach (AuraEffect effect in GetAuraEffects()) foreach (AuraEffect effect in GetAuraEffects())
if (effect != null && !IsRemoved()) if (effect != null && !IsRemoved())
effect.HandleEffect(aurApp, mode, apply); effect.HandleEffect(aurApp, mode, apply);
@@ -1625,7 +1624,7 @@ namespace Game.Spells
SpellProcEntry procEntry = Global.SpellMgr.GetSpellProcEntry(GetId()); SpellProcEntry procEntry = Global.SpellMgr.GetSpellProcEntry(GetId());
Contract.Assert(procEntry != null); Cypher.Assert(procEntry != null);
// cooldowns should be added to the whole aura (see 51698 area aura) // cooldowns should be added to the whole aura (see 51698 area aura)
AddProcCooldown(now + TimeSpan.FromMilliseconds(procEntry.Cooldown)); AddProcCooldown(now + TimeSpan.FromMilliseconds(procEntry.Cooldown));
@@ -2227,12 +2226,12 @@ namespace Game.Spells
public WorldObject GetOwner() { return m_owner; } public WorldObject GetOwner() { return m_owner; }
public Unit GetUnitOwner() public Unit GetUnitOwner()
{ {
Contract.Assert(GetAuraType() == AuraObjectType.Unit); Cypher.Assert(GetAuraType() == AuraObjectType.Unit);
return m_owner.ToUnit(); return m_owner.ToUnit();
} }
public DynamicObject GetDynobjOwner() public DynamicObject GetDynobjOwner()
{ {
Contract.Assert(GetAuraType() == AuraObjectType.DynObj); Cypher.Assert(GetAuraType() == AuraObjectType.DynObj);
return m_owner.ToDynamicObject(); return m_owner.ToDynamicObject();
} }
@@ -2345,8 +2344,8 @@ namespace Game.Spells
//Static Methods //Static Methods
public static uint BuildEffectMaskForOwner(SpellInfo spellProto, uint availableEffectMask, WorldObject owner) public static uint BuildEffectMaskForOwner(SpellInfo spellProto, uint availableEffectMask, WorldObject owner)
{ {
Contract.Assert(spellProto != null); Cypher.Assert(spellProto != null);
Contract.Assert(owner != null); Cypher.Assert(owner != null);
uint effMask = 0; uint effMask = 0;
switch (owner.GetTypeId()) switch (owner.GetTypeId())
{ {
@@ -2377,10 +2376,10 @@ namespace Game.Spells
} }
public static Aura TryRefreshStackOrCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, out bool refresh, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1) public static Aura TryRefreshStackOrCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, out bool refresh, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{ {
Contract.Assert(spellproto != null); Cypher.Assert(spellproto != null);
Contract.Assert(owner != null); Cypher.Assert(owner != null);
Contract.Assert(caster || !casterGUID.IsEmpty()); Cypher.Assert(caster || !casterGUID.IsEmpty());
Contract.Assert(tryEffMask <= SpellConst.MaxEffectMask); Cypher.Assert(tryEffMask <= SpellConst.MaxEffectMask);
refresh = false; refresh = false;
uint effMask = BuildEffectMaskForOwner(spellproto, tryEffMask, owner); uint effMask = BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
@@ -2402,10 +2401,10 @@ namespace Game.Spells
} }
public static Aura TryCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1) public static Aura TryCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{ {
Contract.Assert(spellproto != null); Cypher.Assert(spellproto != null);
Contract.Assert(owner != null); Cypher.Assert(owner != null);
Contract.Assert(caster != null || !casterGUID.IsEmpty()); Cypher.Assert(caster != null || !casterGUID.IsEmpty());
Contract.Assert(tryEffMask <= SpellConst.MaxEffectMask); Cypher.Assert(tryEffMask <= SpellConst.MaxEffectMask);
uint effMask = BuildEffectMaskForOwner(spellproto, tryEffMask, owner); uint effMask = BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
if (effMask == 0) if (effMask == 0)
return null; return null;
@@ -2413,11 +2412,11 @@ namespace Game.Spells
} }
public static Aura Create(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, int castItemLevel) public static Aura Create(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, int castItemLevel)
{ {
Contract.Assert(effMask != 0); Cypher.Assert(effMask != 0);
Contract.Assert(spellproto != null); Cypher.Assert(spellproto != null);
Contract.Assert(owner != null); Cypher.Assert(owner != null);
Contract.Assert(caster != null || !casterGUID.IsEmpty()); Cypher.Assert(caster != null || !casterGUID.IsEmpty());
Contract.Assert(effMask <= SpellConst.MaxEffectMask); Cypher.Assert(effMask <= SpellConst.MaxEffectMask);
// try to get caster of aura // try to get caster of aura
if (!casterGUID.IsEmpty()) if (!casterGUID.IsEmpty())
{ {
@@ -2447,7 +2446,7 @@ namespace Game.Spells
aura = new DynObjAura(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemGuid, castItemLevel); aura = new DynObjAura(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemGuid, castItemLevel);
break; break;
default: default:
Contract.Assert(false); Cypher.Assert(false);
return null; return null;
} }
// aura can be removed in Unit:_AddAura call // aura can be removed in Unit:_AddAura call
@@ -2613,9 +2612,9 @@ namespace Game.Spells
: base(spellproto, castId, owner, caster, castItem, casterGUID, castItemGuid, castItemLevel) : base(spellproto, castId, owner, caster, castItem, casterGUID, castItemGuid, castItemLevel)
{ {
LoadScripts(); LoadScripts();
Contract.Assert(GetDynobjOwner() != null); Cypher.Assert(GetDynobjOwner() != null);
Contract.Assert(GetDynobjOwner().IsInWorld); Cypher.Assert(GetDynobjOwner().IsInWorld);
Contract.Assert(GetDynobjOwner().GetMap() == caster.GetMap()); Cypher.Assert(GetDynobjOwner().GetMap() == caster.GetMap());
_InitEffects(effMask, caster, baseAmount); _InitEffects(effMask, caster, baseAmount);
GetDynobjOwner().SetAura(this); GetDynobjOwner().SetAura(this);
+3 -4
View File
@@ -26,7 +26,6 @@ using Game.Maps;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Spells namespace Game.Spells
@@ -305,7 +304,7 @@ namespace Game.Spells
public void HandleEffect(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) public void HandleEffect(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{ {
// check if call is correct, we really don't want using bitmasks here (with 1 exception) // check if call is correct, we really don't want using bitmasks here (with 1 exception)
Contract.Assert(mode == AuraEffectHandleModes.Real || mode == AuraEffectHandleModes.SendForClient Cypher.Assert(mode == AuraEffectHandleModes.Real || mode == AuraEffectHandleModes.SendForClient
|| mode == AuraEffectHandleModes.ChangeAmount || mode == AuraEffectHandleModes.Stat || mode == AuraEffectHandleModes.ChangeAmount || mode == AuraEffectHandleModes.Stat
|| mode == AuraEffectHandleModes.Skill || mode == AuraEffectHandleModes.Reapply || mode == AuraEffectHandleModes.Skill || mode == AuraEffectHandleModes.Reapply
|| mode == (AuraEffectHandleModes.ChangeAmount | AuraEffectHandleModes.Reapply)); || mode == (AuraEffectHandleModes.ChangeAmount | AuraEffectHandleModes.Reapply));
@@ -345,7 +344,7 @@ namespace Game.Spells
public void HandleEffect(Unit target, AuraEffectHandleModes mode, bool apply) public void HandleEffect(Unit target, AuraEffectHandleModes mode, bool apply)
{ {
AuraApplication aurApp = GetBase().GetApplicationOfTarget(target.GetGUID()); AuraApplication aurApp = GetBase().GetApplicationOfTarget(target.GetGUID());
Contract.Assert(aurApp != null); Cypher.Assert(aurApp != null);
HandleEffect(aurApp, mode, apply); HandleEffect(aurApp, mode, apply);
} }
@@ -578,7 +577,7 @@ namespace Game.Spells
bool CanPeriodicTickCrit(Unit caster) bool CanPeriodicTickCrit(Unit caster)
{ {
Contract.Assert(caster); Cypher.Assert(caster);
return caster.HasAuraTypeWithAffectMask(AuraType.AbilityPeriodicCrit, m_spellInfo); return caster.HasAuraTypeWithAffectMask(AuraType.AbilityPeriodicCrit, m_spellInfo);
} }
+20 -20
View File
@@ -29,7 +29,6 @@ using Game.Network.Packets;
using Game.Scripting; using Game.Scripting;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Game.AI; using Game.AI;
@@ -124,7 +123,7 @@ namespace Game.Spells
} }
if (m_caster && m_caster.GetTypeId() == TypeId.Player) if (m_caster && m_caster.GetTypeId() == TypeId.Player)
Contract.Assert(m_caster.ToPlayer().m_spellModTakingSpell != this); Cypher.Assert(m_caster.ToPlayer().m_spellModTakingSpell != this);
} }
void InitExplicitTargets(SpellCastTargets targets) void InitExplicitTargets(SpellCastTargets targets)
@@ -282,8 +281,9 @@ namespace Game.Spells
else if (m_auraScaleMask != 0) else if (m_auraScaleMask != 0)
{ {
bool checkLvl = !m_UniqueTargetInfo.Empty(); bool checkLvl = !m_UniqueTargetInfo.Empty();
foreach (var ihit in m_UniqueTargetInfo) for (var i = 0; i < m_UniqueTargetInfo.Count; ++i)
{ {
var ihit = m_UniqueTargetInfo[i];
// remove targets which did not pass min level check // remove targets which did not pass min level check
if (m_auraScaleMask != 0 && ihit.effectMask == m_auraScaleMask) if (m_auraScaleMask != 0 && ihit.effectMask == m_auraScaleMask)
{ {
@@ -388,7 +388,7 @@ namespace Game.Spells
m_targets.SetSrc(m_caster); m_targets.SetSrc(m_caster);
break; break;
default: default:
Contract.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_SRC"); Cypher.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_SRC");
break; break;
} }
break; break;
@@ -405,7 +405,7 @@ namespace Game.Spells
SelectImplicitDestDestTargets(effIndex, targetType); SelectImplicitDestDestTargets(effIndex, targetType);
break; break;
default: default:
Contract.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_DEST"); Cypher.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_DEST");
break; break;
} }
break; break;
@@ -419,7 +419,7 @@ namespace Game.Spells
SelectImplicitTargetObjectTargets(effIndex, targetType); SelectImplicitTargetObjectTargets(effIndex, targetType);
break; break;
default: default:
Contract.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT"); Cypher.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT");
break; break;
} }
break; break;
@@ -429,7 +429,7 @@ namespace Game.Spells
Log.outDebug(LogFilter.Spells, "SPELL: target type {0}, found in spellID {1}, effect {2} is not implemented yet!", m_spellInfo.Id, effIndex, targetType.GetTarget()); Log.outDebug(LogFilter.Spells, "SPELL: target type {0}, found in spellID {1}, effect {2} is not implemented yet!", m_spellInfo.Id, effIndex, targetType.GetTarget());
break; break;
default: default:
Contract.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target category"); Cypher.Assert(false, "Spell.SelectEffectImplicitTargets: received not implemented select target category");
break; break;
} }
} }
@@ -438,7 +438,7 @@ namespace Game.Spells
{ {
if (targetType.GetReferenceType() != SpellTargetReferenceTypes.Caster) if (targetType.GetReferenceType() != SpellTargetReferenceTypes.Caster)
{ {
Contract.Assert(false, "Spell.SelectImplicitChannelTargets: received not implemented target reference type"); Cypher.Assert(false, "Spell.SelectImplicitChannelTargets: received not implemented target reference type");
return; return;
} }
@@ -498,7 +498,7 @@ namespace Game.Spells
break; break;
} }
default: default:
Contract.Assert(false, "Spell.SelectImplicitChannelTargets: received not implemented target type"); Cypher.Assert(false, "Spell.SelectImplicitChannelTargets: received not implemented target type");
break; break;
} }
} }
@@ -507,7 +507,7 @@ namespace Game.Spells
{ {
if (targetType.GetReferenceType() != SpellTargetReferenceTypes.Caster) if (targetType.GetReferenceType() != SpellTargetReferenceTypes.Caster)
{ {
Contract.Assert(false, "Spell.SelectImplicitNearbyTargets: received not implemented target reference type"); Cypher.Assert(false, "Spell.SelectImplicitNearbyTargets: received not implemented target reference type");
return; return;
} }
@@ -532,7 +532,7 @@ namespace Game.Spells
range = m_spellInfo.GetMaxRange(m_spellInfo.IsPositive(), m_caster, this); range = m_spellInfo.GetMaxRange(m_spellInfo.IsPositive(), m_caster, this);
break; break;
default: default:
Contract.Assert(false, "Spell.SelectImplicitNearbyTargets: received not implemented selection check type"); Cypher.Assert(false, "Spell.SelectImplicitNearbyTargets: received not implemented selection check type");
break; break;
} }
@@ -629,7 +629,7 @@ namespace Game.Spells
m_targets.SetDst(dest); m_targets.SetDst(dest);
break; break;
default: default:
Contract.Assert(false, "Spell.SelectImplicitNearbyTargets: received not implemented target object type"); Cypher.Assert(false, "Spell.SelectImplicitNearbyTargets: received not implemented target object type");
break; break;
} }
@@ -640,7 +640,7 @@ namespace Game.Spells
{ {
if (targetType.GetReferenceType() != SpellTargetReferenceTypes.Caster) if (targetType.GetReferenceType() != SpellTargetReferenceTypes.Caster)
{ {
Contract.Assert(false, "Spell.SelectImplicitConeTargets: received not implemented target reference type"); Cypher.Assert(false, "Spell.SelectImplicitConeTargets: received not implemented target reference type");
return; return;
} }
List<WorldObject> targets = new List<WorldObject>(); List<WorldObject> targets = new List<WorldObject>();
@@ -709,7 +709,7 @@ namespace Game.Spells
break; break;
} }
default: default:
Contract.Assert(false, "Spell.SelectImplicitAreaTargets: received not implemented target reference type"); Cypher.Assert(false, "Spell.SelectImplicitAreaTargets: received not implemented target reference type");
return; return;
} }
if (referer == null) if (referer == null)
@@ -730,7 +730,7 @@ namespace Game.Spells
center = referer.GetPosition(); center = referer.GetPosition();
break; break;
default: default:
Contract.Assert(false, "Spell.SelectImplicitAreaTargets: received not implemented target reference type"); Cypher.Assert(false, "Spell.SelectImplicitAreaTargets: received not implemented target reference type");
return; return;
} }
List<WorldObject> targets = new List<WorldObject>(); List<WorldObject> targets = new List<WorldObject>();
@@ -2182,7 +2182,7 @@ namespace Game.Spells
if (scaleAura) if (scaleAura)
{ {
aurSpellInfo = m_spellInfo.GetAuraRankForLevel(unitTarget.getLevel()); aurSpellInfo = m_spellInfo.GetAuraRankForLevel(unitTarget.getLevel());
Contract.Assert(aurSpellInfo != null); Cypher.Assert(aurSpellInfo != null);
foreach (SpellEffectInfo effect in aurSpellInfo.GetEffectsForDifficulty(0)) foreach (SpellEffectInfo effect in aurSpellInfo.GetEffectsForDifficulty(0))
{ {
if (effect == null) if (effect == null)
@@ -3507,7 +3507,7 @@ namespace Game.Spells
} }
case SpellCastResult.CantUntalent: case SpellCastResult.CantUntalent:
{ {
Contract.Assert(param1.HasValue); Cypher.Assert(param1.HasValue);
packet.FailedArg1 = (int)param1; packet.FailedArg1 = (int)param1;
break; break;
} }
@@ -6844,7 +6844,7 @@ namespace Game.Spells
hookType = SpellScriptHookType.EffectHitTarget; hookType = SpellScriptHookType.EffectHitTarget;
break; break;
default: default:
Contract.Assert(false); Cypher.Assert(false);
return false; return false;
} }
script._PrepareScriptCall(hookType); script._PrepareScriptCall(hookType);
@@ -7528,7 +7528,7 @@ namespace Game.Spells
public SpellValue(Difficulty difficulty, SpellInfo proto) public SpellValue(Difficulty difficulty, SpellInfo proto)
{ {
var effects = proto.GetEffectsForDifficulty(difficulty); var effects = proto.GetEffectsForDifficulty(difficulty);
Contract.Assert(effects.Length <= SpellConst.MaxEffects); Cypher.Assert(effects.Length <= SpellConst.MaxEffects);
foreach (SpellEffectInfo effect in effects) foreach (SpellEffectInfo effect in effects)
if (effect != null) if (effect != null)
EffectBasePoints[effect.EffectIndex] = effect.BasePoints; EffectBasePoints[effect.EffectIndex] = effect.BasePoints;
@@ -7795,7 +7795,7 @@ namespace Game.Spells
if (!m_Spell.m_targets.HasDst()) if (!m_Spell.m_targets.HasDst())
{ {
ulong n_offset = m_Spell.handle_delayed(0); ulong n_offset = m_Spell.handle_delayed(0);
Contract.Assert(n_offset == m_Spell.GetDelayMoment()); Cypher.Assert(n_offset == m_Spell.GetDelayMoment());
} }
// re-plan the event for the delay moment // re-plan the event for the delay moment
m_Spell.GetCaster().m_Events.AddEvent(this, e_time + m_Spell.GetDelayMoment(), false); m_Spell.GetCaster().m_Events.AddEvent(this, e_time + m_Spell.GetDelayMoment(), false);
+3 -4
View File
@@ -19,7 +19,6 @@ using Framework.Constants;
using Game.Entities; using Game.Entities;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Diagnostics.Contracts;
namespace Game.Spells namespace Game.Spells
{ {
@@ -280,7 +279,7 @@ namespace Game.Spells
public void ModSrc(Position pos) public void ModSrc(Position pos)
{ {
Contract.Assert(m_targetMask.HasAnyFlag(SpellCastTargetFlags.SourceLocation)); Cypher.Assert(m_targetMask.HasAnyFlag(SpellCastTargetFlags.SourceLocation));
m_src.Relocate(pos); m_src.Relocate(pos);
} }
@@ -331,13 +330,13 @@ namespace Game.Spells
public void ModDst(Position pos) public void ModDst(Position pos)
{ {
Contract.Assert(m_targetMask.HasAnyFlag(SpellCastTargetFlags.DestLocation)); Cypher.Assert(m_targetMask.HasAnyFlag(SpellCastTargetFlags.DestLocation));
m_dst.Relocate(pos); m_dst.Relocate(pos);
} }
public void ModDst(SpellDestination spellDest) public void ModDst(SpellDestination spellDest)
{ {
Contract.Assert(m_targetMask.HasAnyFlag(SpellCastTargetFlags.DestLocation)); Cypher.Assert(m_targetMask.HasAnyFlag(SpellCastTargetFlags.DestLocation));
m_dst = spellDest; m_dst = spellDest;
} }
+4 -5
View File
@@ -32,7 +32,6 @@ using Game.Movement;
using Game.Network.Packets; using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
namespace Game.Spells namespace Game.Spells
@@ -770,7 +769,7 @@ namespace Game.Spells
if (m_spellAura == null || unitTarget == null) if (m_spellAura == null || unitTarget == null)
return; return;
Contract.Assert(unitTarget == m_spellAura.GetOwner()); Cypher.Assert(unitTarget == m_spellAura.GetOwner());
m_spellAura._ApplyEffectForTargets(effIndex); m_spellAura._ApplyEffectForTargets(effIndex);
} }
@@ -787,7 +786,7 @@ namespace Game.Spells
if (m_spellAura == null || unitTarget == null) if (m_spellAura == null || unitTarget == null)
return; return;
Contract.Assert(unitTarget == m_spellAura.GetOwner()); Cypher.Assert(unitTarget == m_spellAura.GetOwner());
m_spellAura._ApplyEffectForTargets(effIndex); m_spellAura._ApplyEffectForTargets(effIndex);
} }
@@ -1253,7 +1252,7 @@ namespace Game.Spells
return; return;
} }
Contract.Assert(m_spellAura.GetDynobjOwner()); Cypher.Assert(m_spellAura.GetDynobjOwner());
m_spellAura._ApplyEffectForTargets(effIndex); m_spellAura._ApplyEffectForTargets(effIndex);
} }
@@ -2436,7 +2435,7 @@ namespace Game.Spells
if (OldSummon.IsDead()) if (OldSummon.IsDead())
return; return;
Contract.Assert(OldSummon.GetMap() == owner.GetMap()); Cypher.Assert(OldSummon.GetMap() == owner.GetMap());
float px, py, pz; float px, py, pz;
owner.GetClosePoint(out px, out py, out pz, OldSummon.GetObjectSize()); owner.GetClosePoint(out px, out py, out pz, OldSummon.GetObjectSize());
+5 -5
View File
@@ -1956,11 +1956,11 @@ namespace Game.Entities
Dictionary<uint, MultiMap<uint, SpellXSpellVisualRecord>> visualsBySpell = new Dictionary<uint, MultiMap<uint, SpellXSpellVisualRecord>>(); Dictionary<uint, MultiMap<uint, SpellXSpellVisualRecord>> visualsBySpell = new Dictionary<uint, MultiMap<uint, SpellXSpellVisualRecord>>();
foreach (var effect in CliDB.SpellEffectStorage.Values) foreach (var effect in CliDB.SpellEffectStorage.Values)
{ {
/*Contract.Assert(effect.EffectIndex < MAX_SPELL_EFFECTS, "MAX_SPELL_EFFECTS must be at least {0}", effect.EffectIndex); Cypher.Assert(effect.EffectIndex < SpellConst.MaxEffects, $"MAX_SPELL_EFFECTS must be at least {effect.EffectIndex}");
Contract.Assert(effect.Effect < TOTAL_SPELL_EFFECTS, "TOTAL_SPELL_EFFECTS must be at least {0}", effect.Effect); Cypher.Assert(effect.Effect < (int)SpellEffectName.TotalSpellEffects, $"TOTAL_SPELL_EFFECTS must be at least {effect.Effect}");
Contract.Assert(effect.EffectAura < TOTAL_AURAS, "TOTAL_AURAS must be at least {0}", effect.EffectAura); Cypher.Assert(effect.EffectAura < (int)AuraType.Total, $"TOTAL_AURAS must be at least {effect.EffectAura}");
Contract.Assert(effect.ImplicitTarget[0] < TOTAL_SPELL_TARGETS, "TOTAL_SPELL_TARGETS must be at least {0}", effect.ImplicitTarget[0]); Cypher.Assert(effect.ImplicitTarget[0] < (int)Targets.TotalSpellTargets, $"TOTAL_SPELL_TARGETS must be at least {effect.ImplicitTarget[0]}");
Contract.Assert(effect.ImplicitTarget[1] < TOTAL_SPELL_TARGETS, "TOTAL_SPELL_TARGETS must be at least {0}", effect.ImplicitTarget[1]);*/ Cypher.Assert(effect.ImplicitTarget[1] < (int)Targets.TotalSpellTargets, $"TOTAL_SPELL_TARGETS must be at least {effect.ImplicitTarget[1]}");
if (!effectsBySpell.ContainsKey(effect.SpellID)) if (!effectsBySpell.ContainsKey(effect.SpellID))
effectsBySpell[effect.SpellID] = new Dictionary<uint, SpellEffectRecord[]>(); effectsBySpell[effect.SpellID] = new Dictionary<uint, SpellEffectRecord[]>();
@@ -24,7 +24,6 @@ using Game.Scripting;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Scripts.Northrend.IcecrownCitadel namespace Scripts.Northrend.IcecrownCitadel
{ {
@@ -398,11 +397,10 @@ namespace Scripts.Northrend.IcecrownCitadel
[Script] [Script]
class npc_bone_spike : ScriptedAI class npc_bone_spike : ScriptedAI
{ {
public npc_bone_spike(Creature creature) public npc_bone_spike(Creature creature) : base(creature)
: base(creature)
{ {
_hasTrappedUnit = false; _hasTrappedUnit = false;
Contract.Assert(creature.GetVehicleKit()); Cypher.Assert(creature.GetVehicleKit());
SetCombatMovement(false); SetCombatMovement(false);
} }
@@ -23,7 +23,6 @@ using Game.Scripting;
using Game.Spells; using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Scripts.Northrend.Ulduar.FlameLeviathan namespace Scripts.Northrend.Ulduar.FlameLeviathan
{ {
@@ -217,7 +216,7 @@ namespace Scripts.Northrend.Ulduar.FlameLeviathan
public override void InitializeAI() public override void InitializeAI()
{ {
Contract.Assert(vehicle); Cypher.Assert(vehicle);
if (!me.IsDead()) if (!me.IsDead())
Reset(); Reset();
@@ -558,7 +557,7 @@ namespace Scripts.Northrend.Ulduar.FlameLeviathan
: base(creature) : base(creature)
{ {
vehicle = creature.GetVehicleKit(); vehicle = creature.GetVehicleKit();
Contract.Assert(vehicle); Cypher.Assert(vehicle);
me.SetReactState(ReactStates.Passive); me.SetReactState(ReactStates.Passive);
me.SetDisplayId(me.GetCreatureTemplate().ModelId2); me.SetDisplayId(me.GetCreatureTemplate().ModelId2);
instance = creature.GetInstanceScript(); instance = creature.GetInstanceScript();
@@ -736,7 +735,7 @@ namespace Scripts.Northrend.Ulduar.FlameLeviathan
{ {
public npc_mechanolift(Creature creature) : base(creature) public npc_mechanolift(Creature creature) : base(creature)
{ {
Contract.Assert(me.GetVehicleKit()); Cypher.Assert(me.GetVehicleKit());
} }
uint MoveTimer; uint MoveTimer;
+2 -1
View File
@@ -22,6 +22,7 @@ using Game;
using Game.Chat; using Game.Chat;
using Game.Network; using Game.Network;
using System; using System;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
@@ -39,7 +40,7 @@ namespace WorldServer
Console.CancelKeyPress += (o, e) => Global.WorldMgr.StopNow(ShutdownExitCode.Shutdown); Console.CancelKeyPress += (o, e) => Global.WorldMgr.StopNow(ShutdownExitCode.Shutdown);
if (!ConfigMgr.Load(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".conf")) if (!ConfigMgr.Load(Process.GetCurrentProcess().ProcessName + ".conf"))
ExitNow(); ExitNow();
if (!StartDB()) if (!StartDB())