Some code cleanup.

This commit is contained in:
H0zen 2017-06-06 02:41:26 +03:00 committed by Antz
parent d5f638b8c8
commit 65229fcf4e
32 changed files with 107 additions and 91 deletions

View file

@ -545,9 +545,9 @@ class Creature : public Unit
bool IsGuard() const { return (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_GUARD) != 0; }
bool CanWalk() const { return (GetCreatureInfo()->InhabitType & INHABIT_GROUND) != 0; }
bool CanSwim() const { return (GetCreatureInfo()->InhabitType & INHABIT_WATER) != 0; }
virtual bool CanSwim() const override { return (GetCreatureInfo()->InhabitType & INHABIT_WATER) != 0; }
bool IsSwimming() const { return (m_movementInfo.HasMovementFlag((MovementFlags)(MOVEFLAG_SWIMMING))); }
bool CanFly() const { return (GetCreatureInfo()->InhabitType & INHABIT_AIR) || (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE1_FLAG_FLY_ANIM) || m_movementInfo.HasMovementFlag((MovementFlags)(MOVEFLAG_LEVITATING | MOVEFLAG_CAN_FLY)); }
virtual bool CanFly() const override { return (GetCreatureInfo()->InhabitType & INHABIT_AIR) || (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE1_FLAG_FLY_ANIM) || m_movementInfo.HasMovementFlag((MovementFlags)(MOVEFLAG_LEVITATING | MOVEFLAG_CAN_FLY)); }
bool IsFlying() const { return (m_movementInfo.HasMovementFlag((MovementFlags)(MOVEFLAG_FLYING | MOVEFLAG_LEVITATING))); }
bool IsTrainerOf(Player* player, bool msg) const;
@ -590,7 +590,7 @@ class Creature : public Unit
CreatureAI* AI() { return i_AI; }
void SetWalk(bool enable, bool asDefault = true);
void SetLevitate(bool enable);
void SetLevitate(bool enable) override;
void SetSwim(bool enable) override;
void SetCanFly(bool enable) override;
void SetFeatherFall(bool enable) override;

View file

@ -381,7 +381,7 @@ struct CreatureAIFactory : public SelectableAI
CreatureAI* Create(void*) const override;
int Permit(const Creature* c) const { return REAL_AI::Permissible(c); }
virtual int Permit(const Creature* c) const override { return REAL_AI::Permissible(c); }
};
enum Permitions

View file

@ -639,7 +639,7 @@ class CreatureEventAI : public CreatureAI
void GetAIInformation(ChatHandler& reader) override;
void JustRespawned() override;
void Reset();
void Reset() override;
void JustReachedHome() override;
void EnterCombat(Unit* enemy) override;
void EnterEvadeMode() override;

View file

@ -824,7 +824,7 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi
// only rogue have skill for traps detection
if (Aura* aura = ((Player*)u)->GetAura(2836, EFFECT_INDEX_0))
{
if (roll_chance_i(aura->GetModifier()->m_amount) && u->isInFront(this, 15.0f))
if (roll_chance_i(aura->GetModifier()->m_amount) && u->IsInFront(this, 15.0f))
return true;
}
@ -1196,7 +1196,7 @@ void GameObject::Use(Unit* user)
bool IsBattleGroundTrap = !radius && goInfo->trap.cooldown == 3 && m_respawnTime == 0;
// FIXME: when GO casting will be implemented trap must cast spell to target
if (spellId = goInfo->trap.spellId)
if ((spellId = goInfo->trap.spellId))
caster->CastSpell(user, spellId, true, NULL, NULL, GetObjectGuid());
// use template cooldown if provided
m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));

View file

@ -727,7 +727,7 @@ class GameObject : public WorldObject
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
void SetDisplayId(uint32 modelId);
void SetPhaseMask(uint32 newPhaseMask, bool update);
void SetPhaseMask(uint32 newPhaseMask, bool update) override;
float GetObjectBoundingRadius() const override; // overwrite WorldObject version

View file

@ -792,7 +792,7 @@ void Guild::SwitchRank(uint32 rankId, bool up)
if (rankId >= m_Ranks.size())
return;
if (rankId == GR_GUILDMASTER && up || rankId == GetLowestRank() && !up)
if ((rankId == GR_GUILDMASTER && up) || (rankId == GetLowestRank() && !up))
return;
uint32 otherRankId = rankId + (up ? -1 : 1);

View file

@ -287,7 +287,7 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const
if (group && type == LOOT_ITEM_TYPE_CURRENCY)
{
sLog.outErrorDb("Table '%s' entry %d currency %d: group is set, but currencies must not have group - skipped", store.GetName(), entry, itemid, group, 1 << 7);
sLog.outErrorDb("Table '%s' entry %d currency %d: has group %u, but currencies must not have group - skipped", store.GetName(), entry, itemid, group);
return false;
}

View file

@ -1431,22 +1431,22 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
return ((angle >= lborder) && (angle <= rborder));
}
bool WorldObject::isInFrontInMap(WorldObject const* target, float distance, float arc) const
bool WorldObject::IsInFrontInMap(WorldObject const* target, float distance, float arc) const
{
return IsWithinDistInMap(target, distance) && HasInArc(arc, target);
}
bool WorldObject::isInBackInMap(WorldObject const* target, float distance, float arc) const
bool WorldObject::IsInBackInMap(WorldObject const* target, float distance, float arc) const
{
return IsWithinDistInMap(target, distance) && !HasInArc(2 * M_PI_F - arc, target);
}
bool WorldObject::isInFront(WorldObject const* target, float distance, float arc) const
bool WorldObject::IsInFront(WorldObject const* target, float distance, float arc) const
{
return IsWithinDist(target, distance) && HasInArc(arc, target);
}
bool WorldObject::isInBack(WorldObject const* target, float distance, float arc) const
bool WorldObject::IsInBack(WorldObject const* target, float distance, float arc) const
{
return IsWithinDist(target, distance) && !HasInArc(2 * M_PI_F - arc, target);
}

View file

@ -601,10 +601,10 @@ class WorldObject : public Object
float GetAngle(const WorldObject* obj) const;
float GetAngle(const float x, const float y) const;
bool HasInArc(const float arcangle, const WorldObject* obj) const;
bool isInFrontInMap(WorldObject const* target, float distance, float arc = M_PI) const;
bool isInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const;
bool isInFront(WorldObject const* target, float distance, float arc = M_PI) const;
bool isInBack(WorldObject const* target, float distance, float arc = M_PI) const;
bool IsInFrontInMap(WorldObject const* target, float distance, float arc = M_PI) const;
bool IsInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const;
bool IsInFront(WorldObject const* target, float distance, float arc = M_PI) const;
bool IsInBack(WorldObject const* target, float distance, float arc = M_PI) const;
virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units

View file

@ -25,11 +25,11 @@
#ifndef MANGOS_OBJECT_GUID_H
#define MANGOS_OBJECT_GUID_H
#include <functional>
#include "Common.h"
#include "ByteBuffer.h"
#include <functional>
enum TypeID
{
TYPEID_OBJECT = 0,

View file

@ -162,7 +162,7 @@ class Pet : public Creature
void SetDeathState(DeathState s) override; // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
void Update(uint32 update_diff, uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update
uint8 GetPetAutoSpellSize() const { return m_autospells.size(); }
virtual uint8 GetPetAutoSpellSize() const override { return m_autospells.size(); }
uint32 GetPetAutoSpellOnPos(uint8 pos) const override
{
if (pos >= m_autospells.size())
@ -171,7 +171,7 @@ class Pet : public Creature
return m_autospells[pos];
}
bool CanSwim() const
virtual bool CanSwim() const override
{
Unit const* owner = GetOwner();
if (owner)
@ -290,7 +290,7 @@ class Pet : public Creature
void ResetAuraUpdateMask() { m_auraUpdateMask = 0; }
// overwrite Creature function for name localization back to WorldObject version without localization
const char* GetNameForLocaleIdx(int32 locale_idx) const { return WorldObject::GetNameForLocaleIdx(locale_idx); }
virtual const char* GetNameForLocaleIdx(int32 locale_idx) const override { return WorldObject::GetNameForLocaleIdx(locale_idx); }
DeclinedName const* GetDeclinedNames() const { return m_declinedname; }

View file

@ -5609,7 +5609,7 @@ bool Player::UpdateCraftSkill(uint32 spellid)
uint32 craft_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_CRAFTING);
if (!_spell_idx->second->characterPoints)
sLog.outError("Player::UpdateCraftSkill spell %u has characterPoints == 0!");
sLog.outError("Player::UpdateCraftSkill spell %u has characterPoints == 0!", spellid);
else
craft_skill_gain += _spell_idx->second->characterPoints - 1;
@ -17133,7 +17133,7 @@ DungeonPersistentState* Player::GetBoundInstanceSaveForSelfOrGroup(uint32 mapid)
InstanceGroupBind* groupBind = NULL;
// use the player's difficulty setting (it may not be the same as the group's)
if (Group* group = GetGroup())
if (groupBind = group->GetBoundInstance(mapid, this))
if ((groupBind = group->GetBoundInstance(mapid, this)))
state = groupBind->state;
}
@ -20527,7 +20527,7 @@ void Player::SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaLockS
case AREA_LOCKSTATUS_QUEST_NOT_COMPLETED:
if (mapEntry->MapID == 269) // Exception for Black Morass
{
GetSession()->SendAreaTriggerMessage(GetSession()->GetMangosString(LANG_TELEREQ_QUEST_BLACK_MORASS));
GetSession()->SendAreaTriggerMessage("%s", GetSession()->GetMangosString(LANG_TELEREQ_QUEST_BLACK_MORASS));
break;
}
else if (mapEntry->IsContinent()) // do not report anything for quest areatrigge

View file

@ -2412,8 +2412,8 @@ class Player : public Unit
bool isMoving() const { return m_movementInfo.HasMovementFlag(movementFlagsMask); }
bool isMovingOrTurning() const { return m_movementInfo.HasMovementFlag(movementOrTurningFlagsMask); }
bool CanSwim() const { return true; }
bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_CAN_FLY); }
virtual bool CanSwim() const override { return true; }
virtual bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEFLAG_CAN_FLY); }
bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING); }
bool IsFreeFlying() const { return HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED) || HasAuraType(SPELL_AURA_FLY); }
bool CanStartFlyInArea(uint32 mapid, uint32 zone, uint32 area) const;

View file

@ -247,11 +247,10 @@ inline bool IsLootCraftingSpell(SpellEntry const* spellInfo)
SpellTotemsEntry const* totems = spellInfo->GetSpellTotems();
return spellEffect0->Effect == SPELL_EFFECT_CREATE_RANDOM_ITEM ||
return ((spellEffect0->Effect == SPELL_EFFECT_CREATE_RANDOM_ITEM) ||
// different random cards from Inscription (121==Virtuoso Inking Set category) or without explicit item or explicit spells
spellEffect0->Effect == SPELL_EFFECT_CREATE_ITEM_2 &&
(totems && totems->TotemCategory[0] != 0 || spellEffect0->EffectItemType == 0) ||
spellInfo->Id == 62941;
((spellEffect0->Effect == SPELL_EFFECT_CREATE_ITEM_2) && ((totems && totems->TotemCategory[0] != 0) || (spellEffect0->EffectItemType == 0))) ||
(spellInfo->Id == 62941));
}
int32 CompareAuraRanks(uint32 spellId_1, uint32 spellId_2);

View file

@ -8859,7 +8859,7 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
float visibleDistance = (u->GetTypeId() == TYPEID_PLAYER) ? MAX_PLAYER_STEALTH_DETECT_RANGE : ((Creature const*)u)->GetAttackDistance(this);
// Always invisible from back (when stealth detection is on), also filter max distance cases
bool isInFront = viewPoint->isInFrontInMap(this, visibleDistance);
bool isInFront = viewPoint->IsInFrontInMap(this, visibleDistance);
if (!isInFront)
return false;