Core/Refactor: Part 4

This commit is contained in:
hondacrx
2018-05-27 15:40:06 -04:00
parent d94ad385b1
commit 2c3479c6e2
59 changed files with 159 additions and 223 deletions
@@ -68,7 +68,7 @@ namespace BNetServer.Services
abstract class ServiceBase abstract class ServiceBase
{ {
public ServiceBase(Session session, uint serviceHash) protected ServiceBase(Session session, uint serviceHash)
{ {
_session = session; _session = session;
_serviceHash = serviceHash; _serviceHash = serviceHash;
+1 -1
View File
@@ -359,7 +359,7 @@ namespace System.Collections
internal BitArrayEnumeratorSimple(BitSet bitarray) internal BitArrayEnumeratorSimple(BitSet bitarray)
{ {
this._bitarray = bitarray; _bitarray = bitarray;
_index = -1; _index = -1;
_version = bitarray._version; _version = bitarray._version;
} }
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Framework.Cryptography
sha.TransformBlock(bytes, 0, bytes.Length, bytes, 0); sha.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
} }
public void Finish(byte[] data, int length) public void Finish(byte[] data)
{ {
sha.TransformFinalBlock(data, 0, data.Length); sha.TransformFinalBlock(data, 0, data.Length);
+3 -3
View File
@@ -318,7 +318,7 @@ namespace Framework.Database
_database.Execute(update); _database.Execute(update);
} }
public List<FileEntry> GetFileList() List<FileEntry> GetFileList()
{ {
List<FileEntry> fileList = new List<FileEntry>(); List<FileEntry> fileList = new List<FileEntry>();
@@ -348,7 +348,7 @@ namespace Framework.Database
return fileList; return fileList;
} }
public Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles() Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles()
{ {
Dictionary<string, AppliedFileEntry> map = new Dictionary<string, AppliedFileEntry>(); Dictionary<string, AppliedFileEntry> map = new Dictionary<string, AppliedFileEntry>();
@@ -402,7 +402,7 @@ namespace Framework.Database
} }
} }
protected MySqlBase<T> _database; MySqlBase<T> _database;
} }
public class AppliedFileEntry public class AppliedFileEntry
+1 -1
View File
@@ -22,7 +22,7 @@ namespace Framework.Database
{ {
public class SQLTransaction public class SQLTransaction
{ {
public List<MySqlCommand> commands { get; set; } public List<MySqlCommand> commands { get; }
public SQLTransaction() public SQLTransaction()
{ {
+2 -2
View File
@@ -602,7 +602,7 @@ namespace Framework.Dynamic
/// <returns></returns> /// <returns></returns>
public TaskContext CancelGroup(uint group) public TaskContext CancelGroup(uint group)
{ {
return Dispatch(() => CancelGroup(group)); return Dispatch(() => _owner.CancelGroup(group));
} }
/// <summary> /// <summary>
@@ -612,7 +612,7 @@ namespace Framework.Dynamic
/// <returns></returns> /// <returns></returns>
public TaskContext CancelGroupsOf(List<uint> groups) public TaskContext CancelGroupsOf(List<uint> groups)
{ {
return Dispatch(() => CancelGroupsOf(groups)); return Dispatch(() => _owner.CancelGroupsOf(groups));
} }
/// <summary> /// <summary>
+1 -2
View File
@@ -441,12 +441,11 @@ namespace Framework.IO
public byte[] GetData() public byte[] GetData()
{ {
long pos;
Stream stream = GetCurrentStream(); Stream stream = GetCurrentStream();
var data = new byte[stream.Length]; var data = new byte[stream.Length];
pos = stream.Position; long pos = stream.Position;
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
for (int i = 0; i < data.Length; i++) for (int i = 0; i < data.Length; i++)
data[i] = (byte)stream.ReadByte(); data[i] = (byte)stream.ReadByte();
+39 -42
View File
@@ -1002,8 +1002,6 @@ namespace Framework.IO
public static int deflate(z_stream strm, int flush) public static int deflate(z_stream strm, int flush)
{ {
int old_flush; // value of flush param for previous deflate call
if(strm==null||strm.state==null||flush>Z_BLOCK||flush<0) return Z_STREAM_ERROR; if(strm==null||strm.state==null||flush>Z_BLOCK||flush<0) return Z_STREAM_ERROR;
deflate_state s=(deflate_state)strm.state; deflate_state s=(deflate_state)strm.state;
@@ -1020,7 +1018,7 @@ namespace Framework.IO
} }
s.strm=strm; // just in case s.strm=strm; // just in case
old_flush=s.last_flush; int old_flush = s.last_flush;// value of flush param for previous deflate call
s.last_flush=flush; s.last_flush=flush;
// Write the header // Write the header
@@ -1568,57 +1566,56 @@ namespace Framework.IO
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Optimized version for FASTEST only // Optimized version for FASTEST only
static uint longest_match_fast(deflate_state s, uint cur_match) static uint longest_match_fast(deflate_state s, uint cur_match)
{ {
byte[] scan=s.window; byte[] scan = s.window;
int scan_ind=(int)s.strstart; // current string int scan_ind = (int) s.strstart; // current string
int len; // length of current match int strend_ind = (int) s.strstart + MAX_MATCH;
int strend_ind=(int)s.strstart+MAX_MATCH;
// The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
// It is easy to get rid of this optimization if necessary. // It is easy to get rid of this optimization if necessary.
//Assert(s.hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); //Assert(s.hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
//Assert((uint)s.strstart <= s.window_size-MIN_LOOKAHEAD, "need lookahead"); //Assert((uint)s.strstart <= s.window_size-MIN_LOOKAHEAD, "need lookahead");
//Assert(cur_match < s.strstart, "no future"); //Assert(cur_match < s.strstart, "no future");
byte[] match=s.window; byte[] match = s.window;
int match_ind=(int)cur_match; int match_ind = (int) cur_match;
// Return failure if the match length is less than 2: // Return failure if the match length is less than 2:
if(match[match_ind]!=scan[scan_ind]||match[match_ind+1]!=scan[scan_ind+1]) return MIN_MATCH-1; if (match[match_ind] != scan[scan_ind] || match[match_ind + 1] != scan[scan_ind + 1]) return MIN_MATCH - 1;
// The check at best_len-1 can be removed because it will be made // The check at best_len-1 can be removed because it will be made
// again later. (This heuristic is not always a win.) // again later. (This heuristic is not always a win.)
// It is not necessary to compare scan[2] and match[2] since they // It is not necessary to compare scan[2] and match[2] since they
// are always equal when the other bytes match, given that // are always equal when the other bytes match, given that
// the hash keys are equal and that HASH_BITS >= 8. // the hash keys are equal and that HASH_BITS >= 8.
scan_ind+=2; scan_ind += 2;
match_ind+=2; match_ind += 2;
//Assert(scan[scan_ind] == match[match_ind], "match[2]?"); //Assert(scan[scan_ind] == match[match_ind], "match[2]?");
// We check for insufficient lookahead only every 8th comparison; // We check for insufficient lookahead only every 8th comparison;
// the 256th check will be made at strstart+258. // the 256th check will be made at strstart+258.
do do
{ {
} while(scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& } while (scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan_ind<strend_ind); scan_ind < strend_ind);
//Assert(scan_ind <= (uint)(s.window_size-1), "wild scan"); //Assert(scan_ind <= (uint)(s.window_size-1), "wild scan");
len=MAX_MATCH-(int)(strend_ind-scan_ind); int len = MAX_MATCH - (int) (strend_ind - scan_ind);// length of current match
if(len<MIN_MATCH) return MIN_MATCH-1; if (len < MIN_MATCH) return MIN_MATCH - 1;
s.match_start=cur_match; s.match_start = cur_match;
return (uint)len<=s.lookahead?(uint)len:s.lookahead; return (uint) len <= s.lookahead ? (uint) len : s.lookahead;
} }
// =========================================================================== // ===========================================================================
// Fill the window when the lookahead becomes insufficient. // Fill the window when the lookahead becomes insufficient.
// Updates strstart and lookahead. // Updates strstart and lookahead.
// //
+1 -1
View File
@@ -164,7 +164,7 @@ class DBAppender : Appender
abstract class Appender abstract class Appender
{ {
public Appender(byte id, string name, LogLevel level = LogLevel.Disabled, AppenderFlags flags = AppenderFlags.None) protected Appender(byte id, string name, LogLevel level = LogLevel.Disabled, AppenderFlags flags = AppenderFlags.None)
{ {
_id = id; _id = id;
_name = name; _name = name;
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Framework.Networking
{ {
public abstract class SSLSocket : ISocket public abstract class SSLSocket : ISocket
{ {
public SSLSocket(Socket socket) protected SSLSocket(Socket socket)
{ {
_socket = socket; _socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address; _remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Framework.Networking
{ {
public abstract class SocketBase : ISocket, IDisposable public abstract class SocketBase : ISocket, IDisposable
{ {
public SocketBase(Socket socket) protected SocketBase(Socket socket)
{ {
_socket = socket; _socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address; _remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
@@ -1186,7 +1186,7 @@ public static partial class Detour
case 5: nx--; ny--; break; case 5: nx--; ny--; break;
case 6: ny--; break; case 6: ny--; break;
case 7: nx++; ny--; break; case 7: nx++; ny--; break;
}; }
return getTilesAt(nx, ny, tiles, maxTiles); return getTilesAt(nx, ny, tiles, maxTiles);
} }
@@ -1001,7 +1001,7 @@ public static partial class Detour
case XM | ZM: return 5; case XM | ZM: return 5;
case ZM: return 6; case ZM: return 6;
case XP | ZM: return 7; case XP | ZM: return 7;
}; }
return 0xff; return 0xff;
} }
-2
View File
@@ -23,8 +23,6 @@ public class Singleton<T> where T : class
private static volatile T instance; private static volatile T instance;
private static object syncRoot = new Object(); private static object syncRoot = new Object();
public Singleton() { }
public static T Instance public static T Instance
{ {
get get
@@ -80,7 +80,7 @@ namespace Framework.Threading
{ {
while (_queue.Count != 0) while (_queue.Count != 0)
{ {
T value = _queue.Dequeue(); _queue.Dequeue();
} }
_shutdown = true; _shutdown = true;
@@ -232,10 +232,9 @@ namespace Game.AI
{ {
uint entry = result.Read<uint>(0); uint entry = result.Read<uint>(0);
uint id = result.Read<uint>(1); uint id = result.Read<uint>(1);
float x, y, z; float x = result.Read<float>(2);
x = result.Read<float>(2); float y = result.Read<float>(3);
y = result.Read<float>(3); float z = result.Read<float>(4);
z = result.Read<float>(4);
if (last_entry != entry) if (last_entry != entry)
{ {
+4 -5
View File
@@ -1194,11 +1194,10 @@ namespace Game.AI
Position pos = obj.GetPosition(); Position pos = obj.GetPosition();
// Use forward/backward/left/right cartesian plane movement // Use forward/backward/left/right cartesian plane movement
float x, y, z, o; float o = pos.GetOrientation();
o = pos.GetOrientation(); float x = (float)(pos.GetPositionX() + (Math.Cos(o - (Math.PI / 2)) * e.Target.x) + (Math.Cos(o) * e.Target.y));
x = (float)(pos.GetPositionX() + (Math.Cos(o - (Math.PI / 2)) * e.Target.x) + (Math.Cos(o) * e.Target.y)); float y = (float)(pos.GetPositionY() + (Math.Sin(o - (Math.PI / 2)) * e.Target.x) + (Math.Sin(o) * e.Target.y));
y = (float)(pos.GetPositionY() + (Math.Sin(o - (Math.PI / 2)) * e.Target.x) + (Math.Sin(o) * e.Target.y)); float z = pos.GetPositionZ() + e.Target.z;
z = pos.GetPositionZ() + e.Target.z;
obj.ToCreature().GetMotionMaster().MovePoint(EventId.SmartRandomPoint, x, y, z); obj.ToCreature().GetMotionMaster().MovePoint(EventId.SmartRandomPoint, x, y, z);
} }
} }
+2 -2
View File
@@ -143,7 +143,7 @@ namespace Game.Arenas
newMember.WeekGames = 0; newMember.WeekGames = 0;
newMember.SeasonWins = 0; newMember.SeasonWins = 0;
newMember.WeekWins = 0; newMember.WeekWins = 0;
newMember.PersonalRating = (ushort)(uint)0; newMember.PersonalRating = 0;
newMember.MatchMakerRating = (ushort)matchMakerRating; newMember.MatchMakerRating = (ushort)matchMakerRating;
Members.Add(newMember); Members.Add(newMember);
@@ -498,7 +498,7 @@ namespace Game.Arenas
{ {
// Returns the chance to win against a team with the given rating, used in the rating adjustment calculation // Returns the chance to win against a team with the given rating, used in the rating adjustment calculation
// ELO system // ELO system
return (float)(1.0f / (1.0f + Math.Exp(Math.Log(10.0f) * ((float)opponentRating - (float)ownRating) / 650.0f))); return (float)(1.0f / (1.0f + Math.Exp(Math.Log(10.0f) * ((float)opponentRating - ownRating) / 650.0f)));
} }
int GetMatchmakerRatingMod(uint ownRating, uint opponentRating, bool won) int GetMatchmakerRatingMod(uint ownRating, uint opponentRating, bool won)
@@ -459,7 +459,7 @@ namespace Game.BattleGrounds.Zones
{ {
UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1);
m_prevNodes[node] = m_Nodes[node]; m_prevNodes[node] = m_Nodes[node];
m_Nodes[node] = (ABNodeStatus.Contested + (int)teamIndex); m_Nodes[node] = (ABNodeStatus.Contested + teamIndex);
// burn current contested banner // burn current contested banner
_DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex); _DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex);
// create new contested banner // create new contested banner
@@ -477,7 +477,7 @@ namespace Game.BattleGrounds.Zones
{ {
UpdatePlayerScore(source, ScoreType.BasesDefended, 1); UpdatePlayerScore(source, ScoreType.BasesDefended, 1);
m_prevNodes[node] = m_Nodes[node]; m_prevNodes[node] = m_Nodes[node];
m_Nodes[node] = (ABNodeStatus.Occupied + (int)teamIndex); m_Nodes[node] = (ABNodeStatus.Occupied + teamIndex);
// burn current contested banner // burn current contested banner
_DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex); _DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex);
// create new occupied banner // create new occupied banner
@@ -498,7 +498,7 @@ namespace Game.BattleGrounds.Zones
{ {
UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1);
m_prevNodes[node] = m_Nodes[node]; m_prevNodes[node] = m_Nodes[node];
m_Nodes[node] = (ABNodeStatus.Contested + (int)teamIndex); m_Nodes[node] = (ABNodeStatus.Contested + teamIndex);
// burn current occupied banner // burn current occupied banner
_DelBanner(node, ABNodeStatus.Occupied, (byte)teamIndex); _DelBanner(node, ABNodeStatus.Occupied, (byte)teamIndex);
// create new contested banner // create new contested banner
@@ -639,7 +639,7 @@ namespace Game.BattleGrounds.Zones
// Is there any occupied node for this team? // Is there any occupied node for this team?
List<byte> nodes = new List<byte>(); List<byte> nodes = new List<byte>();
for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i)
if (m_Nodes[i] == ABNodeStatus.Occupied + (int)teamIndex) if (m_Nodes[i] == ABNodeStatus.Occupied + teamIndex)
nodes.Add(i); nodes.Add(i);
WorldSafeLocsRecord good_entry = null; WorldSafeLocsRecord good_entry = null;
@@ -125,7 +125,7 @@ namespace Game.BattleGrounds.Zones
SpawnBGObject(EotSObjectTypes.DoorA, BattlegroundConst.RespawnImmediately); SpawnBGObject(EotSObjectTypes.DoorA, BattlegroundConst.RespawnImmediately);
SpawnBGObject(EotSObjectTypes.DoorH, BattlegroundConst.RespawnImmediately); SpawnBGObject(EotSObjectTypes.DoorH, BattlegroundConst.RespawnImmediately);
for (int i = (int)EotSObjectTypes.ABannerFelReaverCenter; i < EotSObjectTypes.Max; ++i) for (int i = EotSObjectTypes.ABannerFelReaverCenter; i < EotSObjectTypes.Max; ++i)
SpawnBGObject(i, BattlegroundConst.RespawnOneDay); SpawnBGObject(i, BattlegroundConst.RespawnOneDay);
} }
@@ -884,8 +884,6 @@ namespace Game.BattleGrounds.Zones
default: return null; default: return null;
} }
float distance, nearestDistance;
WorldSafeLocsRecord entry = null; WorldSafeLocsRecord entry = null;
WorldSafeLocsRecord nearestEntry = null; WorldSafeLocsRecord nearestEntry = null;
entry = CliDB.WorldSafeLocsStorage.LookupByKey(g_id); entry = CliDB.WorldSafeLocsStorage.LookupByKey(g_id);
@@ -901,8 +899,8 @@ namespace Game.BattleGrounds.Zones
float plr_y = player.GetPositionY(); float plr_y = player.GetPositionY();
float plr_z = player.GetPositionZ(); float plr_z = player.GetPositionZ();
distance = (entry.Loc.X - plr_x) * (entry.Loc.X - plr_x) + (entry.Loc.Y - plr_y) * (entry.Loc.Y - plr_y) + (entry.Loc.Z - plr_z) * (entry.Loc.Z - plr_z); float distance = (entry.Loc.X - plr_x) * (entry.Loc.X - plr_x) + (entry.Loc.Y - plr_y) * (entry.Loc.Y - plr_y) + (entry.Loc.Z - plr_z) * (entry.Loc.Z - plr_z);
nearestDistance = distance; float nearestDistance = distance;
for (byte i = 0; i < EotSPoints.PointsMax; ++i) for (byte i = 0; i < EotSPoints.PointsMax; ++i)
{ {
@@ -603,9 +603,9 @@ namespace Game.BattleGrounds.Zones
void UpdateTeamScore(int team) void UpdateTeamScore(int team)
{ {
if (team == TeamId.Alliance) if (team == TeamId.Alliance)
UpdateWorldState(WSGWorldStates.FlagCapturesAlliance, (uint)GetTeamScore(team)); UpdateWorldState(WSGWorldStates.FlagCapturesAlliance, GetTeamScore(team));
else else
UpdateWorldState(WSGWorldStates.FlagCapturesHorde, (uint)GetTeamScore(team)); UpdateWorldState(WSGWorldStates.FlagCapturesHorde, GetTeamScore(team));
} }
public override void HandleAreaTrigger(Player player, uint trigger, bool entered) public override void HandleAreaTrigger(Player player, uint trigger, bool entered)
@@ -912,7 +912,7 @@ namespace Game.BattleGrounds.Zones
void SetLastFlagCapture(Team team) { _lastFlagCaptureTeam = (uint)team; } void SetLastFlagCapture(Team team) { _lastFlagCaptureTeam = (uint)team; }
public override void SetDroppedFlagGUID(ObjectGuid guid, int team = -1) public override void SetDroppedFlagGUID(ObjectGuid guid, int team = -1)
{ {
if (team == (int)TeamId.Alliance || team == (int)TeamId.Horde) if (team == TeamId.Alliance || team == TeamId.Horde)
m_DroppedFlagGUID[team] = guid; m_DroppedFlagGUID[team] = guid;
} }
@@ -379,7 +379,6 @@ namespace Game.Chat
uint entry = 0; uint entry = 0;
GameObjectTypes type = 0; GameObjectTypes type = 0;
uint displayId = 0; uint displayId = 0;
string name;
uint lootId = 0; uint lootId = 0;
if (args.Empty()) if (args.Empty())
@@ -415,7 +414,7 @@ namespace Game.Chat
type = gameObjectInfo.type; type = gameObjectInfo.type;
displayId = gameObjectInfo.displayId; displayId = gameObjectInfo.displayId;
name = gameObjectInfo.name; string name = gameObjectInfo.name;
lootId = gameObjectInfo.GetLootId(); lootId = gameObjectInfo.GetLootId();
handler.SendSysMessage(CypherStrings.GoinfoEntry, entry); handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
+1 -3
View File
@@ -171,14 +171,12 @@ namespace Game.Chat.Commands
if (count == 0) if (count == 0)
return false; return false;
SQLResult result;
// inventory case // inventory case
uint inventoryCount = 0; uint inventoryCount = 0;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_INVENTORY_COUNT_ITEM); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_INVENTORY_COUNT_ITEM);
stmt.AddValue(0, itemId); stmt.AddValue(0, itemId);
result = DB.Characters.Query(stmt); SQLResult result = DB.Characters.Query(stmt);
if (!result.IsEmpty()) if (!result.IsEmpty())
inventoryCount = result.Read<uint>(0); inventoryCount = result.Read<uint>(0);
+1 -2
View File
@@ -228,7 +228,6 @@ namespace Game.Chat.Commands
uint accountId = 0; uint accountId = 0;
string accountName; string accountName;
uint id = 0; uint id = 0;
RBACCommandData data;
RBACData rdata = null; RBACData rdata = null;
bool useSelectedPlayer = false; bool useSelectedPlayer = false;
@@ -293,7 +292,7 @@ namespace Game.Chat.Commands
if (checkParams && handler.HasLowerSecurityAccount(null, accountId, true)) if (checkParams && handler.HasLowerSecurityAccount(null, accountId, true))
return null; return null;
data = new RBACCommandData(); RBACCommandData data = new RBACCommandData();
if (rdata == null) if (rdata == null)
{ {
+1 -1
View File
@@ -185,7 +185,7 @@ namespace Game.Chat.Commands
ulong titles2 = titles; ulong titles2 = titles;
foreach (CharTitlesRecord tEntry in CliDB.CharTitlesStorage.Values) foreach (CharTitlesRecord tEntry in CliDB.CharTitlesStorage.Values)
titles2 &= ~(1ul << (int)tEntry.MaskID); titles2 &= ~(1ul << tEntry.MaskID);
titles &= ~titles2; // remove not existed titles titles &= ~titles2; // remove not existed titles
+2 -6
View File
@@ -364,7 +364,6 @@ namespace Game.Chat.Commands
string path_number = args.NextString(); string path_number = args.NextString();
uint pathid; uint pathid;
ulong guidLow;
Creature target = handler.getSelectedCreature(); Creature target = handler.getSelectedCreature();
// Did player provide a path_id? // Did player provide a path_id?
@@ -389,7 +388,7 @@ namespace Game.Chat.Commands
return true; return true;
} }
guidLow = target.GetSpawnId(); ulong guidLow = target.GetSpawnId();
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_ADDON_BY_GUID); PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_ADDON_BY_GUID);
stmt.AddValue(0, guidLow); stmt.AddValue(0, guidLow);
@@ -445,9 +444,6 @@ namespace Game.Chat.Commands
return false; return false;
} }
// Next arg is: <PATHID> <WPNUM> <ARGUMENT>
string arg_str;
// Did user provide a GUID // Did user provide a GUID
// or did the user select a creature? // or did the user select a creature?
// . variable lowguid is filled with the GUID of the NPC // . variable lowguid is filled with the GUID of the NPC
@@ -502,7 +498,7 @@ namespace Game.Chat.Commands
// We have the waypoint number and the GUID of the "master npc" // We have the waypoint number and the GUID of the "master npc"
// Text is enclosed in "<>", all other arguments not // Text is enclosed in "<>", all other arguments not
arg_str = args.NextString(); string arg_str = args.NextString();
// Check for argument // Check for argument
if (show != "del" && show != "move" && arg_str == null) if (show != "del" && show != "move" && arg_str == null)
+3 -3
View File
@@ -1679,7 +1679,7 @@ namespace Game
if (condition.MaxLevel != 0 && player.getLevel() > condition.MaxLevel) if (condition.MaxLevel != 0 && player.getLevel() > condition.MaxLevel)
return false; return false;
if (condition.RaceMask != 0 && !Convert.ToBoolean((long)player.getRaceMask() & condition.RaceMask)) if (condition.RaceMask != 0 && !Convert.ToBoolean(player.getRaceMask() & condition.RaceMask))
return false; return false;
if (condition.ClassMask != 0 && !Convert.ToBoolean(player.getClassMask() & condition.ClassMask)) if (condition.ClassMask != 0 && !Convert.ToBoolean(player.getClassMask() & condition.ClassMask))
@@ -1735,7 +1735,7 @@ namespace Game
if (lang != null) if (lang != null)
{ {
uint languageSkill = player.GetSkillValue((SkillType)lang.skill_id); uint languageSkill = player.GetSkillValue((SkillType)lang.skill_id);
if (languageSkill == 0 && player.HasAuraTypeWithMiscvalue(AuraType.ComprehendLanguage, (int)condition.LanguageID)) if (languageSkill == 0 && player.HasAuraTypeWithMiscvalue(AuraType.ComprehendLanguage, condition.LanguageID))
languageSkill = 300; languageSkill = 300;
if (condition.MinLanguage != 0 && languageSkill < condition.MinLanguage) if (condition.MinLanguage != 0 && languageSkill < condition.MinLanguage)
@@ -1784,7 +1784,7 @@ namespace Game
} }
} }
if (condition.PvpMedal != 0 && !Convert.ToBoolean((1 << (int)(condition.PvpMedal - 1)) & player.GetUInt32Value(PlayerFields.PvpMedals))) if (condition.PvpMedal != 0 && !Convert.ToBoolean((1 << (condition.PvpMedal - 1)) & player.GetUInt32Value(PlayerFields.PvpMedals)))
return false; return false;
if (condition.LifetimeMaxPVPRank != 0 && player.GetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetLifetimeMaxPvpRank) != condition.LifetimeMaxPVPRank) if (condition.LifetimeMaxPVPRank != 0 && player.GetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetLifetimeMaxPvpRank) != condition.LifetimeMaxPVPRank)
@@ -393,7 +393,6 @@ namespace Game.DataStorage
BitReader bitReader = new BitReader(recordData); BitReader bitReader = new BitReader(recordData);
bitReader.Offset = i * (int)Header.RecordSize; bitReader.Offset = i * (int)Header.RecordSize;
List<byte> data = new List<byte>();
MemoryStream stream = new MemoryStream(); MemoryStream stream = new MemoryStream();
BinaryWriter binaryWriter = new BinaryWriter(stream); BinaryWriter binaryWriter = new BinaryWriter(stream);
+4 -4
View File
@@ -61,7 +61,7 @@ namespace Game.DataStorage
CliDB.ArtifactPowerLinkStorage.Clear(); CliDB.ArtifactPowerLinkStorage.Clear();
foreach (ArtifactPowerRankRecord artifactPowerRank in CliDB.ArtifactPowerRankStorage.Values) foreach (ArtifactPowerRankRecord artifactPowerRank in CliDB.ArtifactPowerRankStorage.Values)
_artifactPowerRanks[Tuple.Create((uint)artifactPowerRank.ArtifactPowerID, artifactPowerRank.RankIndex)] = artifactPowerRank; _artifactPowerRanks[Tuple.Create(artifactPowerRank.ArtifactPowerID, artifactPowerRank.RankIndex)] = artifactPowerRank;
CliDB.ArtifactPowerRankStorage.Clear(); CliDB.ArtifactPowerRankStorage.Clear();
@@ -228,7 +228,7 @@ namespace Game.DataStorage
CliDB.ItemCurrencyCostStorage.Clear(); CliDB.ItemCurrencyCostStorage.Clear();
foreach (ItemLimitCategoryConditionRecord condition in CliDB.ItemLimitCategoryConditionStorage.Values) foreach (ItemLimitCategoryConditionRecord condition in CliDB.ItemLimitCategoryConditionStorage.Values)
_itemCategoryConditions.Add((uint)condition.ParentItemLimitCategoryID, condition); _itemCategoryConditions.Add(condition.ParentItemLimitCategoryID, condition);
foreach (ItemLevelSelectorQualityRecord itemLevelSelectorQuality in CliDB.ItemLevelSelectorQualityStorage.Values) foreach (ItemLevelSelectorQualityRecord itemLevelSelectorQuality in CliDB.ItemLevelSelectorQualityStorage.Values)
_itemLevelQualitySelectorQualities.Add(itemLevelSelectorQuality.ParentILSQualitySetID, itemLevelSelectorQuality); _itemLevelQualitySelectorQualities.Add(itemLevelSelectorQuality.ParentILSQualitySetID, itemLevelSelectorQuality);
@@ -388,7 +388,7 @@ namespace Game.DataStorage
{ {
//ASSERT(talentUnlock->TierID < MAX_PVP_TALENT_TIERS, "MAX_PVP_TALENT_TIERS must be at least %u", talentUnlock->TierID + 1); //ASSERT(talentUnlock->TierID < MAX_PVP_TALENT_TIERS, "MAX_PVP_TALENT_TIERS must be at least %u", talentUnlock->TierID + 1);
//ASSERT(talentUnlock->ColumnIndex < MAX_PVP_TALENT_COLUMNS, "MAX_PVP_TALENT_COLUMNS must be at least %u", talentUnlock->ColumnIndex + 1); //ASSERT(talentUnlock->ColumnIndex < MAX_PVP_TALENT_COLUMNS, "MAX_PVP_TALENT_COLUMNS must be at least %u", talentUnlock->ColumnIndex + 1);
_pvpTalentUnlock[talentUnlock.TierID][talentUnlock.ColumnIndex] = (uint)talentUnlock.HonorLevel; _pvpTalentUnlock[talentUnlock.TierID][talentUnlock.ColumnIndex] = talentUnlock.HonorLevel;
} }
foreach (QuestPackageItemRecord questPackageItem in CliDB.QuestPackageItemStorage.Values) foreach (QuestPackageItemRecord questPackageItem in CliDB.QuestPackageItemStorage.Values)
@@ -1000,7 +1000,7 @@ namespace Game.DataStorage
public LFGDungeonsRecord GetLfgDungeon(uint mapId, Difficulty difficulty) public LFGDungeonsRecord GetLfgDungeon(uint mapId, Difficulty difficulty)
{ {
foreach (LFGDungeonsRecord dungeon in CliDB.LFGDungeonsStorage.Values) foreach (LFGDungeonsRecord dungeon in CliDB.LFGDungeonsStorage.Values)
if (dungeon.MapID == mapId && (Difficulty)dungeon.DifficultyID == difficulty) if (dungeon.MapID == mapId && dungeon.DifficultyID == difficulty)
return dungeon; return dungeon;
return null; return null;
+2 -9
View File
@@ -71,7 +71,6 @@ namespace Game.DataStorage
targPositions[i] = new M2SplineKey(reader); targPositions[i] = new M2SplineKey(reader);
// Read the data for this set // Read the data for this set
uint currPos = targArray.offset_elements;
for (uint i = 0; i < targTsArray.number; ++i) for (uint i = 0; i < targTsArray.number; ++i)
{ {
// Translate co-ordinates // Translate co-ordinates
@@ -82,7 +81,6 @@ namespace Game.DataStorage
thisCam.timeStamp = targTimestamps[i]; thisCam.timeStamp = targTimestamps[i];
thisCam.locations = new Vector4(newPos.X, newPos.Y, newPos.Z, 0.0f); thisCam.locations = new Vector4(newPos.X, newPos.Y, newPos.Z, 0.0f);
targetcam.Add(thisCam); targetcam.Add(thisCam);
currPos += (uint)Marshal.SizeOf<M2SplineKey>();
} }
} }
@@ -105,7 +103,6 @@ namespace Game.DataStorage
positions[i] = new M2SplineKey(reader); positions[i] = new M2SplineKey(reader);
// Read the data for this set // Read the data for this set
uint currPos = posArray.offset_elements;
for (uint i = 0; i < posTsArray.number; ++i) for (uint i = 0; i < posTsArray.number; ++i)
{ {
// Translate co-ordinates // Translate co-ordinates
@@ -119,12 +116,9 @@ namespace Game.DataStorage
if (targetcam.Count > 0) if (targetcam.Count > 0)
{ {
// Find the target camera before and after this camera // Find the target camera before and after this camera
FlyByCamera lastTarget;
FlyByCamera nextTarget;
// Pre-load first item // Pre-load first item
lastTarget = targetcam[0]; FlyByCamera lastTarget = targetcam[0];
nextTarget = targetcam[0]; FlyByCamera nextTarget = targetcam[0];
for (int j = 0; j < targetcam.Count; ++j) for (int j = 0; j < targetcam.Count; ++j)
{ {
nextTarget = targetcam[j]; nextTarget = targetcam[j];
@@ -159,7 +153,6 @@ namespace Game.DataStorage
} }
cameras.Add(thisCam); cameras.Add(thisCam);
currPos += (uint)Marshal.SizeOf<M2SplineKey>();
} }
} }
+1 -2
View File
@@ -471,10 +471,9 @@ namespace Game.DungeonFinding
if (guid == itguid) if (guid == itguid)
continue; continue;
List<uint> temporal;
List<uint> dungeons = QueueDataStore[itguid].dungeons; List<uint> dungeons = QueueDataStore[itguid].dungeons;
o.AppendFormat(", {0}: ({1})", guid, Global.LFGMgr.ConcatenateDungeons(dungeons)); o.AppendFormat(", {0}: ({1})", guid, Global.LFGMgr.ConcatenateDungeons(dungeons));
temporal = proposalDungeons.Intersect(dungeons).ToList(); List<uint> temporal = proposalDungeons.Intersect(dungeons).ToList();
proposalDungeons = temporal; proposalDungeons = temporal;
} }
-4
View File
@@ -254,7 +254,6 @@ namespace Game.Misc
packet.GossipID = (int)_gossipMenu.GetMenuId(); packet.GossipID = (int)_gossipMenu.GetMenuId();
packet.TextID = (int)titleTextId; packet.TextID = (int)titleTextId;
uint count = 0;
foreach (var pair in _gossipMenu.GetMenuItems()) foreach (var pair in _gossipMenu.GetMenuItems())
{ {
ClientGossipOptions opt = new ClientGossipOptions(); ClientGossipOptions opt = new ClientGossipOptions();
@@ -267,10 +266,8 @@ namespace Game.Misc
opt.Confirm = item.BoxMessage; // accept text (related to money) pop up box, 2.0.3 opt.Confirm = item.BoxMessage; // accept text (related to money) pop up box, 2.0.3
packet.GossipOptions.Add(opt); packet.GossipOptions.Add(opt);
++count;
} }
count = 0;
for (byte i = 0; i < _questMenu.GetMenuItemCount(); ++i) for (byte i = 0; i < _questMenu.GetMenuItemCount(); ++i)
{ {
QuestMenuItem item = _questMenu.GetItem(i); QuestMenuItem item = _questMenu.GetItem(i);
@@ -297,7 +294,6 @@ namespace Game.Misc
} }
packet.GossipText.Add(text); packet.GossipText.Add(text);
++count;
} }
} }
+8 -10
View File
@@ -2731,9 +2731,8 @@ namespace Game.Entities
public void MovePosition(ref Position pos, float dist, float angle) public void MovePosition(ref Position pos, float dist, float angle)
{ {
angle += GetOrientation(); angle += GetOrientation();
float destx, desty, destz, ground, floor; float destx = pos.posX + dist * (float)Math.Cos(angle);
destx = pos.posX + dist * (float)Math.Cos(angle); float desty = pos.posY + dist * (float)Math.Sin(angle);
desty = pos.posY + dist * (float)Math.Sin(angle);
// Prevent invalid coordinates here, position is unchanged // Prevent invalid coordinates here, position is unchanged
if (!GridDefines.IsValidMapCoord(destx, desty, pos.posZ)) if (!GridDefines.IsValidMapCoord(destx, desty, pos.posZ))
@@ -2742,9 +2741,9 @@ namespace Game.Entities
return; return;
} }
ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true); float ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true);
floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true); float floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true);
destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor; float destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor;
float step = dist / 10.0f; float step = dist / 10.0f;
@@ -2802,9 +2801,8 @@ namespace Game.Entities
public void MovePositionToFirstCollision(ref Position pos, float dist, float angle) public void MovePositionToFirstCollision(ref Position pos, float dist, float angle)
{ {
angle += GetOrientation(); angle += GetOrientation();
float destx, desty, destz; float destx = pos.posX + dist * (float)Math.Cos(angle);
destx = pos.posX + dist * (float)Math.Cos(angle); float desty = pos.posY + dist * (float)Math.Sin(angle);
desty = pos.posY + dist * (float)Math.Sin(angle);
// Prevent invalid coordinates here, position is unchanged // Prevent invalid coordinates here, position is unchanged
if (!GridDefines.IsValidMapCoord(destx, desty)) if (!GridDefines.IsValidMapCoord(destx, desty))
@@ -2813,7 +2811,7 @@ namespace Game.Entities
return; return;
} }
destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ()); float destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ());
bool col = Global.VMapMgr.getObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap(), pos.posX, pos.posY), pos.posX, pos.posY, pos.posZ + 0.5f, destx, desty, destz + 0.5f, out destx, out desty, out destz, -0.5f); bool col = Global.VMapMgr.getObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap(), pos.posX, pos.posY), pos.posX, pos.posY, pos.posZ + 0.5f, destx, desty, destz + 0.5f, out destx, out desty, out destz, -0.5f);
// collision occured // collision occured
+1 -2
View File
@@ -3112,10 +3112,9 @@ namespace Game.Entities
UpdateHonorFields(); UpdateHonorFields();
SQLTransaction trans = new SQLTransaction(); SQLTransaction trans = new SQLTransaction();
PreparedStatement stmt;
var index = 0; var index = 0;
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHAR_FISHINGSTEPS); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHAR_FISHINGSTEPS);
stmt.AddValue(0, GetGUID().GetCounter()); stmt.AddValue(0, GetGUID().GetCounter());
trans.Append(stmt); trans.Append(stmt);
+2 -1
View File
@@ -178,9 +178,10 @@ namespace Game.Entities
// Rejoining the last group should not reset the sequence // Rejoining the last group should not reset the sequence
if (m_groupUpdateSequences[(int)category].GroupGuid != group.GetGUID()) if (m_groupUpdateSequences[(int)category].GroupGuid != group.GetGUID())
{ {
var groupUpdate = m_groupUpdateSequences[(int)category]; GroupUpdateCounter groupUpdate;
groupUpdate.GroupGuid = group.GetGUID(); groupUpdate.GroupGuid = group.GetGUID();
groupUpdate.UpdateSequenceNumber = 1; groupUpdate.UpdateSequenceNumber = 1;
m_groupUpdateSequences[(int) category] = groupUpdate;
} }
} }
+22 -27
View File
@@ -4578,8 +4578,6 @@ namespace Game.Entities
// prevent existence 2 corpse for player // prevent existence 2 corpse for player
SpawnCorpseBones(); SpawnCorpseBones();
uint _cfb1, _cfb2;
Corpse corpse = new Corpse(Convert.ToBoolean(m_ExtraFlags & PlayerExtraFlags.PVPDeath) ? CorpseType.ResurrectablePVP : CorpseType.ResurrectablePVE); Corpse corpse = new Corpse(Convert.ToBoolean(m_ExtraFlags & PlayerExtraFlags.PVPDeath) ? CorpseType.ResurrectablePVP : CorpseType.ResurrectablePVE);
SetPvPDeath(false); SetPvPDeath(false);
@@ -4594,8 +4592,8 @@ namespace Game.Entities
byte haircolor = GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairColorId); byte haircolor = GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairColorId);
byte facialhair = GetByteValue(PlayerFields.Bytes2, PlayerFieldOffsets.Bytes2OffsetFacialStyle); byte facialhair = GetByteValue(PlayerFields.Bytes2, PlayerFieldOffsets.Bytes2OffsetFacialStyle);
_cfb1 = (uint)((0x00) | ((int)GetRace() << 8) | (GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) << 16) | (skin << 24)); uint _cfb1 = (uint)((0x00) | ((int)GetRace() << 8) | (GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) << 16) | (skin << 24));
_cfb2 = (uint)((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)); uint _cfb2 = (uint)((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
corpse.SetUInt32Value(CorpseFields.Bytes1, _cfb1); corpse.SetUInt32Value(CorpseFields.Bytes1, _cfb1);
corpse.SetUInt32Value(CorpseFields.Bytes2, _cfb2); corpse.SetUInt32Value(CorpseFields.Bytes2, _cfb2);
@@ -6022,30 +6020,27 @@ namespace Game.Entities
} }
} }
} }
void UpdateVisibilityOf_helper<T>(List<ObjectGuid> s64, GameObject target, List<Unit> v) void UpdateVisibilityOf_helper<T>(List<ObjectGuid> s64, T target, List<Unit> v) where T : WorldObject
{ {
// @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it switch (target.GetTypeId())
// But exclude stoppable elevators from this hack - they would be teleporting from one end to another {
// if affected transports move so far horizontally that it causes them to run out of visibility range then you are out of luck case TypeId.GameObject:
// fix visibility instead of adding hacks here // @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it
if (target.IsDynTransport()) // But exclude stoppable elevators from this hack - they would be teleporting from one end to another
s64.Add(target.GetGUID()); // if affected transports move so far horizontally that it causes them to run out of visibility range then you are out of luck
} // fix visibility instead of adding hacks here
void UpdateVisibilityOf_helper(List<ObjectGuid> s64, Creature target, List<Unit> v) if (target.ToGameObject().IsDynTransport())
{ s64.Add(target.GetGUID());
s64.Add(target.GetGUID()); break;
v.Add(target); case TypeId.Unit:
} s64.Add(target.GetGUID());
v.Add(target.ToCreature());
void UpdateVisibilityOf_helper(List<ObjectGuid> s64, Player target, List<Unit> v) break;
{ case TypeId.Player:
s64.Add(target.GetGUID()); s64.Add(target.GetGUID());
v.Add(target); v.Add(target.ToPlayer());
} break;
}
void UpdateVisibilityOf_helper<T>(List<ObjectGuid> s64, T target, List<Unit> v) where T : WorldObject
{
s64.Add(target.GetGUID());
} }
public void SendInitialVisiblePackets(Unit target) public void SendInitialVisiblePackets(Unit target)
+1 -5
View File
@@ -3411,8 +3411,6 @@ namespace Game.Entities
} }
uint spellId = auraToRemove.GetId(); uint spellId = auraToRemove.GetId();
var range = m_ownedAuras.LookupByKey(spellId);
foreach (var pair in GetOwnedAuras()) foreach (var pair in GetOwnedAuras())
{ {
if (pair.Key != spellId) if (pair.Key != spellId)
@@ -3444,7 +3442,6 @@ namespace Game.Entities
} }
public void RemoveAurasDueToSpellByDispel(uint spellId, uint dispellerSpellId, ObjectGuid casterGUID, Unit dispeller, byte chargesRemoved = 1) public void RemoveAurasDueToSpellByDispel(uint spellId, uint dispellerSpellId, ObjectGuid casterGUID, Unit dispeller, byte chargesRemoved = 1)
{ {
var range = m_ownedAuras.LookupByKey(spellId);
foreach (var pair in GetOwnedAuras()) foreach (var pair in GetOwnedAuras())
{ {
if (pair.Key != spellId) if (pair.Key != spellId)
@@ -4139,8 +4136,7 @@ namespace Game.Entities
else else
bp = effect.BasePoints; bp = effect.BasePoints;
int oldBP = eff.m_baseAmount; eff.m_baseAmount = bp;
oldBP = bp;
} }
// correct cast item guid if needed // correct cast item guid if needed
+1 -1
View File
@@ -2085,7 +2085,7 @@ namespace Game
{ {
Log.outError(LogFilter.Sql, "Table `creature_questitem` has nonexistent item (ID: {0}) in creature (entry: {1}, idx: {2}), skipped", item, entry, idx); Log.outError(LogFilter.Sql, "Table `creature_questitem` has nonexistent item (ID: {0}) in creature (entry: {1}, idx: {2}), skipped", item, entry, idx);
continue; continue;
}; }
_creatureQuestItemStorage.Add(entry, item); _creatureQuestItemStorage.Add(entry, item);
+2 -4
View File
@@ -1145,7 +1145,6 @@ namespace Game.Groups
{ {
byte maxresul = 0; byte maxresul = 0;
ObjectGuid maxguid = roll.playerVote.First().Key; ObjectGuid maxguid = roll.playerVote.First().Key;
Player player;
foreach (var pair in roll.playerVote) foreach (var pair in roll.playerVote)
{ {
@@ -1161,7 +1160,7 @@ namespace Game.Groups
} }
} }
SendLootRollWon(maxguid, maxresul, RollType.Need, roll); SendLootRollWon(maxguid, maxresul, RollType.Need, roll);
player = Global.ObjAccessor.FindPlayer(maxguid); Player player = Global.ObjAccessor.FindPlayer(maxguid);
if (player && player.GetSession() != null) if (player && player.GetSession() != null)
{ {
@@ -1191,7 +1190,6 @@ namespace Game.Groups
{ {
byte maxresul = 0; byte maxresul = 0;
ObjectGuid maxguid = roll.playerVote.First().Key; ObjectGuid maxguid = roll.playerVote.First().Key;
Player player;
RollType rollVote = RollType.NotValid; RollType rollVote = RollType.NotValid;
foreach (var pair in roll.playerVote) foreach (var pair in roll.playerVote)
@@ -1209,7 +1207,7 @@ namespace Game.Groups
} }
} }
SendLootRollWon(maxguid, maxresul, rollVote, roll); SendLootRollWon(maxguid, maxresul, rollVote, roll);
player = Global.ObjAccessor.FindPlayer(maxguid); Player player = Global.ObjAccessor.FindPlayer(maxguid);
if (player && player.GetSession() != null) if (player && player.GetSession() != null)
{ {
+1 -1
View File
@@ -3456,7 +3456,7 @@ namespace Game.Guilds
public abstract class MoveItemData public abstract class MoveItemData
{ {
public MoveItemData(Guild guild, Player player, byte container, byte slotId) protected MoveItemData(Guild guild, Player player, byte container, byte slotId)
{ {
m_pGuild = guild; m_pGuild = guild;
m_pPlayer = player; m_pPlayer = player;
+2 -1
View File
@@ -69,10 +69,11 @@ namespace Game
{ {
inspectResult.GuildData.HasValue = true; inspectResult.GuildData.HasValue = true;
InspectGuildData guildData = inspectResult.GuildData.Value; InspectGuildData guildData;
guildData.GuildGUID = guild.GetGUID(); guildData.GuildGUID = guild.GetGUID();
guildData.NumGuildMembers = guild.GetMembersCount(); guildData.NumGuildMembers = guild.GetMembersCount();
guildData.AchievementPoints = (int)guild.GetAchievementMgr().GetAchievementPoints(); guildData.AchievementPoints = (int)guild.GetAchievementMgr().GetAchievementPoints();
inspectResult.GuildData.Set(guildData);
} }
inspectResult.InspecteeGUID = inspect.Target; inspectResult.InspecteeGUID = inspect.Target;
@@ -70,11 +70,6 @@ namespace Game
return; return;
} }
byte count = 0;
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
if (player.GetVoidStorageItem(i) != null)
++count;
VoidStorageContents voidStorageContents = new VoidStorageContents(); VoidStorageContents voidStorageContents = new VoidStorageContents();
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i) for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
{ {
-5
View File
@@ -126,11 +126,6 @@ namespace Game.Loots
public class LootValidatorRef : Reference<Loot, LootValidatorRef> public class LootValidatorRef : Reference<Loot, LootValidatorRef>
{ {
public LootValidatorRef()
{
}
public override void targetObjectDestroyLink() public override void targetObjectDestroyLink()
{ {
-4
View File
@@ -955,7 +955,6 @@ namespace Game.Maps
public void GameObjectRelocation(GameObject go, float x, float y, float z, float orientation, bool respawnRelocationOnFail = true) public void GameObjectRelocation(GameObject go, float x, float y, float z, float orientation, bool respawnRelocationOnFail = true)
{ {
var integrity_check = new Cell(go.GetPositionX(), go.GetPositionY());
Cell old_cell = go.GetCurrentCell(); Cell old_cell = go.GetCurrentCell();
var new_cell = new Cell(x, y); var new_cell = new Cell(x, y);
@@ -980,9 +979,6 @@ namespace Game.Maps
go.UpdateObjectVisibility(false); go.UpdateObjectVisibility(false);
RemoveGameObjectFromMoveList(go); RemoveGameObjectFromMoveList(go);
} }
old_cell = go.GetCurrentCell();
integrity_check = new Cell(go.GetPositionX(), go.GetPositionY());
} }
public void DynamicObjectRelocation(DynamicObject dynObj, float x, float y, float z, float orientation) public void DynamicObjectRelocation(DynamicObject dynObj, float x, float y, float z, float orientation)
+1 -2
View File
@@ -140,8 +140,7 @@ namespace Game.Entities
if (instance == null) if (instance == null)
return EnterState.CannotEnterUninstancedDungeon; return EnterState.CannotEnterUninstancedDungeon;
Difficulty targetDifficulty, requestedDifficulty; Difficulty targetDifficulty = player.GetDifficultyID(entry);
targetDifficulty = requestedDifficulty = player.GetDifficultyID(entry);
// Get the highest available difficulty if current setting is higher than the instance allows // Get the highest available difficulty if current setting is higher than the instance allows
MapDifficultyRecord mapDiff = Global.DB2Mgr.GetDownscaledMapDifficultyData(entry.Id, ref targetDifficulty); MapDifficultyRecord mapDiff = Global.DB2Mgr.GetDownscaledMapDifficultyData(entry.Id, ref targetDifficulty);
if (mapDiff == null) if (mapDiff == null)
@@ -92,7 +92,7 @@ namespace Game.Movement
return; return;
} }
float respX, respY, respZ, respO, destX, destY, destZ, travelDistZ; float respX, respY, respZ, respO, destZ;
creature.GetHomePosition(out respX, out respY, out respZ, out respO); creature.GetHomePosition(out respX, out respY, out respZ, out respO);
Map map = creature.GetMap(); Map map = creature.GetMap();
@@ -103,14 +103,14 @@ namespace Game.Movement
float distanceX = (float)(range * Math.Cos(angle)); float distanceX = (float)(range * Math.Cos(angle));
float distanceY = (float)(range * Math.Sin(angle)); float distanceY = (float)(range * Math.Sin(angle));
destX = respX + distanceX; float destX = respX + distanceX;
destY = respY + distanceY; float destY = respY + distanceY;
// prevent invalid coordinates generation // prevent invalid coordinates generation
GridDefines.NormalizeMapCoord(ref destX); GridDefines.NormalizeMapCoord(ref destX);
GridDefines.NormalizeMapCoord(ref destY); GridDefines.NormalizeMapCoord(ref destY);
travelDistZ = range; // sin^2+cos^2=1, so travelDistZ=range^2; no need for sqrt below float travelDistZ = range; // sin^2+cos^2=1, so travelDistZ=range^2; no need for sqrt below
if (is_air_ok) // 3D system above ground and above water (flying mode) if (is_air_ok) // 3D system above ground and above water (flying mode)
{ {
@@ -28,7 +28,7 @@ namespace Game.Movement
void stopFollowing(); void stopFollowing();
} }
public abstract class TargetedMovementGeneratorMedium<T, D> : MovementGeneratorMedium<T>, TargetedMovementGeneratorBase where T : Unit public abstract class TargetedMovementGeneratorMedium<T> : MovementGeneratorMedium<T>, TargetedMovementGeneratorBase where T : Unit
{ {
public FollowerReference reftarget { get; set; } public FollowerReference reftarget { get; set; }
public Unit target public Unit target
@@ -38,7 +38,7 @@ namespace Game.Movement
public void stopFollowing() { } public void stopFollowing() { }
public TargetedMovementGeneratorMedium(Unit _target, float _offset = 0, float _angle = 0) protected TargetedMovementGeneratorMedium(Unit _target, float _offset = 0, float _angle = 0)
{ {
reftarget = new FollowerReference(); reftarget = new FollowerReference();
reftarget.link(_target, this); reftarget.link(_target, this);
@@ -268,7 +268,7 @@ namespace Game.Movement
#endregion #endregion
} }
public class ChaseMovementGenerator<T> : TargetedMovementGeneratorMedium<T, ChaseMovementGenerator<T>> where T : Unit public class ChaseMovementGenerator<T> : TargetedMovementGeneratorMedium<T> where T : Unit
{ {
public ChaseMovementGenerator(Unit target) public ChaseMovementGenerator(Unit target)
: base(target) : base(target)
@@ -334,7 +334,7 @@ namespace Game.Movement
} }
} }
public class FollowMovementGenerator<T> : TargetedMovementGeneratorMedium<T, FollowMovementGenerator<T>> where T : Unit public class FollowMovementGenerator<T> : TargetedMovementGeneratorMedium<T> where T : Unit
{ {
public FollowMovementGenerator(Unit target) : base(target) { } public FollowMovementGenerator(Unit target) : base(target) { }
public FollowMovementGenerator(Unit target, float offset, float angle) : base(target, offset, angle) { } public FollowMovementGenerator(Unit target, float offset, float angle) : base(target, offset, angle) { }
+4 -4
View File
@@ -220,9 +220,9 @@ namespace Game.Movement
} }
float SegLengthCatmullRom(int index) float SegLengthCatmullRom(int index)
{ {
Vector3 curPos, nextPos; Vector3 nextPos;
var p = points.Skip(index - 1).ToArray(); var p = points.Skip(index - 1).ToArray();
curPos = nextPos = p[1]; Vector3 curPos = nextPos = p[1];
int i = 1; int i = 1;
double length = 0; double length = 0;
@@ -239,11 +239,11 @@ namespace Game.Movement
{ {
index *= (int)3u; index *= (int)3u;
Vector3 curPos, nextPos; Vector3 nextPos;
var p = points.Skip(index).ToArray(); var p = points.Skip(index).ToArray();
C_Evaluate(p, 0.0f, s_Bezier3Coeffs, out nextPos); C_Evaluate(p, 0.0f, s_Bezier3Coeffs, out nextPos);
curPos = nextPos; Vector3 curPos = nextPos;
int i = 1; int i = 1;
double length = 0; double length = 0;
+3 -3
View File
@@ -24,7 +24,7 @@ namespace Game.Network
{ {
public abstract class ClientPacket : IDisposable public abstract class ClientPacket : IDisposable
{ {
public ClientPacket(WorldPacket worldPacket) protected ClientPacket(WorldPacket worldPacket)
{ {
_worldPacket = worldPacket; _worldPacket = worldPacket;
} }
@@ -48,13 +48,13 @@ namespace Game.Network
public abstract class ServerPacket public abstract class ServerPacket
{ {
public ServerPacket(ServerOpcodes opcode) protected ServerPacket(ServerOpcodes opcode)
{ {
connectionType = ConnectionType.Realm; connectionType = ConnectionType.Realm;
_worldPacket = new WorldPacket(opcode); _worldPacket = new WorldPacket(opcode);
} }
public ServerPacket(ServerOpcodes opcode, ConnectionType type = ConnectionType.Realm) protected ServerPacket(ServerOpcodes opcode, ConnectionType type = ConnectionType.Realm)
{ {
connectionType = type; connectionType = type;
_worldPacket = new WorldPacket(opcode); _worldPacket = new WorldPacket(opcode);
+1 -1
View File
@@ -159,7 +159,7 @@ namespace Game.Network
public abstract class PacketFilter public abstract class PacketFilter
{ {
public PacketFilter(WorldSession pSession) protected PacketFilter(WorldSession pSession)
{ {
m_pSession = pSession; m_pSession = pSession;
} }
@@ -77,8 +77,6 @@ namespace Game.Network.Packets
public override void Read() public override void Read()
{ {
uint realmJoinTicketSize;
DosResponse = _worldPacket.ReadUInt64(); DosResponse = _worldPacket.ReadUInt64();
Build = _worldPacket.ReadUInt16(); Build = _worldPacket.ReadUInt16();
BuildType = _worldPacket.ReadInt8(); BuildType = _worldPacket.ReadInt8();
@@ -92,7 +90,7 @@ namespace Game.Network.Packets
Digest = _worldPacket.ReadBytes(24); Digest = _worldPacket.ReadBytes(24);
UseIPv6 = _worldPacket.HasBit(); UseIPv6 = _worldPacket.HasBit();
realmJoinTicketSize = _worldPacket.ReadUInt32(); uint realmJoinTicketSize = _worldPacket.ReadUInt32();
if (realmJoinTicketSize != 0) if (realmJoinTicketSize != 0)
RealmJoinTicket = _worldPacket.ReadString(realmJoinTicketSize); RealmJoinTicket = _worldPacket.ReadString(realmJoinTicketSize);
} }
+2 -3
View File
@@ -391,14 +391,13 @@ namespace Game.Network
Sha256 digestKeyHash = new Sha256(); Sha256 digestKeyHash = new Sha256();
digestKeyHash.Process(account.game.SessionKey, account.game.SessionKey.Length); digestKeyHash.Process(account.game.SessionKey, account.game.SessionKey.Length);
digestKeyHash.Finish(clientSeed, clientSeed.Length); digestKeyHash.Finish(clientSeed);
HmacSha256 hmac = new HmacSha256(digestKeyHash.Digest); HmacSha256 hmac = new HmacSha256(digestKeyHash.Digest);
hmac.Process(authSession.LocalChallenge, authSession.LocalChallenge.Count); hmac.Process(authSession.LocalChallenge, authSession.LocalChallenge.Count);
hmac.Process(_serverChallenge, 16); hmac.Process(_serverChallenge, 16);
hmac.Finish(AuthCheckSeed, 16); hmac.Finish(AuthCheckSeed, 16);
// Check that Key and account name are the same on client and server // Check that Key and account name are the same on client and server
if (!hmac.Digest.Compare(authSession.Digest)) if (!hmac.Digest.Compare(authSession.Digest))
{ {
@@ -409,7 +408,7 @@ namespace Game.Network
Sha256 keyData = new Sha256(); Sha256 keyData = new Sha256();
keyData.Finish(account.game.SessionKey, account.game.SessionKey.Length); keyData.Finish(account.game.SessionKey);
HmacSha256 sessionKeyHmac = new HmacSha256(keyData.Digest); HmacSha256 sessionKeyHmac = new HmacSha256(keyData.Digest);
sessionKeyHmac.Process(_serverChallenge, 16); sessionKeyHmac.Process(_serverChallenge, 16);
+1 -1
View File
@@ -85,7 +85,7 @@ namespace Game.Scripting
public abstract class EffectHook public abstract class EffectHook
{ {
public EffectHook(uint effIndex) protected EffectHook(uint effIndex)
{ {
// effect index must be in range <0;2>, allow use of special effindexes // effect index must be in range <0;2>, allow use of special effindexes
Contract.Assert(_effIndex == SpellConst.EffectAll || _effIndex == SpellConst.EffectFirstFound || _effIndex < SpellConst.MaxEffects); Contract.Assert(_effIndex == SpellConst.EffectAll || _effIndex == SpellConst.EffectFirstFound || _effIndex < SpellConst.MaxEffects);
+1 -1
View File
@@ -56,7 +56,7 @@ namespace Game.Services
abstract class ServiceBase abstract class ServiceBase
{ {
public ServiceBase(WorldSession session, uint serviceHash) protected ServiceBase(WorldSession session, uint serviceHash)
{ {
_session = session; _session = session;
_serviceHash = serviceHash; _serviceHash = serviceHash;
+4 -3
View File
@@ -1374,9 +1374,8 @@ namespace Game.Spells
bool searchInWorld = containerMask.HasAnyFlag(GridMapTypeMask.Creature | GridMapTypeMask.Player | GridMapTypeMask.Corpse); bool searchInWorld = containerMask.HasAnyFlag(GridMapTypeMask.Creature | GridMapTypeMask.Player | GridMapTypeMask.Corpse);
if (searchInGrid || searchInWorld) if (searchInGrid || searchInWorld)
{ {
float x, y; float x = pos.GetPositionX();
x = pos.GetPositionX(); float y = pos.GetPositionY();
y = pos.GetPositionY();
CellCoord p = GridDefines.ComputeCellCoord(x, y); CellCoord p = GridDefines.ComputeCellCoord(x, y);
Cell cell = new Cell(p); Cell cell = new Cell(p);
@@ -1768,6 +1767,8 @@ namespace Game.Spells
if (effect != null && (effectMask & (1 << (int)effect.EffectIndex)) != 0 && CheckEffectTarget(item, effect)) if (effect != null && (effectMask & (1 << (int)effect.EffectIndex)) != 0 && CheckEffectTarget(item, effect))
validEffectMask |= 1u << (int)effect.EffectIndex; validEffectMask |= 1u << (int)effect.EffectIndex;
effectMask &= validEffectMask;
// no effects left // no effects left
if (effectMask == 0) if (effectMask == 0)
return; return;
-4
View File
@@ -1908,7 +1908,6 @@ namespace Game.Spells
int remaining = dispelList.Count; int remaining = dispelList.Count;
// Ok if exist some buffs for dispel try dispel it // Ok if exist some buffs for dispel try dispel it
uint failCount = 0;
List<DispelableAura> successList = new List<DispelableAura>(); List<DispelableAura> successList = new List<DispelableAura>();
DispelFailed dispelFailed = new DispelFailed(); DispelFailed dispelFailed = new DispelFailed();
@@ -1945,7 +1944,6 @@ namespace Game.Spells
} }
else else
{ {
++failCount;
dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId()); dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId());
} }
++count; ++count;
@@ -4747,7 +4745,6 @@ namespace Game.Spells
int remaining = stealList.Count; int remaining = stealList.Count;
// Ok if exist some buffs for dispel try dispel it // Ok if exist some buffs for dispel try dispel it
uint failCount = 0;
List<Tuple<uint, ObjectGuid>> successList = new List<Tuple<uint, ObjectGuid>>(); List<Tuple<uint, ObjectGuid>> successList = new List<Tuple<uint, ObjectGuid>>();
DispelFailed dispelFailed = new DispelFailed(); DispelFailed dispelFailed = new DispelFailed();
@@ -4772,7 +4769,6 @@ namespace Game.Spells
} }
else else
{ {
++failCount;
dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId()); dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId());
} }
++count; ++count;
+1 -1
View File
@@ -27,7 +27,7 @@ namespace Game
{ {
public abstract class Warden public abstract class Warden
{ {
public Warden() protected Warden()
{ {
_inputCrypto = new SARC4(); _inputCrypto = new SARC4();
_outputCrypto = new SARC4(); _outputCrypto = new SARC4();
@@ -229,7 +229,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion
abstract class boss_basic_toc5AI : ScriptedAI abstract class boss_basic_toc5AI : ScriptedAI
{ {
public boss_basic_toc5AI(Creature creature) : base(creature) protected boss_basic_toc5AI(Creature creature) : base(creature)
{ {
Initialize(); Initialize();
instance = creature.GetInstanceScript(); instance = creature.GetInstanceScript();
@@ -615,7 +615,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader
return CreatureIds.Fizzlebang; return CreatureIds.Fizzlebang;
default: default:
return CreatureIds.Tirion; return CreatureIds.Tirion;
}; }
default: default:
break; break;
} }