mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 19:05:42 +00:00
refactor(Core): code cleanup (part 1) (#6361)
This commit is contained in:
@@ -5,11 +5,8 @@
|
||||
*/
|
||||
|
||||
#include "CreatureAIImpl.h"
|
||||
#include "Errors.h"
|
||||
#include "GuardAI.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "World.h"
|
||||
|
||||
int GuardAI::Permissible(Creature const* creature)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
#include "Creature.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Errors.h"
|
||||
#include "Group.h"
|
||||
#include "ObjectAccessor.h"
|
||||
@@ -17,8 +16,6 @@
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
int PetAI::Permissible(const Creature* creature)
|
||||
{
|
||||
|
||||
@@ -4,11 +4,8 @@
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#include "ByteBuffer.h"
|
||||
#include "CreatureAIImpl.h"
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ReactorAI.h"
|
||||
|
||||
int ReactorAI::Permissible(const Creature* creature)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "Player.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Vehicle.h"
|
||||
#include "World.h"
|
||||
|
||||
//Disable CreatureAI when charmed
|
||||
void CreatureAI::OnCharmed(bool /*apply*/)
|
||||
@@ -103,8 +102,10 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange
|
||||
// MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow
|
||||
void CreatureAI::MoveInLineOfSight_Safe(Unit* who)
|
||||
{
|
||||
if (m_MoveInLineOfSight_locked == true)
|
||||
if (m_MoveInLineOfSight_locked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_MoveInLineOfSight_locked = true;
|
||||
MoveInLineOfSight(who);
|
||||
m_MoveInLineOfSight_locked = false;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace AddonMgr
|
||||
result = CharacterDatabase.Query("SELECT id, name, version, UNIX_TIMESTAMP(timestamp) FROM banned_addons");
|
||||
if (result)
|
||||
{
|
||||
uint32 count = 0;
|
||||
uint32 count2 = 0;
|
||||
uint32 offset = 102;
|
||||
|
||||
do
|
||||
@@ -78,10 +78,10 @@ namespace AddonMgr
|
||||
|
||||
m_bannedAddons.push_back(addon);
|
||||
|
||||
++count;
|
||||
++count2;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u banned addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", ">> Loaded %u banned addons in %u ms", count2, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "BattlefieldWG.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "SpellAuras.h"
|
||||
@@ -740,27 +739,31 @@ void BattlefieldWG::PromotePlayer(Player* killer)
|
||||
if (!m_isActive)
|
||||
return;
|
||||
// Updating rank of player
|
||||
if (Aura* aur = killer->GetAura(SPELL_RECRUIT))
|
||||
if (Aura* recruitAura = killer->GetAura(SPELL_RECRUIT))
|
||||
{
|
||||
if (aur->GetStackAmount() >= 5)
|
||||
if (recruitAura->GetStackAmount() >= 5)
|
||||
{
|
||||
killer->RemoveAura(SPELL_RECRUIT);
|
||||
killer->CastSpell(killer, SPELL_CORPORAL, true);
|
||||
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_FIRSTRANK);
|
||||
}
|
||||
else
|
||||
{
|
||||
killer->CastSpell(killer, SPELL_RECRUIT, true);
|
||||
}
|
||||
}
|
||||
else if (Aura* aur = killer->GetAura(SPELL_CORPORAL))
|
||||
else if (Aura* corporalAura = killer->GetAura(SPELL_CORPORAL))
|
||||
{
|
||||
if (aur->GetStackAmount() >= 5)
|
||||
if (corporalAura->GetStackAmount() >= 5)
|
||||
{
|
||||
killer->RemoveAura(SPELL_CORPORAL);
|
||||
killer->CastSpell(killer, SPELL_LIEUTENANT, true);
|
||||
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_SECONDRANK);
|
||||
}
|
||||
else
|
||||
{
|
||||
killer->CastSpell(killer, SPELL_CORPORAL, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -990,9 +993,13 @@ void BattlefieldWG::ProcessEvent(WorldObject* obj, uint32 eventId)
|
||||
if (go->GetEntry() == GO_WINTERGRASP_TITAN_S_RELIC)
|
||||
{
|
||||
if (CanInteractWithRelic())
|
||||
{
|
||||
EndBattle(false);
|
||||
else if (GameObject* go = GetRelic())
|
||||
go->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
else if (GameObject* relic = GetRelic())
|
||||
{
|
||||
relic->SetRespawnTime(RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
}
|
||||
|
||||
// if destroy or damage event, search the wall/tower and update worldstate/send warning message
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "Player.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "Transport.h"
|
||||
#include "Util.h"
|
||||
@@ -823,36 +822,36 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
||||
uint32 currOnline = (uint32)(sWorld->GetActiveSessionCount());
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
|
||||
stmt->setUInt32(0, fightId);
|
||||
stmt->setUInt8(1, m_ArenaType);
|
||||
stmt->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt->setUInt32(3, winnerArenaTeam->GetId());
|
||||
stmt->setUInt32(4, loserArenaTeam->GetId());
|
||||
stmt->setUInt16(5, (uint16)winnerTeamRating);
|
||||
stmt->setUInt16(6, (uint16)winnerMatchmakerRating);
|
||||
stmt->setInt16(7, (int16)winnerChange);
|
||||
stmt->setUInt16(8, (uint16)loserTeamRating);
|
||||
stmt->setUInt16(9, (uint16)loserMatchmakerRating);
|
||||
stmt->setInt16(10, (int16)loserChange);
|
||||
stmt->setUInt32(11, currOnline);
|
||||
trans->Append(stmt);
|
||||
PreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
|
||||
stmt2->setUInt32(0, fightId);
|
||||
stmt2->setUInt8(1, m_ArenaType);
|
||||
stmt2->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt2->setUInt32(3, winnerArenaTeam->GetId());
|
||||
stmt2->setUInt32(4, loserArenaTeam->GetId());
|
||||
stmt2->setUInt16(5, (uint16)winnerTeamRating);
|
||||
stmt2->setUInt16(6, (uint16)winnerMatchmakerRating);
|
||||
stmt2->setInt16(7, (int16)winnerChange);
|
||||
stmt2->setUInt16(8, (uint16)loserTeamRating);
|
||||
stmt2->setUInt16(9, (uint16)loserMatchmakerRating);
|
||||
stmt2->setInt16(10, (int16)loserChange);
|
||||
stmt2->setUInt32(11, currOnline);
|
||||
trans->Append(stmt2);
|
||||
|
||||
uint8 memberId = 0;
|
||||
for (Battleground::ArenaLogEntryDataMap::const_iterator itr = ArenaLogEntries.begin(); itr != ArenaLogEntries.end(); ++itr)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt->setUInt32(0, fightId);
|
||||
stmt->setUInt8(1, ++memberId);
|
||||
stmt->setString(2, itr->second.Name);
|
||||
stmt->setUInt32(3, itr->second.Guid);
|
||||
stmt->setUInt32(4, itr->second.ArenaTeamId);
|
||||
stmt->setUInt32(5, itr->second.Acc);
|
||||
stmt->setString(6, itr->second.IP);
|
||||
stmt->setUInt32(7, itr->second.DamageDone);
|
||||
stmt->setUInt32(8, itr->second.HealingDone);
|
||||
stmt->setUInt32(9, itr->second.KillingBlows);
|
||||
trans->Append(stmt);
|
||||
stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt2->setUInt32(0, fightId);
|
||||
stmt2->setUInt8(1, ++memberId);
|
||||
stmt2->setString(2, itr->second.Name);
|
||||
stmt2->setUInt32(3, itr->second.Guid);
|
||||
stmt2->setUInt32(4, itr->second.ArenaTeamId);
|
||||
stmt2->setUInt32(5, itr->second.Acc);
|
||||
stmt2->setString(6, itr->second.IP);
|
||||
stmt2->setUInt32(7, itr->second.DamageDone);
|
||||
stmt2->setUInt32(8, itr->second.HealingDone);
|
||||
stmt2->setUInt32(9, itr->second.KillingBlows);
|
||||
trans->Append(stmt2);
|
||||
}
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
@@ -882,36 +881,36 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
||||
uint32 currOnline = (uint32)(sWorld->GetActiveSessionCount());
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
|
||||
stmt->setUInt32(0, fightId);
|
||||
stmt->setUInt8(1, m_ArenaType);
|
||||
stmt->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt->setUInt32(3, winnerArenaTeam->GetId());
|
||||
stmt->setUInt32(4, loserArenaTeam->GetId());
|
||||
stmt->setUInt16(5, (uint16)winnerTeamRating);
|
||||
stmt->setUInt16(6, (uint16)winnerMatchmakerRating);
|
||||
stmt->setInt16(7, (int16)winnerChange);
|
||||
stmt->setUInt16(8, (uint16)loserTeamRating);
|
||||
stmt->setUInt16(9, (uint16)loserMatchmakerRating);
|
||||
stmt->setInt16(10, (int16)loserChange);
|
||||
stmt->setUInt32(11, currOnline);
|
||||
trans->Append(stmt);
|
||||
PreparedStatement* stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
|
||||
stmt3->setUInt32(0, fightId);
|
||||
stmt3->setUInt8(1, m_ArenaType);
|
||||
stmt3->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt3->setUInt32(3, winnerArenaTeam->GetId());
|
||||
stmt3->setUInt32(4, loserArenaTeam->GetId());
|
||||
stmt3->setUInt16(5, (uint16)winnerTeamRating);
|
||||
stmt3->setUInt16(6, (uint16)winnerMatchmakerRating);
|
||||
stmt3->setInt16(7, (int16)winnerChange);
|
||||
stmt3->setUInt16(8, (uint16)loserTeamRating);
|
||||
stmt3->setUInt16(9, (uint16)loserMatchmakerRating);
|
||||
stmt3->setInt16(10, (int16)loserChange);
|
||||
stmt3->setUInt32(11, currOnline);
|
||||
trans->Append(stmt3);
|
||||
|
||||
uint8 memberId = 0;
|
||||
for (Battleground::ArenaLogEntryDataMap::const_iterator itr = ArenaLogEntries.begin(); itr != ArenaLogEntries.end(); ++itr)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt->setUInt32(0, fightId);
|
||||
stmt->setUInt8(1, ++memberId);
|
||||
stmt->setString(2, itr->second.Name);
|
||||
stmt->setUInt32(3, itr->second.Guid);
|
||||
stmt->setUInt32(4, itr->second.ArenaTeamId);
|
||||
stmt->setUInt32(5, itr->second.Acc);
|
||||
stmt->setString(6, itr->second.IP);
|
||||
stmt->setUInt32(7, itr->second.DamageDone);
|
||||
stmt->setUInt32(8, itr->second.HealingDone);
|
||||
stmt->setUInt32(9, itr->second.KillingBlows);
|
||||
trans->Append(stmt);
|
||||
stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt3->setUInt32(0, fightId);
|
||||
stmt3->setUInt8(1, ++memberId);
|
||||
stmt3->setString(2, itr->second.Name);
|
||||
stmt3->setUInt32(3, itr->second.Guid);
|
||||
stmt3->setUInt32(4, itr->second.ArenaTeamId);
|
||||
stmt3->setUInt32(5, itr->second.Acc);
|
||||
stmt3->setString(6, itr->second.IP);
|
||||
stmt3->setUInt32(7, itr->second.DamageDone);
|
||||
stmt3->setUInt32(8, itr->second.HealingDone);
|
||||
stmt3->setUInt32(9, itr->second.KillingBlows);
|
||||
trans->Append(stmt3);
|
||||
}
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include "BattlegroundRL.h"
|
||||
#include "Language.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
@@ -71,7 +71,7 @@ void BattlegroundRV::PostUpdateImpl(uint32 diff)
|
||||
setTimer(BG_RV_CLOSE_FIRE_TIMER);
|
||||
setState(BG_RV_STATE_CLOSE_FIRE);
|
||||
|
||||
for (BattlegroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
for (auto itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
if (Player* player = itr->second)
|
||||
{
|
||||
// Demonic Circle Summon
|
||||
@@ -90,16 +90,16 @@ void BattlegroundRV::PostUpdateImpl(uint32 diff)
|
||||
if (totem->GetPositionZ() < 28.0f)
|
||||
TeleportUnitToNewZ(totem, 28.28f, true);
|
||||
|
||||
for (Unit::ControlSet::const_iterator itr = player->m_Controlled.begin(); itr != player->m_Controlled.end(); ++itr)
|
||||
for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2)
|
||||
{
|
||||
if ((*itr)->GetPositionZ() < 28.0f)
|
||||
TeleportUnitToNewZ((*itr), 28.28f, true);
|
||||
if ((*itr2)->GetPositionZ() < 28.0f)
|
||||
TeleportUnitToNewZ((*itr2), 28.28f, true);
|
||||
|
||||
// Xinef: override stay position
|
||||
if (CharmInfo* charmInfo = (*itr)->GetCharmInfo())
|
||||
if (CharmInfo* charmInfo = (*itr2)->GetCharmInfo())
|
||||
if (charmInfo->IsAtStay())
|
||||
{
|
||||
(*itr)->StopMovingOnCurrentPos();
|
||||
(*itr2)->StopMovingOnCurrentPos();
|
||||
charmInfo->SaveStayPosition(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,21 +624,28 @@ void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, ui
|
||||
case BG_SA_BLUE_GATE:
|
||||
case BG_SA_GREEN_GATE:
|
||||
{
|
||||
GameObject* go = nullptr;
|
||||
if ((go = GetBGObject(BG_SA_RED_GATE)))
|
||||
go->SetDestructibleBuildingModifyState(true);
|
||||
if ((go = GetBGObject(BG_SA_PURPLE_GATE)))
|
||||
go->SetDestructibleBuildingModifyState(true);
|
||||
if (auto redGate = GetBGObject(BG_SA_RED_GATE))
|
||||
{
|
||||
redGate->SetDestructibleBuildingModifyState(true);
|
||||
}
|
||||
if (auto purpleGate = GetBGObject(BG_SA_PURPLE_GATE))
|
||||
{
|
||||
purpleGate->SetDestructibleBuildingModifyState(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BG_SA_RED_GATE:
|
||||
case BG_SA_PURPLE_GATE:
|
||||
if (GameObject* go = GetBGObject(BG_SA_YELLOW_GATE))
|
||||
go->SetDestructibleBuildingModifyState(true);
|
||||
if (auto yellowGate = GetBGObject(BG_SA_YELLOW_GATE))
|
||||
{
|
||||
yellowGate->SetDestructibleBuildingModifyState(true);
|
||||
}
|
||||
break;
|
||||
case BG_SA_YELLOW_GATE:
|
||||
if (GameObject* go = GetBGObject(BG_SA_ANCIENT_GATE))
|
||||
go->SetDestructibleBuildingModifyState(true);
|
||||
if (auto ancientGate = GetBGObject(BG_SA_ANCIENT_GATE))
|
||||
{
|
||||
ancientGate->SetDestructibleBuildingModifyState(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -876,7 +883,7 @@ void BattlegroundSA::EventPlayerClickedOnFlag(Player* Source, GameObject* gameOb
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
|
||||
@@ -996,7 +1003,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
|
||||
default:
|
||||
ABORT();
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundSA::EventPlayerUsedGO(Player* Source, GameObject* object)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "BattlegroundWS.h"
|
||||
#include "Creature.h"
|
||||
#include "GameGraveyard.h"
|
||||
#include "GameObject.h"
|
||||
#include "Language.h"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#include "DBCStructure.h"
|
||||
#include "HostileRefManager.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
@@ -210,12 +210,12 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
|
||||
}
|
||||
case CONDITION_NEAR_CREATURE:
|
||||
{
|
||||
condMeets = !!GetClosestCreatureWithEntry(object, ConditionValue1, (float)ConditionValue2, !ConditionValue3);
|
||||
condMeets = static_cast<bool>(GetClosestCreatureWithEntry(object, ConditionValue1, static_cast<float>(ConditionValue2),!ConditionValue3));
|
||||
break;
|
||||
}
|
||||
case CONDITION_NEAR_GAMEOBJECT:
|
||||
{
|
||||
condMeets = !!GetClosestGameObjectWithEntry(object, ConditionValue1, (float)ConditionValue2);
|
||||
condMeets = static_cast<bool>(GetClosestGameObjectWithEntry(object, ConditionValue1, static_cast<float>(ConditionValue2)));
|
||||
break;
|
||||
}
|
||||
case CONDITION_OBJECT_ENTRY_GUID:
|
||||
|
||||
Reference in New Issue
Block a user