Refactoring Cleanup

This commit is contained in:
hondacrx
2020-02-03 14:42:20 -05:00
parent 2a065d22da
commit 752137af52
37 changed files with 107 additions and 157 deletions
+3 -3
View File
@@ -55,16 +55,16 @@ public class RealmManager : Singleton<RealmManager>
build.MinorVersion = result.Read<uint>(1); build.MinorVersion = result.Read<uint>(1);
build.BugfixVersion = result.Read<uint>(2); build.BugfixVersion = result.Read<uint>(2);
string hotfixVersion = result.Read<string>(3); string hotfixVersion = result.Read<string>(3);
if (hotfixVersion.Length < build.HotfixVersion.Length) if (!hotfixVersion.IsEmpty() && hotfixVersion.Length < build.HotfixVersion.Length)
build.HotfixVersion = hotfixVersion.ToCharArray(); build.HotfixVersion = hotfixVersion.ToCharArray();
build.Build = result.Read<uint>(4); build.Build = result.Read<uint>(4);
string win64AuthSeedHexStr = result.Read<string>(5); string win64AuthSeedHexStr = result.Read<string>(5);
if (win64AuthSeedHexStr.Length == build.Win64AuthSeed.Length * 2) if (!win64AuthSeedHexStr.IsEmpty() && win64AuthSeedHexStr.Length == build.Win64AuthSeed.Length * 2)
build.Win64AuthSeed = win64AuthSeedHexStr.ToByteArray(); build.Win64AuthSeed = win64AuthSeedHexStr.ToByteArray();
string mac64AuthSeedHexStr = result.Read<string>(6); string mac64AuthSeedHexStr = result.Read<string>(6);
if (mac64AuthSeedHexStr.Length == build.Mac64AuthSeed.Length * 2) if (!mac64AuthSeedHexStr.IsEmpty() && mac64AuthSeedHexStr.Length == build.Mac64AuthSeed.Length * 2)
build.Mac64AuthSeed = mac64AuthSeedHexStr.ToByteArray(); build.Mac64AuthSeed = mac64AuthSeedHexStr.ToByteArray();
_builds.Add(build); _builds.Add(build);
@@ -312,7 +312,7 @@ namespace Game.AI
UpdateEscortAI(diff); UpdateEscortAI(diff);
} }
void UpdateEscortAI(uint diff) public virtual void UpdateEscortAI(uint diff)
{ {
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
@@ -505,7 +505,7 @@ namespace Game.AI
return false; return false;
int size = WaypointList.Count; int size = WaypointList.Count;
Escort_Waypoint waypoint = new Escort_Waypoint(0, 0, 0, 0, 0); Escort_Waypoint waypoint;
do do
{ {
waypoint = WaypointList.First(); waypoint = WaypointList.First();
-11
View File
@@ -448,17 +448,6 @@ namespace Game.AI
MovepointReached(Data); MovepointReached(Data);
} }
void RemoveAuras()
{
//fixme: duplicated logic in CreatureAI._EnterEvadeMode (could use RemoveAllAurasExceptType)
foreach (var pair in me.GetAppliedAuras())
{
Aura aura = pair.Value.GetBase();
if (!aura.IsPassive() && !aura.HasEffectType(AuraType.ControlVehicle) && !aura.HasEffectType(AuraType.CloneCaster) && aura.GetCasterGUID() != me.GetGUID())
me.RemoveAura(pair);
}
}
public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other) public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other)
{ {
if (mEvadeDisabled) if (mEvadeDisabled)
+1 -1
View File
@@ -1583,7 +1583,7 @@ namespace Game.AI
if (!IsSmart()) if (!IsSmart())
break; break;
WorldObject target = null; WorldObject target;
/*if (e.GetTargetType() == SmartTargets.CreatureRange || e.GetTargetType() == SmartTargets.CreatureGuid || /*if (e.GetTargetType() == SmartTargets.CreatureRange || e.GetTargetType() == SmartTargets.CreatureGuid ||
e.GetTargetType() == SmartTargets.CreatureDistance || e.GetTargetType() == SmartTargets.GameobjectRange || e.GetTargetType() == SmartTargets.CreatureDistance || e.GetTargetType() == SmartTargets.GameobjectRange ||
+2 -6
View File
@@ -189,9 +189,7 @@ namespace Game
public AccountOpResult ChangeEmail(uint accountId, string newEmail) public AccountOpResult ChangeEmail(uint accountId, string newEmail)
{ {
string username; if (!GetName(accountId, out _))
if (!GetName(accountId, out username))
return AccountOpResult.NameNotExist; // account doesn't exist return AccountOpResult.NameNotExist; // account doesn't exist
if (newEmail.Length > MaxEmailLength) if (newEmail.Length > MaxEmailLength)
@@ -207,9 +205,7 @@ namespace Game
public AccountOpResult ChangeRegEmail(uint accountId, string newEmail) public AccountOpResult ChangeRegEmail(uint accountId, string newEmail)
{ {
string username; if (!GetName(accountId, out _))
if (!GetName(accountId, out username))
return AccountOpResult.NameNotExist; // account doesn't exist return AccountOpResult.NameNotExist; // account doesn't exist
if (newEmail.Length > MaxEmailLength) if (newEmail.Length > MaxEmailLength)
@@ -425,7 +425,7 @@ namespace Game.Achievements
SendPacket(achievementData); SendPacket(achievementData);
} }
public void SendAchievementInfo(Player receiver, uint achievementId = 0) public void SendAchievementInfo(Player receiver)
{ {
RespondInspectAchievements inspectedAchievements = new RespondInspectAchievements(); RespondInspectAchievements inspectedAchievements = new RespondInspectAchievements();
inspectedAchievements.Player = _owner.GetGUID(); inspectedAchievements.Player = _owner.GetGUID();
+3 -4
View File
@@ -79,12 +79,12 @@ namespace Game
if (!item) if (!item)
return; return;
uint bidderAccId = 0; uint bidderAccId;
ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, auction.bidder); ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, auction.bidder);
Player bidder = Global.ObjAccessor.FindPlayer(bidderGuid); Player bidder = Global.ObjAccessor.FindPlayer(bidderGuid);
// data for gm.log // data for gm.log
string bidderName = ""; string bidderName = "";
bool logGmTrade = false; bool logGmTrade;
if (bidder) if (bidder)
{ {
@@ -428,8 +428,7 @@ namespace Game
public bool RemoveAuction(AuctionEntry auction) public bool RemoveAuction(AuctionEntry auction)
{ {
Global.ScriptMgr.OnAuctionRemove(this, auction); Global.ScriptMgr.OnAuctionRemove(this, auction);
return AuctionsMap.TryRemove(auction.Id, out _);
return AuctionsMap.TryRemove(auction.Id, out AuctionEntry removedItem);
} }
public void Update() public void Update()
+2 -2
View File
@@ -1125,7 +1125,7 @@ namespace Game.BattleFields
{ {
capturePoint.SetRespawnTime(0); // not save respawn time capturePoint.SetRespawnTime(0); // not save respawn time
capturePoint.Delete(); capturePoint.Delete();
capturePoint = null; capturePoint.Dispose();
} }
m_capturePointGUID.Clear(); m_capturePointGUID.Clear();
} }
@@ -1176,7 +1176,7 @@ namespace Game.BattleFields
if (MathFunctions.fuzzyEq(fact_diff, 0.0f)) if (MathFunctions.fuzzyEq(fact_diff, 0.0f))
return false; return false;
Team Challenger = 0; Team Challenger;
float maxDiff = m_maxSpeed * diff; float maxDiff = m_maxSpeed * diff;
if (fact_diff < 0) if (fact_diff < 0)
@@ -527,7 +527,7 @@ namespace Game.BattleFields
public override void OnGameObjectCreate(GameObject go) public override void OnGameObjectCreate(GameObject go)
{ {
uint workshopId = 0; uint workshopId;
switch (go.GetEntry()) switch (go.GetEntry())
{ {
+1 -1
View File
@@ -674,7 +674,7 @@ namespace Game.BattleGrounds
SetWinner(BattlegroundTeamId.Neutral); SetWinner(BattlegroundTeamId.Neutral);
} }
PreparedStatement stmt = null; PreparedStatement stmt;
ulong battlegroundId = 1; ulong battlegroundId = 1;
if (IsBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable)) if (IsBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable))
{ {
@@ -428,7 +428,7 @@ namespace Game.BattleGrounds.Zones
return; return;
source.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.EnterPvpCombat); source.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.EnterPvpCombat);
uint sound = 0; uint sound;
// If node is neutral, change to contested // If node is neutral, change to contested
if (m_Nodes[node] == ABNodeStatus.Neutral) if (m_Nodes[node] == ABNodeStatus.Neutral)
{ {
+7 -10
View File
@@ -163,7 +163,7 @@ namespace Game.BattleGrounds.Zones
void CheckSomeoneJoinedPo() void CheckSomeoneJoinedPo()
{ {
GameObject obj = null; GameObject obj;
for (byte i = 0; i < EotSPoints.PointsMax; ++i) for (byte i = 0; i < EotSPoints.PointsMax; ++i)
{ {
obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]); obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]);
@@ -203,7 +203,8 @@ namespace Game.BattleGrounds.Zones
//reset current point counts //reset current point counts
for (byte i = 0; i < 2 * EotSPoints.PointsMax; ++i) for (byte i = 0; i < 2 * EotSPoints.PointsMax; ++i)
m_CurrentPointPlayersCount[i] = 0; m_CurrentPointPlayersCount[i] = 0;
GameObject obj = null;
GameObject obj;
for (byte i = 0; i < EotSPoints.PointsMax; ++i) for (byte i = 0; i < EotSPoints.PointsMax; ++i)
{ {
obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]); obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]);
@@ -255,7 +256,7 @@ namespace Game.BattleGrounds.Zones
//point is fully horde's //point is fully horde's
m_PointBarStatus[point] = EotSProgressBarConsts.ProgressBarHordeControlled; m_PointBarStatus[point] = EotSProgressBarConsts.ProgressBarHordeControlled;
uint pointOwnerTeamId = 0; uint pointOwnerTeamId;
//find which team should own this point //find which team should own this point
if (m_PointBarStatus[point] <= EotSProgressBarConsts.ProgressBarNeutralLow) if (m_PointBarStatus[point] <= EotSProgressBarConsts.ProgressBarNeutralLow)
pointOwnerTeamId = (uint)Team.Horde; pointOwnerTeamId = (uint)Team.Horde;
@@ -871,8 +872,7 @@ namespace Game.BattleGrounds.Zones
public override WorldSafeLocsEntry GetClosestGraveYard(Player player) public override WorldSafeLocsEntry GetClosestGraveYard(Player player)
{ {
uint g_id = 0; uint g_id;
switch (player.GetTeam()) switch (player.GetTeam())
{ {
case Team.Alliance: case Team.Alliance:
@@ -884,11 +884,8 @@ namespace Game.BattleGrounds.Zones
default: return null; default: return null;
} }
WorldSafeLocsEntry entry = null; WorldSafeLocsEntry entry = Global.ObjectMgr.GetWorldSafeLoc(g_id);
WorldSafeLocsEntry nearestEntry = null; WorldSafeLocsEntry nearestEntry = entry;
entry = Global.ObjectMgr.GetWorldSafeLoc(g_id);
nearestEntry = entry;
if (entry == null) if (entry == null)
{ {
Log.outError(LogFilter.Battleground, "BattlegroundEY: The main team graveyard could not be found. The graveyard system will not be operational!"); Log.outError(LogFilter.Battleground, "BattlegroundEY: The main team graveyard could not be found. The graveyard system will not be operational!");
@@ -702,7 +702,7 @@ namespace Game.BattleGrounds.Zones
public override WorldSafeLocsEntry GetClosestGraveYard(Player player) public override WorldSafeLocsEntry GetClosestGraveYard(Player player)
{ {
uint safeloc = 0; uint safeloc;
if (player.GetTeamId() == Attackers) if (player.GetTeamId() == Attackers)
safeloc = SAMiscConst.GYEntries[SAGraveyards.BeachGy]; safeloc = SAMiscConst.GYEntries[SAGraveyards.BeachGy];
@@ -820,9 +820,9 @@ namespace Game.BattleGrounds.Zones
} }
AddSpiritGuide(i + SACreatureTypes.Max, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), SAMiscConst.GYOrientation[i], GraveyardStatus[i]); AddSpiritGuide(i + SACreatureTypes.Max, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), SAMiscConst.GYOrientation[i], GraveyardStatus[i]);
uint npc = 0;
int flag = 0;
uint npc;
int flag;
switch (i) switch (i)
{ {
case SAGraveyards.LeftCapturableGy: case SAGraveyards.LeftCapturableGy:
+3 -7
View File
@@ -474,18 +474,14 @@ namespace Game.BattlePets
{ {
public void CalculateStats() public void CalculateStats()
{ {
float health = 0.0f;
float power = 0.0f;
float speed = 0.0f;
// get base breed stats // get base breed stats
var breedState = _battlePetBreedStates.LookupByKey(PacketInfo.Breed); var breedState = _battlePetBreedStates.LookupByKey(PacketInfo.Breed);
if (breedState == null) // non existing breed id if (breedState == null) // non existing breed id
return; return;
health = breedState[BattlePetState.StatStamina]; float health = breedState[BattlePetState.StatStamina];
power = breedState[BattlePetState.StatPower]; float power = breedState[BattlePetState.StatPower];
speed = breedState[BattlePetState.StatSpeed]; float speed = breedState[BattlePetState.StatSpeed];
// modify stats depending on species - not all pets have this // modify stats depending on species - not all pets have this
var speciesState = _battlePetSpeciesStates.LookupByKey(PacketInfo.Species); var speciesState = _battlePetSpeciesStates.LookupByKey(PacketInfo.Species);
@@ -213,12 +213,12 @@ namespace Game.BlackMarket
if (entry.GetMailSent()) if (entry.GetMailSent())
return; return;
uint bidderAccId = 0; uint bidderAccId;
ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, entry.GetBidder()); ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, entry.GetBidder());
Player bidder = Global.ObjAccessor.FindConnectedPlayer(bidderGuid); Player bidder = Global.ObjAccessor.FindConnectedPlayer(bidderGuid);
// data for gm.log // data for gm.log
string bidderName = ""; string bidderName = "";
bool logGmTrade = false; bool logGmTrade;
if (bidder) if (bidder)
{ {
+5 -12
View File
@@ -273,13 +273,11 @@ namespace Game.Chat
public string ExtractKeyFromLink(StringArguments args, params string[] linkType) public string ExtractKeyFromLink(StringArguments args, params string[] linkType)
{ {
int throwaway; return ExtractKeyFromLink(args, linkType, out _);
return ExtractKeyFromLink(args, linkType, out throwaway);
} }
public string ExtractKeyFromLink(StringArguments args, string[] linkType, out int found_idx) public string ExtractKeyFromLink(StringArguments args, string[] linkType, out int found_idx)
{ {
string throwaway; return ExtractKeyFromLink(args, linkType, out found_idx, out _);
return ExtractKeyFromLink(args, linkType, out found_idx, out throwaway);
} }
public string ExtractKeyFromLink(StringArguments args, string[] linkType, out int found_idx, out string something1) public string ExtractKeyFromLink(StringArguments args, string[] linkType, out int found_idx, out string something1)
{ {
@@ -378,14 +376,11 @@ namespace Game.Chat
} }
public bool ExtractPlayerTarget(StringArguments args, out Player player) public bool ExtractPlayerTarget(StringArguments args, out Player player)
{ {
ObjectGuid guid; return ExtractPlayerTarget(args, out player, out _, out _);
string name;
return ExtractPlayerTarget(args, out player, out guid, out name);
} }
public bool ExtractPlayerTarget(StringArguments args, out Player player, out ObjectGuid playerGuid) public bool ExtractPlayerTarget(StringArguments args, out Player player, out ObjectGuid playerGuid)
{ {
string name; return ExtractPlayerTarget(args, out player, out playerGuid, out _);
return ExtractPlayerTarget(args, out player, out playerGuid, out name);
} }
public bool ExtractPlayerTarget(StringArguments args, out Player player, out ObjectGuid playerGuid, out string playerName) public bool ExtractPlayerTarget(StringArguments args, out Player player, out ObjectGuid playerGuid, out string playerName)
@@ -496,9 +491,7 @@ namespace Game.Chat
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
// number or [name] Shift-click form |color|Htalent:talent_id, rank|h[name]|h|r // number or [name] Shift-click form |color|Htalent:talent_id, rank|h[name]|h|r
// number or [name] Shift-click form |color|Htrade:spell_id, skill_id, max_value, cur_value|h[name]|h|r // number or [name] Shift-click form |color|Htrade:spell_id, skill_id, max_value, cur_value|h[name]|h|r
int type = 0; string idS = ExtractKeyFromLink(args, spellKeys, out int type, out string param1Str);
string param1Str = null;
string idS = ExtractKeyFromLink(args, spellKeys, out type, out param1Str);
if (string.IsNullOrEmpty(idS)) if (string.IsNullOrEmpty(idS))
return 0; return 0;
+4 -3
View File
@@ -521,9 +521,10 @@ namespace Game.Chat
} }
string targetAccountName = ""; string targetAccountName = "";
uint targetAccountId = 0; uint targetAccountId;
AccountTypes targetSecurity = 0; AccountTypes targetSecurity;
uint gm = 0; uint gm;
string arg1 = args.NextString(); string arg1 = args.NextString();
string arg2 = args.NextString(); string arg2 = args.NextString();
string arg3 = args.NextString(); string arg3 = args.NextString();
+3 -5
View File
@@ -133,8 +133,7 @@ namespace Game.Chat.Commands
} }
break; break;
case BanMode.IP: case BanMode.IP:
IPAddress address; if (!IPAddress.TryParse(nameOrIP, out _))
if (!IPAddress.TryParse(nameOrIP, out address))
return false; return false;
break; break;
} }
@@ -143,7 +142,7 @@ namespace Game.Chat.Commands
switch (Global.WorldMgr.BanAccount(mode, nameOrIP, durationStr, reasonStr, author)) switch (Global.WorldMgr.BanAccount(mode, nameOrIP, durationStr, reasonStr, author))
{ {
case BanReturn.Success: case BanReturn.Success:
if (!uint.TryParse(durationStr, out uint tempValue) || tempValue > 0) if (duration > 0)
{ {
if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld)) if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld))
Global.WorldMgr.SendWorldText(CypherStrings.BanAccountYoubannedmessageWorld, author, nameOrIP, Time.secsToTimeString(Time.TimeStringToSecs(durationStr)), reasonStr); Global.WorldMgr.SendWorldText(CypherStrings.BanAccountYoubannedmessageWorld, author, nameOrIP, Time.secsToTimeString(Time.TimeStringToSecs(durationStr)), reasonStr);
@@ -654,8 +653,7 @@ namespace Game.Chat.Commands
} }
break; break;
case BanMode.IP: case BanMode.IP:
IPAddress address; if (!IPAddress.TryParse(nameOrIP, out _))
if (!IPAddress.TryParse(nameOrIP, out address))
return false; return false;
break; break;
} }
@@ -277,8 +277,7 @@ namespace Game.Chat
ObjectGuid targetGuid; ObjectGuid targetGuid;
string targetName; string targetName;
Player playerNotUsed; if (!handler.ExtractPlayerTarget(new StringArguments(playerNameStr), out _, out targetGuid, out targetName))
if (!handler.ExtractPlayerTarget(new StringArguments(playerNameStr), out playerNotUsed, out targetGuid, out targetName))
return false; return false;
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(targetGuid); CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(targetGuid);
@@ -393,11 +393,6 @@ namespace Game.Chat
[Command("info", RBACPermissions.CommandGobjectInfo)] [Command("info", RBACPermissions.CommandGobjectInfo)]
static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler) static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
{ {
uint entry = 0;
GameObjectTypes type = 0;
uint displayId = 0;
uint lootId = 0;
if (args.Empty()) if (args.Empty())
return false; return false;
@@ -405,6 +400,7 @@ namespace Game.Chat
if (param1.IsEmpty()) if (param1.IsEmpty())
return false; return false;
uint entry;
if (param1.Equals("guid")) if (param1.Equals("guid"))
{ {
string cValue = handler.ExtractKeyFromLink(args, "Hgameobject"); string cValue = handler.ExtractKeyFromLink(args, "Hgameobject");
@@ -429,10 +425,10 @@ namespace Game.Chat
if (gameObjectInfo == null) if (gameObjectInfo == null)
return false; return false;
type = gameObjectInfo.type; GameObjectTypes type = gameObjectInfo.type;
displayId = gameObjectInfo.displayId; uint displayId = gameObjectInfo.displayId;
string name = gameObjectInfo.name; string name = gameObjectInfo.name;
lootId = gameObjectInfo.GetLootId(); uint lootId = gameObjectInfo.GetLootId();
handler.SendSysMessage(CypherStrings.GoinfoEntry, entry); handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
handler.SendSysMessage(CypherStrings.GoinfoType, type); handler.SendSysMessage(CypherStrings.GoinfoType, type);
+2 -2
View File
@@ -262,8 +262,8 @@ namespace Game.Chat.Commands
return false; return false;
} }
float x, y, z = 0; float x, y, z;
uint mapId = 0; uint mapId;
var poiData = Global.ObjectMgr.GetQuestPOIData(questID); var poiData = Global.ObjectMgr.GetQuestPOIData(questID);
if (poiData != null) if (poiData != null)
+16 -19
View File
@@ -125,9 +125,9 @@ namespace Game.Chat
[Command("leader", RBACPermissions.CommandGroupLeader)] [Command("leader", RBACPermissions.CommandGroupLeader)]
static bool HandleGroupLeaderCommand(StringArguments args, CommandHandler handler) static bool HandleGroupLeaderCommand(StringArguments args, CommandHandler handler)
{ {
Player player = null; Player player;
Group group = null; Group group;
ObjectGuid guid = ObjectGuid.Empty; ObjectGuid guid;
string nameStr = args.NextString(); string nameStr = args.NextString();
if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid)) if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid))
@@ -151,12 +151,11 @@ namespace Game.Chat
[Command("disband", RBACPermissions.CommandGroupDisband)] [Command("disband", RBACPermissions.CommandGroupDisband)]
static bool HandleGroupDisbandCommand(StringArguments args, CommandHandler handler) static bool HandleGroupDisbandCommand(StringArguments args, CommandHandler handler)
{ {
Player player = null; Player player;
Group group = null; Group group;
ObjectGuid guid = ObjectGuid.Empty;
string nameStr = args.NextString(); string nameStr = args.NextString();
if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid)) if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out _))
return false; return false;
if (!group) if (!group)
@@ -172,9 +171,9 @@ namespace Game.Chat
[Command("remove", RBACPermissions.CommandGroupRemove)] [Command("remove", RBACPermissions.CommandGroupRemove)]
static bool HandleGroupRemoveCommand(StringArguments args, CommandHandler handler) static bool HandleGroupRemoveCommand(StringArguments args, CommandHandler handler)
{ {
Player player = null; Player player;
Group group = null; Group group;
ObjectGuid guid = ObjectGuid.Empty; ObjectGuid guid;
string nameStr = args.NextString(); string nameStr = args.NextString();
if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid)) if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid))
@@ -196,16 +195,14 @@ namespace Game.Chat
if (args.Empty()) if (args.Empty())
return false; return false;
Player playerSource = null; Player playerSource;
Player playerTarget = null; Player playerTarget;
Group groupSource = null; Group groupSource;
Group groupTarget = null; Group groupTarget;
ObjectGuid guidSource = ObjectGuid.Empty;
ObjectGuid guidTarget = ObjectGuid.Empty;
string nameplgrStr = args.NextString(); string nameplgrStr = args.NextString();
string nameplStr = args.NextString(); string nameplStr = args.NextString();
if (!handler.GetPlayerGroupAndGUIDByName(nameplgrStr, out playerSource, out groupSource, out guidSource, true)) if (!handler.GetPlayerGroupAndGUIDByName(nameplgrStr, out playerSource, out groupSource, out _, true))
return false; return false;
if (!groupSource) if (!groupSource)
@@ -214,7 +211,7 @@ namespace Game.Chat
return false; return false;
} }
if (!handler.GetPlayerGroupAndGUIDByName(nameplStr, out playerTarget, out groupTarget, out guidTarget, true)) if (!handler.GetPlayerGroupAndGUIDByName(nameplStr, out playerTarget, out groupTarget, out _, true))
return false; return false;
if (groupTarget || playerTarget.GetGroup() == groupSource) if (groupTarget || playerTarget.GetGroup() == groupSource)
@@ -243,7 +240,7 @@ namespace Game.Chat
ObjectGuid guidTarget; ObjectGuid guidTarget;
string nameTarget; string nameTarget;
string zoneName = ""; string zoneName = "";
string onlineState = ""; string onlineState;
// Parse the guid to uint32... // Parse the guid to uint32...
ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64()); ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64());
+2 -3
View File
@@ -99,7 +99,7 @@ namespace Game.Chat
static bool HandleGuildUninviteCommand(StringArguments args, CommandHandler handler) static bool HandleGuildUninviteCommand(StringArguments args, CommandHandler handler)
{ {
Player target; Player target;
ObjectGuid targetGuid = ObjectGuid.Empty; ObjectGuid targetGuid;
if (!handler.ExtractPlayerTarget(args, out target, out targetGuid)) if (!handler.ExtractPlayerTarget(args, out target, out targetGuid))
return false; return false;
@@ -126,8 +126,7 @@ namespace Game.Chat
Player target; Player target;
ObjectGuid targetGuid; ObjectGuid targetGuid;
string target_name; if (!handler.ExtractPlayerTarget(new StringArguments(nameStr), out target, out targetGuid, out _))
if (!handler.ExtractPlayerTarget(new StringArguments(nameStr), out target, out targetGuid, out target_name))
return false; return false;
ulong guildId = target ? target.GetGuildId() : Global.CharacterCacheStorage.GetCharacterGuildIdByGuid(targetGuid); ulong guildId = target ? target.GetGuildId() : Global.CharacterCacheStorage.GetCharacterGuildIdByGuid(targetGuid);
@@ -220,7 +220,6 @@ namespace Game.Chat
string param1 = args.NextString(); string param1 = args.NextString();
string param2 = args.NextString(); string param2 = args.NextString();
uint encounterId = 0;
Player player = null; Player player = null;
// Character name must be provided when using this from console. // Character name must be provided when using this from console.
@@ -257,7 +256,7 @@ namespace Game.Chat
return false; return false;
} }
if (!uint.TryParse(param1, out encounterId)) if (!uint.TryParse(param1, out uint encounterId))
return false; return false;
if (encounterId > map.GetInstanceScript().GetEncounterCount()) if (encounterId > map.GetInstanceScript().GetEncounterCount())
+3 -5
View File
@@ -30,10 +30,8 @@ namespace Game.Chat
[Command("player", RBACPermissions.CommandLfgPlayer, true)] [Command("player", RBACPermissions.CommandLfgPlayer, true)]
static bool HandleLfgPlayerInfoCommand(StringArguments args, CommandHandler handler) static bool HandleLfgPlayerInfoCommand(StringArguments args, CommandHandler handler)
{ {
Player target = null; Player target;
string playerName; if (!handler.ExtractPlayerTarget(args, out target))
ObjectGuid guid;
if (!handler.ExtractPlayerTarget(args, out target, out guid, out playerName))
return false; return false;
GetPlayerInfo(handler, target); GetPlayerInfo(handler, target);
@@ -46,7 +44,7 @@ namespace Game.Chat
if (args.Empty()) if (args.Empty())
return false; return false;
Player playerTarget = null; Player playerTarget;
ObjectGuid guidTarget; ObjectGuid guidTarget;
string nameTarget; string nameTarget;
+14 -16
View File
@@ -125,7 +125,7 @@ namespace Game.Chat
[CommandNonGroup("gps", RBACPermissions.CommandGps)] [CommandNonGroup("gps", RBACPermissions.CommandGps)]
static bool HandleGPSCommand(StringArguments args, CommandHandler handler) static bool HandleGPSCommand(StringArguments args, CommandHandler handler)
{ {
WorldObject obj = null; WorldObject obj;
if (!args.Empty()) if (!args.Empty())
{ {
HighGuid guidHigh = 0; HighGuid guidHigh = 0;
@@ -604,8 +604,7 @@ namespace Game.Chat
// to point where player stay (if loaded) // to point where player stay (if loaded)
WorldLocation loc; WorldLocation loc;
bool in_flight; if (!Player.LoadPositionFromDB(out loc, out _, targetGuid))
if (!Player.LoadPositionFromDB(out loc, out in_flight, targetGuid))
return false; return false;
// stop flight if need // stop flight if need
@@ -809,7 +808,7 @@ namespace Game.Chat
[CommandNonGroup("distance", RBACPermissions.CommandDistance)] [CommandNonGroup("distance", RBACPermissions.CommandDistance)]
static bool HandleGetDistanceCommand(StringArguments args, CommandHandler handler) static bool HandleGetDistanceCommand(StringArguments args, CommandHandler handler)
{ {
WorldObject obj = null; WorldObject obj;
if (!args.Empty()) if (!args.Empty())
{ {
@@ -935,10 +934,9 @@ namespace Game.Chat
[CommandNonGroup("kick", RBACPermissions.CommandKick, true)] [CommandNonGroup("kick", RBACPermissions.CommandKick, true)]
static bool Kick(StringArguments args, CommandHandler handler) static bool Kick(StringArguments args, CommandHandler handler)
{ {
Player target = null; Player target;
string playerName; string playerName;
ObjectGuid guid; if (!handler.ExtractPlayerTarget(args, out target, out _, out playerName))
if (!handler.ExtractPlayerTarget(args, out target, out guid, out playerName))
return false; return false;
if (handler.GetSession() != null && target == handler.GetSession().GetPlayer()) if (handler.GetSession() != null && target == handler.GetSession().GetPlayer())
@@ -990,7 +988,7 @@ namespace Game.Chat
if (string.IsNullOrEmpty(loc)) if (string.IsNullOrEmpty(loc))
location_str = loc; location_str = loc;
Player player = null; Player player;
ObjectGuid targetGUID; ObjectGuid targetGUID;
if (!handler.ExtractPlayerTarget(args, out player, out targetGUID)) if (!handler.ExtractPlayerTarget(args, out player, out targetGUID))
return false; return false;
@@ -1285,7 +1283,7 @@ namespace Game.Chat
Player target; Player target;
ObjectGuid targetGuid; ObjectGuid targetGuid;
string targetName; string targetName;
PreparedStatement stmt = null; PreparedStatement stmt;
// To make sure we get a target, we convert our guid to an omniversal... // To make sure we get a target, we convert our guid to an omniversal...
ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64()); ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64());
@@ -1334,7 +1332,7 @@ namespace Game.Chat
// Account data print variables // Account data print variables
string userName = handler.GetCypherString(CypherStrings.Error); string userName = handler.GetCypherString(CypherStrings.Error);
uint accId = 0; uint accId;
ulong lowguid = targetGuid.GetCounter(); ulong lowguid = targetGuid.GetCounter();
string eMail = handler.GetCypherString(CypherStrings.Error); string eMail = handler.GetCypherString(CypherStrings.Error);
string regMail = handler.GetCypherString(CypherStrings.Error); string regMail = handler.GetCypherString(CypherStrings.Error);
@@ -1362,10 +1360,10 @@ namespace Game.Chat
Class classid; Class classid;
Gender gender; Gender gender;
LocaleConstant locale = handler.GetSessionDbcLocale(); LocaleConstant locale = handler.GetSessionDbcLocale();
uint totalPlayerTime = 0; uint totalPlayerTime;
uint level = 0; uint level;
string alive = handler.GetCypherString(CypherStrings.Error); string alive = handler.GetCypherString(CypherStrings.Error);
ulong money = 0; ulong money;
uint xp = 0; uint xp = 0;
uint xptotal = 0; uint xptotal = 0;
@@ -1691,7 +1689,7 @@ namespace Game.Chat
return false; return false;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_MUTE_TIME); PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_MUTE_TIME);
string muteBy = ""; string muteBy;
if (handler.GetSession() != null) if (handler.GetSession() != null)
muteBy = handler.GetSession().GetPlayerName(); muteBy = handler.GetSession().GetPlayerName();
else else
@@ -1875,7 +1873,7 @@ namespace Game.Chat
break; break;
case MovementGeneratorType.Chase: case MovementGeneratorType.Chase:
{ {
Unit target = null; Unit target;
if (unit.IsTypeId(TypeId.Player)) if (unit.IsTypeId(TypeId.Player))
target = ((ChaseMovementGenerator<Player>)movementGenerator).Target; target = ((ChaseMovementGenerator<Player>)movementGenerator).Target;
else else
@@ -1891,7 +1889,7 @@ namespace Game.Chat
} }
case MovementGeneratorType.Follow: case MovementGeneratorType.Follow:
{ {
Unit target = null; Unit target;
if (unit.IsTypeId(TypeId.Player)) if (unit.IsTypeId(TypeId.Player))
target = ((FollowMovementGenerator<Player>)movementGenerator).Target; target = ((FollowMovementGenerator<Player>)movementGenerator).Target;
else else
+2 -4
View File
@@ -31,9 +31,8 @@ namespace Game.Chat
[Command("hp", RBACPermissions.CommandModifyHp)] [Command("hp", RBACPermissions.CommandModifyHp)]
static bool HandleModifyHPCommand(StringArguments args, CommandHandler handler) static bool HandleModifyHPCommand(StringArguments args, CommandHandler handler)
{ {
int hp, hpmax = 0;
Player target = handler.GetSelectedPlayerOrSelf(); Player target = handler.GetSelectedPlayerOrSelf();
if (CheckModifyResources(args, handler, target, out hp, out hpmax)) if (CheckModifyResources(args, handler, target, out int hp, out int hpmax))
{ {
NotifyModification(handler, target, CypherStrings.YouChangeHp, CypherStrings.YoursHpChanged, hp, hpmax); NotifyModification(handler, target, CypherStrings.YouChangeHp, CypherStrings.YoursHpChanged, hp, hpmax);
target.SetMaxHealth((uint)hpmax); target.SetMaxHealth((uint)hpmax);
@@ -390,9 +389,8 @@ namespace Game.Chat
if (!uint.TryParse(factionTxt, out uint factionId)) if (!uint.TryParse(factionTxt, out uint factionId))
return false; return false;
int amount = 0;
string rankTxt = args.NextString(); string rankTxt = args.NextString();
if (factionId == 0 || !int.TryParse(rankTxt, out amount)) if (factionId == 0 || !int.TryParse(rankTxt, out int amount))
return false; return false;
if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber()) if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber())
+3 -3
View File
@@ -113,7 +113,7 @@ namespace Game.Chat
[Command("move", RBACPermissions.CommandNpcMove)] [Command("move", RBACPermissions.CommandNpcMove)]
static bool Move(StringArguments args, CommandHandler handler) static bool Move(StringArguments args, CommandHandler handler)
{ {
ulong lowguid = 0; ulong lowguid;
Creature creature = handler.GetSelectedCreature(); Creature creature = handler.GetSelectedCreature();
if (!creature) if (!creature)
@@ -812,7 +812,7 @@ namespace Game.Chat
if (string.IsNullOrEmpty(guid_str)) if (string.IsNullOrEmpty(guid_str))
return false; return false;
ulong lowguid = 0; ulong lowguid;
Creature creature = null; Creature creature = null;
if (!string.IsNullOrEmpty(dontdel_str)) if (!string.IsNullOrEmpty(dontdel_str))
@@ -980,7 +980,7 @@ namespace Game.Chat
mtype = MovementGeneratorType.Random; mtype = MovementGeneratorType.Random;
Creature creature = handler.GetSelectedCreature(); Creature creature = handler.GetSelectedCreature();
ulong guidLow = 0; ulong guidLow;
if (creature) if (creature)
guidLow = creature.GetSpawnId(); guidLow = creature.GetSpawnId();
+1 -1
View File
@@ -225,7 +225,7 @@ namespace Game.Chat.Commands
string param3 = args.NextString(); string param3 = args.NextString();
int realmId = -1; int realmId = -1;
uint accountId = 0; uint accountId;
string accountName; string accountName;
uint id = 0; uint id = 0;
RBACData rdata = null; RBACData rdata = null;
+1 -2
View File
@@ -118,8 +118,7 @@ namespace Game.Chat.Commands
return false; return false;
} }
uint itemCount = 0; if (string.IsNullOrEmpty(itemCountStr) || !uint.TryParse(itemCountStr, out uint itemCount))
if (string.IsNullOrEmpty(itemCountStr) || !uint.TryParse(itemCountStr, out itemCount))
itemCount = 1; itemCount = 1;
if (itemCount < 1 || (item_proto.GetMaxCount() > 0 && itemCount > item_proto.GetMaxCount())) if (itemCount < 1 || (item_proto.GetMaxCount() > 0 && itemCount > item_proto.GetMaxCount()))
+1 -1
View File
@@ -115,7 +115,7 @@ namespace Game.Chat
uint playerAmountLimit = Global.WorldMgr.GetPlayerAmountLimit(); uint playerAmountLimit = Global.WorldMgr.GetPlayerAmountLimit();
AccountTypes allowedAccountType = Global.WorldMgr.GetPlayerSecurityLimit(); AccountTypes allowedAccountType = Global.WorldMgr.GetPlayerSecurityLimit();
string secName = ""; string secName;
switch (allowedAccountType) switch (allowedAccountType)
{ {
case AccountTypes.Player: case AccountTypes.Player:
+1 -1
View File
@@ -440,7 +440,7 @@ namespace Game.Chat.Commands
} }
// Get security level of player, whom this ticket is assigned to // Get security level of player, whom this ticket is assigned to
AccountTypes security = AccountTypes.Player; AccountTypes security;
Player assignedPlayer = ticket.GetAssignedPlayer(); Player assignedPlayer = ticket.GetAssignedPlayer();
if (assignedPlayer && assignedPlayer.IsInWorld) if (assignedPlayer && assignedPlayer.IsInWorld)
security = assignedPlayer.GetSession().GetSecurity(); security = assignedPlayer.GetSession().GetSecurity();
+3 -3
View File
@@ -33,7 +33,7 @@ namespace Game.Chat.Commands
{ {
// optional // optional
string path_number = null; string path_number = null;
uint pathid = 0; uint pathid;
if (!args.Empty()) if (!args.Empty())
path_number = args.NextString(); path_number = args.NextString();
@@ -108,7 +108,7 @@ namespace Game.Chat.Commands
return false; return false;
string arg_id = args.NextString(); string arg_id = args.NextString();
uint id = 0; uint id;
if (show == "add") if (show == "add")
{ {
if (!uint.TryParse(arg_id, out id)) if (!uint.TryParse(arg_id, out id))
@@ -624,7 +624,7 @@ namespace Game.Chat.Commands
// second arg: GUID (optional, if a creature is selected) // second arg: GUID (optional, if a creature is selected)
string guid_str = args.NextString(); string guid_str = args.NextString();
uint pathid = 0; uint pathid;
Creature target = handler.GetSelectedCreature(); Creature target = handler.GetSelectedCreature();
// Did player provide a PathID? // Did player provide a PathID?
+3 -3
View File
@@ -324,7 +324,7 @@ namespace Game.Collision
public bool GetObjectHitPos(Vector3 pPos1, Vector3 pPos2, out Vector3 pResultHitPos, float pModifyDist) public bool GetObjectHitPos(Vector3 pPos1, Vector3 pPos2, out Vector3 pResultHitPos, float pModifyDist)
{ {
bool result = false; bool result;
float maxDist = (pPos2 - pPos1).magnitude(); float maxDist = (pPos2 - pPos1).magnitude();
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too // valid map coords should *never ever* produce float overflow, but this would produce NaNs too
Cypher.Assert(maxDist < float.MaxValue); Cypher.Assert(maxDist < float.MaxValue);
@@ -344,7 +344,7 @@ namespace Game.Collision
{ {
if ((pResultHitPos - pPos1).magnitude() > -pModifyDist) if ((pResultHitPos - pPos1).magnitude() > -pModifyDist)
{ {
pResultHitPos = pResultHitPos + dir * pModifyDist; pResultHitPos += dir * pModifyDist;
} }
else else
{ {
@@ -353,7 +353,7 @@ namespace Game.Collision
} }
else else
{ {
pResultHitPos = pResultHitPos + dir * pModifyDist; pResultHitPos += dir * pModifyDist;
} }
result = true; result = true;
} }
@@ -196,7 +196,6 @@ namespace Game.Collision
void SetLiquidData(WmoLiquid liquid) void SetLiquidData(WmoLiquid liquid)
{ {
iLiquid = liquid; iLiquid = liquid;
liquid = null;
} }
public bool ReadFromFile(BinaryReader reader) public bool ReadFromFile(BinaryReader reader)
@@ -861,7 +861,7 @@ namespace Scripts.Northrend.IcecrownCitadel
} }
} }
void UpdateEscortAI(uint diff) public override void UpdateEscortAI(uint diff)
{ {
if (_wipeCheckTimer <= diff) if (_wipeCheckTimer <= diff)
_wipeCheckTimer = 0; _wipeCheckTimer = 0;
@@ -1029,7 +1029,7 @@ namespace Scripts.Northrend.IcecrownCitadel
{ {
IsUndead = true; IsUndead = true;
me.SetDeathState(DeathState.JustRespawned); me.SetDeathState(DeathState.JustRespawned);
uint newEntry = 0; uint newEntry;
switch (me.GetEntry()) switch (me.GetEntry())
{ {
case CreatureIds.CaptainArnath: case CreatureIds.CaptainArnath:
@@ -1367,7 +1367,7 @@ namespace Scripts.Northrend.IcecrownCitadel
_events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(1000, 6000)); _events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(1000, 6000));
} }
void Update(uint diff) public override void UpdateAI(uint diff)
{ {
if (_events.Empty()) if (_events.Empty())
return; return;
@@ -1427,7 +1427,7 @@ namespace Scripts.Northrend.IcecrownCitadel
void HandleEvent(uint effIndex) void HandleEvent(uint effIndex)
{ {
PreventHitDefaultEffect(effIndex); PreventHitDefaultEffect(effIndex);
uint trapId = 0; uint trapId;
switch (GetSpellInfo().GetEffect(effIndex).MiscValue) switch (GetSpellInfo().GetEffect(effIndex).MiscValue)
{ {
case AwakenWard1: case AwakenWard1:
+1 -2
View File
@@ -983,8 +983,7 @@ namespace Scripts.World.NpcSpecial
if (Coordinates.Empty()) if (Coordinates.Empty())
return; return;
uint patientEntry = 0; uint patientEntry;
switch (me.GetEntry()) switch (me.GetEntry())
{ {
case CreatureIds.DoctorAlliance: case CreatureIds.DoctorAlliance: