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
{
public ServiceBase(Session session, uint serviceHash)
protected ServiceBase(Session session, uint serviceHash)
{
_session = session;
_serviceHash = serviceHash;
+1 -1
View File
@@ -359,7 +359,7 @@ namespace System.Collections
internal BitArrayEnumeratorSimple(BitSet bitarray)
{
this._bitarray = bitarray;
_bitarray = bitarray;
_index = -1;
_version = bitarray._version;
}
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Framework.Cryptography
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);
+3 -3
View File
@@ -318,7 +318,7 @@ namespace Framework.Database
_database.Execute(update);
}
public List<FileEntry> GetFileList()
List<FileEntry> GetFileList()
{
List<FileEntry> fileList = new List<FileEntry>();
@@ -348,7 +348,7 @@ namespace Framework.Database
return fileList;
}
public Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles()
Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles()
{
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
+1 -1
View File
@@ -22,7 +22,7 @@ namespace Framework.Database
{
public class SQLTransaction
{
public List<MySqlCommand> commands { get; set; }
public List<MySqlCommand> commands { get; }
public SQLTransaction()
{
+2 -2
View File
@@ -602,7 +602,7 @@ namespace Framework.Dynamic
/// <returns></returns>
public TaskContext CancelGroup(uint group)
{
return Dispatch(() => CancelGroup(group));
return Dispatch(() => _owner.CancelGroup(group));
}
/// <summary>
@@ -612,7 +612,7 @@ namespace Framework.Dynamic
/// <returns></returns>
public TaskContext CancelGroupsOf(List<uint> groups)
{
return Dispatch(() => CancelGroupsOf(groups));
return Dispatch(() => _owner.CancelGroupsOf(groups));
}
/// <summary>
+1 -2
View File
@@ -441,12 +441,11 @@ namespace Framework.IO
public byte[] GetData()
{
long pos;
Stream stream = GetCurrentStream();
var data = new byte[stream.Length];
pos = stream.Position;
long pos = stream.Position;
stream.Seek(0, SeekOrigin.Begin);
for (int i = 0; i < data.Length; i++)
data[i] = (byte)stream.ReadByte();
+2 -5
View File
@@ -1002,8 +1002,6 @@ namespace Framework.IO
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;
deflate_state s=(deflate_state)strm.state;
@@ -1020,7 +1018,7 @@ namespace Framework.IO
}
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;
// Write the header
@@ -1572,7 +1570,6 @@ namespace Framework.IO
{
byte[] scan = s.window;
int scan_ind = (int) s.strstart; // current string
int len; // length of current match
int strend_ind = (int) s.strstart + MAX_MATCH;
// The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
@@ -1610,7 +1607,7 @@ namespace Framework.IO
//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;
+1 -1
View File
@@ -164,7 +164,7 @@ class DBAppender : 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;
_name = name;
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Framework.Networking
{
public abstract class SSLSocket : ISocket
{
public SSLSocket(Socket socket)
protected SSLSocket(Socket socket)
{
_socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Framework.Networking
{
public abstract class SocketBase : ISocket, IDisposable
{
public SocketBase(Socket socket)
protected SocketBase(Socket socket)
{
_socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
@@ -1186,7 +1186,7 @@ public static partial class Detour
case 5: nx--; ny--; break;
case 6: ny--; break;
case 7: nx++; ny--; break;
};
}
return getTilesAt(nx, ny, tiles, maxTiles);
}
@@ -1001,7 +1001,7 @@ public static partial class Detour
case XM | ZM: return 5;
case ZM: return 6;
case XP | ZM: return 7;
};
}
return 0xff;
}
-2
View File
@@ -23,8 +23,6 @@ public class Singleton<T> where T : class
private static volatile T instance;
private static object syncRoot = new Object();
public Singleton() { }
public static T Instance
{
get
@@ -80,7 +80,7 @@ namespace Framework.Threading
{
while (_queue.Count != 0)
{
T value = _queue.Dequeue();
_queue.Dequeue();
}
_shutdown = true;
@@ -232,10 +232,9 @@ namespace Game.AI
{
uint entry = result.Read<uint>(0);
uint id = result.Read<uint>(1);
float x, y, z;
x = result.Read<float>(2);
y = result.Read<float>(3);
z = result.Read<float>(4);
float x = result.Read<float>(2);
float y = result.Read<float>(3);
float z = result.Read<float>(4);
if (last_entry != entry)
{
+4 -5
View File
@@ -1194,11 +1194,10 @@ namespace Game.AI
Position pos = obj.GetPosition();
// Use forward/backward/left/right cartesian plane movement
float x, y, z, o;
o = pos.GetOrientation();
x = (float)(pos.GetPositionX() + (Math.Cos(o - (Math.PI / 2)) * e.Target.x) + (Math.Cos(o) * e.Target.y));
y = (float)(pos.GetPositionY() + (Math.Sin(o - (Math.PI / 2)) * e.Target.x) + (Math.Sin(o) * e.Target.y));
z = pos.GetPositionZ() + e.Target.z;
float o = pos.GetOrientation();
float 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));
float z = pos.GetPositionZ() + e.Target.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.SeasonWins = 0;
newMember.WeekWins = 0;
newMember.PersonalRating = (ushort)(uint)0;
newMember.PersonalRating = 0;
newMember.MatchMakerRating = (ushort)matchMakerRating;
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
// 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)
@@ -459,7 +459,7 @@ namespace Game.BattleGrounds.Zones
{
UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1);
m_prevNodes[node] = m_Nodes[node];
m_Nodes[node] = (ABNodeStatus.Contested + (int)teamIndex);
m_Nodes[node] = (ABNodeStatus.Contested + teamIndex);
// burn current contested banner
_DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex);
// create new contested banner
@@ -477,7 +477,7 @@ namespace Game.BattleGrounds.Zones
{
UpdatePlayerScore(source, ScoreType.BasesDefended, 1);
m_prevNodes[node] = m_Nodes[node];
m_Nodes[node] = (ABNodeStatus.Occupied + (int)teamIndex);
m_Nodes[node] = (ABNodeStatus.Occupied + teamIndex);
// burn current contested banner
_DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex);
// create new occupied banner
@@ -498,7 +498,7 @@ namespace Game.BattleGrounds.Zones
{
UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1);
m_prevNodes[node] = m_Nodes[node];
m_Nodes[node] = (ABNodeStatus.Contested + (int)teamIndex);
m_Nodes[node] = (ABNodeStatus.Contested + teamIndex);
// burn current occupied banner
_DelBanner(node, ABNodeStatus.Occupied, (byte)teamIndex);
// create new contested banner
@@ -639,7 +639,7 @@ namespace Game.BattleGrounds.Zones
// Is there any occupied node for this team?
List<byte> nodes = new List<byte>();
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);
WorldSafeLocsRecord good_entry = null;
@@ -125,7 +125,7 @@ namespace Game.BattleGrounds.Zones
SpawnBGObject(EotSObjectTypes.DoorA, 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);
}
@@ -884,8 +884,6 @@ namespace Game.BattleGrounds.Zones
default: return null;
}
float distance, nearestDistance;
WorldSafeLocsRecord entry = null;
WorldSafeLocsRecord nearestEntry = null;
entry = CliDB.WorldSafeLocsStorage.LookupByKey(g_id);
@@ -901,8 +899,8 @@ namespace Game.BattleGrounds.Zones
float plr_y = player.GetPositionY();
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);
nearestDistance = distance;
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);
float nearestDistance = distance;
for (byte i = 0; i < EotSPoints.PointsMax; ++i)
{
@@ -603,9 +603,9 @@ namespace Game.BattleGrounds.Zones
void UpdateTeamScore(int team)
{
if (team == TeamId.Alliance)
UpdateWorldState(WSGWorldStates.FlagCapturesAlliance, (uint)GetTeamScore(team));
UpdateWorldState(WSGWorldStates.FlagCapturesAlliance, GetTeamScore(team));
else
UpdateWorldState(WSGWorldStates.FlagCapturesHorde, (uint)GetTeamScore(team));
UpdateWorldState(WSGWorldStates.FlagCapturesHorde, GetTeamScore(team));
}
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; }
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;
}
@@ -379,7 +379,6 @@ namespace Game.Chat
uint entry = 0;
GameObjectTypes type = 0;
uint displayId = 0;
string name;
uint lootId = 0;
if (args.Empty())
@@ -415,7 +414,7 @@ namespace Game.Chat
type = gameObjectInfo.type;
displayId = gameObjectInfo.displayId;
name = gameObjectInfo.name;
string name = gameObjectInfo.name;
lootId = gameObjectInfo.GetLootId();
handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
+1 -3
View File
@@ -171,14 +171,12 @@ namespace Game.Chat.Commands
if (count == 0)
return false;
SQLResult result;
// inventory case
uint inventoryCount = 0;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_INVENTORY_COUNT_ITEM);
stmt.AddValue(0, itemId);
result = DB.Characters.Query(stmt);
SQLResult result = DB.Characters.Query(stmt);
if (!result.IsEmpty())
inventoryCount = result.Read<uint>(0);
+1 -2
View File
@@ -228,7 +228,6 @@ namespace Game.Chat.Commands
uint accountId = 0;
string accountName;
uint id = 0;
RBACCommandData data;
RBACData rdata = null;
bool useSelectedPlayer = false;
@@ -293,7 +292,7 @@ namespace Game.Chat.Commands
if (checkParams && handler.HasLowerSecurityAccount(null, accountId, true))
return null;
data = new RBACCommandData();
RBACCommandData data = new RBACCommandData();
if (rdata == null)
{
+1 -1
View File
@@ -185,7 +185,7 @@ namespace Game.Chat.Commands
ulong titles2 = titles;
foreach (CharTitlesRecord tEntry in CliDB.CharTitlesStorage.Values)
titles2 &= ~(1ul << (int)tEntry.MaskID);
titles2 &= ~(1ul << tEntry.MaskID);
titles &= ~titles2; // remove not existed titles
+2 -6
View File
@@ -364,7 +364,6 @@ namespace Game.Chat.Commands
string path_number = args.NextString();
uint pathid;
ulong guidLow;
Creature target = handler.getSelectedCreature();
// Did player provide a path_id?
@@ -389,7 +388,7 @@ namespace Game.Chat.Commands
return true;
}
guidLow = target.GetSpawnId();
ulong guidLow = target.GetSpawnId();
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_ADDON_BY_GUID);
stmt.AddValue(0, guidLow);
@@ -445,9 +444,6 @@ namespace Game.Chat.Commands
return false;
}
// Next arg is: <PATHID> <WPNUM> <ARGUMENT>
string arg_str;
// Did user provide a GUID
// or did the user select a creature?
// . 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"
// Text is enclosed in "<>", all other arguments not
arg_str = args.NextString();
string arg_str = args.NextString();
// Check for argument
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)
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;
if (condition.ClassMask != 0 && !Convert.ToBoolean(player.getClassMask() & condition.ClassMask))
@@ -1735,7 +1735,7 @@ namespace Game
if (lang != null)
{
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;
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;
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.Offset = i * (int)Header.RecordSize;
List<byte> data = new List<byte>();
MemoryStream stream = new MemoryStream();
BinaryWriter binaryWriter = new BinaryWriter(stream);
+4 -4
View File
@@ -61,7 +61,7 @@ namespace Game.DataStorage
CliDB.ArtifactPowerLinkStorage.Clear();
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();
@@ -228,7 +228,7 @@ namespace Game.DataStorage
CliDB.ItemCurrencyCostStorage.Clear();
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)
_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->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)
@@ -1000,7 +1000,7 @@ namespace Game.DataStorage
public LFGDungeonsRecord GetLfgDungeon(uint mapId, Difficulty difficulty)
{
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 null;
+2 -9
View File
@@ -71,7 +71,6 @@ namespace Game.DataStorage
targPositions[i] = new M2SplineKey(reader);
// Read the data for this set
uint currPos = targArray.offset_elements;
for (uint i = 0; i < targTsArray.number; ++i)
{
// Translate co-ordinates
@@ -82,7 +81,6 @@ namespace Game.DataStorage
thisCam.timeStamp = targTimestamps[i];
thisCam.locations = new Vector4(newPos.X, newPos.Y, newPos.Z, 0.0f);
targetcam.Add(thisCam);
currPos += (uint)Marshal.SizeOf<M2SplineKey>();
}
}
@@ -105,7 +103,6 @@ namespace Game.DataStorage
positions[i] = new M2SplineKey(reader);
// Read the data for this set
uint currPos = posArray.offset_elements;
for (uint i = 0; i < posTsArray.number; ++i)
{
// Translate co-ordinates
@@ -119,12 +116,9 @@ namespace Game.DataStorage
if (targetcam.Count > 0)
{
// Find the target camera before and after this camera
FlyByCamera lastTarget;
FlyByCamera nextTarget;
// Pre-load first item
lastTarget = targetcam[0];
nextTarget = targetcam[0];
FlyByCamera lastTarget = targetcam[0];
FlyByCamera nextTarget = targetcam[0];
for (int j = 0; j < targetcam.Count; ++j)
{
nextTarget = targetcam[j];
@@ -159,7 +153,6 @@ namespace Game.DataStorage
}
cameras.Add(thisCam);
currPos += (uint)Marshal.SizeOf<M2SplineKey>();
}
}
+1 -2
View File
@@ -471,10 +471,9 @@ namespace Game.DungeonFinding
if (guid == itguid)
continue;
List<uint> temporal;
List<uint> dungeons = QueueDataStore[itguid].dungeons;
o.AppendFormat(", {0}: ({1})", guid, Global.LFGMgr.ConcatenateDungeons(dungeons));
temporal = proposalDungeons.Intersect(dungeons).ToList();
List<uint> temporal = proposalDungeons.Intersect(dungeons).ToList();
proposalDungeons = temporal;
}
-4
View File
@@ -254,7 +254,6 @@ namespace Game.Misc
packet.GossipID = (int)_gossipMenu.GetMenuId();
packet.TextID = (int)titleTextId;
uint count = 0;
foreach (var pair in _gossipMenu.GetMenuItems())
{
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
packet.GossipOptions.Add(opt);
++count;
}
count = 0;
for (byte i = 0; i < _questMenu.GetMenuItemCount(); ++i)
{
QuestMenuItem item = _questMenu.GetItem(i);
@@ -297,7 +294,6 @@ namespace Game.Misc
}
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)
{
angle += GetOrientation();
float destx, desty, destz, ground, floor;
destx = pos.posX + dist * (float)Math.Cos(angle);
desty = pos.posY + dist * (float)Math.Sin(angle);
float destx = pos.posX + dist * (float)Math.Cos(angle);
float desty = pos.posY + dist * (float)Math.Sin(angle);
// Prevent invalid coordinates here, position is unchanged
if (!GridDefines.IsValidMapCoord(destx, desty, pos.posZ))
@@ -2742,9 +2741,9 @@ namespace Game.Entities
return;
}
ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true);
floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true);
destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor;
float ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true);
float floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true);
float destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor;
float step = dist / 10.0f;
@@ -2802,9 +2801,8 @@ namespace Game.Entities
public void MovePositionToFirstCollision(ref Position pos, float dist, float angle)
{
angle += GetOrientation();
float destx, desty, destz;
destx = pos.posX + dist * (float)Math.Cos(angle);
desty = pos.posY + dist * (float)Math.Sin(angle);
float destx = pos.posX + dist * (float)Math.Cos(angle);
float desty = pos.posY + dist * (float)Math.Sin(angle);
// Prevent invalid coordinates here, position is unchanged
if (!GridDefines.IsValidMapCoord(destx, desty))
@@ -2813,7 +2811,7 @@ namespace Game.Entities
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);
// collision occured
+1 -2
View File
@@ -3112,10 +3112,9 @@ namespace Game.Entities
UpdateHonorFields();
SQLTransaction trans = new SQLTransaction();
PreparedStatement stmt;
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());
trans.Append(stmt);
+2 -1
View File
@@ -178,9 +178,10 @@ namespace Game.Entities
// Rejoining the last group should not reset the sequence
if (m_groupUpdateSequences[(int)category].GroupGuid != group.GetGUID())
{
var groupUpdate = m_groupUpdateSequences[(int)category];
GroupUpdateCounter groupUpdate;
groupUpdate.GroupGuid = group.GetGUID();
groupUpdate.UpdateSequenceNumber = 1;
m_groupUpdateSequences[(int) category] = groupUpdate;
}
}
+16 -21
View File
@@ -4578,8 +4578,6 @@ namespace Game.Entities
// prevent existence 2 corpse for player
SpawnCorpseBones();
uint _cfb1, _cfb2;
Corpse corpse = new Corpse(Convert.ToBoolean(m_ExtraFlags & PlayerExtraFlags.PVPDeath) ? CorpseType.ResurrectablePVP : CorpseType.ResurrectablePVE);
SetPvPDeath(false);
@@ -4594,8 +4592,8 @@ namespace Game.Entities
byte haircolor = GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairColorId);
byte facialhair = GetByteValue(PlayerFields.Bytes2, PlayerFieldOffsets.Bytes2OffsetFacialStyle);
_cfb1 = (uint)((0x00) | ((int)GetRace() << 8) | (GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) << 16) | (skin << 24));
_cfb2 = (uint)((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
uint _cfb1 = (uint)((0x00) | ((int)GetRace() << 8) | (GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) << 16) | (skin << 24));
uint _cfb2 = (uint)((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
corpse.SetUInt32Value(CorpseFields.Bytes1, _cfb1);
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
{
switch (target.GetTypeId())
{
case TypeId.GameObject:
// @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it
// 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
// fix visibility instead of adding hacks here
if (target.IsDynTransport())
if (target.ToGameObject().IsDynTransport())
s64.Add(target.GetGUID());
break;
case TypeId.Unit:
s64.Add(target.GetGUID());
v.Add(target.ToCreature());
break;
case TypeId.Player:
s64.Add(target.GetGUID());
v.Add(target.ToPlayer());
break;
}
void UpdateVisibilityOf_helper(List<ObjectGuid> s64, Creature target, List<Unit> v)
{
s64.Add(target.GetGUID());
v.Add(target);
}
void UpdateVisibilityOf_helper(List<ObjectGuid> s64, Player target, List<Unit> v)
{
s64.Add(target.GetGUID());
v.Add(target);
}
void UpdateVisibilityOf_helper<T>(List<ObjectGuid> s64, T target, List<Unit> v) where T : WorldObject
{
s64.Add(target.GetGUID());
}
public void SendInitialVisiblePackets(Unit target)
+1 -5
View File
@@ -3411,8 +3411,6 @@ namespace Game.Entities
}
uint spellId = auraToRemove.GetId();
var range = m_ownedAuras.LookupByKey(spellId);
foreach (var pair in GetOwnedAuras())
{
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)
{
var range = m_ownedAuras.LookupByKey(spellId);
foreach (var pair in GetOwnedAuras())
{
if (pair.Key != spellId)
@@ -4139,8 +4136,7 @@ namespace Game.Entities
else
bp = effect.BasePoints;
int oldBP = eff.m_baseAmount;
oldBP = bp;
eff.m_baseAmount = bp;
}
// 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);
continue;
};
}
_creatureQuestItemStorage.Add(entry, item);
+2 -4
View File
@@ -1145,7 +1145,6 @@ namespace Game.Groups
{
byte maxresul = 0;
ObjectGuid maxguid = roll.playerVote.First().Key;
Player player;
foreach (var pair in roll.playerVote)
{
@@ -1161,7 +1160,7 @@ namespace Game.Groups
}
}
SendLootRollWon(maxguid, maxresul, RollType.Need, roll);
player = Global.ObjAccessor.FindPlayer(maxguid);
Player player = Global.ObjAccessor.FindPlayer(maxguid);
if (player && player.GetSession() != null)
{
@@ -1191,7 +1190,6 @@ namespace Game.Groups
{
byte maxresul = 0;
ObjectGuid maxguid = roll.playerVote.First().Key;
Player player;
RollType rollVote = RollType.NotValid;
foreach (var pair in roll.playerVote)
@@ -1209,7 +1207,7 @@ namespace Game.Groups
}
}
SendLootRollWon(maxguid, maxresul, rollVote, roll);
player = Global.ObjAccessor.FindPlayer(maxguid);
Player player = Global.ObjAccessor.FindPlayer(maxguid);
if (player && player.GetSession() != null)
{
+1 -1
View File
@@ -3456,7 +3456,7 @@ namespace Game.Guilds
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_pPlayer = player;
+2 -1
View File
@@ -69,10 +69,11 @@ namespace Game
{
inspectResult.GuildData.HasValue = true;
InspectGuildData guildData = inspectResult.GuildData.Value;
InspectGuildData guildData;
guildData.GuildGUID = guild.GetGUID();
guildData.NumGuildMembers = guild.GetMembersCount();
guildData.AchievementPoints = (int)guild.GetAchievementMgr().GetAchievementPoints();
inspectResult.GuildData.Set(guildData);
}
inspectResult.InspecteeGUID = inspect.Target;
@@ -70,11 +70,6 @@ namespace Game
return;
}
byte count = 0;
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
if (player.GetVoidStorageItem(i) != null)
++count;
VoidStorageContents voidStorageContents = new VoidStorageContents();
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 LootValidatorRef()
{
}
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)
{
var integrity_check = new Cell(go.GetPositionX(), go.GetPositionY());
Cell old_cell = go.GetCurrentCell();
var new_cell = new Cell(x, y);
@@ -980,9 +979,6 @@ namespace Game.Maps
go.UpdateObjectVisibility(false);
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)
+1 -2
View File
@@ -140,8 +140,7 @@ namespace Game.Entities
if (instance == null)
return EnterState.CannotEnterUninstancedDungeon;
Difficulty targetDifficulty, requestedDifficulty;
targetDifficulty = requestedDifficulty = player.GetDifficultyID(entry);
Difficulty targetDifficulty = player.GetDifficultyID(entry);
// Get the highest available difficulty if current setting is higher than the instance allows
MapDifficultyRecord mapDiff = Global.DB2Mgr.GetDownscaledMapDifficultyData(entry.Id, ref targetDifficulty);
if (mapDiff == null)
@@ -92,7 +92,7 @@ namespace Game.Movement
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);
Map map = creature.GetMap();
@@ -103,14 +103,14 @@ namespace Game.Movement
float distanceX = (float)(range * Math.Cos(angle));
float distanceY = (float)(range * Math.Sin(angle));
destX = respX + distanceX;
destY = respY + distanceY;
float destX = respX + distanceX;
float destY = respY + distanceY;
// prevent invalid coordinates generation
GridDefines.NormalizeMapCoord(ref destX);
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)
{
@@ -28,7 +28,7 @@ namespace Game.Movement
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 Unit target
@@ -38,7 +38,7 @@ namespace Game.Movement
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.link(_target, this);
@@ -268,7 +268,7 @@ namespace Game.Movement
#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)
: 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, float offset, float angle) : base(target, offset, angle) { }
+4 -4
View File
@@ -220,9 +220,9 @@ namespace Game.Movement
}
float SegLengthCatmullRom(int index)
{
Vector3 curPos, nextPos;
Vector3 nextPos;
var p = points.Skip(index - 1).ToArray();
curPos = nextPos = p[1];
Vector3 curPos = nextPos = p[1];
int i = 1;
double length = 0;
@@ -239,11 +239,11 @@ namespace Game.Movement
{
index *= (int)3u;
Vector3 curPos, nextPos;
Vector3 nextPos;
var p = points.Skip(index).ToArray();
C_Evaluate(p, 0.0f, s_Bezier3Coeffs, out nextPos);
curPos = nextPos;
Vector3 curPos = nextPos;
int i = 1;
double length = 0;
+3 -3
View File
@@ -24,7 +24,7 @@ namespace Game.Network
{
public abstract class ClientPacket : IDisposable
{
public ClientPacket(WorldPacket worldPacket)
protected ClientPacket(WorldPacket worldPacket)
{
_worldPacket = worldPacket;
}
@@ -48,13 +48,13 @@ namespace Game.Network
public abstract class ServerPacket
{
public ServerPacket(ServerOpcodes opcode)
protected ServerPacket(ServerOpcodes opcode)
{
connectionType = ConnectionType.Realm;
_worldPacket = new WorldPacket(opcode);
}
public ServerPacket(ServerOpcodes opcode, ConnectionType type = ConnectionType.Realm)
protected ServerPacket(ServerOpcodes opcode, ConnectionType type = ConnectionType.Realm)
{
connectionType = type;
_worldPacket = new WorldPacket(opcode);
+1 -1
View File
@@ -159,7 +159,7 @@ namespace Game.Network
public abstract class PacketFilter
{
public PacketFilter(WorldSession pSession)
protected PacketFilter(WorldSession pSession)
{
m_pSession = pSession;
}
@@ -77,8 +77,6 @@ namespace Game.Network.Packets
public override void Read()
{
uint realmJoinTicketSize;
DosResponse = _worldPacket.ReadUInt64();
Build = _worldPacket.ReadUInt16();
BuildType = _worldPacket.ReadInt8();
@@ -92,7 +90,7 @@ namespace Game.Network.Packets
Digest = _worldPacket.ReadBytes(24);
UseIPv6 = _worldPacket.HasBit();
realmJoinTicketSize = _worldPacket.ReadUInt32();
uint realmJoinTicketSize = _worldPacket.ReadUInt32();
if (realmJoinTicketSize != 0)
RealmJoinTicket = _worldPacket.ReadString(realmJoinTicketSize);
}
+2 -3
View File
@@ -391,14 +391,13 @@ namespace Game.Network
Sha256 digestKeyHash = new Sha256();
digestKeyHash.Process(account.game.SessionKey, account.game.SessionKey.Length);
digestKeyHash.Finish(clientSeed, clientSeed.Length);
digestKeyHash.Finish(clientSeed);
HmacSha256 hmac = new HmacSha256(digestKeyHash.Digest);
hmac.Process(authSession.LocalChallenge, authSession.LocalChallenge.Count);
hmac.Process(_serverChallenge, 16);
hmac.Finish(AuthCheckSeed, 16);
// Check that Key and account name are the same on client and server
if (!hmac.Digest.Compare(authSession.Digest))
{
@@ -409,7 +408,7 @@ namespace Game.Network
Sha256 keyData = new Sha256();
keyData.Finish(account.game.SessionKey, account.game.SessionKey.Length);
keyData.Finish(account.game.SessionKey);
HmacSha256 sessionKeyHmac = new HmacSha256(keyData.Digest);
sessionKeyHmac.Process(_serverChallenge, 16);
+1 -1
View File
@@ -85,7 +85,7 @@ namespace Game.Scripting
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
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
{
public ServiceBase(WorldSession session, uint serviceHash)
protected ServiceBase(WorldSession session, uint serviceHash)
{
_session = session;
_serviceHash = serviceHash;
+4 -3
View File
@@ -1374,9 +1374,8 @@ namespace Game.Spells
bool searchInWorld = containerMask.HasAnyFlag(GridMapTypeMask.Creature | GridMapTypeMask.Player | GridMapTypeMask.Corpse);
if (searchInGrid || searchInWorld)
{
float x, y;
x = pos.GetPositionX();
y = pos.GetPositionY();
float x = pos.GetPositionX();
float y = pos.GetPositionY();
CellCoord p = GridDefines.ComputeCellCoord(x, y);
Cell cell = new Cell(p);
@@ -1768,6 +1767,8 @@ namespace Game.Spells
if (effect != null && (effectMask & (1 << (int)effect.EffectIndex)) != 0 && CheckEffectTarget(item, effect))
validEffectMask |= 1u << (int)effect.EffectIndex;
effectMask &= validEffectMask;
// no effects left
if (effectMask == 0)
return;
-4
View File
@@ -1908,7 +1908,6 @@ namespace Game.Spells
int remaining = dispelList.Count;
// Ok if exist some buffs for dispel try dispel it
uint failCount = 0;
List<DispelableAura> successList = new List<DispelableAura>();
DispelFailed dispelFailed = new DispelFailed();
@@ -1945,7 +1944,6 @@ namespace Game.Spells
}
else
{
++failCount;
dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId());
}
++count;
@@ -4747,7 +4745,6 @@ namespace Game.Spells
int remaining = stealList.Count;
// Ok if exist some buffs for dispel try dispel it
uint failCount = 0;
List<Tuple<uint, ObjectGuid>> successList = new List<Tuple<uint, ObjectGuid>>();
DispelFailed dispelFailed = new DispelFailed();
@@ -4772,7 +4769,6 @@ namespace Game.Spells
}
else
{
++failCount;
dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId());
}
++count;
+1 -1
View File
@@ -27,7 +27,7 @@ namespace Game
{
public abstract class Warden
{
public Warden()
protected Warden()
{
_inputCrypto = new SARC4();
_outputCrypto = new SARC4();
@@ -229,7 +229,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion
abstract class boss_basic_toc5AI : ScriptedAI
{
public boss_basic_toc5AI(Creature creature) : base(creature)
protected boss_basic_toc5AI(Creature creature) : base(creature)
{
Initialize();
instance = creature.GetInstanceScript();
@@ -615,7 +615,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader
return CreatureIds.Fizzlebang;
default:
return CreatureIds.Tirion;
};
}
default:
break;
}