More Cleanups
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BNetServer;
|
||||
|
||||
public static class Global
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Framework.Networking;
|
||||
using System.Net.Sockets;
|
||||
using Framework.Web;
|
||||
using Framework.Configuration;
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.Configuration;
|
||||
using Framework.Networking;
|
||||
using Framework.Serialization;
|
||||
using Framework.Web;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
@@ -53,7 +52,7 @@ namespace BNetServer.Networking
|
||||
public void HandleLoginRequest(HttpHeader request)
|
||||
{
|
||||
LogonData loginForm = Json.CreateObject<LogonData>(request.Content);
|
||||
LogonResult loginResult = new LogonResult();
|
||||
LogonResult loginResult = new();
|
||||
if (loginForm == null)
|
||||
{
|
||||
loginResult.AuthenticationState = "LOGIN";
|
||||
@@ -96,7 +95,7 @@ namespace BNetServer.Networking
|
||||
{
|
||||
if (loginTicket.IsEmpty() || loginTicketExpiry < Time.UnixTime)
|
||||
{
|
||||
byte[] ticket = new byte[0].GenerateRandomKey(20);
|
||||
byte[] ticket = Array.Empty<byte>().GenerateRandomKey(20);
|
||||
loginTicket = "TC-" + ticket.ToHexString();
|
||||
}
|
||||
|
||||
@@ -117,7 +116,7 @@ namespace BNetServer.Networking
|
||||
|
||||
if (maxWrongPassword != 0)
|
||||
{
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
SQLTransaction trans = new();
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetFailedLogins);
|
||||
stmt.AddValue(0, accountId);
|
||||
trans.Append(stmt);
|
||||
|
||||
@@ -6,10 +6,9 @@ using Bgs.Protocol.Authentication.V1;
|
||||
using Bgs.Protocol.Challenge.V1;
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.Realm;
|
||||
using Google.Protobuf;
|
||||
using System;
|
||||
using Framework.Realm;
|
||||
using System.Net;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
@@ -42,7 +41,7 @@ namespace BNetServer.Networking
|
||||
|
||||
var endpoint = Global.LoginServiceMgr.GetAddressForClient(GetRemoteIpEndPoint().Address);
|
||||
|
||||
ChallengeExternalRequest externalChallenge = new ChallengeExternalRequest();
|
||||
ChallengeExternalRequest externalChallenge = new();
|
||||
externalChallenge.PayloadType = "web_auth_url";
|
||||
externalChallenge.Payload = ByteString.CopyFromUtf8($"https://{endpoint.Address}:{endpoint.Port}/bnetserver/login/");
|
||||
|
||||
@@ -92,7 +91,7 @@ namespace BNetServer.Networking
|
||||
{
|
||||
var realmId = new RealmId(lastPlayerCharactersResult.Read<byte>(1), lastPlayerCharactersResult.Read<byte>(2), lastPlayerCharactersResult.Read<uint>(3));
|
||||
|
||||
LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo();
|
||||
LastPlayedCharacterInfo lastPlayedCharacter = new();
|
||||
lastPlayedCharacter.RealmId = realmId;
|
||||
lastPlayedCharacter.CharacterName = lastPlayerCharactersResult.Read<string>(4);
|
||||
lastPlayedCharacter.CharacterGUID = lastPlayerCharactersResult.Read<ulong>(5);
|
||||
@@ -142,14 +141,14 @@ namespace BNetServer.Networking
|
||||
}
|
||||
}
|
||||
|
||||
LogonResult logonResult = new LogonResult();
|
||||
LogonResult logonResult = new();
|
||||
logonResult.ErrorCode = 0;
|
||||
logonResult.AccountId = new EntityId();
|
||||
logonResult.AccountId.Low = accountInfo.Id;
|
||||
logonResult.AccountId.High = 0x100000000000000;
|
||||
foreach (var pair in accountInfo.GameAccounts)
|
||||
{
|
||||
EntityId gameAccountId = new EntityId();
|
||||
EntityId gameAccountId = new();
|
||||
gameAccountId.Low = pair.Value.Id;
|
||||
gameAccountId.High = 0x200000200576F57;
|
||||
logonResult.GameAccountId.Add(gameAccountId);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Connection.V1;
|
||||
using Framework.Constants;
|
||||
using System.Collections.Generic;
|
||||
using Google.Protobuf;
|
||||
using Bgs.Protocol;
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
@@ -19,7 +17,7 @@ namespace BNetServer.Networking
|
||||
response.ClientId.MergeFrom(request.ClientId);
|
||||
|
||||
response.ServerId = new ProcessId();
|
||||
response.ServerId.Label = (uint)Process.GetCurrentProcess().Id;
|
||||
response.ServerId.Label = (uint)Environment.ProcessId;
|
||||
response.ServerId.Epoch = (uint)Time.UnixTime;
|
||||
response.ServerTime = (ulong)Time.UnixTimeMilliseconds;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace BNetServer.Networking
|
||||
return BattlenetRpcErrorCode.Denied;
|
||||
|
||||
Bgs.Protocol.Attribute command = null;
|
||||
Dictionary<string, Variant> Params = new Dictionary<string, Variant>();
|
||||
Dictionary<string, Variant> Params = new();
|
||||
|
||||
for (int i = 0; i < request.Attribute.Count; ++i)
|
||||
{
|
||||
|
||||
@@ -125,12 +125,12 @@ namespace BNetServer.Networking
|
||||
|
||||
public async void SendResponse(uint token, IMessage response)
|
||||
{
|
||||
Header header = new Header();
|
||||
Header header = new();
|
||||
header.Token = token;
|
||||
header.ServiceId = 0xFE;
|
||||
header.Size = (uint)response.CalculateSize();
|
||||
|
||||
ByteBuffer buffer = new ByteBuffer();
|
||||
ByteBuffer buffer = new();
|
||||
buffer.WriteBytes(GetHeaderSize(header), 2);
|
||||
buffer.WriteBytes(header.ToByteArray());
|
||||
buffer.WriteBytes(response.ToByteArray());
|
||||
@@ -140,12 +140,12 @@ namespace BNetServer.Networking
|
||||
|
||||
public async void SendResponse(uint token, BattlenetRpcErrorCode status)
|
||||
{
|
||||
Header header = new Header();
|
||||
Header header = new();
|
||||
header.Token = token;
|
||||
header.Status = (uint)status;
|
||||
header.ServiceId = 0xFE;
|
||||
|
||||
ByteBuffer buffer = new ByteBuffer();
|
||||
ByteBuffer buffer = new();
|
||||
buffer.WriteBytes(GetHeaderSize(header), 2);
|
||||
buffer.WriteBytes(header.ToByteArray());
|
||||
|
||||
@@ -154,14 +154,14 @@ namespace BNetServer.Networking
|
||||
|
||||
public async void SendRequest(uint serviceHash, uint methodId, IMessage request)
|
||||
{
|
||||
Header header = new Header();
|
||||
Header header = new();
|
||||
header.ServiceId = 0;
|
||||
header.ServiceHash = serviceHash;
|
||||
header.MethodId = methodId;
|
||||
header.Size = (uint)request.CalculateSize();
|
||||
header.Token = requestToken++;
|
||||
|
||||
ByteBuffer buffer = new ByteBuffer();
|
||||
ByteBuffer buffer = new();
|
||||
buffer.WriteBytes(GetHeaderSize(header), 2);
|
||||
buffer.WriteBytes(header.ToByteArray());
|
||||
buffer.WriteBytes(request.ToByteArray());
|
||||
@@ -260,7 +260,7 @@ namespace BNetServer.Networking
|
||||
|
||||
int hashPos = Name.IndexOf('#');
|
||||
if (hashPos != -1)
|
||||
DisplayName = "WoW" + Name.Substring(hashPos + 1);
|
||||
DisplayName = "WoW" + Name[(hashPos + 1)..];
|
||||
else
|
||||
DisplayName = Name;
|
||||
|
||||
|
||||
@@ -3,19 +3,12 @@
|
||||
|
||||
using BNetServer.Networking;
|
||||
using Framework.Configuration;
|
||||
using Framework.Cryptography;
|
||||
using Framework.Database;
|
||||
using Framework.Networking;
|
||||
using Framework.Web.API;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Timers;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Framework.Cryptography;
|
||||
|
||||
namespace BNetServer
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum AuctionResult
|
||||
@@ -59,6 +61,7 @@ namespace Framework.Constants
|
||||
Items = 50
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum AuctionHouseFilterMask
|
||||
{
|
||||
None = 0x0,
|
||||
|
||||
@@ -764,6 +764,7 @@ namespace Framework.Constants
|
||||
LoadedFromDB = 0x02
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ItemSearchLocation
|
||||
{
|
||||
Equipment = 0x01,
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace Framework.Constants
|
||||
DamageCancels = 0x400
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SpellAuraInterruptFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
@@ -154,6 +155,7 @@ namespace Framework.Constants
|
||||
NotVictim = (HostileActionReceived | Damage | NonPeriodicDamage)
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SpellAuraInterruptFlags2
|
||||
{
|
||||
None = 0,
|
||||
|
||||
@@ -153,12 +153,12 @@ namespace Game.Arenas
|
||||
// arena rating calculation
|
||||
if (IsRated())
|
||||
{
|
||||
uint loserTeamRating = 0;
|
||||
uint loserMatchmakerRating = 0;
|
||||
uint loserTeamRating;
|
||||
uint loserMatchmakerRating;
|
||||
int loserChange = 0;
|
||||
int loserMatchmakerChange = 0;
|
||||
uint winnerTeamRating = 0;
|
||||
uint winnerMatchmakerRating = 0;
|
||||
uint winnerTeamRating;
|
||||
uint winnerMatchmakerRating;
|
||||
int winnerChange = 0;
|
||||
int winnerMatchmakerChange = 0;
|
||||
bool guildAwarded = false;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Game.Arenas
|
||||
newMember.WeekGames = 0;
|
||||
newMember.SeasonWins = 0;
|
||||
newMember.WeekWins = 0;
|
||||
newMember.PersonalRating = 0;
|
||||
newMember.PersonalRating = (ushort)personalRating;
|
||||
newMember.MatchMakerRating = (ushort)matchMakerRating;
|
||||
|
||||
Members.Add(newMember);
|
||||
|
||||
@@ -2031,7 +2031,7 @@ namespace Game
|
||||
public Span<T> GetResultRange()
|
||||
{
|
||||
Span<T> h = _items.ToArray();
|
||||
return h.Slice((int)_offset);
|
||||
return h[(int)_offset..];
|
||||
}
|
||||
|
||||
public bool HasMoreResults()
|
||||
|
||||
@@ -715,8 +715,8 @@ namespace Game.BattleFields
|
||||
{
|
||||
public WintergraspTowerCannonData()
|
||||
{
|
||||
TowerCannonBottom = new Position[0];
|
||||
TurretTop = new Position[0];
|
||||
TowerCannonBottom = System.Array.Empty<Position>();
|
||||
TurretTop = System.Array.Empty<Position>();
|
||||
}
|
||||
|
||||
public uint towerEntry;
|
||||
|
||||
@@ -2088,12 +2088,10 @@ namespace Game.BattleGrounds
|
||||
// Arena team ids by team
|
||||
uint[] m_ArenaTeamIds = new uint[SharedConst.BGTeamsCount];
|
||||
|
||||
int[] m_ArenaTeamRatingChanges = new int[SharedConst.BGTeamsCount];
|
||||
uint[] m_ArenaTeamMMR = new uint[SharedConst.BGTeamsCount];
|
||||
|
||||
// Start location
|
||||
BattlegroundMap m_Map;
|
||||
Position[] StartPosition = new Position[SharedConst.BGTeamsCount];
|
||||
|
||||
BattlegroundTemplate _battlegroundTemplate;
|
||||
PvpDifficultyRecord _pvpDifficultyEntry;
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace Game.BattleGrounds
|
||||
m_SumOfWaitTimes[team_index][(int)bracket_id] += timeInQueue;
|
||||
//set index of last player added to next one
|
||||
lastPlayerAddedPointer++;
|
||||
lastPlayerAddedPointer %= SharedConst.CountOfPlayersToAverageWaitTime;
|
||||
m_WaitTimeLastPlayer[team_index][(int)bracket_id] = lastPlayerAddedPointer % SharedConst.CountOfPlayersToAverageWaitTime;
|
||||
}
|
||||
|
||||
public uint GetAverageQueueWaitTime(GroupQueueInfo ginfo, BattlegroundBracketId bracket_id)
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace Game
|
||||
packet.ResponseTime = invite.ResponseTime;
|
||||
packet.Status = invite.Status;
|
||||
packet.Type = (byte)(calendarEvent != null ? calendarEvent.IsGuildEvent() ? 1 : 0 : 0); // Correct ?
|
||||
packet.ClearPending = calendarEvent != null ? !calendarEvent.IsGuildEvent() : true; // Correct ?
|
||||
packet.ClearPending = calendarEvent == null || !calendarEvent.IsGuildEvent(); // Correct ?
|
||||
|
||||
if (calendarEvent == null) // Pre-invite
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ using Framework.Database;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Maps;
|
||||
using Game.Networking;
|
||||
using Game.Networking.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -83,7 +82,7 @@ namespace Game.Chat
|
||||
for (var i = 0; i < tokens.Length; ++i)
|
||||
{
|
||||
ObjectGuid bannedGuid = new();
|
||||
if (ulong.TryParse(tokens[i].Substring(0, 16), out ulong highguid) && ulong.TryParse(tokens[i].Substring(16), out ulong lowguid))
|
||||
if (ulong.TryParse(tokens[i].Substring(0, 16), out ulong highguid) && ulong.TryParse(tokens[i][16..], out ulong lowguid))
|
||||
bannedGuid.SetRawValue(highguid, lowguid);
|
||||
|
||||
if (!bannedGuid.IsEmpty())
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Game.Chat
|
||||
|
||||
// Security level required
|
||||
WorldSession session = handler.GetSession();
|
||||
bool hasRBAC = (session.HasPermission(RBACPermissions.EmailConfirmForPassChange) ? true : false);
|
||||
bool hasRBAC = (session.HasPermission(RBACPermissions.EmailConfirmForPassChange));
|
||||
uint pwConfig = 0; // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
|
||||
|
||||
handler.SendSysMessage(CypherStrings.AccountSecType, (pwConfig == 0 ? "Lowest level: No Email input required." :
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Game.Chat.Commands
|
||||
string accountName = accountId.ToString() + '#' + index;
|
||||
|
||||
// Generate random hex string for password, these accounts must not be logged on with GRUNT
|
||||
byte[] randPassword = new byte[0].GenerateRandomKey(8);
|
||||
byte[] randPassword = Array.Empty<byte>().GenerateRandomKey(8);
|
||||
switch (Global.AccountMgr.CreateAccount(accountName, randPassword.ToHexString(), bnetAccountName, accountId, index))
|
||||
{
|
||||
case AccountOpResult.Ok:
|
||||
@@ -179,7 +179,7 @@ namespace Game.Chat.Commands
|
||||
{
|
||||
int index = name.IndexOf('#');
|
||||
if (index > 0)
|
||||
return "WoW" + name.Substring(++index);
|
||||
return "WoW" + name[++index..];
|
||||
else
|
||||
return name;
|
||||
});
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
uint oldAccountId = characterInfo.AccountId;
|
||||
uint newAccountId = oldAccountId;
|
||||
uint newAccountId;
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_ID_BY_NAME);
|
||||
stmt.AddValue(0, accountName);
|
||||
|
||||
@@ -369,17 +369,15 @@ namespace Game.Chat.Commands
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
Player target;
|
||||
ObjectGuid targetGuid;
|
||||
string targetName;
|
||||
|
||||
ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64());
|
||||
if (Global.CharacterCacheStorage.GetCharacterNameByGuid(parseGUID, out targetName))
|
||||
{
|
||||
target = Global.ObjAccessor.FindPlayer(parseGUID);
|
||||
targetGuid = parseGUID;
|
||||
}
|
||||
else if (!handler.ExtractPlayerTarget(args, out target, out targetGuid, out targetName))
|
||||
else if (!handler.ExtractPlayerTarget(args, out _, out targetGuid, out targetName))
|
||||
return false;
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MAIL_LIST_COUNT);
|
||||
|
||||
@@ -1580,7 +1580,7 @@ namespace Game.Chat
|
||||
Locale locale = handler.GetSessionDbcLocale();
|
||||
uint totalPlayerTime;
|
||||
uint level;
|
||||
string alive = handler.GetCypherString(CypherStrings.Error);
|
||||
string alive;
|
||||
ulong money;
|
||||
uint xp = 0;
|
||||
uint xptotal = 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Game.Collision
|
||||
void InitEmpty()
|
||||
{
|
||||
tree= new uint[3];
|
||||
objects = new uint[0];
|
||||
objects = Array.Empty<uint>();
|
||||
// create space for the first node
|
||||
tree[0] = (3u << 30); // dummy leaf
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Game.Collision
|
||||
public void Remove(T obj)
|
||||
{
|
||||
++unbalanced_times;
|
||||
uint Idx = 0;
|
||||
uint Idx;
|
||||
if (m_obj2Idx.TryGetValue(obj, out Idx))
|
||||
m_objects[(int)Idx] = null;
|
||||
else
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Game.Collision
|
||||
impl.Update(diff);
|
||||
}
|
||||
|
||||
public bool GetIntersectionTime(Ray ray, Vector3 endPos, PhaseShift phaseShift, float maxDist)
|
||||
public bool GetIntersectionTime(Ray ray, Vector3 endPos, PhaseShift phaseShift, ref float maxDist)
|
||||
{
|
||||
float distance = maxDist;
|
||||
DynamicTreeIntersectionCallback callback = new(phaseShift);
|
||||
@@ -63,7 +63,7 @@ namespace Game.Collision
|
||||
|
||||
public bool GetObjectHitPos(Vector3 startPos, Vector3 endPos, ref Vector3 resultHitPos, float modifyDist, PhaseShift phaseShift)
|
||||
{
|
||||
bool result = false;
|
||||
bool result;
|
||||
float maxDist = (endPos - startPos).magnitude();
|
||||
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too
|
||||
Cypher.Assert(maxDist < float.MaxValue);
|
||||
@@ -76,7 +76,7 @@ namespace Game.Collision
|
||||
Vector3 dir = (endPos - startPos) / maxDist; // direction with length of 1
|
||||
Ray ray = new(startPos, dir);
|
||||
float dist = maxDist;
|
||||
if (GetIntersectionTime(ray, endPos, phaseShift, dist))
|
||||
if (GetIntersectionTime(ray, endPos, phaseShift, ref dist))
|
||||
{
|
||||
resultHitPos = startPos + dir * dist;
|
||||
if (modifyDist < 0)
|
||||
|
||||
@@ -121,60 +121,58 @@ namespace Game.Collision
|
||||
if (fileResult.File != null)
|
||||
{
|
||||
result = LoadResult.Success;
|
||||
using (BinaryReader reader = new(fileResult.File))
|
||||
using BinaryReader reader = new(fileResult.File);
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
result = LoadResult.VersionMismatch;
|
||||
|
||||
if (result == LoadResult.Success)
|
||||
{
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
result = LoadResult.VersionMismatch;
|
||||
|
||||
if (result == LoadResult.Success)
|
||||
uint numSpawns = reader.ReadUInt32();
|
||||
for (uint i = 0; i < numSpawns && result == LoadResult.Success; ++i)
|
||||
{
|
||||
uint numSpawns = reader.ReadUInt32();
|
||||
for (uint i = 0; i < numSpawns && result == LoadResult.Success; ++i)
|
||||
// read model spawns
|
||||
if (ModelSpawn.ReadFromFile(reader, out ModelSpawn spawn))
|
||||
{
|
||||
// read model spawns
|
||||
if (ModelSpawn.ReadFromFile(reader, out ModelSpawn spawn))
|
||||
{
|
||||
// acquire model instance
|
||||
WorldModel model = vm.AcquireModelInstance(spawn.name, spawn.flags);
|
||||
if (model == null)
|
||||
Log.outError(LogFilter.Server, "StaticMapTree.LoadMapTile() : could not acquire WorldModel [{0}, {1}]", tileX, tileY);
|
||||
// acquire model instance
|
||||
WorldModel model = vm.AcquireModelInstance(spawn.name, spawn.flags);
|
||||
if (model == null)
|
||||
Log.outError(LogFilter.Server, "StaticMapTree.LoadMapTile() : could not acquire WorldModel [{0}, {1}]", tileX, tileY);
|
||||
|
||||
// update tree
|
||||
if (iSpawnIndices.ContainsKey(spawn.Id))
|
||||
// update tree
|
||||
if (iSpawnIndices.ContainsKey(spawn.Id))
|
||||
{
|
||||
uint referencedVal = iSpawnIndices[spawn.Id];
|
||||
if (!iLoadedSpawns.ContainsKey(referencedVal))
|
||||
{
|
||||
uint referencedVal = iSpawnIndices[spawn.Id];
|
||||
if (!iLoadedSpawns.ContainsKey(referencedVal))
|
||||
if (referencedVal >= iNTreeValues)
|
||||
{
|
||||
if (referencedVal >= iNTreeValues)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "StaticMapTree.LoadMapTile() : invalid tree element ({0}/{1}) referenced in tile {2}", referencedVal, iNTreeValues, fileResult.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
iTreeValues[referencedVal] = new ModelInstance(spawn, model);
|
||||
iLoadedSpawns[referencedVal] = 1;
|
||||
Log.outError(LogFilter.Maps, "StaticMapTree.LoadMapTile() : invalid tree element ({0}/{1}) referenced in tile {2}", referencedVal, iNTreeValues, fileResult.Name);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
++iLoadedSpawns[referencedVal];
|
||||
}
|
||||
else if (iMapID == fileResult.UsedMapId)
|
||||
{
|
||||
// unknown parent spawn might appear in because it overlaps multiple tiles
|
||||
// in case the original tile is swapped but its neighbour is now (adding this spawn)
|
||||
// we want to not mark it as loading error and just skip that model
|
||||
Log.outError(LogFilter.Maps, $"StaticMapTree.LoadMapTile() : invalid tree element (spawn {spawn.Id}) referenced in tile fileResult.Name{fileResult.Name} by map {iMapID}");
|
||||
result = LoadResult.ReadFromFileFailed;
|
||||
|
||||
iTreeValues[referencedVal] = new ModelInstance(spawn, model);
|
||||
iLoadedSpawns[referencedVal] = 1;
|
||||
}
|
||||
else
|
||||
++iLoadedSpawns[referencedVal];
|
||||
}
|
||||
else
|
||||
else if (iMapID == fileResult.UsedMapId)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, $"StaticMapTree.LoadMapTile() : cannot read model from file (spawn index {i}) referenced in tile {fileResult.Name} by map {iMapID}");
|
||||
// unknown parent spawn might appear in because it overlaps multiple tiles
|
||||
// in case the original tile is swapped but its neighbour is now (adding this spawn)
|
||||
// we want to not mark it as loading error and just skip that model
|
||||
Log.outError(LogFilter.Maps, $"StaticMapTree.LoadMapTile() : invalid tree element (spawn {spawn.Id}) referenced in tile fileResult.Name{fileResult.Name} by map {iMapID}");
|
||||
result = LoadResult.ReadFromFileFailed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Maps, $"StaticMapTree.LoadMapTile() : cannot read model from file (spawn index {i}) referenced in tile {fileResult.Name} by map {iMapID}");
|
||||
result = LoadResult.ReadFromFileFailed;
|
||||
}
|
||||
}
|
||||
iLoadedTiles[PackTileID(tileX, tileY)] = true;
|
||||
}
|
||||
iLoadedTiles[PackTileID(tileX, tileY)] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -197,38 +195,36 @@ namespace Game.Collision
|
||||
TileFileOpenResult fileResult = OpenMapTileFile(VMapManager.VMapPath, iMapID, tileX, tileY, vm);
|
||||
if (fileResult.File != null)
|
||||
{
|
||||
using (BinaryReader reader = new(fileResult.File))
|
||||
using BinaryReader reader = new(fileResult.File);
|
||||
bool result = true;
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
result = false;
|
||||
|
||||
uint numSpawns = reader.ReadUInt32();
|
||||
for (uint i = 0; i < numSpawns && result; ++i)
|
||||
{
|
||||
bool result = true;
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
result = false;
|
||||
|
||||
uint numSpawns = reader.ReadUInt32();
|
||||
for (uint i = 0; i < numSpawns && result; ++i)
|
||||
// read model spawns
|
||||
ModelSpawn spawn;
|
||||
result = ModelSpawn.ReadFromFile(reader, out spawn);
|
||||
if (result)
|
||||
{
|
||||
// read model spawns
|
||||
ModelSpawn spawn;
|
||||
result = ModelSpawn.ReadFromFile(reader, out spawn);
|
||||
if (result)
|
||||
{
|
||||
// release model instance
|
||||
vm.ReleaseModelInstance(spawn.name);
|
||||
// release model instance
|
||||
vm.ReleaseModelInstance(spawn.name);
|
||||
|
||||
// update tree
|
||||
if (iSpawnIndices.ContainsKey(spawn.Id))
|
||||
// update tree
|
||||
if (iSpawnIndices.ContainsKey(spawn.Id))
|
||||
{
|
||||
uint referencedNode = iSpawnIndices[spawn.Id];
|
||||
if (!iLoadedSpawns.ContainsKey(referencedNode))
|
||||
Log.outError(LogFilter.Server, "StaticMapTree.UnloadMapTile() : trying to unload non-referenced model '{0}' (ID:{1})", spawn.name, spawn.Id);
|
||||
else if (--iLoadedSpawns[referencedNode] == 0)
|
||||
{
|
||||
uint referencedNode = iSpawnIndices[spawn.Id];
|
||||
if (!iLoadedSpawns.ContainsKey(referencedNode))
|
||||
Log.outError(LogFilter.Server, "StaticMapTree.UnloadMapTile() : trying to unload non-referenced model '{0}' (ID:{1})", spawn.name, spawn.Id);
|
||||
else if (--iLoadedSpawns[referencedNode] == 0)
|
||||
{
|
||||
iTreeValues[referencedNode].SetUnloaded();
|
||||
iLoadedSpawns.Remove(referencedNode);
|
||||
}
|
||||
iTreeValues[referencedNode].SetUnloaded();
|
||||
iLoadedSpawns.Remove(referencedNode);
|
||||
}
|
||||
else if (iMapID == fileResult.UsedMapId) // logic documented in StaticMapTree::LoadMapTile
|
||||
result = false;
|
||||
}
|
||||
else if (iMapID == fileResult.UsedMapId) // logic documented in StaticMapTree::LoadMapTile
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,30 +189,28 @@ namespace Game.Collision
|
||||
}
|
||||
try
|
||||
{
|
||||
using (BinaryReader reader = new(new FileStream(filename, FileMode.Open, FileAccess.Read)))
|
||||
using BinaryReader reader = new(new FileStream(filename, FileMode.Open, FileAccess.Read));
|
||||
string magic = reader.ReadStringFromChars(8);
|
||||
if (magic != MapConst.VMapMagic)
|
||||
{
|
||||
string magic = reader.ReadStringFromChars(8);
|
||||
if (magic != MapConst.VMapMagic)
|
||||
{
|
||||
Log.outError(LogFilter.Misc, $"File '{filename}' has wrong header, expected {MapConst.VMapMagic}.");
|
||||
return;
|
||||
}
|
||||
Log.outError(LogFilter.Misc, $"File '{filename}' has wrong header, expected {MapConst.VMapMagic}.");
|
||||
return;
|
||||
}
|
||||
|
||||
long length = reader.BaseStream.Length;
|
||||
while (true)
|
||||
{
|
||||
if (reader.BaseStream.Position >= length)
|
||||
break;
|
||||
long length = reader.BaseStream.Length;
|
||||
while (true)
|
||||
{
|
||||
if (reader.BaseStream.Position >= length)
|
||||
break;
|
||||
|
||||
uint displayId = reader.ReadUInt32();
|
||||
bool isWmo = reader.ReadBoolean();
|
||||
int name_length = reader.ReadInt32();
|
||||
string name = reader.ReadString(name_length);
|
||||
Vector3 v1 = reader.Read<Vector3>();
|
||||
Vector3 v2 = reader.Read<Vector3>();
|
||||
uint displayId = reader.ReadUInt32();
|
||||
bool isWmo = reader.ReadBoolean();
|
||||
int name_length = reader.ReadInt32();
|
||||
string name = reader.ReadString(name_length);
|
||||
Vector3 v1 = reader.Read<Vector3>();
|
||||
Vector3 v2 = reader.Read<Vector3>();
|
||||
|
||||
StaticModelList.models.Add(displayId, new GameobjectModelData(name, v1, v2, isWmo));
|
||||
}
|
||||
StaticModelList.models.Add(displayId, new GameobjectModelData(name, v1, v2, isWmo));
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException ex)
|
||||
|
||||
@@ -371,40 +371,38 @@ namespace Game.Collision
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
filename = filename + ".vmo";
|
||||
filename += ".vmo";
|
||||
if (!File.Exists(filename))
|
||||
return false;
|
||||
}
|
||||
|
||||
using (BinaryReader reader = new(new FileStream(filename, FileMode.Open, FileAccess.Read)))
|
||||
using BinaryReader reader = new(new FileStream(filename, FileMode.Open, FileAccess.Read));
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
return false;
|
||||
|
||||
if (reader.ReadStringFromChars(4) != "WMOD")
|
||||
return false;
|
||||
|
||||
reader.ReadUInt32(); //chunkSize notused
|
||||
RootWMOID = reader.ReadUInt32();
|
||||
|
||||
// read group models
|
||||
if (reader.ReadStringFromChars(4) != "GMOD")
|
||||
return false;
|
||||
|
||||
uint count = reader.ReadUInt32();
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
return false;
|
||||
|
||||
if (reader.ReadStringFromChars(4) != "WMOD")
|
||||
return false;
|
||||
|
||||
reader.ReadUInt32(); //chunkSize notused
|
||||
RootWMOID = reader.ReadUInt32();
|
||||
|
||||
// read group models
|
||||
if (reader.ReadStringFromChars(4) != "GMOD")
|
||||
return false;
|
||||
|
||||
uint count = reader.ReadUInt32();
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
GroupModel group = new();
|
||||
group.ReadFromFile(reader);
|
||||
groupModels.Add(group);
|
||||
}
|
||||
|
||||
// read group BIH
|
||||
if (reader.ReadStringFromChars(4) != "GBIH")
|
||||
return false;
|
||||
|
||||
return groupTree.ReadFromFile(reader);
|
||||
GroupModel group = new();
|
||||
group.ReadFromFile(reader);
|
||||
groupModels.Add(group);
|
||||
}
|
||||
|
||||
// read group BIH
|
||||
if (reader.ReadStringFromChars(4) != "GBIH")
|
||||
return false;
|
||||
|
||||
return groupTree.ReadFromFile(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ namespace Game.Combat
|
||||
|
||||
void PutThreatListRef(ObjectGuid guid, ThreatReference refe)
|
||||
{
|
||||
Cypher.Assert(!_myThreatListEntries.ContainsKey(guid), $"Duplicate threat reference being inserted on {_owner.GetGUID()} for {guid.ToString()}!");
|
||||
Cypher.Assert(!_myThreatListEntries.ContainsKey(guid), $"Duplicate threat reference being inserted on {_owner.GetGUID()} for {guid}!");
|
||||
_myThreatListEntries[guid] = refe;
|
||||
_sortedThreatList.Add(refe);
|
||||
_sortedThreatList.Sort();
|
||||
@@ -771,7 +771,6 @@ namespace Game.Combat
|
||||
if (onlineState == _online)
|
||||
return;
|
||||
|
||||
bool increase = (onlineState > _online);
|
||||
_online = onlineState;
|
||||
ListNotifyChanged();
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Game.Conditions
|
||||
{
|
||||
// don't allow 0 items (it's checked during table load)
|
||||
Cypher.Assert(ConditionValue2 != 0);
|
||||
bool checkBank = ConditionValue3 != 0 ? true : false;
|
||||
bool checkBank = ConditionValue3 != 0;
|
||||
condMeets = player.HasItemCount(ConditionValue1, ConditionValue2, checkBank);
|
||||
}
|
||||
break;
|
||||
@@ -176,7 +176,7 @@ namespace Game.Conditions
|
||||
condMeets = (uint)Player.GetDrunkenstateByValue(player.GetDrunkValue()) >= ConditionValue1;
|
||||
break;
|
||||
case ConditionTypes.NearCreature:
|
||||
condMeets = obj.FindNearestCreature(ConditionValue1, ConditionValue2, ConditionValue3 == 0 ? true : false) != null;
|
||||
condMeets = obj.FindNearestCreature(ConditionValue1, ConditionValue2, ConditionValue3 == 0) != null;
|
||||
break;
|
||||
case ConditionTypes.NearGameobject:
|
||||
condMeets = obj.FindNearestGameObject(ConditionValue1, ConditionValue2) != null;
|
||||
@@ -550,7 +550,7 @@ namespace Game.Conditions
|
||||
ss.Append(" (Unknown)");
|
||||
}
|
||||
|
||||
ss.Append("]");
|
||||
ss.Append(']');
|
||||
return ss.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1529,7 +1529,7 @@ namespace Game
|
||||
}
|
||||
case ConditionTypes.StandState:
|
||||
{
|
||||
bool valid = false;
|
||||
bool valid;
|
||||
switch (cond.ConditionValue1)
|
||||
{
|
||||
case 0:
|
||||
@@ -1677,8 +1677,7 @@ namespace Game
|
||||
|
||||
public static uint GetPlayerConditionLfgValue(Player player, PlayerConditionLfgStatus status)
|
||||
{
|
||||
Group group = player.GetGroup();
|
||||
if (group = null)
|
||||
if (player.GetGroup() == null)
|
||||
return 0;
|
||||
|
||||
switch (status)
|
||||
|
||||
@@ -170,27 +170,25 @@ namespace Game.DataStorage
|
||||
|
||||
try
|
||||
{
|
||||
using (BinaryReader m2file = new(new FileStream(filename, FileMode.Open, FileAccess.Read)))
|
||||
using BinaryReader m2file = new(new FileStream(filename, FileMode.Open, FileAccess.Read));
|
||||
// Check file has correct magic (MD21)
|
||||
if (m2file.ReadUInt32() != 0x3132444D) //"MD21"
|
||||
{
|
||||
// Check file has correct magic (MD21)
|
||||
if (m2file.ReadUInt32() != 0x3132444D) //"MD21"
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, "Camera file {0} is damaged. File identifier not found.", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
m2file.ReadUInt32(); //unknown size
|
||||
|
||||
// Read header
|
||||
M2Header header = m2file.Read<M2Header>();
|
||||
|
||||
// Get camera(s) - Main header, then dump them.
|
||||
m2file.BaseStream.Position = 8 + header.ofsCameras;
|
||||
M2Camera cam = m2file.Read<M2Camera>();
|
||||
|
||||
m2file.BaseStream.Position = 8;
|
||||
ReadCamera(cam, new BinaryReader(new MemoryStream(m2file.ReadBytes((int)m2file.BaseStream.Length - 8))), cameraEntry);
|
||||
Log.outError(LogFilter.ServerLoading, "Camera file {0} is damaged. File identifier not found.", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
m2file.ReadUInt32(); //unknown size
|
||||
|
||||
// Read header
|
||||
M2Header header = m2file.Read<M2Header>();
|
||||
|
||||
// Get camera(s) - Main header, then dump them.
|
||||
m2file.BaseStream.Position = 8 + header.ofsCameras;
|
||||
M2Camera cam = m2file.Read<M2Camera>();
|
||||
|
||||
m2file.BaseStream.Position = 8;
|
||||
ReadCamera(cam, new BinaryReader(new MemoryStream(m2file.ReadBytes((int)m2file.BaseStream.Length - 8))), cameraEntry);
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
|
||||
@@ -987,7 +987,7 @@ namespace Game.DungeonFinding
|
||||
ObjectGuid pguid = it.Key;
|
||||
ObjectGuid gguid = it.Value.group;
|
||||
uint dungeonId = GetSelectedDungeons(pguid).First();
|
||||
int waitTime = -1;
|
||||
int waitTime;
|
||||
if (sendUpdate)
|
||||
SendLfgUpdateProposal(pguid, proposal);
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace Game.Entities
|
||||
if (GetMiscTemplate().ExtraScale.Raw.Data[5] != 0)
|
||||
SetUpdateFieldValue(extraScaleCurve.ModifyValue(extraScaleCurve.ParameterCurve), GetMiscTemplate().ExtraScale.Raw.Data[5]);
|
||||
if (GetMiscTemplate().ExtraScale.Structured.OverrideActive != 0)
|
||||
SetUpdateFieldValue(extraScaleCurve.ModifyValue(extraScaleCurve.OverrideActive), GetMiscTemplate().ExtraScale.Structured.OverrideActive != 0 ? true : false);
|
||||
SetUpdateFieldValue(extraScaleCurve.ModifyValue(extraScaleCurve.OverrideActive), GetMiscTemplate().ExtraScale.Structured.OverrideActive != 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -921,7 +921,7 @@ namespace Game.Entities
|
||||
|
||||
public Unit SelectVictim()
|
||||
{
|
||||
Unit target = null;
|
||||
Unit target;
|
||||
|
||||
ThreatManager mgr = GetThreatManager();
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Game.Misc
|
||||
continue;
|
||||
|
||||
// Store texts for localization.
|
||||
string strOptionText = "", strBoxText = "";
|
||||
string strOptionText, strBoxText;
|
||||
BroadcastTextRecord optionBroadcastText = CliDB.BroadcastTextStorage.LookupByKey(item.OptionBroadcastTextId);
|
||||
BroadcastTextRecord boxBroadcastText = CliDB.BroadcastTextStorage.LookupByKey(item.BoxBroadcastTextId);
|
||||
|
||||
|
||||
@@ -635,7 +635,7 @@ namespace Game.Entities
|
||||
else
|
||||
radius = goInfo.Trap.radius / 2.0f;
|
||||
|
||||
Unit target = null;
|
||||
Unit target;
|
||||
// @todo this hack with search required until GO casting not implemented
|
||||
Unit owner = GetOwner();
|
||||
if (owner)
|
||||
@@ -1169,7 +1169,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
long thisRespawnTime = forceDelay != 0 ? GameTime.GetGameTime() + forceDelay : m_respawnTime;
|
||||
GetMap().SaveRespawnTime(SpawnObjectType.GameObject, m_spawnId, GetEntry(), thisRespawnTime, GetZoneId(), GridDefines.ComputeGridCoord(GetPositionX(), GetPositionY()).GetId(), m_goData.dbData ? savetodb : false);
|
||||
GetMap().SaveRespawnTime(SpawnObjectType.GameObject, m_spawnId, GetEntry(), thisRespawnTime, GetZoneId(), GridDefines.ComputeGridCoord(GetPositionX(), GetPositionY()).GetId(), m_goData.dbData && savetodb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Game.Entities
|
||||
{
|
||||
posX = (float)(posX + (offset.posX * Math.Cos(Orientation) + offset.posY * Math.Sin(Orientation + MathFunctions.PI)));
|
||||
posY = (float)(posY + (offset.posY * Math.Cos(Orientation) + offset.posX * Math.Sin(Orientation)));
|
||||
posZ = posZ + offset.posZ;
|
||||
posZ += offset.posZ;
|
||||
SetOrientation(Orientation + offset.Orientation);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Game.Entities
|
||||
if (o < 0)
|
||||
{
|
||||
float mod = o * -1;
|
||||
mod = mod % (2.0f * MathFunctions.PI);
|
||||
mod %= (2.0f * MathFunctions.PI);
|
||||
mod = -mod + 2.0f * MathFunctions.PI;
|
||||
return mod;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,8 @@ namespace Game.Entities
|
||||
public class UpdateFieldHolder
|
||||
{
|
||||
UpdateMask _changesMask = new((int)TypeId.Max);
|
||||
WorldObject _owner;
|
||||
|
||||
public UpdateFieldHolder(WorldObject owner) { _owner = owner; }
|
||||
public UpdateFieldHolder(WorldObject owner) { }
|
||||
|
||||
public BaseUpdateData<T> ModifyValue<T>(BaseUpdateData<T> updateData)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Game.Entities
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Player, $"Player._LoadInventory: Player '{GetName()}' ({GetGUID().ToString()}) has child item ({item.GetGUID()}, entry: {item.GetEntry()}) which can't be loaded into inventory because parent item was not found (Bag {bagGuid}, slot: {slot}). Item will be sent by mail.");
|
||||
Log.outError(LogFilter.Player, $"Player._LoadInventory: Player '{GetName()}' ({GetGUID()}) has child item ({item.GetGUID()}, entry: {item.GetEntry()}) which can't be loaded into inventory because parent item was not found (Bag {bagGuid}, slot: {slot}). Item will be sent by mail.");
|
||||
item.DeleteFromInventoryDB(trans);
|
||||
problematicItems.Enqueue(item);
|
||||
continue;
|
||||
@@ -1891,7 +1891,7 @@ namespace Game.Entities
|
||||
|
||||
void _SaveActions(SQLTransaction trans)
|
||||
{
|
||||
PreparedStatement stmt = null;
|
||||
PreparedStatement stmt;
|
||||
|
||||
foreach (var pair in m_actionButtons.ToList())
|
||||
{
|
||||
|
||||
@@ -495,8 +495,7 @@ namespace Game.Entities
|
||||
}
|
||||
InventoryResult CanStoreItem(byte bag, byte slot, List<ItemPosCount> dest, uint entry, uint count, Item pItem, bool swap)
|
||||
{
|
||||
uint throwaway;
|
||||
return CanStoreItem(bag, slot, dest, entry, count, pItem, swap, out throwaway);
|
||||
return CanStoreItem(bag, slot, dest, entry, count, pItem, swap, out _);
|
||||
}
|
||||
InventoryResult CanStoreItem(byte bag, byte slot, List<ItemPosCount> dest, uint entry, uint count, Item pItem, bool swap, out uint no_space_count)
|
||||
{
|
||||
|
||||
@@ -1413,13 +1413,13 @@ namespace Game.Entities
|
||||
switch (Condition.Operator[i])
|
||||
{
|
||||
case 2: // requires less <color> than (<value> || <comparecolor>) gems
|
||||
activate &= (_cur_gem < _cmp_gem) ? true : false;
|
||||
activate &= (_cur_gem < _cmp_gem);
|
||||
break;
|
||||
case 3: // requires more <color> than (<value> || <comparecolor>) gems
|
||||
activate &= (_cur_gem > _cmp_gem) ? true : false;
|
||||
activate &= (_cur_gem > _cmp_gem);
|
||||
break;
|
||||
case 5: // requires at least <color> than (<value> || <comparecolor>) gems
|
||||
activate &= (_cur_gem >= _cmp_gem) ? true : false;
|
||||
activate &= (_cur_gem >= _cmp_gem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2039,7 +2039,7 @@ namespace Game.Entities
|
||||
{
|
||||
PlayerSpell spell = m_spells.LookupByKey(spellId);
|
||||
|
||||
bool disabled = (spell != null) ? spell.Disabled : false;
|
||||
bool disabled = (spell != null) && spell.Disabled;
|
||||
bool active = !disabled || spell.Active;
|
||||
|
||||
bool learning = AddSpell(spellId, active, true, dependent, false, false, fromSkill);
|
||||
@@ -2989,7 +2989,7 @@ namespace Game.Entities
|
||||
public void SetRuneCooldown(byte index, uint cooldown)
|
||||
{
|
||||
m_runes.Cooldown[index] = cooldown;
|
||||
m_runes.SetRuneState(index, (cooldown == 0) ? true : false);
|
||||
m_runes.SetRuneState(index, (cooldown == 0));
|
||||
int activeRunes = m_runes.Cooldown.Count(p => p == 0);
|
||||
if (activeRunes != GetPower(PowerType.Runes))
|
||||
SetPower(PowerType.Runes, activeRunes);
|
||||
|
||||
@@ -155,9 +155,8 @@ namespace Game.Entities
|
||||
|
||||
for (int i = 1; i < m_TaxiDestinations.Count; ++i)
|
||||
{
|
||||
uint cost;
|
||||
uint path;
|
||||
Global.ObjectMgr.GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], out path, out cost);
|
||||
Global.ObjectMgr.GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], out path, out _);
|
||||
if (path == 0)
|
||||
return false;
|
||||
}
|
||||
@@ -189,9 +188,8 @@ namespace Game.Entities
|
||||
return 0;
|
||||
|
||||
uint path;
|
||||
uint cost;
|
||||
|
||||
Global.ObjectMgr.GetTaxiPath(m_TaxiDestinations[0], m_TaxiDestinations[1], out path, out cost);
|
||||
Global.ObjectMgr.GetTaxiPath(m_TaxiDestinations[0], m_TaxiDestinations[1], out path, out _);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -137,8 +137,7 @@ namespace Game.Entities
|
||||
*/
|
||||
|
||||
// Find if we have a direct path
|
||||
uint pathId, goldCost;
|
||||
Global.ObjectMgr.GetTaxiPath(from.Id, to.Id, out pathId, out goldCost);
|
||||
Global.ObjectMgr.GetTaxiPath(from.Id, to.Id, out uint pathId, out _);
|
||||
if (pathId != 0)
|
||||
{
|
||||
shortestPath.Add(from.Id);
|
||||
|
||||
@@ -833,7 +833,7 @@ namespace Game.Entities
|
||||
if (ranged)
|
||||
return;
|
||||
|
||||
float val = 0.0f;
|
||||
float val;
|
||||
float bonusAP = 0.0f;
|
||||
UnitMods unitMod = UnitMods.AttackPower;
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Game.Entities
|
||||
if (_pendingStop && GetGoState() != GameObjectState.Ready)
|
||||
{
|
||||
SetGoState(GameObjectState.Ready);
|
||||
m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetTransportPeriod());
|
||||
m_goValue.Transport.PathProgress /= GetTransportPeriod();
|
||||
m_goValue.Transport.PathProgress *= GetTransportPeriod();
|
||||
m_goValue.Transport.PathProgress += _currentFrame.ArriveTime;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Game.Entities
|
||||
{
|
||||
_charmspells[x].SetActionAndType(spellId, ActiveStates.Disabled);
|
||||
|
||||
ActiveStates newstate = ActiveStates.Passive;
|
||||
ActiveStates newstate;
|
||||
|
||||
if (!spellInfo.IsAutocastable())
|
||||
newstate = ActiveStates.Passive;
|
||||
|
||||
@@ -1337,7 +1337,7 @@ namespace Game.Entities
|
||||
// 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8.
|
||||
// MISS > DODGE > PARRY > GLANCING > BLOCK > CRIT > CRUSHING > HIT
|
||||
|
||||
int sum = 0, tmp = 0;
|
||||
int sum = 0;
|
||||
int roll = RandomHelper.IRand(0, 9999);
|
||||
|
||||
uint attackerLevel = GetLevelForTarget(victim);
|
||||
@@ -1357,7 +1357,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// 1. MISS
|
||||
tmp = miss_chance;
|
||||
int tmp = miss_chance;
|
||||
if (tmp > 0 && roll < (sum += tmp))
|
||||
return MeleeHitOutcome.Miss;
|
||||
|
||||
@@ -1477,9 +1477,9 @@ namespace Game.Entities
|
||||
|
||||
if (minDamage > maxDamage)
|
||||
{
|
||||
minDamage = minDamage + maxDamage;
|
||||
minDamage += maxDamage;
|
||||
maxDamage = minDamage - maxDamage;
|
||||
minDamage = minDamage - maxDamage;
|
||||
minDamage -= maxDamage;
|
||||
}
|
||||
|
||||
if (maxDamage == 0.0f)
|
||||
|
||||
@@ -84,7 +84,6 @@ namespace Game.Entities
|
||||
|
||||
//Spells
|
||||
protected Dictionary<CurrentSpellTypes, Spell> m_currentSpells = new((int)CurrentSpellTypes.Max);
|
||||
Dictionary<SpellValueMod, int> CustomSpellValueMod = new();
|
||||
MultiMap<uint, uint>[] m_spellImmune = new MultiMap<uint, uint>[(int)SpellImmunity.Max];
|
||||
SpellAuraInterruptFlags m_interruptMask;
|
||||
SpellAuraInterruptFlags2 m_interruptMask2;
|
||||
@@ -93,7 +92,6 @@ namespace Game.Entities
|
||||
SpellHistory _spellHistory;
|
||||
|
||||
//Auras
|
||||
List<AuraEffect> AuraEffectList = new();
|
||||
MultiMap<AuraType, AuraEffect> m_modAuras = new();
|
||||
List<Aura> m_removedAuras = new();
|
||||
List<AuraApplication> m_interruptableAuras = new(); // auras which have interrupt mask applied on unit
|
||||
|
||||
@@ -687,8 +687,8 @@ namespace Game.Entities
|
||||
uint areaId = GetAreaId();
|
||||
uint ridingSkill = 5000;
|
||||
AreaMountFlags mountFlags = 0;
|
||||
bool isSubmerged = false;
|
||||
bool isInWater = false;
|
||||
bool isSubmerged;
|
||||
bool isInWater;
|
||||
|
||||
if (IsTypeId(TypeId.Player))
|
||||
ridingSkill = ToPlayer().GetSkillValue(SkillType.Riding);
|
||||
@@ -705,8 +705,7 @@ namespace Game.Entities
|
||||
mountFlags = (AreaMountFlags)areaTable.MountFlags;
|
||||
}
|
||||
|
||||
LiquidData liquid;
|
||||
ZLiquidStatus liquidStatus = GetMap().GetLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), LiquidHeaderTypeFlags.AllLiquids, out liquid);
|
||||
ZLiquidStatus liquidStatus = GetMap().GetLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), LiquidHeaderTypeFlags.AllLiquids, out _);
|
||||
isSubmerged = liquidStatus.HasAnyFlag(ZLiquidStatus.UnderWater) || HasUnitMovementFlag(MovementFlag.Swimming);
|
||||
isInWater = liquidStatus.HasAnyFlag(ZLiquidStatus.InWater | ZLiquidStatus.UnderWater);
|
||||
|
||||
|
||||
@@ -1371,7 +1371,7 @@ namespace Game.Entities
|
||||
|
||||
public bool IsVisible()
|
||||
{
|
||||
return (m_serverSideVisibility.GetValue(ServerSideVisibilityType.GM) > (uint)AccountTypes.Player) ? false : true;
|
||||
return m_serverSideVisibility.GetValue(ServerSideVisibilityType.GM) <= (uint)AccountTypes.Player;
|
||||
}
|
||||
|
||||
public void SetVisible(bool val)
|
||||
|
||||
@@ -527,7 +527,6 @@ namespace Game.Entities
|
||||
|
||||
Unit _me;
|
||||
VehicleRecord _vehicleInfo; //< DBC data for vehicle
|
||||
List<ulong> vehiclePlayers = new();
|
||||
|
||||
uint _creatureEntry; //< Can be different than the entry of _me in case of players
|
||||
Status _status; //< Internal variable for sanity checks
|
||||
|
||||
@@ -782,7 +782,7 @@ namespace Game.Garrisons
|
||||
|
||||
foreach (var guid in BuildingInfo.Spawns)
|
||||
{
|
||||
WorldObject obj = null;
|
||||
WorldObject obj;
|
||||
switch (guid.GetHigh())
|
||||
{
|
||||
case HighGuid.Creature:
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Game
|
||||
{
|
||||
int pos = name.IndexOf('-');
|
||||
if (pos != -1)
|
||||
return new ExtendedPlayerName(name.Substring(0, pos), name.Substring(pos + 1));
|
||||
return new ExtendedPlayerName(name.Substring(0, pos), name[(pos + 1)..]);
|
||||
else
|
||||
return new ExtendedPlayerName(name, "");
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace Game.Groups
|
||||
|
||||
public void ConvertToRaid()
|
||||
{
|
||||
m_groupFlags = (m_groupFlags | GroupFlags.Raid);
|
||||
m_groupFlags |= GroupFlags.Raid;
|
||||
|
||||
_initRaidSubGroupsCounter();
|
||||
|
||||
@@ -1144,7 +1144,7 @@ namespace Game.Groups
|
||||
{
|
||||
byte maxresul = 0;
|
||||
ObjectGuid maxguid = ObjectGuid.Empty;
|
||||
Player player = null;
|
||||
Player player;
|
||||
|
||||
foreach (var pair in roll.playerVote)
|
||||
{
|
||||
@@ -1205,7 +1205,7 @@ namespace Game.Groups
|
||||
{
|
||||
byte maxresul = 0;
|
||||
ObjectGuid maxguid = ObjectGuid.Empty;
|
||||
Player player = null;
|
||||
Player player;
|
||||
RollType rollVote = RollType.NotValid;
|
||||
|
||||
foreach (var pair in roll.playerVote)
|
||||
@@ -2102,7 +2102,7 @@ namespace Game.Groups
|
||||
public void ResetMaxEnchantingLevel()
|
||||
{
|
||||
m_maxEnchantingLevel = 0;
|
||||
Player member = null;
|
||||
Player member;
|
||||
foreach (var memberSlot in m_memberSlots)
|
||||
{
|
||||
member = Global.ObjAccessor.FindPlayer(memberSlot.guid);
|
||||
|
||||
@@ -783,7 +783,7 @@ namespace Game
|
||||
bool _sendFactionIncreased; //! Play visual effect on next SMSG_SET_FACTION_STANDING sent
|
||||
#endregion
|
||||
|
||||
static int[] ReputationRankThresholds =
|
||||
public static int[] ReputationRankThresholds =
|
||||
{
|
||||
-42000,
|
||||
// Hated
|
||||
@@ -803,7 +803,7 @@ namespace Game
|
||||
// Exalted
|
||||
};
|
||||
|
||||
static CypherStrings[] ReputationRankStrIndex =
|
||||
public static CypherStrings[] ReputationRankStrIndex =
|
||||
{
|
||||
CypherStrings.RepHated, CypherStrings.RepHostile, CypherStrings.RepUnfriendly, CypherStrings.RepNeutral,
|
||||
CypherStrings.RepFriendly, CypherStrings.RepHonored, CypherStrings.RepRevered, CypherStrings.RepExalted
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace WorldServer
|
||||
//- Launch CliRunnable thread
|
||||
if (ConfigMgr.GetDefaultValue("Console.Enable", true))
|
||||
{
|
||||
Thread commandThread = new Thread(CommandManager.InitConsole);
|
||||
Thread commandThread = new(CommandManager.InitConsole);
|
||||
commandThread.Start();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace WorldServer
|
||||
static bool StartDB()
|
||||
{
|
||||
// Load databases
|
||||
DatabaseLoader loader = new DatabaseLoader(DatabaseTypeFlags.All);
|
||||
DatabaseLoader loader = new(DatabaseTypeFlags.All);
|
||||
loader.AddDatabase(DB.Login, "Login");
|
||||
loader.AddDatabase(DB.Characters, "Character");
|
||||
loader.AddDatabase(DB.World, "World");
|
||||
|
||||
Reference in New Issue
Block a user