mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-04 11:33:48 +00:00
refactor(Core): code cleanup (part 2) (#6374)
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include "Common.h"
|
||||
#include "Corpse.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "GossipDef.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
|
||||
@@ -14,23 +14,18 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Formulas.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "GroupMgr.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
#include "LootMgr.h"
|
||||
#include "MapManager.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "OutdoorPvPMgr.h"
|
||||
#include "Player.h"
|
||||
#include "PoolMgr.h"
|
||||
#include "QuestDef.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellMgr.h"
|
||||
@@ -42,6 +37,11 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
// TODO: this import is not necessary for compilation and marked as unused by the IDE
|
||||
// however, for some reasons removing it would cause a damn linking issue
|
||||
// there is probably some underlying problem with imports which should properly addressed
|
||||
#include "GridNotifiersImpl.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
@@ -553,7 +553,7 @@ void Creature::Update(uint32 diff)
|
||||
time_t now = time(nullptr);
|
||||
if (m_respawnTime <= now)
|
||||
{
|
||||
bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
|
||||
bool allowed = !IsAIEnabled || AI()->CanRespawn(); // First check if there are any scripts that object to us respawning
|
||||
if (!allowed) // Will be rechecked on next Update call
|
||||
break;
|
||||
|
||||
@@ -1899,7 +1899,7 @@ void Creature::InitializeReactState()
|
||||
else
|
||||
SetReactState(REACT_AGGRESSIVE);
|
||||
/*else if (IsCivilian())
|
||||
SetReactState(REACT_DEFENSIVE);*/;
|
||||
SetReactState(REACT_DEFENSIVE);*/
|
||||
}
|
||||
|
||||
bool Creature::HasMechanicTemplateImmunity(uint32 mask) const
|
||||
@@ -3154,7 +3154,7 @@ bool Creature::IsMovementPreventedByCasting() const
|
||||
{
|
||||
Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL];
|
||||
// first check if currently a movement allowed channel is active and we're not casting
|
||||
if (!!spell && spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive() && spell->GetSpellInfo()->IsMoveAllowedChannel())
|
||||
if (spell && spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive() && spell->GetSpellInfo()->IsMoveAllowedChannel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#include "QuestDef.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "Formulas.h"
|
||||
#include "Player.h"
|
||||
|
||||
GossipMenu::GossipMenu()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -282,11 +281,11 @@ void Minion::InitStats(uint32 duration)
|
||||
|
||||
SetReactState(REACT_PASSIVE);
|
||||
|
||||
Unit* m_owner = GetOwner();
|
||||
SetCreatorGUID(m_owner->GetGUID());
|
||||
setFaction(m_owner->getFaction());
|
||||
Unit* owner = GetOwner();
|
||||
SetCreatorGUID(owner->GetGUID());
|
||||
setFaction(owner->getFaction());
|
||||
|
||||
m_owner->SetMinion(this, true);
|
||||
owner->SetMinion(this, true);
|
||||
}
|
||||
|
||||
void Minion::RemoveFromWorld()
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#include "CellImpl.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "ObjectAccessor.h"
|
||||
|
||||
@@ -292,10 +292,10 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
|
||||
|
||||
SetObjectScale(goinfo->size);
|
||||
|
||||
if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
|
||||
if (GameObjectTemplateAddon const* templateAddon = GetTemplateAddon())
|
||||
{
|
||||
SetUInt32Value(GAMEOBJECT_FACTION, addon->faction);
|
||||
SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags);
|
||||
SetUInt32Value(GAMEOBJECT_FACTION, templateAddon->faction);
|
||||
SetUInt32Value(GAMEOBJECT_FLAGS, templateAddon->flags);
|
||||
}
|
||||
|
||||
SetEntry(goinfo->entry);
|
||||
@@ -2432,12 +2432,13 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
|
||||
}
|
||||
else if (index == GAMEOBJECT_FLAGS)
|
||||
{
|
||||
uint32 flags = m_uint32Values[GAMEOBJECT_FLAGS];
|
||||
if (GetGoType() == GAMEOBJECT_TYPE_CHEST)
|
||||
if (GetGOInfo()->chest.groupLootRules && !IsLootAllowedFor(target))
|
||||
flags |= GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE;
|
||||
uint32 goFlags = m_uint32Values[GAMEOBJECT_FLAGS];
|
||||
if (GetGoType() == GAMEOBJECT_TYPE_CHEST && GetGOInfo() && GetGOInfo()->chest.groupLootRules && !IsLootAllowedFor(target))
|
||||
{
|
||||
goFlags |= GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE;
|
||||
}
|
||||
|
||||
fieldBuffer << flags;
|
||||
fieldBuffer << goFlags;
|
||||
}
|
||||
else
|
||||
fieldBuffer << m_uint32Values[index]; // other cases
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
#include "Bag.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
void AddItemsSetItem(Player* player, Item* item)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Util.h"
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include "DynamicTree.h"
|
||||
#include "DynamicVisibility.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
#include "Log.h"
|
||||
#include "MapManager.h"
|
||||
#include "MovementPacketBuilder.h"
|
||||
@@ -37,11 +35,14 @@
|
||||
#include "UpdateMask.h"
|
||||
#include "Util.h"
|
||||
#include "Vehicle.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "WaypointMovementGenerator.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
// TODO: this import is not necessary for compilation and marked as unused by the IDE
|
||||
// however, for some reasons removing it would cause a damn linking issue
|
||||
// there is probably some underlying problem with imports which should properly addressed
|
||||
#include "GridNotifiersImpl.h"
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "ElunaEventMgr.h"
|
||||
#include "LuaEngine.h"
|
||||
@@ -2740,7 +2741,7 @@ Position WorldObject::GetFirstCollisionPosition(float startX, float startY, floa
|
||||
|
||||
MovePositionToFirstCollision(pos, distance, ang);
|
||||
return pos;
|
||||
};
|
||||
}
|
||||
|
||||
Position WorldObject::GetFirstCollisionPosition(float destX, float destY, float destZ)
|
||||
{
|
||||
@@ -2755,7 +2756,7 @@ Position WorldObject::GetFirstCollisionPosition(float destX, float destY, float
|
||||
|
||||
MovePositionToFirstCollision(pos, distance, ang);
|
||||
return pos;
|
||||
};
|
||||
}
|
||||
|
||||
Position WorldObject::GetFirstCollisionPosition(float dist, float angle)
|
||||
{
|
||||
|
||||
@@ -630,7 +630,7 @@ struct MovementInfo
|
||||
void AddExtraMovementFlag(uint16 flag) { flags2 |= flag; }
|
||||
[[nodiscard]] bool HasExtraMovementFlag(uint16 flag) const { return flags2 & flag; }
|
||||
|
||||
void SetFallTime(uint32 time) { fallTime = time; }
|
||||
void SetFallTime(uint32 newFallTime) { fallTime = newFallTime; }
|
||||
|
||||
void OutDebug();
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "UpdateData.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "Common.h"
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "Common.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Formulas.h"
|
||||
#include "Group.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
@@ -192,8 +191,10 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui
|
||||
stmt->setUInt8(2, uint8(PET_SAVE_LAST_STABLE_SLOT));
|
||||
}
|
||||
|
||||
if (AsynchPetSummon* info = owner->GetSession()->_loadPetFromDBFirstCallback.GetSecondParam())
|
||||
delete info;
|
||||
if (AsynchPetSummon* infoToDelete = owner->GetSession()->_loadPetFromDBFirstCallback.GetSecondParam())
|
||||
{
|
||||
delete infoToDelete;
|
||||
}
|
||||
|
||||
owner->GetSession()->_loadPetFromDBFirstCallback.Reset();
|
||||
owner->GetSession()->_loadPetFromDBFirstCallback.SetFirstParam(asynchLoadType);
|
||||
@@ -1402,24 +1403,24 @@ void Pet::_SaveAuras(SQLTransaction& trans, bool logout)
|
||||
|
||||
uint8 index = 0;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA);
|
||||
stmt->setUInt32(index++, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt64(index++, casterGUID.GetRawValue());
|
||||
stmt->setUInt32(index++, itr->second->GetId());
|
||||
stmt->setUInt8(index++, effMask);
|
||||
stmt->setUInt8(index++, recalculateMask);
|
||||
stmt->setUInt8(index++, itr->second->GetStackAmount());
|
||||
stmt->setInt32(index++, damage[0]);
|
||||
stmt->setInt32(index++, damage[1]);
|
||||
stmt->setInt32(index++, damage[2]);
|
||||
stmt->setInt32(index++, baseDamage[0]);
|
||||
stmt->setInt32(index++, baseDamage[1]);
|
||||
stmt->setInt32(index++, baseDamage[2]);
|
||||
stmt->setInt32(index++, itr->second->GetMaxDuration());
|
||||
stmt->setInt32(index++, itr->second->GetDuration());
|
||||
stmt->setUInt8(index++, itr->second->GetCharges());
|
||||
PreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA);
|
||||
stmt2->setUInt32(index++, m_charmInfo->GetPetNumber());
|
||||
stmt2->setUInt64(index++, casterGUID.GetRawValue());
|
||||
stmt2->setUInt32(index++, itr->second->GetId());
|
||||
stmt2->setUInt8(index++, effMask);
|
||||
stmt2->setUInt8(index++, recalculateMask);
|
||||
stmt2->setUInt8(index++, itr->second->GetStackAmount());
|
||||
stmt2->setInt32(index++, damage[0]);
|
||||
stmt2->setInt32(index++, damage[1]);
|
||||
stmt2->setInt32(index++, damage[2]);
|
||||
stmt2->setInt32(index++, baseDamage[0]);
|
||||
stmt2->setInt32(index++, baseDamage[1]);
|
||||
stmt2->setInt32(index++, baseDamage[2]);
|
||||
stmt2->setInt32(index++, itr->second->GetMaxDuration());
|
||||
stmt2->setInt32(index++, itr->second->GetDuration());
|
||||
stmt2->setUInt8(index++, itr->second->GetCharges());
|
||||
|
||||
trans->Append(stmt);
|
||||
trans->Append(stmt2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4229,8 +4229,10 @@ void Player::removeSpell(uint32 spellId, uint8 removeSpecMask, bool onlyTemporar
|
||||
if (GetTalentSpellCost(firstRankSpellId))
|
||||
{
|
||||
SpellsRequiringSpellMapBounds spellsRequiringSpell = sSpellMgr->GetSpellsRequiringSpellBounds(spellId);
|
||||
for (SpellsRequiringSpellMap::const_iterator itr = spellsRequiringSpell.first; itr != spellsRequiringSpell.second; ++itr)
|
||||
removeSpell(itr->second, removeSpecMask, onlyTemporary);
|
||||
for (auto spellsItr = spellsRequiringSpell.first; spellsItr != spellsRequiringSpell.second; ++spellsItr)
|
||||
{
|
||||
removeSpell(spellsItr->second, removeSpecMask, onlyTemporary);
|
||||
}
|
||||
}
|
||||
|
||||
// pussywizard: re-search, it can be corrupted in prev loop
|
||||
@@ -7732,12 +7734,14 @@ uint32 Player::GetZoneIdFromDB(ObjectGuid guid)
|
||||
// stored zone is zero, use generic and slow zone detection
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_POSITION_XYZ);
|
||||
stmt->setUInt32(0, guidLow);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
PreparedQueryResult posResult = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
if (!posResult)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fields = result->Fetch();
|
||||
fields = posResult->Fetch();
|
||||
uint32 map = fields[0].GetUInt16();
|
||||
float posx = fields[1].GetFloat();
|
||||
float posy = fields[2].GetFloat();
|
||||
@@ -19073,9 +19077,11 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff)
|
||||
}
|
||||
else if (invalidBagMap.find(bagGuid) != invalidBagMap.end())
|
||||
{
|
||||
std::map<ObjectGuid::LowType, Item*>::iterator itr = invalidBagMap.find(bagGuid);
|
||||
if (std::find(problematicItems.begin(), problematicItems.end(), itr->second) != problematicItems.end())
|
||||
std::map<ObjectGuid::LowType, Item*>::iterator iterator = invalidBagMap.find(bagGuid);
|
||||
if (std::find(problematicItems.begin(), problematicItems.end(), iterator->second) != problematicItems.end())
|
||||
{
|
||||
err = EQUIP_ERR_INT_BAG_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
#include "Group.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "Vehicle.h"
|
||||
#include "World.h"
|
||||
#include "WorldModel.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
MotionTransport::MotionTransport() : Transport(), _transportInfo(nullptr), _isMoving(true), _pendingStop(false), _triggeredArrivalEvent(false), _triggeredDepartureEvent(false), _passengersLoaded(false), _delayedTeleport(false)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Unit.h"
|
||||
|
||||
|
||||
@@ -960,8 +960,8 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
|
||||
// Rage from damage received
|
||||
if (attacker != victim && victim->getPowerType() == POWER_RAGE)
|
||||
{
|
||||
uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
|
||||
victim->RewardRage(rage_damage, 0, false);
|
||||
uint32 rageDamage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
|
||||
victim->RewardRage(rageDamage, 0, false);
|
||||
}
|
||||
|
||||
if (attacker && attacker->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -2209,7 +2209,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr
|
||||
return;
|
||||
|
||||
// CombatStart puts the target into stand state, so we need to cache sit state here to know if we should crit later
|
||||
const bool sittingVictim = victim->GetTypeId() == TYPEID_PLAYER && (victim->IsSitState() || victim->getStandState() == UNIT_STAND_STATE_SLEEP) ? true : false;
|
||||
const bool sittingVictim = victim->GetTypeId() == TYPEID_PLAYER && (victim->IsSitState() || victim->getStandState() == UNIT_STAND_STATE_SLEEP);
|
||||
|
||||
CombatStart(victim);
|
||||
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MELEE_ATTACK);
|
||||
@@ -11272,8 +11272,8 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
|
||||
{
|
||||
int32 modifierMax = 0;
|
||||
int32 modifierMin = 0;
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
AuraEffectList const& auraEffectList = GetAuraEffectsByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = auraEffectList.begin(); i != auraEffectList.end(); ++i)
|
||||
{
|
||||
if (!spellProto->ValidateAttribute6SpellDamageMods(caster, *i, damagetype == DOT))
|
||||
continue;
|
||||
@@ -18099,9 +18099,9 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
|
||||
if (Target->IsAlive())
|
||||
TagUnitMap.push_back(Target);
|
||||
|
||||
for (Unit::ControlSet::iterator itr = Target->m_Controlled.begin(); itr != Target->m_Controlled.end(); ++itr)
|
||||
for (Unit::ControlSet::iterator iterator = Target->m_Controlled.begin(); iterator != Target->m_Controlled.end(); ++iterator)
|
||||
{
|
||||
if (Unit* pet = *itr)
|
||||
if (Unit* pet = *iterator)
|
||||
if (pet->IsGuardian() && pet->IsAlive())
|
||||
TagUnitMap.push_back(pet);
|
||||
}
|
||||
|
||||
@@ -2177,7 +2177,7 @@ public:
|
||||
bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const;
|
||||
|
||||
// Visibility system
|
||||
[[nodiscard]] bool IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; }
|
||||
[[nodiscard]] bool IsVisible() const { return m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) <= SEC_PLAYER; }
|
||||
void SetVisible(bool x);
|
||||
void SetModelVisible(bool on);
|
||||
|
||||
|
||||
@@ -13,13 +13,11 @@
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "ZoneScript.h"
|
||||
|
||||
Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) :
|
||||
_me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
|
||||
|
||||
Reference in New Issue
Block a user