diff options
Diffstat (limited to 'src')
164 files changed, 3207 insertions, 1869 deletions
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index cdd8298174f..9931595e860 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -21,6 +21,7 @@ #include "AuthCodes.h" #include "Database/DatabaseEnv.h" #include "SHA1.h" +#include "TOTP.h" #include "openssl/crypto.h" #include "Configuration/Config.h" #include "RealmList.h" @@ -52,7 +53,6 @@ enum eStatus typedef struct AUTH_LOGON_CHALLENGE_C { - uint8 cmd; uint8 error; uint16 size; uint8 gamename[4]; @@ -71,7 +71,6 @@ typedef struct AUTH_LOGON_CHALLENGE_C typedef struct AUTH_LOGON_PROOF_C { - uint8 cmd; uint8 A[32]; uint8 M1[20]; uint8 crc_hash[20]; @@ -99,7 +98,6 @@ typedef struct AUTH_LOGON_PROOF_S_OLD typedef struct AUTH_RECONNECT_PROOF_C { - uint8 cmd; uint8 R1[16]; uint8 R2[20]; uint8 R3[20]; @@ -114,10 +112,10 @@ enum class BufferSizes : uint32 SRP_6_S = 0x20, }; -#define REALM_LIST_PACKET_SIZE 5 -#define XFER_ACCEPT_SIZE 1 -#define XFER_RESUME_SIZE 9 -#define XFER_CANCEL_SIZE 1 +#define REALM_LIST_PACKET_SIZE 4 +#define XFER_ACCEPT_SIZE 0 +#define XFER_RESUME_SIZE 8 +#define XFER_CANCEL_SIZE 0 std::unordered_map<uint8, AuthHandler> AuthSession::InitHandlers() { @@ -137,48 +135,43 @@ std::unordered_map<uint8, AuthHandler> AuthSession::InitHandlers() std::unordered_map<uint8, AuthHandler> const Handlers = AuthSession::InitHandlers(); -void AuthSession::ReadHeaderHandler(boost::system::error_code error, size_t transferedBytes) +void AuthSession::ReadHeaderHandler() { - if (!error && transferedBytes == 1) + uint8 cmd = GetHeaderBuffer()[0]; + auto itr = Handlers.find(cmd); + if (itr != Handlers.end()) { - uint8 cmd = GetReadBuffer()[0]; - auto itr = Handlers.find(cmd); - if (itr != Handlers.end()) + // Handle dynamic size packet + if (cmd == AUTH_LOGON_CHALLENGE || cmd == AUTH_RECONNECT_CHALLENGE) { - // Handle dynamic size packet - if (cmd == AUTH_LOGON_CHALLENGE || cmd == AUTH_RECONNECT_CHALLENGE) - { - ReadData(sizeof(uint8) + sizeof(uint16), sizeof(cmd)); //error + size - sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer()); + ReadData(sizeof(uint8) + sizeof(uint16)); //error + size + sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetDataBuffer()); - AsyncReadData(challenge->size, sizeof(uint8) + sizeof(uint8) + sizeof(uint16)); // cmd + error + size - } - else - AsyncReadData(itr->second.packetSize, sizeof(uint8)); + AsyncReadData(challenge->size); } + else + AsyncReadData(itr->second.packetSize); } else CloseSocket(); } -void AuthSession::ReadDataHandler(boost::system::error_code error, size_t transferedBytes) +void AuthSession::ReadDataHandler() { - if (!error && transferedBytes > 0) + if (!(*this.*Handlers.at(GetHeaderBuffer()[0]).handler)()) { - if (!(*this.*Handlers.at(GetReadBuffer()[0]).handler)()) - { - CloseSocket(); - return; - } - - AsyncReadHeader(); - } - else CloseSocket(); + return; + } + + AsyncReadHeader(); } void AuthSession::AsyncWrite(ByteBuffer& packet) { + if (!IsOpen()) + return; + std::lock_guard<std::mutex> guard(_writeLock); bool needsWriteStart = _writeQueue.empty(); @@ -191,7 +184,7 @@ void AuthSession::AsyncWrite(ByteBuffer& packet) bool AuthSession::HandleLogonChallenge() { - sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer()); + sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetDataBuffer()); //TC_LOG_DEBUG("server.authserver", "[AuthChallenge] got full packet, %#04x bytes", challenge->size); TC_LOG_DEBUG("server.authserver", "[AuthChallenge] name(%d): '%s'", challenge->I_len, challenge->I); @@ -410,7 +403,7 @@ bool AuthSession::HandleLogonProof() TC_LOG_DEBUG("server.authserver", "Entering _HandleLogonProof"); // Read the packet - sAuthLogonProof_C *logonProof = reinterpret_cast<sAuthLogonProof_C*>(GetReadBuffer()); + sAuthLogonProof_C *logonProof = reinterpret_cast<sAuthLogonProof_C*>(GetDataBuffer()); // If the client has no valid version if (_expversion == NO_VALID_EXP_FLAG) @@ -522,17 +515,12 @@ bool AuthSession::HandleLogonProof() // Check auth token if ((logonProof->securityFlags & 0x04) || !_tokenKey.empty()) { - // TODO To be fixed - - /* - uint8 size; - socket().recv((char*)&size, 1); - char* token = new char[size + 1]; - token[size] = '\0'; - socket().recv(token, size); - unsigned int validToken = TOTP::GenerateToken(_tokenKey.c_str()); - unsigned int incomingToken = atoi(token); - delete[] token; + ReadData(1); + uint8 size = *(GetDataBuffer() + sizeof(sAuthLogonProof_C)); + ReadData(size); + std::string token(reinterpret_cast<char*>(GetDataBuffer() + sizeof(sAuthLogonProof_C) + sizeof(size)), size); + uint32 validToken = TOTP::GenerateToken(_tokenKey.c_str()); + uint32 incomingToken = atoi(token.c_str()); if (validToken != incomingToken) { ByteBuffer packet; @@ -542,7 +530,7 @@ bool AuthSession::HandleLogonProof() packet << uint8(0); AsyncWrite(packet); return false; - }*/ + } } ByteBuffer packet; @@ -650,7 +638,7 @@ bool AuthSession::HandleLogonProof() bool AuthSession::HandleReconnectChallenge() { TC_LOG_DEBUG("server.authserver", "Entering _HandleReconnectChallenge"); - sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer()); + sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetDataBuffer()); //TC_LOG_DEBUG("server.authserver", "[AuthChallenge] got full packet, %#04x bytes", challenge->size); TC_LOG_DEBUG("server.authserver", "[AuthChallenge] name(%d): '%s'", challenge->I_len, challenge->I); @@ -701,7 +689,7 @@ bool AuthSession::HandleReconnectChallenge() bool AuthSession::HandleReconnectProof() { TC_LOG_DEBUG("server.authserver", "Entering _HandleReconnectProof"); - sAuthReconnectProof_C *reconnectProof = reinterpret_cast<sAuthReconnectProof_C*>(GetReadBuffer()); + sAuthReconnectProof_C *reconnectProof = reinterpret_cast<sAuthReconnectProof_C*>(GetDataBuffer()); if (_login.empty() || !_reconnectProof.GetNumBytes() || !K.GetNumBytes()) return false; diff --git a/src/server/authserver/Server/AuthSession.h b/src/server/authserver/Server/AuthSession.h index 5a05ee6f8e9..3497e3a030c 100644 --- a/src/server/authserver/Server/AuthSession.h +++ b/src/server/authserver/Server/AuthSession.h @@ -53,8 +53,8 @@ public: void AsyncWrite(ByteBuffer& packet); protected: - void ReadHeaderHandler(boost::system::error_code error, size_t transferedBytes) override; - void ReadDataHandler(boost::system::error_code error, size_t transferedBytes) override; + void ReadHeaderHandler() override; + void ReadDataHandler() override; private: bool HandleLogonChallenge(); diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h index 03de6951d5d..04292e7d8e4 100644 --- a/src/server/collision/Management/VMapManager2.h +++ b/src/server/collision/Management/VMapManager2.h @@ -53,7 +53,7 @@ namespace VMAP class ManagedModel { public: - ManagedModel() : iModel(0), iRefCount(0) { } + ManagedModel() : iModel(nullptr), iRefCount(0) { } void setModel(WorldModel* model) { iModel = model; } WorldModel* getModel() { return iModel; } void incRefCount() { ++iRefCount; } @@ -86,32 +86,32 @@ namespace VMAP VMapManager2(); ~VMapManager2(void); - int loadMap(const char* pBasePath, unsigned int mapId, int x, int y); + int loadMap(const char* pBasePath, unsigned int mapId, int x, int y) override; - void unloadMap(unsigned int mapId, int x, int y); - void unloadMap(unsigned int mapId); + void unloadMap(unsigned int mapId, int x, int y) override; + void unloadMap(unsigned int mapId) override; - bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2) ; + bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2) override ; /** fill the hit pos and return true, if an object was hit */ - bool getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist); - float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist); + bool getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist) override; + float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist) override; - bool processCommand(char* /*command*/) { return false; } // for debug and extensions + bool processCommand(char* /*command*/) override { return false; } // for debug and extensions - bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const; - bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const; + bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const override; + bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const override; WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename); void releaseModelInstance(const std::string& filename); // what's the use of this? o.O - virtual std::string getDirFileName(unsigned int mapId, int /*x*/, int /*y*/) const + virtual std::string getDirFileName(unsigned int mapId, int /*x*/, int /*y*/) const override { return getMapFileName(mapId); } - virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y); + virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override; public: void getInstanceMapTree(InstanceTreeMap &instanceMapTree); }; diff --git a/src/server/collision/Maps/MapTree.h b/src/server/collision/Maps/MapTree.h index 05351b74019..e16f5701de1 100644 --- a/src/server/collision/Maps/MapTree.h +++ b/src/server/collision/Maps/MapTree.h @@ -31,7 +31,7 @@ namespace VMAP struct LocationInfo { - LocationInfo(): hitInstance(0), hitModel(0), ground_Z(-G3D::inf()) { } + LocationInfo(): hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::inf()) { } const ModelInstance* hitInstance; const GroupModel* hitModel; float ground_Z; diff --git a/src/server/collision/Models/ModelInstance.h b/src/server/collision/Models/ModelInstance.h index 3ea68f57ba4..1cb8fdde942 100644 --- a/src/server/collision/Models/ModelInstance.h +++ b/src/server/collision/Models/ModelInstance.h @@ -63,9 +63,9 @@ namespace VMAP class ModelInstance: public ModelSpawn { public: - ModelInstance(): iInvScale(0.0f), iModel(0) { } + ModelInstance(): iInvScale(0.0f), iModel(nullptr) { } ModelInstance(const ModelSpawn &spawn, WorldModel* model); - void setUnloaded() { iModel = 0; } + void setUnloaded() { iModel = nullptr; } bool intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const; void intersectPoint(const G3D::Vector3& p, AreaInfo &info) const; bool GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const; diff --git a/src/server/collision/Models/WorldModel.cpp b/src/server/collision/Models/WorldModel.cpp index 99f3782215d..d6b0a76f23b 100644 --- a/src/server/collision/Models/WorldModel.cpp +++ b/src/server/collision/Models/WorldModel.cpp @@ -108,7 +108,7 @@ namespace VMAP iFlags = new uint8[width*height]; } - WmoLiquid::WmoLiquid(const WmoLiquid &other): iHeight(0), iFlags(0) + WmoLiquid::WmoLiquid(const WmoLiquid &other): iHeight(nullptr), iFlags(nullptr) { *this = other; // use assignment operator... } @@ -135,14 +135,14 @@ namespace VMAP memcpy(iHeight, other.iHeight, (iTilesX+1)*(iTilesY+1)*sizeof(float)); } else - iHeight = 0; + iHeight = nullptr; if (other.iFlags) { iFlags = new uint8[iTilesX * iTilesY]; memcpy(iFlags, other.iFlags, iTilesX * iTilesY); } else - iFlags = 0; + iFlags = nullptr; return *this; } @@ -254,7 +254,7 @@ namespace VMAP GroupModel::GroupModel(const GroupModel &other): iBound(other.iBound), iMogpFlags(other.iMogpFlags), iGroupWMOID(other.iGroupWMOID), - vertices(other.vertices), triangles(other.triangles), meshTree(other.meshTree), iLiquid(0) + vertices(other.vertices), triangles(other.triangles), meshTree(other.meshTree), iLiquid(nullptr) { if (other.iLiquid) iLiquid = new WmoLiquid(*other.iLiquid); diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index f73daa2d720..4b6af3cbdda 100644 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -30,7 +30,7 @@ class AggressorAI : public CreatureAI public: explicit AggressorAI(Creature* c) : CreatureAI(c) { } - void UpdateAI(uint32); + void UpdateAI(uint32) override; static int Permissible(const Creature*); }; @@ -41,12 +41,12 @@ class CombatAI : public CreatureAI public: explicit CombatAI(Creature* c) : CreatureAI(c) { } - void InitializeAI(); - void Reset(); - void EnterCombat(Unit* who); - void JustDied(Unit* killer); - void UpdateAI(uint32 diff); - void SpellInterrupted(uint32 spellId, uint32 unTimeMs); + void InitializeAI() override; + void Reset() override; + void EnterCombat(Unit* who) override; + void JustDied(Unit* killer) override; + void UpdateAI(uint32 diff) override; + void SpellInterrupted(uint32 spellId, uint32 unTimeMs) override; static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } @@ -59,10 +59,10 @@ class CasterAI : public CombatAI { public: explicit CasterAI(Creature* c) : CombatAI(c) { m_attackDist = MELEE_RANGE; } - void InitializeAI(); - void AttackStart(Unit* victim) { AttackStartCaster(victim, m_attackDist); } - void UpdateAI(uint32 diff); - void EnterCombat(Unit* /*who*/); + void InitializeAI() override; + void AttackStart(Unit* victim) override { AttackStartCaster(victim, m_attackDist); } + void UpdateAI(uint32 diff) override; + void EnterCombat(Unit* /*who*/) override; private: float m_attackDist; }; @@ -71,8 +71,8 @@ struct ArcherAI : public CreatureAI { public: explicit ArcherAI(Creature* c); - void AttackStart(Unit* who); - void UpdateAI(uint32 diff); + void AttackStart(Unit* who) override; + void UpdateAI(uint32 diff) override; static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } @@ -84,9 +84,9 @@ struct TurretAI : public CreatureAI { public: explicit TurretAI(Creature* c); - bool CanAIAttack(Unit const* who) const; - void AttackStart(Unit* who); - void UpdateAI(uint32 diff); + bool CanAIAttack(Unit const* who) const override; + void AttackStart(Unit* who) override; + void UpdateAI(uint32 diff) override; static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } @@ -102,10 +102,10 @@ struct VehicleAI : public CreatureAI public: explicit VehicleAI(Creature* creature); - void UpdateAI(uint32 diff); - void MoveInLineOfSight(Unit*) { } - void AttackStart(Unit*) { } - void OnCharmed(bool apply); + void UpdateAI(uint32 diff) override; + void MoveInLineOfSight(Unit*) override { } + void AttackStart(Unit*) override { } + void OnCharmed(bool apply) override; static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index 36ca2c3253f..6e03103e269 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -68,7 +68,7 @@ class NullGameObjectAI : public GameObjectAI public: explicit NullGameObjectAI(GameObject* g); - void UpdateAI(uint32 /*diff*/) { } + void UpdateAI(uint32 /*diff*/) override { } static int Permissible(GameObject const* /*go*/) { return PERMIT_BASE_IDLE; } }; diff --git a/src/server/game/AI/CoreAI/GuardAI.h b/src/server/game/AI/CoreAI/GuardAI.h index 9af047e8906..c2b05d71e03 100644 --- a/src/server/game/AI/CoreAI/GuardAI.h +++ b/src/server/game/AI/CoreAI/GuardAI.h @@ -29,10 +29,10 @@ class GuardAI : public ScriptedAI explicit GuardAI(Creature* creature); static int Permissible(Creature const* creature); - bool CanSeeAlways(WorldObject const* obj); + bool CanSeeAlways(WorldObject const* obj) override; - void EnterEvadeMode(); - void JustDied(Unit* killer); + void EnterEvadeMode() override; + void JustDied(Unit* killer) override; }; #endif diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp index 07987cf8cec..3ae73636619 100644 --- a/src/server/game/AI/CoreAI/PassiveAI.cpp +++ b/src/server/game/AI/CoreAI/PassiveAI.cpp @@ -75,5 +75,5 @@ void CritterAI::EnterEvadeMode() void TriggerAI::IsSummonedBy(Unit* summoner) { if (me->m_spells[0]) - me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner->GetGUID()); + me->CastSpell(me, me->m_spells[0], false, nullptr, nullptr, summoner->GetGUID()); } diff --git a/src/server/game/AI/CoreAI/PassiveAI.h b/src/server/game/AI/CoreAI/PassiveAI.h index 33bfde4f9f2..7f5ab5f29a2 100644 --- a/src/server/game/AI/CoreAI/PassiveAI.h +++ b/src/server/game/AI/CoreAI/PassiveAI.h @@ -26,9 +26,9 @@ class PassiveAI : public CreatureAI public: explicit PassiveAI(Creature* c); - void MoveInLineOfSight(Unit*) { } - void AttackStart(Unit*) { } - void UpdateAI(uint32); + void MoveInLineOfSight(Unit*) override { } + void AttackStart(Unit*) override { } + void UpdateAI(uint32) override; static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; @@ -38,13 +38,13 @@ class PossessedAI : public CreatureAI public: explicit PossessedAI(Creature* c); - void MoveInLineOfSight(Unit*) { } - void AttackStart(Unit* target); - void UpdateAI(uint32); - void EnterEvadeMode() { } + void MoveInLineOfSight(Unit*) override { } + void AttackStart(Unit* target) override; + void UpdateAI(uint32) override; + void EnterEvadeMode() override { } - void JustDied(Unit*); - void KilledUnit(Unit* victim); + void JustDied(Unit*) override; + void KilledUnit(Unit* victim) override; static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; @@ -54,11 +54,11 @@ class NullCreatureAI : public CreatureAI public: explicit NullCreatureAI(Creature* c); - void MoveInLineOfSight(Unit*) { } - void AttackStart(Unit*) { } - void UpdateAI(uint32) { } - void EnterEvadeMode() { } - void OnCharmed(bool /*apply*/) { } + void MoveInLineOfSight(Unit*) override { } + void AttackStart(Unit*) override { } + void UpdateAI(uint32) override { } + void EnterEvadeMode() override { } + void OnCharmed(bool /*apply*/) override { } static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; @@ -68,15 +68,15 @@ class CritterAI : public PassiveAI public: explicit CritterAI(Creature* c) : PassiveAI(c) { } - void DamageTaken(Unit* done_by, uint32& /*damage*/); - void EnterEvadeMode(); + void DamageTaken(Unit* done_by, uint32& /*damage*/) override; + void EnterEvadeMode() override; }; class TriggerAI : public NullCreatureAI { public: explicit TriggerAI(Creature* c) : NullCreatureAI(c) { } - void IsSummonedBy(Unit* summoner); + void IsSummonedBy(Unit* summoner) override; }; #endif diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 8032568434f..4bce9113082 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -246,8 +246,6 @@ void PetAI::UpdateAI(uint32 diff) me->SendUpdateToPlayer(owner->ToPlayer()); } - me->AddCreatureSpellCooldown(spell->m_spellInfo->Id); - spell->prepare(&targets); } diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 450f68443f0..c24bf3a0c1b 100644 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -31,23 +31,23 @@ class PetAI : public CreatureAI explicit PetAI(Creature* c); - void UpdateAI(uint32); + void UpdateAI(uint32) override; static int Permissible(const Creature*); - void KilledUnit(Unit* /*victim*/); - void AttackStart(Unit* target); - void MovementInform(uint32 moveType, uint32 data); - void OwnerAttackedBy(Unit* attacker); - void OwnerAttacked(Unit* target); - void AttackedBy(Unit* attacker); - void ReceiveEmote(Player* player, uint32 textEmote); + void KilledUnit(Unit* /*victim*/) override; + void AttackStart(Unit* target) override; + void MovementInform(uint32 moveType, uint32 data) override; + void OwnerAttackedBy(Unit* attacker) override; + void OwnerAttacked(Unit* target) override; + void AttackedBy(Unit* attacker) override; + void ReceiveEmote(Player* player, uint32 textEmote) override; // The following aren't used by the PetAI but need to be defined to override // default CreatureAI functions which interfere with the PetAI // - void MoveInLineOfSight(Unit* /*who*/) { } // CreatureAI interferes with returning pets + void MoveInLineOfSight(Unit* /*who*/) override { } // CreatureAI interferes with returning pets void MoveInLineOfSight_Safe(Unit* /*who*/) { } // CreatureAI interferes with returning pets - void EnterEvadeMode() { } // For fleeing, pets don't use this type of Evade mechanic + void EnterEvadeMode() override { } // For fleeing, pets don't use this type of Evade mechanic private: bool _isVisible(Unit*) const; diff --git a/src/server/game/AI/CoreAI/ReactorAI.h b/src/server/game/AI/CoreAI/ReactorAI.h index 417944f9ba2..2fdccac802d 100644 --- a/src/server/game/AI/CoreAI/ReactorAI.h +++ b/src/server/game/AI/CoreAI/ReactorAI.h @@ -29,8 +29,8 @@ class ReactorAI : public CreatureAI explicit ReactorAI(Creature* c) : CreatureAI(c) { } - void MoveInLineOfSight(Unit*) { } - void UpdateAI(uint32 diff); + void MoveInLineOfSight(Unit*) override { } + void UpdateAI(uint32 diff) override; static int Permissible(const Creature*); }; diff --git a/src/server/game/AI/CoreAI/TotemAI.h b/src/server/game/AI/CoreAI/TotemAI.h index 4d5f03566ba..93106b91492 100644 --- a/src/server/game/AI/CoreAI/TotemAI.h +++ b/src/server/game/AI/CoreAI/TotemAI.h @@ -31,11 +31,11 @@ class TotemAI : public CreatureAI explicit TotemAI(Creature* c); - void MoveInLineOfSight(Unit* who); - void AttackStart(Unit* victim); - void EnterEvadeMode(); + void MoveInLineOfSight(Unit* who) override; + void AttackStart(Unit* victim) override; + void EnterEvadeMode() override; - void UpdateAI(uint32 diff); + void UpdateAI(uint32 diff) override; static int Permissible(Creature const* creature); private: diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 6ca79dc0a49..b6743b572cb 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -275,13 +275,13 @@ class PlayerAI : public UnitAI public: explicit PlayerAI(Player* player) : UnitAI((Unit*)player), me(player) { } - void OnCharmed(bool apply); + void OnCharmed(bool apply) override; }; class SimpleCharmedAI : public PlayerAI { public: - void UpdateAI(uint32 diff); + void UpdateAI(uint32 diff) override; SimpleCharmedAI(Player* player): PlayerAI(player) { } }; diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 209995d359d..b79dd6abbc8 100644 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -127,7 +127,7 @@ class CreatureAI : public UnitAI // Called at waypoint reached or point movement finished virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) { } - void OnCharmed(bool apply); + void OnCharmed(bool apply) override; // Called at reaching home after evade virtual void JustReachedHome() { } diff --git a/src/server/game/AI/CreatureAIFactory.h b/src/server/game/AI/CreatureAIFactory.h index f2854f1a9ce..61e3cd2b240 100644 --- a/src/server/game/AI/CreatureAIFactory.h +++ b/src/server/game/AI/CreatureAIFactory.h @@ -34,9 +34,9 @@ struct CreatureAIFactory : public SelectableAI { CreatureAIFactory(const char* name) : SelectableAI(name) { } - CreatureAI* Create(void*) const; + CreatureAI* Create(void*) const override; - int Permit(const Creature* c) const { return REAL_AI::Permissible(c); } + int Permit(const Creature* c) const override { return REAL_AI::Permissible(c); } }; template<class REAL_AI> @@ -61,9 +61,9 @@ struct GameObjectAIFactory : public SelectableGameObjectAI { GameObjectAIFactory(const char* name) : SelectableGameObjectAI(name) { } - GameObjectAI* Create(void*) const; + GameObjectAI* Create(void*) const override; - int Permit(const GameObject* g) const { return REAL_GO_AI::Permissible(g); } + int Permit(const GameObject* g) const override { return REAL_GO_AI::Permissible(g); } }; template<class REAL_GO_AI> diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index afbd306c184..3643bccdb6f 100644 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -68,7 +68,7 @@ namespace FactorySelector else ai_factory = ai_registry.GetRegistryItem("NullCreatureAI"); } - else if (creature->GetCreatureType() == CREATURE_TYPE_CRITTER && !creature->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) + else if (creature->IsCritter() && !creature->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) ai_factory = ai_registry.GetRegistryItem("CritterAI"); } diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 42a849354ef..788da26ea4a 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -150,31 +150,31 @@ struct ScriptedAI : public CreatureAI void AttackStartNoMove(Unit* target); // Called at any Damage from any attacker (before damage apply) - void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) { } + void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override { } //Called at World update tick - virtual void UpdateAI(uint32 diff); + virtual void UpdateAI(uint32 diff) override; //Called at creature death - void JustDied(Unit* /*killer*/) { } + void JustDied(Unit* /*killer*/) override { } //Called at creature killing another unit - void KilledUnit(Unit* /*victim*/) { } + void KilledUnit(Unit* /*victim*/) override { } // Called when the creature summon successfully other creature - void JustSummoned(Creature* /*summon*/) { } + void JustSummoned(Creature* /*summon*/) override { } // Called when a summoned creature is despawned - void SummonedCreatureDespawn(Creature* /*summon*/) { } + void SummonedCreatureDespawn(Creature* /*summon*/) override { } // Called when hit by a spell - void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) { } + void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) override { } // Called when spell hits a target - void SpellHitTarget(Unit* /*target*/, SpellInfo const* /*spell*/) { } + void SpellHitTarget(Unit* /*target*/, SpellInfo const* /*spell*/) override { } //Called at waypoint reached or PointMovement end - void MovementInform(uint32 /*type*/, uint32 /*id*/) { } + void MovementInform(uint32 /*type*/, uint32 /*id*/) override { } // Called when AI is temporarily replaced or put back when possess is applied or removed void OnPossess(bool /*apply*/) { } @@ -194,13 +194,13 @@ struct ScriptedAI : public CreatureAI // ************* //Called at creature reset either by death or evade - void Reset() { } + void Reset() override { } //Called at creature aggro either by MoveInLOS or Attack Start - void EnterCombat(Unit* /*victim*/) { } + void EnterCombat(Unit* /*victim*/) override { } // Called before EnterCombat even before the creature is in combat. - void AttackStart(Unit* /*target*/); + void AttackStart(Unit* /*target*/) override; // ************* //AI Helper Functions @@ -348,10 +348,10 @@ class BossAI : public ScriptedAI InstanceScript* const instance; BossBoundaryMap const* GetBoundary() const { return _boundary; } - void JustSummoned(Creature* summon); - void SummonedCreatureDespawn(Creature* summon); + void JustSummoned(Creature* summon) override; + void SummonedCreatureDespawn(Creature* summon) override; - virtual void UpdateAI(uint32 diff); + virtual void UpdateAI(uint32 diff) override; // Hook used to execute events scheduled into EventMap without the need // to override UpdateAI @@ -359,10 +359,10 @@ class BossAI : public ScriptedAI // is supposed to run more than once virtual void ExecuteEvent(uint32 /*eventId*/) { } - void Reset() { _Reset(); } - void EnterCombat(Unit* /*who*/) { _EnterCombat(); } - void JustDied(Unit* /*killer*/) { _JustDied(); } - void JustReachedHome() { _JustReachedHome(); } + void Reset() override { _Reset(); } + void EnterCombat(Unit* /*who*/) override { _EnterCombat(); } + void JustDied(Unit* /*killer*/) override { _JustDied(); } + void JustReachedHome() override { _JustReachedHome(); } protected: void _Reset(); @@ -396,10 +396,10 @@ class WorldBossAI : public ScriptedAI WorldBossAI(Creature* creature); virtual ~WorldBossAI() { } - void JustSummoned(Creature* summon); - void SummonedCreatureDespawn(Creature* summon); + void JustSummoned(Creature* summon) override; + void SummonedCreatureDespawn(Creature* summon) override; - virtual void UpdateAI(uint32 diff); + virtual void UpdateAI(uint32 diff) override; // Hook used to execute events scheduled into EventMap without the need // to override UpdateAI @@ -407,9 +407,9 @@ class WorldBossAI : public ScriptedAI // is supposed to run more than once virtual void ExecuteEvent(uint32 /*eventId*/) { } - void Reset() { _Reset(); } - void EnterCombat(Unit* /*who*/) { _EnterCombat(); } - void JustDied(Unit* /*killer*/) { _JustDied(); } + void Reset() override { _Reset(); } + void EnterCombat(Unit* /*who*/) override { _EnterCombat(); } + void JustDied(Unit* /*killer*/) override { _JustDied(); } protected: void _Reset(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h index 177810bbbfd..b8c9ee57aeb 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h @@ -56,22 +56,22 @@ struct npc_escortAI : public ScriptedAI ~npc_escortAI() { } // CreatureAI functions - void AttackStart(Unit* who); + void AttackStart(Unit* who) override; - void MoveInLineOfSight(Unit* who); + void MoveInLineOfSight(Unit* who) override; - void JustDied(Unit*); + void JustDied(Unit*) override; - void JustRespawned(); + void JustRespawned() override; void ReturnToLastPoint(); - void EnterEvadeMode(); + void EnterEvadeMode() override; - void UpdateAI(uint32 diff); //the "internal" update, calls UpdateEscortAI() + void UpdateAI(uint32 diff) override; //the "internal" update, calls UpdateEscortAI() virtual void UpdateEscortAI(uint32 const diff); //used when it's needed to add code in update (abilities, scripted events, etc) - void MovementInform(uint32, uint32); + void MovementInform(uint32, uint32) override; // EscortAI functions void AddWaypoint(uint32 id, float x, float y, float z, uint32 waitTime = 0); // waitTime is in ms @@ -94,7 +94,7 @@ struct npc_escortAI : public ScriptedAI void SetEscortPaused(bool on); bool HasEscortState(uint32 escortState) { return (m_uiEscortState & escortState) != 0; } - virtual bool IsEscorted() { return (m_uiEscortState & STATE_ESCORT_ESCORTING); } + virtual bool IsEscorted() override { return (m_uiEscortState & STATE_ESCORT_ESCORTING); } void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; } float GetMaxPlayerDistance() { return MaxPlayerDistance; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h index af7508441b9..adb17ef76b1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h @@ -40,19 +40,19 @@ class FollowerAI : public ScriptedAI //virtual void WaypointReached(uint32 uiPointId) = 0; - void MovementInform(uint32 motionType, uint32 pointId); + void MovementInform(uint32 motionType, uint32 pointId) override; - void AttackStart(Unit*); + void AttackStart(Unit*) override; - void MoveInLineOfSight(Unit*); + void MoveInLineOfSight(Unit*) override; - void EnterEvadeMode(); + void EnterEvadeMode() override; - void JustDied(Unit*); + void JustDied(Unit*) override; - void JustRespawned(); + void JustRespawned() override; - void UpdateAI(uint32); //the "internal" update, calls UpdateFollowerAI() + void UpdateAI(uint32) override; //the "internal" update, calls UpdateFollowerAI() virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc) void StartFollow(Player* player, uint32 factionForFollower = 0, const Quest* quest = NULL); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index af47b52f500..41f783f4289 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -931,7 +931,7 @@ class SmartTrigger : public AreaTriggerScript SmartTrigger() : AreaTriggerScript("SmartTrigger") { } - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) + bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override { if (!player->IsAlive()) return false; diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 4d66b976746..e674bbfdaac 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -70,94 +70,94 @@ class SmartAI : public CreatureAI bool IsEscortInvokerInRange(); // Called when creature is spawned or respawned - void JustRespawned(); + void JustRespawned() override; // Called at reaching home after evade, InitializeAI(), EnterEvadeMode() for resetting variables - void JustReachedHome(); + void JustReachedHome() override; // Called for reaction at enter to combat if not in combat yet (enemy can be NULL) - void EnterCombat(Unit* enemy); + void EnterCombat(Unit* enemy) override; // Called for reaction at stopping attack at no attackers or targets - void EnterEvadeMode(); + void EnterEvadeMode() override; // Called when the creature is killed - void JustDied(Unit* killer); + void JustDied(Unit* killer) override; // Called when the creature kills a unit - void KilledUnit(Unit* victim); + void KilledUnit(Unit* victim) override; // Called when the creature summon successfully other creature - void JustSummoned(Creature* creature); + void JustSummoned(Creature* creature) override; // Tell creature to attack and follow the victim - void AttackStart(Unit* who); + void AttackStart(Unit* who) override; // Called if IsVisible(Unit* who) is true at each *who move, reaction at visibility zone enter - void MoveInLineOfSight(Unit* who); + void MoveInLineOfSight(Unit* who) override; // Called when hit by a spell - void SpellHit(Unit* unit, const SpellInfo* spellInfo); + void SpellHit(Unit* unit, const SpellInfo* spellInfo) override; // Called when spell hits a target - void SpellHitTarget(Unit* target, const SpellInfo* spellInfo); + void SpellHitTarget(Unit* target, const SpellInfo* spellInfo) override; // Called at any Damage from any attacker (before damage apply) - void DamageTaken(Unit* doneBy, uint32& damage); + void DamageTaken(Unit* doneBy, uint32& damage) override; // Called when the creature receives heal - void HealReceived(Unit* doneBy, uint32& addhealth); + void HealReceived(Unit* doneBy, uint32& addhealth) override; // Called at World update tick - void UpdateAI(uint32 diff); + void UpdateAI(uint32 diff) override; // Called at text emote receive from player - void ReceiveEmote(Player* player, uint32 textEmote); + void ReceiveEmote(Player* player, uint32 textEmote) override; // Called at waypoint reached or point movement finished - void MovementInform(uint32 MovementType, uint32 Data); + void MovementInform(uint32 MovementType, uint32 Data) override; // Called when creature is summoned by another unit - void IsSummonedBy(Unit* summoner); + void IsSummonedBy(Unit* summoner) override; // Called at any Damage to any victim (before damage apply) - void DamageDealt(Unit* doneTo, uint32& damage, DamageEffectType /*damagetype*/); + void DamageDealt(Unit* doneTo, uint32& damage, DamageEffectType /*damagetype*/) override; // Called when a summoned creature dissapears (UnSommoned) - void SummonedCreatureDespawn(Creature* unit); + void SummonedCreatureDespawn(Creature* unit) override; // called when the corpse of this creature gets removed - void CorpseRemoved(uint32& respawnDelay); + void CorpseRemoved(uint32& respawnDelay) override; // Called at World update tick if creature is charmed void UpdateAIWhileCharmed(const uint32 diff); // Called when a Player/Creature enters the creature (vehicle) - void PassengerBoarded(Unit* who, int8 seatId, bool apply); + void PassengerBoarded(Unit* who, int8 seatId, bool apply) override; // Called when gets initialized, when creature is added to world - void InitializeAI(); + void InitializeAI() override; // Called when creature gets charmed by another unit - void OnCharmed(bool apply); + void OnCharmed(bool apply) override; // Called when victim is in line of sight - bool CanAIAttack(const Unit* who) const; + bool CanAIAttack(const Unit* who) const override; // Used in scripts to share variables - void DoAction(int32 param = 0); + void DoAction(int32 param = 0) override; // Used in scripts to share variables - uint32 GetData(uint32 id = 0) const; + uint32 GetData(uint32 id = 0) const override; // Used in scripts to share variables - void SetData(uint32 id, uint32 value); + void SetData(uint32 id, uint32 value) override; // Used in scripts to share variables - void SetGUID(uint64 guid, int32 id = 0); + void SetGUID(uint64 guid, int32 id = 0) override; // Used in scripts to share variables - uint64 GetGUID(int32 id = 0) const; + uint64 GetGUID(int32 id = 0) const override; //core related static int Permissible(const Creature*); @@ -174,15 +174,15 @@ class SmartAI : public CreatureAI void SetInvincibilityHpLevel(uint32 level) { mInvincibilityHpLevel = level; } - void sGossipHello(Player* player); - void sGossipSelect(Player* player, uint32 sender, uint32 action); - void sGossipSelectCode(Player* player, uint32 sender, uint32 action, const char* code); - void sQuestAccept(Player* player, Quest const* quest); + void sGossipHello(Player* player) override; + void sGossipSelect(Player* player, uint32 sender, uint32 action) override; + void sGossipSelectCode(Player* player, uint32 sender, uint32 action, const char* code) override; + void sQuestAccept(Player* player, Quest const* quest) override; //void sQuestSelect(Player* player, Quest const* quest); //void sQuestComplete(Player* player, Quest const* quest); - void sQuestReward(Player* player, Quest const* quest, uint32 opt); - bool sOnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex); - void sOnGameEvent(bool start, uint16 eventId); + void sQuestReward(Player* player, Quest const* quest, uint32 opt) override; + bool sOnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex) override; + void sOnGameEvent(bool start, uint16 eventId) override; uint32 mEscortQuestID; @@ -193,7 +193,7 @@ class SmartAI : public CreatureAI } void StartDespawn() { mDespawnState = 2; } - void OnSpellClick(Unit* clicker, bool& result); + void OnSpellClick(Unit* clicker, bool& result) override; private: uint32 mFollowCreditType; @@ -237,23 +237,23 @@ class SmartGameObjectAI : public GameObjectAI SmartGameObjectAI(GameObject* g) : GameObjectAI(g) { } ~SmartGameObjectAI() { } - void UpdateAI(uint32 diff); - void InitializeAI(); - void Reset(); + void UpdateAI(uint32 diff) override; + void InitializeAI() override; + void Reset() override; SmartScript* GetScript() { return &mScript; } static int Permissible(const GameObject* g); - bool GossipHello(Player* player); - bool GossipSelect(Player* player, uint32 sender, uint32 action); - bool GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/); - bool QuestAccept(Player* player, Quest const* quest); - bool QuestReward(Player* player, Quest const* quest, uint32 opt); - void Destroyed(Player* player, uint32 eventId); - void SetData(uint32 id, uint32 value); + bool GossipHello(Player* player) override; + bool GossipSelect(Player* player, uint32 sender, uint32 action) override; + bool GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) override; + bool QuestAccept(Player* player, Quest const* quest) override; + bool QuestReward(Player* player, Quest const* quest, uint32 opt) override; + void Destroyed(Player* player, uint32 eventId) override; + void SetData(uint32 id, uint32 value) override; void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker); - void OnGameEvent(bool start, uint16 eventId); - void OnStateChanged(uint32 state, Unit* unit); - void EventInform(uint32 eventId); + void OnGameEvent(bool start, uint16 eventId) override; + void OnStateChanged(uint32 state, Unit* unit) override; + void EventInform(uint32 eventId) override; private: SmartScript mScript; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index b06ee8613e9..cd80c646a2d 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -3213,7 +3213,7 @@ void SmartScript::InitTimer(SmartScriptHolder& e) void SmartScript::RecalcTimer(SmartScriptHolder& e, uint32 min, uint32 max) { // min/max was checked at loading! - e.timer = urand(uint32(min), uint32(max)); + e.timer = urand(min, max); e.active = e.timer ? false : true; } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index d4afba54498..fbcffb47b7c 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1413,7 +1413,7 @@ class SmartWaypointMgr { if (waypoint_map.find(id) != waypoint_map.end()) return waypoint_map[id]; - else return 0; + else return nullptr; } private: diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index f2637a5febc..855ffd51bb8 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -427,8 +427,8 @@ enum RBACPermissions RBAC_PERM_COMMAND_REPAIRITEMS = 521, RBAC_PERM_COMMAND_RESPAWN = 522, RBAC_PERM_COMMAND_REVIVE = 523, - RBAC_PERM_COMMAND_SAVE = 524, - RBAC_PERM_COMMAND_SAVEALL = 525, + RBAC_PERM_COMMAND_SAVEALL = 524, + RBAC_PERM_COMMAND_SAVE = 525, RBAC_PERM_COMMAND_SETSKILL = 526, RBAC_PERM_COMMAND_SHOWAREA = 527, RBAC_PERM_COMMAND_SUMMON = 528, @@ -549,10 +549,10 @@ enum RBACPermissions RBAC_PERM_COMMAND_RELOAD_EVENT_SCRIPTS = 643, RBAC_PERM_COMMAND_RELOAD_FISHING_LOOT_TEMPLATE = 644, RBAC_PERM_COMMAND_RELOAD_GAME_GRAVEYARD_ZONE = 645, - RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTENDER = 646, - RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUEST_LOOT_TEMPLATE = 647, - RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTSTARTER = 648, - RBAC_PERM_COMMAND_RELOAD_GAME_TELE = 649, + RBAC_PERM_COMMAND_RELOAD_GAME_TELE = 646, + RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTENDER = 647, + RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUEST_LOOT_TEMPLATE = 648, + RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTSTARTER = 649, RBAC_PERM_COMMAND_RELOAD_GM_TICKETS = 650, RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU = 651, RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU_OPTION = 652, @@ -585,34 +585,34 @@ enum RBACPermissions RBAC_PERM_COMMAND_RELOAD_QUEST_TEMPLATE = 679, RBAC_PERM_COMMAND_RELOAD_RBAC = 680, RBAC_PERM_COMMAND_RELOAD_REFERENCE_LOOT_TEMPLATE = 681, - RBAC_PERM_COMMAND_RELOAD_REPUTATION_REWARD_RATE = 682, - RBAC_PERM_COMMAND_RELOAD_RESERVED_NAME = 683, - RBAC_PERM_COMMAND_RELOAD_SKILL_DISCOVERY_TEMPLATE = 684, - RBAC_PERM_COMMAND_RELOAD_SKILL_EXTRA_ITEM_TEMPLATE = 685, - RBAC_PERM_COMMAND_RELOAD_SKILL_FISHING_BASE_LEVEL = 686, - RBAC_PERM_COMMAND_RELOAD_SKINNING_LOOT_TEMPLATE = 687, - RBAC_PERM_COMMAND_RELOAD_SMART_SCRIPTS = 688, - RBAC_PERM_COMMAND_RELOAD_SPELL_AREA = 689, - RBAC_PERM_COMMAND_RELOAD_SPELL_BONUS_DATA = 690, - RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP = 691, - RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES = 692, - RBAC_PERM_COMMAND_RELOAD_SPELL_LEARN_SPELL = 693, - RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL = 694, + RBAC_PERM_COMMAND_RELOAD_RESERVED_NAME = 682, + RBAC_PERM_COMMAND_RELOAD_REPUTATION_REWARD_RATE = 683, + RBAC_PERM_COMMAND_RELOAD_SPILLOVER_TEMPLATE = 684, + RBAC_PERM_COMMAND_RELOAD_SKILL_DISCOVERY_TEMPLATE = 685, + RBAC_PERM_COMMAND_RELOAD_SKILL_EXTRA_ITEM_TEMPLATE = 686, + RBAC_PERM_COMMAND_RELOAD_SKILL_FISHING_BASE_LEVEL = 687, + RBAC_PERM_COMMAND_RELOAD_SKINNING_LOOT_TEMPLATE = 688, + RBAC_PERM_COMMAND_RELOAD_SMART_SCRIPTS = 689, + RBAC_PERM_COMMAND_RELOAD_SPELL_REQUIRED = 690, + RBAC_PERM_COMMAND_RELOAD_SPELL_AREA = 691, + RBAC_PERM_COMMAND_RELOAD_SPELL_BONUS_DATA = 692, + RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP = 693, + RBAC_PERM_COMMAND_RELOAD_SPELL_LEARN_SPELL = 694, RBAC_PERM_COMMAND_RELOAD_SPELL_LOOT_TEMPLATE = 695, - RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS = 696, - RBAC_PERM_COMMAND_RELOAD_SPELL_PROC = 697, + RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL = 696, + RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS = 697, RBAC_PERM_COMMAND_RELOAD_SPELL_PROC_EVENT = 698, - RBAC_PERM_COMMAND_RELOAD_SPELL_REQUIRED = 699, + RBAC_PERM_COMMAND_RELOAD_SPELL_PROC = 699, RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS = 700, RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION = 701, RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS = 702, - RBAC_PERM_COMMAND_RELOAD_SPILLOVER_TEMPLATE = 703, + RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES = 703, RBAC_PERM_COMMAND_RELOAD_TRINITY_STRING = 704, - RBAC_PERM_COMMAND_RELOAD_VEHICLE_ACCESORY = 705, - RBAC_PERM_COMMAND_RELOAD_VEHICLE_TEMPLATE_ACCESSORY = 706, - RBAC_PERM_COMMAND_RELOAD_WARDEN_ACTION = 707, - RBAC_PERM_COMMAND_RELOAD_WAYPOINT_DATA = 708, - RBAC_PERM_COMMAND_RELOAD_WAYPOINT_SCRIPTS = 709, + RBAC_PERM_COMMAND_RELOAD_WARDEN_ACTION = 705, + RBAC_PERM_COMMAND_RELOAD_WAYPOINT_SCRIPTS = 706, + RBAC_PERM_COMMAND_RELOAD_WAYPOINT_DATA = 707, + RBAC_PERM_COMMAND_RELOAD_VEHICLE_ACCESORY = 708, + RBAC_PERM_COMMAND_RELOAD_VEHICLE_TEMPLATE_ACCESSORY = 709, RBAC_PERM_COMMAND_RESET = 710, RBAC_PERM_COMMAND_RESET_ACHIEVEMENTS = 711, RBAC_PERM_COMMAND_RESET_HONOR = 712, diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index e38b9f352e9..547cd9a8502 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -1279,7 +1279,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // check item level and quality via achievement_criteria_data AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(), 0, miscValue1)) + if (!data || !data->Meets(GetPlayer(), nullptr, miscValue1)) continue; SetCriteriaProgress(achievementCriteria, 1); @@ -1301,7 +1301,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // check item level via achievement_criteria_data AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(), 0, pProto->ItemLevel)) + if (!data || !data->Meets(GetPlayer(), nullptr, pProto->ItemLevel)) continue; SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE); @@ -2584,7 +2584,7 @@ void AchievementGlobalMgr::LoadRewardLocales() AchievementRewardLocale& data = m_achievementRewardLocales[entry]; - for (int i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = (LocaleConstant) i; ObjectMgr::AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.subject); @@ -2593,7 +2593,7 @@ void AchievementGlobalMgr::LoadRewardLocales() } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu achievement reward locale strings in %u ms", (unsigned long)m_achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u achievement reward locale strings in %u ms", uint32(m_achievementRewardLocales.size()), GetMSTimeDiffToNow(oldMSTime)); } AchievementEntry const* AchievementGlobalMgr::GetAchievement(uint32 achievementId) const diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 15498d1f045..c6bfee40cd2 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -245,12 +245,12 @@ class Battlefield : public ZoneScript void HandlePlayerLeaveZone(Player* player, uint32 zone); // All-purpose data storage 64 bit - virtual uint64 GetData64(uint32 dataId) const { return m_Data64[dataId]; } - virtual void SetData64(uint32 dataId, uint64 value) { m_Data64[dataId] = value; } + virtual uint64 GetData64(uint32 dataId) const override { return m_Data64[dataId]; } + virtual void SetData64(uint32 dataId, uint64 value) override { m_Data64[dataId] = value; } // All-purpose data storage 32 bit - virtual uint32 GetData(uint32 dataId) const { return m_Data32[dataId]; } - virtual void SetData(uint32 dataId, uint32 value) { m_Data32[dataId] = value; } + virtual uint32 GetData(uint32 dataId) const override { return m_Data32[dataId]; } + virtual void SetData(uint32 dataId, uint32 value) override { m_Data32[dataId] = value; } virtual void UpdateData(uint32 index, int32 pad) { m_Data32[index] += pad; } // Battlefield - generic methods diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index 0ba9e816b2e..341ccdeb44c 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -255,7 +255,7 @@ class WintergraspCapturePoint : public BfCapturePoint void LinkToWorkshop(WGWorkshop* workshop) { m_Workshop = workshop; } - void ChangeTeam(TeamId oldteam); + void ChangeTeam(TeamId oldteam) override; TeamId GetTeam() const { return m_team; } protected: @@ -276,7 +276,7 @@ class BattlefieldWG : public Battlefield * - Rebuild tower and wall * - Invite player to war */ - void OnBattleStart(); + void OnBattleStart() override; /** * \brief Called when battle end @@ -287,13 +287,13 @@ class BattlefieldWG : public Battlefield * - Remove vehicle * \param endByTimer : true if battle ended when timer is at 00:00, false if battle ended by clicking on relic */ - void OnBattleEnd(bool endByTimer); + void OnBattleEnd(bool endByTimer) override; /** * \brief Called when grouping starts (15 minutes before battlestart) * - Invite all player in zone to join queue */ - void OnStartGrouping(); + void OnStartGrouping() override; /** * \brief Called when player accept invite to join battle @@ -303,20 +303,20 @@ class BattlefieldWG : public Battlefield * - Update tenacity * \param player: Player who accepted invite */ - void OnPlayerJoinWar(Player* player); + void OnPlayerJoinWar(Player* player) override; /** * \brief Called when player left the battle * - Update player aura * \param player : Player who left the battle */ - void OnPlayerLeaveWar(Player* player); + void OnPlayerLeaveWar(Player* player) override; /** * \brief Called when player left the WG zone * \param player : Player who left the zone */ - void OnPlayerLeaveZone(Player* player); + void OnPlayerLeaveZone(Player* player) override; /** * \brief Called when player enters in WG zone @@ -324,7 +324,7 @@ class BattlefieldWG : public Battlefield * - Update worldstate * \param player : Player who enters the zone */ - void OnPlayerEnterZone(Player* player); + void OnPlayerEnterZone(Player* player) override; /** * \brief Called for update battlefield data @@ -332,24 +332,24 @@ class BattlefieldWG : public Battlefield * - Update imunity aura from graveyard * \param diff : time elapsed since the last call (in ms) */ - bool Update(uint32 diff); + bool Update(uint32 diff) override; /** * \brief Called when a creature is created * - Update vehicle count */ - void OnCreatureCreate(Creature* creature); + void OnCreatureCreate(Creature* creature) override; /** * \brief Called when a creature is removed * - Update vehicle count */ - void OnCreatureRemove(Creature* creature); + void OnCreatureRemove(Creature* creature) override; /** * \brief Called when a gameobject is created */ - void OnGameObjectCreate(GameObject* go); + void OnGameObjectCreate(GameObject* go) override; /** * \brief Called when a wall/tower is broken @@ -370,14 +370,14 @@ class BattlefieldWG : public Battlefield */ void UpdatedDestroyedTowerCount(TeamId team); - void DoCompleteOrIncrementAchievement(uint32 achievement, Player* player, uint8 incrementNumber = 1); + void DoCompleteOrIncrementAchievement(uint32 achievement, Player* player, uint8 incrementNumber = 1) override; void RemoveAurasFromPlayer(Player* player); /** * \brief Called when battlefield is setup, at server start */ - bool SetupBattlefield(); + bool SetupBattlefield() override; /// Return pointer to relic object GameObject* GetRelic() { return GetGameObject(m_titansRelicGUID); } @@ -395,22 +395,22 @@ class BattlefieldWG : public Battlefield void UpdateCounterVehicle(bool init); void SendInitWorldStatesTo(Player* player); - void SendInitWorldStatesToAll(); - void FillInitialWorldStates(WorldPacket& data); + void SendInitWorldStatesToAll() override; + void FillInitialWorldStates(WorldPacket& data) override; - void HandleKill(Player* killer, Unit* victim); - void OnUnitDeath(Unit* unit); + void HandleKill(Player* killer, Unit* victim) override; + void OnUnitDeath(Unit* unit) override; void PromotePlayer(Player* killer); void UpdateTenacity(); - void ProcessEvent(WorldObject* obj, uint32 eventId); + void ProcessEvent(WorldObject* obj, uint32 eventId) override; bool FindAndRemoveVehicleFromList(Unit* vehicle); // returns the graveyardId in the specified area. uint8 GetSpiritGraveyardId(uint32 areaId) const; - uint32 GetData(uint32 data) const; + uint32 GetData(uint32 data) const override; protected: bool m_isRelicInteractible; diff --git a/src/server/game/Battlegrounds/ArenaScore.h b/src/server/game/Battlegrounds/ArenaScore.h index 638275b1833..bd0ea6b02e9 100644 --- a/src/server/game/Battlegrounds/ArenaScore.h +++ b/src/server/game/Battlegrounds/ArenaScore.h @@ -28,7 +28,7 @@ struct ArenaScore : public BattlegroundScore protected: ArenaScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid), TeamId(team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE) { } - void AppendToPacket(WorldPacket& data) final + void AppendToPacket(WorldPacket& data) final override { data << uint64(PlayerGuid); @@ -40,7 +40,7 @@ struct ArenaScore : public BattlegroundScore BuildObjectivesBlock(data); } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(0); // Objectives Count } diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 86236cd0f2b..3a59ffa8cf9 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -844,12 +844,14 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac Player* player = ObjectAccessor::FindPlayer(guid); - // should remove spirit of redemption if (player) { + // should remove spirit of redemption if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); + player->RemoveAurasByType(SPELL_AURA_MOUNTED); + if (!player->IsAlive()) // resurrect on exit { player->ResurrectPlayer(1.0f); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index af283cb825f..f95e8bafd06 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -143,8 +143,8 @@ class BGQueueInviteEvent : public BasicEvent { } virtual ~BGQueueInviteEvent() { } - virtual bool Execute(uint64 e_time, uint32 p_time); - virtual void Abort(uint64 e_time); + virtual bool Execute(uint64 e_time, uint32 p_time) override; + virtual void Abort(uint64 e_time) override; private: uint64 m_PlayerGuid; uint32 m_BgInstanceGUID; @@ -167,8 +167,8 @@ class BGQueueRemoveEvent : public BasicEvent virtual ~BGQueueRemoveEvent() { } - virtual bool Execute(uint64 e_time, uint32 p_time); - virtual void Abort(uint64 e_time); + virtual bool Execute(uint64 e_time, uint32 p_time) override; + virtual void Abort(uint64 e_time) override; private: uint64 m_PlayerGuid; uint32 m_BgInstanceGUID; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index a6b4be10fdf..7655880117f 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -260,7 +260,7 @@ struct BattlegroundABScore final : public BattlegroundScore } } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(2); data << uint32(BasesAssaulted); @@ -277,31 +277,31 @@ class BattlegroundAB : public Battleground BattlegroundAB(); ~BattlegroundAB(); - void AddPlayer(Player* player); - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); - void RemovePlayer(Player* player, uint64 guid, uint32 team); - void HandleAreaTrigger(Player* Source, uint32 Trigger); - bool SetupBattleground(); - void Reset(); - void EndBattleground(uint32 winner); - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + void AddPlayer(Player* player) override; + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; + void RemovePlayer(Player* player, uint64 guid, uint32 team) override; + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + bool SetupBattleground() override; + void Reset() override; + void EndBattleground(uint32 winner) override; + WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; /* Scorekeeping */ bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; - void FillInitialWorldStates(WorldPacket& data); + void FillInitialWorldStates(WorldPacket& data) override; /* Nodes occupying */ - void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); + void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override; /* achievement req. */ - bool IsAllNodesControlledByTeam(uint32 team) const; - bool CheckAchievementCriteriaMeet(uint32 /*criteriaId*/, Player const* /*player*/, Unit const* /*target*/ = NULL, uint32 /*miscvalue1*/ = 0); + bool IsAllNodesControlledByTeam(uint32 team) const override; + bool CheckAchievementCriteriaMeet(uint32 /*criteriaId*/, Player const* /*player*/, Unit const* /*target*/ = nullptr, uint32 /*miscvalue1*/ = 0) override; - uint32 GetPrematureWinner(); + uint32 GetPrematureWinner() override; private: - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; /* Gameobject spawning/despawning */ void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay); void _DelBanner(uint8 node, uint8 type, uint8 teamIndex); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index feb3c016e55..882d729c1e8 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1558,7 +1558,7 @@ struct BattlegroundAVScore final : public BattlegroundScore } } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(5); // Objectives Count data << uint32(GraveyardsAssaulted); @@ -1582,37 +1582,37 @@ class BattlegroundAV : public Battleground ~BattlegroundAV(); /* inherited from BattlegroundClass */ - void AddPlayer(Player* player); - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void AddPlayer(Player* player) override; + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; - void RemovePlayer(Player* player, uint64 guid, uint32 team); - void HandleAreaTrigger(Player* player, uint32 trigger); - bool SetupBattleground(); - void ResetBGSubclass(); + void RemovePlayer(Player* player, uint64 guid, uint32 team) override; + void HandleAreaTrigger(Player* player, uint32 trigger) override; + bool SetupBattleground() override; + void ResetBGSubclass() override; /*general stuff*/ void UpdateScore(uint16 team, int16 points); bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; /*handlestuff*/ //these are functions which get called from extern - void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); - void HandleKillPlayer(Player* player, Player* killer); - void HandleKillUnit(Creature* unit, Player* killer); - void HandleQuestComplete(uint32 questid, Player* player); - bool CanActivateGO(int32 GOId, uint32 team) const; + void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override; + void HandleKillPlayer(Player* player, Player* killer) override; + void HandleKillUnit(Creature* unit, Player* killer) override; + void HandleQuestComplete(uint32 questid, Player* player) override; + bool CanActivateGO(int32 GOId, uint32 team) const override; - void EndBattleground(uint32 winner); + void EndBattleground(uint32 winner) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; // Achievement: Av perfection and Everything counts - bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = NULL, uint32 miscvalue1 = 0); + bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = nullptr, uint32 miscvalue1 = 0) override; - uint32 GetPrematureWinner(); + uint32 GetPrematureWinner() override; private: - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; /* Nodes occupying */ void EventPlayerAssaultsPoint(Player* player, uint32 object); @@ -1636,7 +1636,7 @@ class BattlegroundAV : public Battleground void ChangeMineOwner(uint8 mine, uint32 team, bool initial=false); /*worldstates*/ - void FillInitialWorldStates(WorldPacket& data); + void FillInitialWorldStates(WorldPacket& data) override; uint8 GetWorldStateType(uint8 state, uint16 team); void SendMineWorldStates(uint32 mine); void UpdateNodeWorldState(BG_AV_Nodes node); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h index f391edbf747..6aa3e56ca13 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h @@ -48,11 +48,11 @@ class BattlegroundBE : public Arena BattlegroundBE(); /* inherited from BattlegroundClass */ - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; - void HandleAreaTrigger(Player* Source, uint32 Trigger); - bool SetupBattleground(); - void FillInitialWorldStates(WorldPacket &d); + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + bool SetupBattleground() override; + void FillInitialWorldStates(WorldPacket &d) override; }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index 4c763316d83..7b91996ed0e 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -94,15 +94,15 @@ class BattlegroundDS : public Arena BattlegroundDS(); /* inherited from BattlegroundClass */ - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; - void HandleAreaTrigger(Player* Source, uint32 Trigger); - bool SetupBattleground(); - void FillInitialWorldStates(WorldPacket &d); + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + bool SetupBattleground() override; + void FillInitialWorldStates(WorldPacket &d) override; private: - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; EventMap _events; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 056deb3498b..4a146a17917 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -343,7 +343,7 @@ struct BattlegroundEYScore final : public BattlegroundScore } } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(1); // Objectives Count data << uint32(FlagCaptures); @@ -359,42 +359,42 @@ class BattlegroundEY : public Battleground ~BattlegroundEY(); /* inherited from BattlegroundClass */ - void AddPlayer(Player* player); - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void AddPlayer(Player* player) override; + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; /* BG Flags */ - uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return m_FlagKeeper; } + uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const override { return m_FlagKeeper; } void SetFlagPicker(uint64 guid) { m_FlagKeeper = guid; } bool IsFlagPickedup() const { return m_FlagKeeper != 0; } uint8 GetFlagState() const { return m_FlagState; } void RespawnFlag(bool send_message); void RespawnFlagAfterDrop(); - void RemovePlayer(Player* player, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team) override; void HandleBuffUse(uint64 buff_guid); - void HandleAreaTrigger(Player* Source, uint32 Trigger); - void HandleKillPlayer(Player* player, Player* killer); - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); - bool SetupBattleground(); - void Reset(); + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + void HandleKillPlayer(Player* player, Player* killer) override; + WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + bool SetupBattleground() override; + void Reset() override; void UpdateTeamScore(uint32 Team); - void EndBattleground(uint32 winner); + void EndBattleground(uint32 winner) override; bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; - void FillInitialWorldStates(WorldPacket& data); - void SetDroppedFlagGUID(uint64 guid, int32 /*TeamID*/ = -1) { m_DroppedFlagGUID = guid;} + void FillInitialWorldStates(WorldPacket& data) override; + void SetDroppedFlagGUID(uint64 guid, int32 /*TeamID*/ = -1) override { m_DroppedFlagGUID = guid;} uint64 GetDroppedFlagGUID() const { return m_DroppedFlagGUID;} /* Battleground Events */ - void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj); - void EventPlayerDroppedFlag(Player* Source); + void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) override; + void EventPlayerDroppedFlag(Player* Source) override; /* achievement req. */ - bool IsAllNodesControlledByTeam(uint32 team) const; + bool IsAllNodesControlledByTeam(uint32 team) const override; - uint32 GetPrematureWinner(); + uint32 GetPrematureWinner() override; private: - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; void EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType); void EventTeamCapturedPoint(Player* Source, uint32 Point); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 0b317cabef3..5a9b47ec9b5 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -871,7 +871,7 @@ struct BattlegroundICScore final : public BattlegroundScore } } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(2); // Objectives Count data << uint32(BasesAssaulted); @@ -889,36 +889,36 @@ class BattlegroundIC : public Battleground ~BattlegroundIC(); /* inherited from BattlegroundClass */ - void AddPlayer(Player* player); - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); - void PostUpdateImpl(uint32 diff); - - void RemovePlayer(Player* player, uint64 guid, uint32 team); - void HandleAreaTrigger(Player* player, uint32 trigger); - bool SetupBattleground(); + void AddPlayer(Player* player) override; + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; + void PostUpdateImpl(uint32 diff) override; + + void RemovePlayer(Player* player, uint64 guid, uint32 team) override; + void HandleAreaTrigger(Player* player, uint32 trigger) override; + bool SetupBattleground() override; void SpawnLeader(uint32 teamid); - void HandleKillUnit(Creature* unit, Player* killer); - void HandleKillPlayer(Player* player, Player* killer); - void EndBattleground(uint32 winner); - void EventPlayerClickedOnFlag(Player* source, GameObject* /*target_obj*/); + void HandleKillUnit(Creature* unit, Player* killer) override; + void HandleKillPlayer(Player* player, Player* killer) override; + void EndBattleground(uint32 winner) override; + void EventPlayerClickedOnFlag(Player* source, GameObject* /*target_obj*/) override; - void DestroyGate(Player* player, GameObject* go); + void DestroyGate(Player* player, GameObject* go) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; /* Scorekeeping */ - void FillInitialWorldStates(WorldPacket& data); + void FillInitialWorldStates(WorldPacket& data) override; - void DoAction(uint32 action, uint64 var); + void DoAction(uint32 action, uint64 var) override; - void HandlePlayerResurrect(Player* player); + void HandlePlayerResurrect(Player* player) override; uint32 GetNodeState(uint8 nodeType) const { return (uint8)nodePoint[nodeType].nodeState; } - bool IsAllNodesControlledByTeam(uint32 team) const; + bool IsAllNodesControlledByTeam(uint32 team) const override; - bool IsSpellAllowed(uint32 spellId, Player const* player) const; + bool IsSpellAllowed(uint32 spellId, Player const* player) const override; private: uint32 closeFortressDoorsTimer; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h index 2fa93a07651..17df258a0b8 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h @@ -47,11 +47,11 @@ class BattlegroundNA : public Arena BattlegroundNA(); /* inherited from BattlegroundClass */ - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; - void HandleAreaTrigger(Player* Source, uint32 Trigger); - bool SetupBattleground(); - void FillInitialWorldStates(WorldPacket &d); + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + bool SetupBattleground() override; + void FillInitialWorldStates(WorldPacket &d) override; }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h index ad4fe18a3c7..e96129b05f0 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h @@ -43,11 +43,11 @@ class BattlegroundRL : public Arena BattlegroundRL(); /* inherited from BattlegroundClass */ - void FillInitialWorldStates(WorldPacket &d); - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void FillInitialWorldStates(WorldPacket &d) override; + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; - void HandleAreaTrigger(Player* Source, uint32 Trigger); - bool SetupBattleground(); + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + bool SetupBattleground() override; }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h index d23f6757b83..eda4bf7fa00 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h @@ -96,14 +96,14 @@ class BattlegroundRV : public Arena BattlegroundRV(); /* inherited from BattlegroundClass */ - void StartingEventOpenDoors(); - void FillInitialWorldStates(WorldPacket &d); + void StartingEventOpenDoors() override; + void FillInitialWorldStates(WorldPacket &d) override; - void HandleAreaTrigger(Player* Source, uint32 Trigger); - bool SetupBattleground(); + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; + bool SetupBattleground() override; private: - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; void TogglePillarCollision(); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index a3947334417..627c23850d2 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -531,7 +531,7 @@ struct BattlegroundSAScore final : public BattlegroundScore } } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(2); // Objectives Count data << uint32(DemolishersDestroyed); @@ -554,27 +554,27 @@ class BattlegroundSA : public Battleground * -Update timer * -Round switch */ - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; /* inherited from BattlegroundClass */ /// Called when a player join battle - void AddPlayer(Player* player); + void AddPlayer(Player* player) override; /// Called when battle start - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; /// Called for ini battleground, after that the first player be entered - bool SetupBattleground(); - void Reset(); + bool SetupBattleground() override; + void Reset() override; /// Called for generate packet contain worldstate data - void FillInitialWorldStates(WorldPacket& data); + void FillInitialWorldStates(WorldPacket& data) override; /// Called when a player kill a unit in bg - void HandleKillUnit(Creature* creature, Player* killer); + void HandleKillUnit(Creature* creature, Player* killer) override; /// Return the nearest graveyard where player can respawn - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; /// Called when someone activates an event void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/, WorldObject* /*invoker*/ = NULL) override; /// Called when a player click on flag (graveyard flag) - void EventPlayerClickedOnFlag(Player* source, GameObject* go); + void EventPlayerClickedOnFlag(Player* source, GameObject* go) override; /// Called when a player clicked on relic void TitanRelicActivated(Player* clicker); @@ -588,11 +588,11 @@ class BattlegroundSA : public Battleground } /// Called on battleground ending - void EndBattleground(uint32 winner); + void EndBattleground(uint32 winner) override; /// Called when a player leave battleground - void RemovePlayer(Player* player, uint64 guid, uint32 team); - void HandleAreaTrigger(Player* Source, uint32 Trigger); + void RemovePlayer(Player* player, uint64 guid, uint32 team) override; + void HandleAreaTrigger(Player* Source, uint32 Trigger) override; /* Scorekeeping */ @@ -630,7 +630,7 @@ class BattlegroundSA : public Battleground * -Update worldstate * -Delete gameobject in front of door (lighting object, with different colours for each door) */ - void DestroyGate(Player* player, GameObject* go); + void DestroyGate(Player* player, GameObject* go) override; /// Update timer worldstate void SendTime(); /** diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index 3d449580fb9..d29715c982b 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -170,7 +170,7 @@ struct BattlegroundWGScore final : public BattlegroundScore } } - void BuildObjectivesBlock(WorldPacket& data) final + void BuildObjectivesBlock(WorldPacket& data) final override { data << uint32(2); // Objectives Count data << uint32(FlagCaptures); @@ -189,12 +189,12 @@ class BattlegroundWS : public Battleground ~BattlegroundWS(); /* inherited from BattlegroundClass */ - void AddPlayer(Player* player); - void StartingEventCloseDoors(); - void StartingEventOpenDoors(); + void AddPlayer(Player* player) override; + void StartingEventCloseDoors() override; + void StartingEventOpenDoors() override; /* BG Flags */ - uint64 GetFlagPickerGUID(int32 team) const + uint64 GetFlagPickerGUID(int32 team) const override { if (team == TEAM_ALLIANCE || team == TEAM_HORDE) return m_FlagKeepers[team]; @@ -209,40 +209,40 @@ class BattlegroundWS : public Battleground uint8 GetFlagState(uint32 team) { return _flagState[GetTeamIndexByTeamId(team)]; } /* Battleground Events */ - void EventPlayerDroppedFlag(Player* player); - void EventPlayerClickedOnFlag(Player* player, GameObject* target_obj); + void EventPlayerDroppedFlag(Player* player) override; + void EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) override; void EventPlayerCapturedFlag(Player* player); - void RemovePlayer(Player* player, uint64 guid, uint32 team); - void HandleAreaTrigger(Player* player, uint32 trigger); - void HandleKillPlayer(Player* player, Player* killer); - bool SetupBattleground(); - void Reset(); - void EndBattleground(uint32 winner); - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + void RemovePlayer(Player* player, uint64 guid, uint32 team) override; + void HandleAreaTrigger(Player* player, uint32 trigger) override; + void HandleKillPlayer(Player* player, Player* killer) override; + bool SetupBattleground() override; + void Reset() override; + void EndBattleground(uint32 winner) override; + WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; void UpdateFlagState(uint32 team, uint32 value); void SetLastFlagCapture(uint32 team) { _lastFlagCaptureTeam = team; } void UpdateTeamScore(uint32 team); bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; - void SetDroppedFlagGUID(uint64 guid, int32 team = -1) + void SetDroppedFlagGUID(uint64 guid, int32 team = -1) override { if (team == TEAM_ALLIANCE || team == TEAM_HORDE) m_DroppedFlagGUID[team] = guid; } uint64 GetDroppedFlagGUID(uint32 TeamID) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)];} - void FillInitialWorldStates(WorldPacket& data); + void FillInitialWorldStates(WorldPacket& data) override; /* Scorekeeping */ void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; } void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } - uint32 GetPrematureWinner(); + uint32 GetPrematureWinner() override; /* Achievements*/ - bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = NULL, uint32 miscvalue1 = 0); + bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = nullptr, uint32 miscvalue1 = 0) override; private: uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde @@ -260,6 +260,6 @@ class BattlegroundWS : public Battleground uint8 _flagDebuffState; // 0 - no debuffs, 1 - focused assault, 2 - brutal assault uint8 _minutesElapsed; - void PostUpdateImpl(uint32 diff); + void PostUpdateImpl(uint32 diff) override; }; #endif diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index d77ee5b7f61..50f67d4f920 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -966,7 +966,7 @@ static char const* const spellKeys[] = "Henchant", // enchanting recipe spell "Htrade", // profession/skill spell "Hglyph", // glyph - 0 + nullptr }; uint32 ChatHandler::extractSpellIdFromLink(char* text) @@ -1050,7 +1050,7 @@ static char const* const guidKeys[] = "Hplayer", "Hcreature", "Hgameobject", - 0 + nullptr }; uint64 ChatHandler::extractGuidFromLink(char* text) diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index a56b79077d7..32820de0fc2 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -147,14 +147,14 @@ class CliHandler : public ChatHandler explicit CliHandler(void* callbackArg, Print* zprint) : m_callbackArg(callbackArg), m_print(zprint) { } // overwrite functions - const char *GetTrinityString(int32 entry) const; - bool isAvailable(ChatCommand const& cmd) const; - bool HasPermission(uint32 /*permission*/) const { return true; } - void SendSysMessage(const char *str); - std::string GetNameLink() const; - bool needReportToTarget(Player* chr) const; - LocaleConstant GetSessionDbcLocale() const; - int GetSessionDbLocaleIndex() const; + const char *GetTrinityString(int32 entry) const override; + bool isAvailable(ChatCommand const& cmd) const override; + bool HasPermission(uint32 /*permission*/) const override { return true; } + void SendSysMessage(const char *str) override; + std::string GetNameLink() const override; + bool needReportToTarget(Player* chr) const override; + LocaleConstant GetSessionDbcLocale() const override; + int GetSessionDbLocaleIndex() const override; private: void* m_callbackArg; diff --git a/src/server/game/Chat/ChatLink.h b/src/server/game/Chat/ChatLink.h index 4cfa9c34bf7..33fb3431a84 100644 --- a/src/server/game/Chat/ChatLink.h +++ b/src/server/game/Chat/ChatLink.h @@ -61,8 +61,8 @@ public: { memset(_data, 0, sizeof(_data)); } - virtual bool Initialize(std::istringstream& iss); - virtual bool ValidateName(char* buffer, const char* context); + virtual bool Initialize(std::istringstream& iss) override; + virtual bool ValidateName(char* buffer, const char* context) override; protected: std::string FormatName(uint8 index, ItemLocale const* locale, char* const* suffixStrings) const; @@ -77,9 +77,9 @@ protected: class QuestChatLink : public ChatLink { public: - QuestChatLink() : ChatLink(), _quest(NULL), _questLevel(0) { } - virtual bool Initialize(std::istringstream& iss); - virtual bool ValidateName(char* buffer, const char* context); + QuestChatLink() : ChatLink(), _quest(nullptr), _questLevel(0) { } + virtual bool Initialize(std::istringstream& iss) override; + virtual bool ValidateName(char* buffer, const char* context) override; protected: Quest const* _quest; @@ -90,9 +90,9 @@ protected: class SpellChatLink : public ChatLink { public: - SpellChatLink() : ChatLink(), _spell(NULL) { } - virtual bool Initialize(std::istringstream& iss); - virtual bool ValidateName(char* buffer, const char* context); + SpellChatLink() : ChatLink(), _spell(nullptr) { } + virtual bool Initialize(std::istringstream& iss) override; + virtual bool ValidateName(char* buffer, const char* context) override; protected: SpellInfo const* _spell; @@ -106,8 +106,8 @@ public: { memset(_data, 0, sizeof(_data)); } - virtual bool Initialize(std::istringstream& iss); - virtual bool ValidateName(char* buffer, const char* context); + virtual bool Initialize(std::istringstream& iss) override; + virtual bool ValidateName(char* buffer, const char* context) override; protected: uint32 _guid; @@ -120,7 +120,7 @@ class TradeChatLink : public SpellChatLink { public: TradeChatLink() : SpellChatLink(), _minSkillLevel(0), _maxSkillLevel(0), _guid(0) { } - virtual bool Initialize(std::istringstream& iss); + virtual bool Initialize(std::istringstream& iss) override; private: int32 _minSkillLevel; int32 _maxSkillLevel; @@ -133,7 +133,7 @@ class TalentChatLink : public SpellChatLink { public: TalentChatLink() : SpellChatLink(), _talentId(0), _rankId(0) { } - virtual bool Initialize(std::istringstream& iss); + virtual bool Initialize(std::istringstream& iss) override; private: uint32 _talentId; @@ -145,7 +145,7 @@ class EnchantmentChatLink : public SpellChatLink { public: EnchantmentChatLink() : SpellChatLink() { } - virtual bool Initialize(std::istringstream& iss); + virtual bool Initialize(std::istringstream& iss) override; }; // GlyphChatLink - link to glyph @@ -153,7 +153,7 @@ class GlyphChatLink : public SpellChatLink { public: GlyphChatLink() : SpellChatLink(), _slotId(0), _glyph(NULL) { } - virtual bool Initialize(std::istringstream& iss); + virtual bool Initialize(std::istringstream& iss) override; private: uint32 _slotId; GlyphPropertiesEntry const* _glyph; diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index dd5904ae2ec..f0741f81067 100644 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -117,13 +117,13 @@ class HostileReference : public Reference<Unit, ThreatManager> //================================================= // Tell our refTo (target) object that we have a link - void targetObjectBuildLink(); + void targetObjectBuildLink() override; // Tell our refTo (taget) object, that the link is cut - void targetObjectDestroyLink(); + void targetObjectDestroyLink() override; // Tell our refFrom (source) object, that the link is cut (Target destroyed) - void sourceObjectDestroyLink(); + void sourceObjectDestroyLink() override; private: // Inform the source, that the status of that reference was changed void fireStatusChanged(ThreatRefStatusChangeEvent& threatRefStatusChangeEvent); diff --git a/src/server/game/DungeonFinding/LFGScripts.h b/src/server/game/DungeonFinding/LFGScripts.h index 1ed37bd9d05..3f1dcbb218b 100644 --- a/src/server/game/DungeonFinding/LFGScripts.h +++ b/src/server/game/DungeonFinding/LFGScripts.h @@ -35,9 +35,9 @@ class LFGPlayerScript : public PlayerScript LFGPlayerScript(); // Player Hooks - void OnLogout(Player* player); - void OnLogin(Player* player, bool loginFirst); - void OnMapChanged(Player* player); + void OnLogout(Player* player) override; + void OnLogin(Player* player, bool loginFirst) override; + void OnMapChanged(Player* player) override; }; class LFGGroupScript : public GroupScript @@ -46,11 +46,11 @@ class LFGGroupScript : public GroupScript LFGGroupScript(); // Group Hooks - void OnAddMember(Group* group, uint64 guid); - void OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason); - void OnDisband(Group* group); - void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid); - void OnInviteMember(Group* group, uint64 guid); + void OnAddMember(Group* group, uint64 guid) override; + void OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason) override; + void OnDisband(Group* group) override; + void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) override; + void OnInviteMember(Group* group, uint64 guid) override; }; } // namespace lfg diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index def84dd93a9..5039c85bcb9 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -52,8 +52,8 @@ class Corpse : public WorldObject, public GridObject<Corpse> explicit Corpse(CorpseType type = CORPSE_BONES); ~Corpse(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; bool Create(uint32 guidlow, Map* map); bool Create(uint32 guidlow, Player* owner); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index c9a2015dbb8..c04f2845110 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -384,9 +384,9 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - SetAttackTime(BASE_ATTACK, cInfo->baseattacktime); - SetAttackTime(OFF_ATTACK, cInfo->baseattacktime); - SetAttackTime(RANGED_ATTACK, cInfo->rangeattacktime); + SetAttackTime(BASE_ATTACK, cInfo->BaseAttackTime); + SetAttackTime(OFF_ATTACK, cInfo->BaseAttackTime); + SetAttackTime(RANGED_ATTACK, cInfo->RangeAttackTime); SelectLevel(); @@ -815,7 +815,7 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, void Creature::InitializeReactState() { - if (IsTotem() || IsTrigger() || GetCreatureType() == CREATURE_TYPE_CRITTER || IsSpiritService()) + if (IsTotem() || IsTrigger() || IsCritter() || IsSpiritService()) SetReactState(REACT_PASSIVE); /* else if (IsCivilian()) @@ -2277,7 +2277,7 @@ void Creature::AllLootRemovedFromCorpse() if (loot.loot_type == LOOT_SKINNING) m_corpseRemoveTime = now; else - m_corpseRemoveTime = now + m_corpseDelay * decayRate; + m_corpseRemoveTime = now + uint32(m_corpseDelay * decayRate); m_respawnTime = m_corpseRemoveTime + m_respawnDelay; } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 1154bc17d1f..9b332bb5de4 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -64,12 +64,12 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_NO_SKILLGAIN | CREATURE_FLAG_EXTRA_TAUNT_DIMINISH | CREATURE_FLAG_EXTRA_ALL_DIMINISH | \ CREATURE_FLAG_EXTRA_GUARD) -#define MAX_KILL_CREDIT 2 #define CREATURE_REGEN_INTERVAL 2 * IN_MILLISECONDS +#define MAX_KILL_CREDIT 2 +#define MAX_CREATURE_MODELS 4 #define MAX_CREATURE_QUEST_ITEMS 6 - -#define MAX_EQUIPMENT_ITEMS 3 +#define CREATURE_MAX_SPELLS 8 // from `creature_template` table struct CreatureTemplate @@ -94,13 +94,11 @@ struct CreatureTemplate float speed_run; float scale; uint32 rank; - float mindmg; - float maxdmg; uint32 dmgschool; - uint32 attackpower; - float dmg_multiplier; - uint32 baseattacktime; - uint32 rangeattacktime; + uint32 BaseAttackTime; + uint32 RangeAttackTime; + float BaseVariance; + float RangeVariance; uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures. uint32 unit_flags; // enum UnitFlags mask values uint32 unit_flags2; // enum UnitFlags2 mask values @@ -110,9 +108,6 @@ struct CreatureTemplate uint32 trainer_spell; uint32 trainer_class; uint32 trainer_race; - float minrangedmg; - float maxrangedmg; - uint32 rangedattackpower; uint32 type; // enum CreatureType values uint32 type_flags; // enum CreatureTypeFlags mask values uint32 lootid; @@ -131,6 +126,8 @@ struct CreatureTemplate float ModHealth; float ModMana; float ModArmor; + float ModDamage; + float ModExperience; bool RacialLeader; uint32 questItems[MAX_CREATURE_QUEST_ITEMS]; uint32 movementId; @@ -237,6 +234,8 @@ struct PointOfInterestLocale StringVector IconName; }; +#define MAX_EQUIPMENT_ITEMS 3 + struct EquipmentInfo { uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]; @@ -428,11 +427,11 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject explicit Creature(bool isWorldObject = false); virtual ~Creature(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void SetObjectScale(float scale); - void SetDisplayId(uint32 modelId); + void SetObjectScale(float scale) override; + void SetDisplayId(uint32 modelId) override; void DisappearAndDie(); @@ -443,8 +442,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } - void Update(uint32 time); // overwrited Unit::Update - void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; + void Update(uint32 time) override; // overwrited Unit::Update + void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr, float* dist =nullptr) const; void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } uint32 GetCorpseDelay() const { return m_corpseDelay; } @@ -454,7 +453,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject bool IsGuard() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD) != 0; } bool CanWalk() const { return (GetCreatureTemplate()->InhabitType & INHABIT_GROUND) != 0; } bool CanSwim() const { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) != 0 || IsPet(); } - bool CanFly() const { return (GetCreatureTemplate()->InhabitType & INHABIT_AIR) != 0; } + bool CanFly() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_AIR) != 0; } void SetReactState(ReactStates st) { m_reactState = st; } ReactStates GetReactState() { return m_reactState; } @@ -465,14 +464,14 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject bool isCanInteractWithBattleMaster(Player* player, bool msg) const; bool isCanTrainingAndResetTalentsOf(Player* player) const; bool CanCreatureAttack(Unit const* victim, bool force = true) const; - bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // override Unit::IsImmunedToSpell - bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; // override Unit::IsImmunedToSpellEffect + bool IsImmunedToSpell(SpellInfo const* spellInfo) const override; // override Unit::IsImmunedToSpell + bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; // override Unit::IsImmunedToSpellEffect bool isElite() const; bool isWorldBoss() const; bool IsDungeonBoss() const; - uint8 getLevelForTarget(WorldObject const* target) const; // overwrite Unit::getLevelForTarget for boss level support + uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); } @@ -481,17 +480,17 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject CreatureAI* AI() const { return (CreatureAI*)i_AI; } - bool SetWalk(bool enable); - bool SetDisableGravity(bool disable, bool packetOnly = false); - bool SetSwim(bool enable); - bool SetCanFly(bool enable); - bool SetWaterWalking(bool enable, bool packetOnly = false); - bool SetFeatherFall(bool enable, bool packetOnly = false); - bool SetHover(bool enable, bool packetOnly = false); + bool SetWalk(bool enable) override; + bool SetDisableGravity(bool disable, bool packetOnly = false) override; + bool SetSwim(bool enable) override; + bool SetCanFly(bool enable) override; + bool SetWaterWalking(bool enable, bool packetOnly = false) override; + bool SetFeatherFall(bool enable, bool packetOnly = false) override; + bool SetHover(bool enable, bool packetOnly = false) override; - uint32 GetShieldBlockValue() const; + uint32 GetShieldBlockValue() const override; - SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; } + SpellSchoolMask GetMeleeDamageSchoolMask() const override { return m_meleeDamageSchoolMask; } void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); } void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time); @@ -500,21 +499,21 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const; - virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override; - bool HasSpell(uint32 spellID) const; + bool HasSpell(uint32 spellID) const override; bool UpdateEntry(uint32 entry, CreatureData const* data = nullptr); void UpdateMovementFlags(); - bool UpdateStats(Stats stat); - bool UpdateAllStats(); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); - void UpdateAttackPowerAndDamage(bool ranged = false); + bool UpdateStats(Stats stat) override; + bool UpdateAllStats() override; + void UpdateResistances(uint32 school) override; + void UpdateArmor() override; + void UpdateMaxHealth() override; + void UpdateMaxPower(Powers power) override; + void UpdateAttackPowerAndDamage(bool ranged = false) override; void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) override; void SetCanDualWield(bool value) override; @@ -539,9 +538,9 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject uint32 GetScriptId() const; // override WorldObject function for proper name localization - std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override; - void setDeathState(DeathState s); // override virtual Unit::setDeathState + void setDeathState(DeathState s) override; // override virtual Unit::setDeathState bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); } bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true); @@ -609,7 +608,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject time_t GetRespawnTimeEx() const; void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } void Respawn(bool force = false); - void SaveRespawnTime(); + void SaveRespawnTime() override; uint32 GetRespawnDelay() const { return m_respawnDelay; } void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; } @@ -624,8 +623,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void SetInCombatWithZone(); - bool hasQuest(uint32 quest_id) const; - bool hasInvolvedQuest(uint32 quest_id) const; + bool hasQuest(uint32 quest_id) const override; + bool hasInvolvedQuest(uint32 quest_id) const override; bool isRegeneratingHealth() { return m_regenHealth; } void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; } @@ -676,7 +675,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject bool m_isTempWorldObject; //true when possessed // Handling caster facing during spellcast - void SetTarget(uint64 guid); + void SetTarget(uint64 guid) override; void FocusTarget(Spell const* focusSpell, WorldObject const* target); void ReleaseFocus(Spell const* focusSpell); @@ -728,8 +727,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject uint16 m_LootMode; // Bitmask (default: LOOT_MODE_DEFAULT) that determines what loot will be lootable - bool IsInvisibleDueToDespawn() const; - bool CanAlwaysSee(WorldObject const* obj) const; + bool IsInvisibleDueToDespawn() const override; + bool CanAlwaysSee(WorldObject const* obj) const override; private: void ForcedDespawn(uint32 timeMSToDespawn = 0); @@ -750,7 +749,7 @@ class AssistDelayEvent : public BasicEvent public: AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { } - bool Execute(uint64 e_time, uint32 p_time); + bool Execute(uint64 e_time, uint32 p_time) override; void AddAssistant(uint64 guid) { m_assistants.push_back(guid); } private: AssistDelayEvent(); @@ -764,7 +763,7 @@ class ForcedDespawnDelayEvent : public BasicEvent { public: ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { } - bool Execute(uint64 e_time, uint32 p_time); + bool Execute(uint64 e_time, uint32 p_time) override; private: Creature& m_owner; diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index 1cee6361172..58cc6eb7d0b 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -42,13 +42,13 @@ class TempSummon : public Creature public: explicit TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject); virtual ~TempSummon() { } - void Update(uint32 time); + void Update(uint32 time) override; virtual void InitStats(uint32 lifetime); virtual void InitSummon(); virtual void UnSummon(uint32 msTime = 0); - void RemoveFromWorld(); + void RemoveFromWorld() override; void SetTempSummonType(TempSummonType type); - void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) { } + void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override { } Unit* GetSummoner() const; Creature* GetSummonerCreatureBase() const; uint64 GetSummonerGUID() const { return m_summonerGUID; } @@ -67,10 +67,10 @@ class Minion : public TempSummon { public: Minion(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject); - void InitStats(uint32 duration); - void RemoveFromWorld(); + void InitStats(uint32 duration) override; + void RemoveFromWorld() override; Unit* GetOwner() const { return m_owner; } - float GetFollowAngle() const { return m_followAngle; } + float GetFollowAngle() const override { return m_followAngle; } void SetFollowAngle(float angle) { m_followAngle = angle; } bool IsPetGhoul() const {return GetEntry() == 26125;} // Ghoul may be guardian or pet bool IsSpiritWolf() const {return GetEntry() == 29264;} // Spirit wolf from feral spirits @@ -84,17 +84,17 @@ class Guardian : public Minion { public: Guardian(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject); - void InitStats(uint32 duration); + void InitStats(uint32 duration) override; bool InitStatsForLevel(uint8 level); - void InitSummon(); + void InitSummon() override; - bool UpdateStats(Stats stat); - bool UpdateAllStats(); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); - void UpdateAttackPowerAndDamage(bool ranged = false); + bool UpdateStats(Stats stat) override; + bool UpdateAllStats() override; + void UpdateResistances(uint32 school) override; + void UpdateArmor() override; + void UpdateMaxHealth() override; + void UpdateMaxPower(Powers power) override; + void UpdateAttackPowerAndDamage(bool ranged = false) override; void UpdateDamagePhysical(WeaponAttackType attType) override; int32 GetBonusDamage() const { return m_bonusSpellDamage; } @@ -108,17 +108,17 @@ class Puppet : public Minion { public: Puppet(SummonPropertiesEntry const* properties, Unit* owner); - void InitStats(uint32 duration); - void InitSummon(); - void Update(uint32 time); - void RemoveFromWorld(); + void InitStats(uint32 duration) override; + void InitSummon() override; + void Update(uint32 time) override; + void RemoveFromWorld() override; }; class ForcedUnsummonDelayEvent : public BasicEvent { public: ForcedUnsummonDelayEvent(TempSummon& owner) : BasicEvent(), m_owner(owner) { } - bool Execute(uint64 e_time, uint32 p_time); + bool Execute(uint64 e_time, uint32 p_time) override; private: TempSummon& m_owner; diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index c9fd1d29f8b..7816600b7a4 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -38,11 +38,11 @@ class DynamicObject : public WorldObject, public GridObject<DynamicObject>, publ DynamicObject(bool isWorldObject); ~DynamicObject(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); - void Update(uint32 p_time); + void Update(uint32 p_time) override; void Remove(); void SetDuration(int32 newDuration); int32 GetDuration() const; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 0f3e68bb1ae..c8c0eaefb27 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -143,7 +143,12 @@ void GameObject::AddToWorld() // The state can be changed after GameObject::Create but before GameObject::AddToWorld bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport()); if (m_model) - GetMap()->InsertGameObjectModel(*m_model); + { + if (Transport* trans = ToTransport()) + trans->SetDelayedAddModelToMap(); + else + GetMap()->InsertGameObjectModel(*m_model); + } EnableCollision(toggledState); WorldObject::AddToWorld(); @@ -1791,14 +1796,14 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, bool triggered /*= true trigger->setFaction(owner->getFaction()); // needed for GO casts for proper target validation checks trigger->SetOwnerGUID(owner->GetGUID()); - trigger->CastSpell(target ? target : trigger, spellInfo, triggered, 0, 0, owner->GetGUID()); + trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, owner->GetGUID()); } else { trigger->setFaction(14); // Set owner guid for target if no owner available - needed by trigger auras // - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell()) - trigger->CastSpell(target ? target : trigger, spellInfo, triggered, 0, 0, target ? target->GetGUID() : 0); + trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : 0); } } diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index f5074e202e9..f551ab2046c 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -635,14 +635,14 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map explicit GameObject(); ~GameObject(); - void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const; + void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override; - void AddToWorld(); - void RemoveFromWorld(); - void CleanupsBeforeDelete(bool finalCleanup = true); + void AddToWorld() override; + void RemoveFromWorld() override; + void CleanupsBeforeDelete(bool finalCleanup = true) override; bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0); - void Update(uint32 p_time); + void Update(uint32 p_time) override; static GameObject* GetGameObject(WorldObject& object, uint64 guid); GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectData const* GetGOData() const { return m_goData; } @@ -657,7 +657,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f); // overwrite WorldObject function for proper name localization - std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override; void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); @@ -757,7 +757,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map uint32 GetUseCount() const { return m_usetimes; } uint32 GetUniqueUseCount() const { return m_unique_users.size(); } - void SaveRespawnTime(); + void SaveRespawnTime() override; Loot loot; @@ -769,8 +769,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map uint32 m_groupLootTimer; // (msecs)timer used for group loot uint32 lootingGroupLowGUID; // used to find group which is looting - bool hasQuest(uint32 quest_id) const; - bool hasInvolvedQuest(uint32 quest_id) const; + bool hasQuest(uint32 quest_id) const override; + bool hasInvolvedQuest(uint32 quest_id) const override; bool ActivateToQuest(Player* target) const; void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = NULL); // 0 = use `gameobject`.`spawntimesecs` @@ -780,10 +780,10 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool IsNeverVisible() const override; - bool IsAlwaysVisibleFor(WorldObject const* seer) const; - bool IsInvisibleDueToDespawn() const; + bool IsAlwaysVisibleFor(WorldObject const* seer) const override; + bool IsInvisibleDueToDespawn() const override; - uint8 getLevelForTarget(WorldObject const* target) const + uint8 getLevelForTarget(WorldObject const* target) const override { if (Unit* owner = GetOwner()) return owner->getLevelForTarget(target); @@ -828,10 +828,10 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map Transport* ToTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<Transport*>(this); else return NULL; } Transport const* ToTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return NULL; } - float GetStationaryX() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); } - float GetStationaryY() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); } - float GetStationaryZ() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); } - float GetStationaryO() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); } + float GetStationaryX() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); } + float GetStationaryY() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); } + float GetStationaryZ() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); } + float GetStationaryO() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); } float GetInteractionDistance(); @@ -873,7 +873,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void SwitchDoorOrButton(bool activate, bool alternative = false); //! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size. - bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const + bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/) const override { //! Following check does check 3d distance return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare); diff --git a/src/server/game/Entities/Item/Container/Bag.h b/src/server/game/Entities/Item/Container/Bag.h index 1e39e5a41ad..db0c8edf556 100644 --- a/src/server/game/Entities/Item/Container/Bag.h +++ b/src/server/game/Entities/Item/Container/Bag.h @@ -32,10 +32,10 @@ class Bag : public Item Bag(); ~Bag(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - bool Create(uint32 guidlow, uint32 itemid, Player const* owner); + bool Create(uint32 guidlow, uint32 itemid, Player const* owner) override; void Clear(); void StoreItem(uint8 slot, Item* pItem, bool update); @@ -52,13 +52,13 @@ class Bag : public Item // DB operations // overwrite virtual Item::SaveToDB - void SaveToDB(SQLTransaction& trans); + void SaveToDB(SQLTransaction& trans) override; // overwrite virtual Item::LoadFromDB - bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry); + bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) override; // overwrite virtual Item::DeleteFromDB - void DeleteFromDB(SQLTransaction& trans); + void DeleteFromDB(SQLTransaction& trans) override; - void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; + void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override; protected: diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 09911fc8f57..6894dd86493 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -1265,6 +1265,14 @@ void Item::ItemContainerSaveLootToDB() // but we don't want to resave it. if (!_li->canSave) continue; + // Conditions are not checked when loot is generated, it is checked when loot is sent to a player. + // For items that are lootable, loot is saved to the DB immediately, that means that loot can be + // saved to the DB that the player never should have gotten. This check prevents that, so that only + // items that the player should get in loot are in the DB. + // IE: Horde items are not saved to the DB for Ally players. + Player* const guid = GetOwner(); + if (!_li->AllowedForPlayer(guid)) + continue; stmt_items = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_ITEMS); diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index a65579cc134..32fbe9e35fd 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -324,8 +324,8 @@ class Item : public Object uState = state; } - bool hasQuest(uint32 quest_id) const { return GetTemplate()->StartQuest == quest_id; } - bool hasInvolvedQuest(uint32 /*quest_id*/) const { return false; } + bool hasQuest(uint32 quest_id) const override { return GetTemplate()->StartQuest == quest_id; } + bool hasInvolvedQuest(uint32 /*quest_id*/) const override { return false; } bool IsPotion() const { return GetTemplate()->IsPotion(); } bool IsWeaponVellum() const { return GetTemplate()->IsWeaponVellum(); } bool IsArmorVellum() const { return GetTemplate()->IsArmorVellum(); } @@ -350,7 +350,7 @@ class Item : public Object void ClearSoulboundTradeable(Player* currentOwner); bool CheckSoulboundTradeExpire(); - void BuildUpdate(UpdateDataMapType&); + void BuildUpdate(UpdateDataMapType&) override; uint32 GetScriptId() const { return GetTemplate()->ScriptId; } private: diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index dfc0c438662..c96b6e31c61 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -119,7 +119,7 @@ Object::~Object() } delete [] m_uint32Values; - m_uint32Values = 0; + m_uint32Values = nullptr; } void Object::_InitValues() diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index b82ca1cb0b2..13f4dd13a83 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -580,7 +580,7 @@ class WorldObject : public Object, public WorldLocation virtual void Update (uint32 /*time_diff*/) { } void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask); - virtual void RemoveFromWorld(); + virtual void RemoveFromWorld() override; void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const; void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const; @@ -713,7 +713,7 @@ class WorldObject : public Object, public WorldLocation void DestroyForNearbyPlayers(); virtual void UpdateObjectVisibility(bool forced = true); - void BuildUpdate(UpdateDataMapType&); + void BuildUpdate(UpdateDataMapType&) override; //relocation and visibility system functions void AddToNotify(uint16 f) { m_notifyflags |= f;} @@ -805,14 +805,16 @@ namespace Trinity class ObjectDistanceOrderPred { public: - ObjectDistanceOrderPred(WorldObject const* pRefObj, bool ascending = true) : m_refObj(pRefObj), m_ascending(ascending) { } - bool operator()(WorldObject const* pLeft, WorldObject const* pRight) const + ObjectDistanceOrderPred(WorldObject const* refObj, bool ascending = true) : _refObj(refObj), _ascending(ascending) { } + + bool operator()(WorldObject const* left, WorldObject const* right) const { - return m_ascending ? m_refObj->GetDistanceOrder(pLeft, pRight) : !m_refObj->GetDistanceOrder(pLeft, pRight); + return _refObj->GetDistanceOrder(left, right) == _ascending; } + private: - WorldObject const* m_refObj; - const bool m_ascending; + WorldObject const* _refObj; + bool _ascending; }; } diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp index e996db52c38..f6ac0bc67cc 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.cpp +++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp @@ -47,9 +47,9 @@ void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size) { z_stream c_stream; - c_stream.zalloc = (alloc_func)0; - c_stream.zfree = (free_func)0; - c_stream.opaque = (voidpf)0; + c_stream.zalloc = (alloc_func)nullptr; + c_stream.zfree = (free_func)nullptr; + c_stream.opaque = (voidpf)nullptr; // default Z_BEST_SPEED (1) int z_res = deflateInit(&c_stream, sWorld->getIntConfig(CONFIG_COMPRESSION)); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 876f35a58ce..37087663328 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -182,8 +182,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c setFaction(owner->getFaction()); SetUInt32Value(UNIT_CREATED_BY_SPELL, summonSpellId); - CreatureTemplate const* cinfo = GetCreatureTemplate(); - if (cinfo->type == CREATURE_TYPE_CRITTER) + if (IsCritter()) { float px, py, pz; owner->GetClosePoint(px, py, pz, GetObjectSize(), PET_FOLLOW_DIST, GetFollowAngle()); @@ -1019,7 +1018,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetCreateHealth(30*petlevel); // wolf attack speed is 1.5s - SetAttackTime(BASE_ATTACK, cinfo->baseattacktime); + SetAttackTime(BASE_ATTACK, cinfo->BaseAttackTime); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel))); diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 68465f6b8e7..7d4523be9af 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -43,10 +43,10 @@ class Pet : public Guardian explicit Pet(Player* owner, PetType type = MAX_PET_TYPE); virtual ~Pet(); - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void SetDisplayId(uint32 modelId); + void SetDisplayId(uint32 modelId) override; PetType getPetType() const { return m_petType; } void setPetType(PetType type) { m_petType = type; } @@ -60,16 +60,16 @@ class Pet : public Guardian bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner); bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask); bool LoadPetFromDB(Player* owner, uint32 petentry = 0, uint32 petnumber = 0, bool current = false); - bool isBeingLoaded() const { return m_loading;} + bool isBeingLoaded() const override { return m_loading;} void SavePetToDB(PetSaveMode mode); void Remove(PetSaveMode mode, bool returnreagent = false); static void DeleteFromDB(uint32 guidlow); - void setDeathState(DeathState s); // overwrite virtual Creature::setDeathState and Unit::setDeathState - void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update + void setDeathState(DeathState s) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState + void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update - uint8 GetPetAutoSpellSize() const { return m_autospells.size(); } - uint32 GetPetAutoSpellOnPos(uint8 pos) const + uint8 GetPetAutoSpellSize() const override { return m_autospells.size(); } + uint32 GetPetAutoSpellOnPos(uint8 pos) const override { if (pos >= m_autospells.size()) return 0; @@ -100,7 +100,7 @@ class Pet : public Guardian void ToggleAutocast(SpellInfo const* spellInfo, bool apply); - bool HasSpell(uint32 spell) const; + bool HasSpell(uint32 spell) const override; void LearnPetPassives(); void CastPetAuras(bool current); @@ -121,7 +121,7 @@ class Pet : public Guardian bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); void CleanupActionBar(); - virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override; PetSpellMap m_spells; AutoSpellList m_autospells; @@ -129,7 +129,7 @@ class Pet : public Guardian void InitPetCreateSpells(); bool resetTalents(); - static void resetTalentsForAllPetsOf(Player* owner, Pet* online_pet = NULL); + static void resetTalentsForAllPetsOf(Player* owner, Pet* online_pet = nullptr); void InitTalentForLevel(); uint8 GetMaxTalentPointsForLevel(uint8 level); @@ -159,11 +159,11 @@ class Pet : public Guardian DeclinedName *m_declinedname; private: - void SaveToDB(uint32, uint8, uint32) // override of Creature::SaveToDB - must not be called + void SaveToDB(uint32, uint8, uint32) override // override of Creature::SaveToDB - must not be called { ASSERT(false); } - void DeleteFromDB() // override of Creature::DeleteFromDB - must not be called + void DeleteFromDB() override // override of Creature::DeleteFromDB - must not be called { ASSERT(false); } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index fa009d94fe2..c9ac4e73374 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -13176,13 +13176,6 @@ void Player::SwapItem(uint16 src, uint16 dst) // SRC checks - if (pSrcItem->m_lootGenerated) // prevent swap looting item - { - //best error message found for attempting to swap while looting - SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, pSrcItem, NULL); - return; - } - // check unequip potability for equipped items and bank bags if (IsEquipmentPos(src) || IsBagPos(src)) { @@ -13213,13 +13206,6 @@ void Player::SwapItem(uint16 src, uint16 dst) if (pDstItem) { - if (pDstItem->m_lootGenerated) // prevent swap looting item - { - //best error message found for attempting to swap while looting - SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, pDstItem, NULL); - return; - } - // check unequip potability for equipped items and bank bags if (IsEquipmentPos(dst) || IsBagPos(dst)) { diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 508be730a18..b1fd9d5a97f 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1101,12 +1101,12 @@ class Player : public Unit, public GridObject<Player> explicit Player(WorldSession* session); ~Player(); - void CleanupsBeforeDelete(bool finalCleanup = true); + void CleanupsBeforeDelete(bool finalCleanup = true) override; - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; - void SetObjectScale(float scale) + void SetObjectScale(float scale) override { Unit::SetObjectScale(scale); SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, scale * DEFAULT_WORLD_OBJECT_SIZE); @@ -1122,14 +1122,14 @@ class Player : public Unit, public GridObject<Player> bool Create(uint32 guidlow, CharacterCreateInfo* createInfo); - void Update(uint32 time); + void Update(uint32 time) override; static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data); void SetInWater(bool apply); - bool IsInWater() const { return m_isInWater; } - bool IsUnderWater() const; + bool IsInWater() const override { return m_isInWater; } + bool IsUnderWater() const override; bool IsFalling() { return GetPositionZ() < m_lastFallZ; } void SendInitialPacketsBeforeAddToMap(); @@ -1191,7 +1191,7 @@ class Player : public Unit, public GridObject<Player> uint32 GetTotalPlayedTime() { return m_Played_time[PLAYED_TIME_TOTAL]; } uint32 GetLevelPlayedTime() { return m_Played_time[PLAYED_TIME_LEVEL]; } - void setDeathState(DeathState s); // overwrite Unit::setDeathState + void setDeathState(DeathState s) override; // overwrite Unit::setDeathState void InnEnter(time_t time, uint32 mapid, float x, float y, float z); @@ -1228,7 +1228,7 @@ class Player : public Unit, public GridObject<Player> /*********************************************************/ void SetVirtualItemSlot(uint8 i, Item* item); - void SetSheath(SheathState sheathed); // overwrite Unit version + void SetSheath(SheathState sheathed) override; // overwrite Unit version uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const; @@ -1489,7 +1489,7 @@ class Player : public Unit, public GridObject<Player> /*********************************************************/ bool LoadFromDB(uint32 guid, SQLQueryHolder *holder); - bool isBeingLoaded() const; + bool isBeingLoaded() const override; void Initialize(uint32 guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); @@ -1592,7 +1592,7 @@ class Player : public Unit, public GridObject<Player> void PossessSpellInitialize(); void VehicleSpellInitialize(); void SendRemoveControlBar(); - bool HasSpell(uint32 spell) const; + bool HasSpell(uint32 spell) const override; bool HasActiveSpell(uint32 spell) const; // show in spellbook TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; bool IsSpellFitByClassAndRace(uint32 spell_id) const; @@ -1671,7 +1671,7 @@ class Player : public Unit, public GridObject<Player> void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); void ModifySpellCooldown(uint32 spellId, int32 cooldown); void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true); - void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override; void RemoveSpellCooldown(uint32 spell_id, bool update = false); void RemoveSpellCategoryCooldown(uint32 cat, bool update = false); void SendClearCooldown(uint32 spell_id, Unit* target); @@ -1779,15 +1779,15 @@ class Player : public Unit, public GridObject<Player> float GetHealthBonusFromStamina(); float GetManaBonusFromIntellect(); - bool UpdateStats(Stats stat); - bool UpdateAllStats(); + bool UpdateStats(Stats stat) override; + bool UpdateAllStats() override; void ApplySpellPenetrationBonus(int32 amount, bool apply); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); + void UpdateResistances(uint32 school) override; + void UpdateArmor() override; + void UpdateMaxHealth() override; + void UpdateMaxPower(Powers power) override; void ApplyFeralAPBonus(int32 amount, bool apply); - void UpdateAttackPowerAndDamage(bool ranged = false); + void UpdateAttackPowerAndDamage(bool ranged = false) override; void UpdateShieldBlockValue(); void ApplySpellPowerBonus(int32 amount, bool apply); void UpdateSpellDamageAndHealingBonus(); @@ -1836,8 +1836,8 @@ class Player : public Unit, public GridObject<Player> WorldSession* GetSession() const { return m_session; } - void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; - void DestroyForPlayer(Player* target, bool onDeath = false) const; + void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override; + void DestroyForPlayer(Player* target, bool onDeath = false) const override; void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate=1.0f); // notifiers @@ -1856,14 +1856,14 @@ class Player : public Unit, public GridObject<Player> void SendResetInstanceFailed(uint32 reason, uint32 MapId); void SendResetFailedNotify(uint32 mapid); - virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false); + virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override; bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } - void UpdateUnderwaterState(Map* m, float x, float y, float z); + void UpdateUnderwaterState(Map* m, float x, float y, float z) override; - void SendMessageToSet(WorldPacket* data, bool self) {SendMessageToSetInRange(data, GetVisibilityRange(), self); };// overwrite Object::SendMessageToSet - void SendMessageToSetInRange(WorldPacket* data, float fist, bool self);// overwrite Object::SendMessageToSetInRange + void SendMessageToSet(WorldPacket* data, bool self) override {SendMessageToSetInRange(data, GetVisibilityRange(), self); };// overwrite Object::SendMessageToSet + void SendMessageToSetInRange(WorldPacket* data, float fist, bool self) override;// overwrite Object::SendMessageToSetInRange void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only); - void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr); + void SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr) override; void SendTeleportAckPacket(); @@ -1980,7 +1980,7 @@ class Player : public Unit, public GridObject<Player> int32 CalculateCorpseReclaimDelay(bool load = false); void SendCorpseReclaimDelay(uint32 delay); - uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual) + uint32 GetShieldBlockValue() const override; // overwrite Unit version (virtual) bool CanParry() const { return m_canParry; } void SetCanParry(bool value); bool CanBlock() const { return m_canBlock; } @@ -2169,12 +2169,12 @@ class Player : public Unit, public GridObject<Player> bool HaveAtClient(WorldObject const* u) const; - bool IsNeverVisible() const; + bool IsNeverVisible() const override; bool IsVisibleGloballyFor(Player const* player) const; void SendInitialVisiblePackets(Unit* target); - void UpdateObjectVisibility(bool forced = true); + void UpdateObjectVisibility(bool forced = true) override; void UpdateVisibilityForPlayer(); void UpdateVisibilityOf(WorldObject* target); void UpdateTriggerVisibility(); @@ -2269,8 +2269,8 @@ class Player : public Unit, public GridObject<Player> MapReference &GetMapRef() { return m_mapRef; } // Set map to player and add reference - void SetMap(Map* map); - void ResetMap(); + void SetMap(Map* map) override; + void ResetMap() override; bool isAllowedToLoot(const Creature* creature); @@ -2324,13 +2324,13 @@ class Player : public Unit, public GridObject<Player> bool IsInWhisperWhiteList(uint64 guid); void RemoveFromWhisperWhiteList(uint64 guid) { WhisperList.remove(guid); } - bool SetDisableGravity(bool disable, bool packetOnly /* = false */); - bool SetCanFly(bool apply); - bool SetWaterWalking(bool apply, bool packetOnly = false); - bool SetFeatherFall(bool apply, bool packetOnly = false); - bool SetHover(bool enable, bool packetOnly = false); + bool SetDisableGravity(bool disable, bool packetOnly /* = false */) override; + bool SetCanFly(bool apply) override; + bool SetWaterWalking(bool apply, bool packetOnly = false) override; + bool SetFeatherFall(bool apply, bool packetOnly = false) override; + bool SetHover(bool enable, bool packetOnly = false) override; - bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } + bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } //! Return collision height sent to client float GetCollisionHeight(bool mounted) const; @@ -2594,9 +2594,9 @@ class Player : public Unit, public GridObject<Player> Runes *m_runes; EquipmentSets m_EquipmentSets; - bool CanAlwaysSee(WorldObject const* obj) const; + bool CanAlwaysSee(WorldObject const* obj) const override; - bool IsAlwaysDetectableFor(WorldObject const* seer) const; + bool IsAlwaysDetectableFor(WorldObject const* seer) const override; uint8 m_grantableLevels; diff --git a/src/server/game/Entities/Totem/Totem.h b/src/server/game/Entities/Totem/Totem.h index da0398f3a96..534e818842e 100644 --- a/src/server/game/Entities/Totem/Totem.h +++ b/src/server/game/Entities/Totem/Totem.h @@ -37,25 +37,25 @@ class Totem : public Minion public: Totem(SummonPropertiesEntry const* properties, Unit* owner); virtual ~Totem() { } - void Update(uint32 time); - void InitStats(uint32 duration); - void InitSummon(); - void UnSummon(uint32 msTime = 0); + void Update(uint32 time) override; + void InitStats(uint32 duration) override; + void InitSummon() override; + void UnSummon(uint32 msTime = 0) override; uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; } uint32 GetTotemDuration() const { return m_duration; } void SetTotemDuration(uint32 duration) { m_duration = duration; } TotemType GetTotemType() const { return m_type; } - bool UpdateStats(Stats /*stat*/) { return true; } - bool UpdateAllStats() { return true; } - void UpdateResistances(uint32 /*school*/) { } - void UpdateArmor() { } - void UpdateMaxHealth() { } - void UpdateMaxPower(Powers /*power*/) { } - void UpdateAttackPowerAndDamage(bool /*ranged*/) { } + bool UpdateStats(Stats /*stat*/) override { return true; } + bool UpdateAllStats() override { return true; } + void UpdateResistances(uint32 /*school*/) override { } + void UpdateArmor() override { } + void UpdateMaxHealth() override { } + void UpdateMaxPower(Powers /*power*/) override { } + void UpdateAttackPowerAndDamage(bool /*ranged*/) override { } void UpdateDamagePhysical(WeaponAttackType /*attType*/) override { } - bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; + bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; protected: TotemType m_type; diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index d907274f8d1..367ccd34cdb 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -35,7 +35,8 @@ Transport::Transport() : GameObject(), _transportInfo(NULL), _isMoving(true), _pendingStop(false), - _triggeredArrivalEvent(false), _triggeredDepartureEvent(false), _passengerTeleportItr(_passengers.begin()) + _triggeredArrivalEvent(false), _triggeredDepartureEvent(false), + _passengerTeleportItr(_passengers.begin()), _delayedAddModel(false) { m_updateFlag = UPDATEFLAG_TRANSPORT | UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_ROTATION; } @@ -186,6 +187,14 @@ void Transport::Update(uint32 diff) return; // Update more in new map thread } + // Add model to map after we are fully done with moving maps + if (_delayedAddModel) + { + _delayedAddModel = false; + if (m_model) + GetMap()->InsertGameObjectModel(*m_model); + } + // Set position _positionChangeTimer.Update(diff); if (_positionChangeTimer.Passed()) @@ -625,7 +634,6 @@ bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, fl } Relocate(x, y, z, o); - UpdateModelPosition(); GetMap()->AddToMap<Transport>(this); return true; } diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index e644417f1ac..2c924eb33ed 100644 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -95,6 +95,8 @@ class Transport : public GameObject, public TransportBase void EnableMovement(bool enabled); + void SetDelayedAddModelToMap() { _delayedAddModel = true; } + TransportTemplate const* GetTransportTemplate() const { return _transportInfo; } private: @@ -123,6 +125,8 @@ class Transport : public GameObject, public TransportBase PassengerSet _passengers; PassengerSet::iterator _passengerTeleportItr; PassengerSet _staticPassengers; + + bool _delayedAddModel; }; #endif diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 04136221d0d..bac2a8ef856 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -1037,17 +1037,21 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged) void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) { + float variance = 1.0f; UnitMods unitMod; switch (attType) { case BASE_ATTACK: default: + variance = GetCreatureTemplate()->BaseVariance; unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; case OFF_ATTACK: + variance = GetCreatureTemplate()->BaseVariance; unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; case RANGED_ATTACK: + variance = GetCreatureTemplate()->RangeVariance; unitMod = UNIT_MOD_DAMAGE_RANGED; break; } @@ -1070,11 +1074,11 @@ void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float attackPower = GetTotalAttackPowerValue(attType); float attackSpeedMulti = GetAPMultiplier(attType, normalized); - float baseValue = GetModifierValue(unitMod, BASE_VALUE) + (attackPower / 14.0f); + float baseValue = GetModifierValue(unitMod, BASE_VALUE) + (attackPower / 14.0f) * variance; float basePct = GetModifierValue(unitMod, BASE_PCT) * attackSpeedMulti; float totalValue = GetModifierValue(unitMod, TOTAL_VALUE); float totalPct = addTotalPct ? GetModifierValue(unitMod, TOTAL_PCT) : 1.0f; - float dmgMultiplier = GetCreatureTemplate()->dmg_multiplier; // = dmg_multiplier * _GetDamageMod(rank); + float dmgMultiplier = GetCreatureTemplate()->ModDamage; // = ModDamage * _GetDamageMod(rank); minDamage = ((weaponMinDamage + baseValue) * dmgMultiplier * basePct + totalValue) * totalPct; maxDamage = ((weaponMaxDamage + baseValue) * dmgMultiplier * basePct + totalValue) * totalPct; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b5a60793d63..a42836682bb 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12791,6 +12791,10 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in if (duration < 0) return duration; + // some auras are not affected by duration modifiers + if (spellProto->AttributesEx7 & SPELL_ATTR7_IGNORE_DURATION_MODS) + return duration; + // cut duration only of negative effects if (!positive) { @@ -13994,7 +13998,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u // On melee based hit/miss/resist need update skill (for victim and attacker) if (procExtra & (PROC_EX_NORMAL_HIT|PROC_EX_MISS|PROC_EX_RESIST)) { - if (target->GetTypeId() != TYPEID_PLAYER && target->GetCreatureType() != CREATURE_TYPE_CRITTER) + if (target->GetTypeId() != TYPEID_PLAYER && !target->IsCritter()) ToPlayer()->UpdateCombatSkills(target, attType, isVictim); } // Update defence if player is victim and parry/dodge/block @@ -14658,7 +14662,7 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const // remove not LoS targets for (std::list<Unit*>::iterator tIter = targets.begin(); tIter != targets.end();) { - if (!IsWithinLOSInMap(*tIter) || (*tIter)->IsTotem() || (*tIter)->IsSpiritService() || (*tIter)->GetCreatureType() == CREATURE_TYPE_CRITTER) + if (!IsWithinLOSInMap(*tIter) || (*tIter)->IsTotem() || (*tIter)->IsSpiritService() || (*tIter)->IsCritter()) targets.erase(tIter++); else ++tIter; @@ -15279,7 +15283,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) if (Unit* owner = GetOwner()) owner->ProcDamageAndSpell(victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_EX_NONE, 0); - if (victim->GetCreatureType() != CREATURE_TYPE_CRITTER) + if (!victim->IsCritter()) ProcDamageAndSpell(victim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0); // Proc auras on death - must be before aura/combat remove diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index b88ea856c77..2e8d93ec995 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -265,7 +265,6 @@ enum UnitRename UNIT_CAN_BE_ABANDONED = 0x02 }; -#define CREATURE_MAX_SPELLS 8 #define MAX_SPELL_CHARM 4 #define MAX_SPELL_VEHICLE 6 #define MAX_SPELL_POSSESS 8 @@ -1284,8 +1283,8 @@ class Unit : public WorldObject UnitAI* GetAI() { return i_AI; } void SetAI(UnitAI* newAI) { i_AI = newAI; } - void AddToWorld(); - void RemoveFromWorld(); + void AddToWorld() override; + void RemoveFromWorld() override; void CleanupBeforeRemoveFromMap(bool finalCleanup); void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) @@ -1300,7 +1299,7 @@ class Unit : public WorldObject float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; - virtual void Update(uint32 time); + virtual void Update(uint32 time) override; void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); @@ -1356,7 +1355,7 @@ class Unit : public WorldObject bool IsVehicle() const { return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; } uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); } - uint8 getLevelForTarget(WorldObject const* /*target*/) const { return getLevel(); } + uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); } void SetLevel(uint8 lvl); uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); } uint32 getRaceMask() const { return 1 << (getRace()-1); } @@ -1528,6 +1527,7 @@ class Unit : public WorldObject bool IsArmorer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); } bool IsServiceProvider() const; bool IsSpiritService() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); } + bool IsCritter() const { return GetCreatureType() == CREATURE_TYPE_CRITTER; } bool IsInFlight() const { return HasUnitState(UNIT_STATE_IN_FLIGHT); } @@ -1916,8 +1916,8 @@ class Unit : public WorldObject void SetVisible(bool x); // common function for visibility checks for player/creatures with detection code - void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask - void UpdateObjectVisibility(bool forced = true); + void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite WorldObject::SetPhaseMask + void UpdateObjectVisibility(bool forced = true) override; SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]; uint32 m_lastSanctuaryTime; @@ -2104,7 +2104,7 @@ class Unit : public WorldObject bool IsOnVehicle(const Unit* vehicle) const; Unit* GetVehicleBase() const; Creature* GetVehicleCreatureBase() const; - uint64 GetTransGUID() const; + uint64 GetTransGUID() const override; /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) TransportBase* GetDirectTransport() const; @@ -2160,7 +2160,7 @@ class Unit : public WorldObject protected: explicit Unit (bool isWorldObject); - void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const; + void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override; UnitAI* i_AI, *i_disabledAI; @@ -2229,8 +2229,8 @@ class Unit : public WorldObject uint32 m_unitTypeMask; LiquidTypeEntry const* _lastLiquid; - bool IsAlwaysVisibleFor(WorldObject const* seer) const; - bool IsAlwaysDetectableFor(WorldObject const* seer) const; + bool IsAlwaysVisibleFor(WorldObject const* seer) const override; + bool IsAlwaysDetectableFor(WorldObject const* seer) const override; void DisableSpline(); private: diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 36119fa0027..be008330f0c 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -89,7 +89,7 @@ class Vehicle : public TransportBase void InitMovementInfoForBase(); /// This method transforms supplied transport offsets into global coordinates - void CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const + void CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const override { TransportBase::CalculatePassengerPosition(x, y, z, o, GetBase()->GetPositionX(), GetBase()->GetPositionY(), @@ -97,7 +97,7 @@ class Vehicle : public TransportBase } /// This method transforms supplied global coordinates into local offsets - void CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const + void CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const override { TransportBase::CalculatePassengerOffset(x, y, z, o, GetBase()->GetPositionX(), GetBase()->GetPositionY(), @@ -126,8 +126,8 @@ class VehicleJoinEvent : public BasicEvent protected: VehicleJoinEvent(Vehicle* v, Unit* u) : Target(v), Passenger(u), Seat(Target->Seats.end()) { } ~VehicleJoinEvent(); - bool Execute(uint64, uint32); - void Abort(uint64); + bool Execute(uint64, uint32) override; + void Abort(uint64) override; Vehicle* Target; Unit* Passenger; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b7f2cd3dae4..944ad4d4a19 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -315,7 +315,7 @@ void ObjectMgr::LoadCreatureLocales() CreatureLocale& data = _creatureLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = (LocaleConstant) i; AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.Name); @@ -323,7 +323,7 @@ void ObjectMgr::LoadCreatureLocales() } } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu creature locale strings in %u ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u creature locale strings in %u ms", uint32(_creatureLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadGossipMenuItemsLocales() @@ -351,7 +351,7 @@ void ObjectMgr::LoadGossipMenuItemsLocales() GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(menuId, id)]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = (LocaleConstant) i; AddLocaleString(fields[2 + 2 * (i - 1)].GetString(), locale, data.OptionText); @@ -360,7 +360,7 @@ void ObjectMgr::LoadGossipMenuItemsLocales() } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu gossip_menu_option locale strings in %u ms", (unsigned long)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu_option locale strings in %u ms", uint32(_gossipMenuItemsLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadPointOfInterestLocales() @@ -382,33 +382,33 @@ void ObjectMgr::LoadPointOfInterestLocales() PointOfInterestLocale& data = _pointOfInterestLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.IconName); } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu points_of_interest locale strings in %u ms", (unsigned long)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u points_of_interest locale strings in %u ms", uint32(_pointOfInterestLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadCreatureTemplates() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 5 6 7 8 + // 0 1 2 3 4 5 6 7 8 QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, " - // 9 10 11 12 13 14 15 16 17 18 19 20 21 + // 9 10 11 12 13 14 15 16 17 18 19 20 "modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, " - // 22 23 24 25 26 27 28 29 30 31 32 33 - "scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, " - // 34 35 36 37 38 39 40 41 42 43 - "dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, " - // 44 45 46 47 48 49 50 51 52 53 54 + // 21 22 23 24 25 26 27 28 29 30 + "scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, " + // 31 32 33 34 35 36 37 + "dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, type, " + // 38 39 40 41 42 43 44 45 46 47 48 "type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, " - // 55 56 57 58 59 60 61 62 63 64 65 66 67 + // 49 50 51 52 53 54 55 56 57 58 59 60 61 "spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, " - // 68 69 70 71 72 73 74 75 76 77 78 - "InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, " - // 79 80 81 82 83 84 - " questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName " + // 62 63 64 65 66 67 68 69 + "InhabitType, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, " + // 70 71 72 73 74 75 76 77 78 79 80 + "questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName " "FROM creature_template;"); if (!result) @@ -422,90 +422,7 @@ void ObjectMgr::LoadCreatureTemplates() do { Field* fields = result->Fetch(); - - uint32 entry = fields[0].GetUInt32(); - - - CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry]; - - creatureTemplate.Entry = entry; - - for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i) - creatureTemplate.DifficultyEntry[i] = fields[1 + i].GetUInt32(); - - for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i) - creatureTemplate.KillCredit[i] = fields[4 + i].GetUInt32(); - - creatureTemplate.Modelid1 = fields[6].GetUInt32(); - creatureTemplate.Modelid2 = fields[7].GetUInt32(); - creatureTemplate.Modelid3 = fields[8].GetUInt32(); - creatureTemplate.Modelid4 = fields[9].GetUInt32(); - creatureTemplate.Name = fields[10].GetString(); - creatureTemplate.SubName = fields[11].GetString(); - creatureTemplate.IconName = fields[12].GetString(); - creatureTemplate.GossipMenuId = fields[13].GetUInt32(); - creatureTemplate.minlevel = fields[14].GetUInt8(); - creatureTemplate.maxlevel = fields[15].GetUInt8(); - creatureTemplate.expansion = uint32(fields[16].GetInt16()); - creatureTemplate.faction = uint32(fields[17].GetUInt16()); - creatureTemplate.npcflag = fields[18].GetUInt32(); - creatureTemplate.speed_walk = fields[19].GetFloat(); - creatureTemplate.speed_run = fields[20].GetFloat(); - creatureTemplate.scale = fields[21].GetFloat(); - creatureTemplate.rank = uint32(fields[22].GetUInt8()); - creatureTemplate.mindmg = fields[23].GetFloat(); - creatureTemplate.maxdmg = fields[24].GetFloat(); - creatureTemplate.dmgschool = uint32(fields[25].GetInt8()); - creatureTemplate.attackpower = fields[26].GetUInt32(); - creatureTemplate.dmg_multiplier = fields[27].GetFloat(); - creatureTemplate.baseattacktime = fields[28].GetUInt32(); - creatureTemplate.rangeattacktime = fields[29].GetUInt32(); - creatureTemplate.unit_class = uint32(fields[30].GetUInt8()); - creatureTemplate.unit_flags = fields[31].GetUInt32(); - creatureTemplate.unit_flags2 = fields[32].GetUInt32(); - creatureTemplate.dynamicflags = fields[33].GetUInt32(); - creatureTemplate.family = uint32(fields[34].GetUInt8()); - creatureTemplate.trainer_type = uint32(fields[35].GetUInt8()); - creatureTemplate.trainer_spell = fields[36].GetUInt32(); - creatureTemplate.trainer_class = uint32(fields[37].GetUInt8()); - creatureTemplate.trainer_race = uint32(fields[38].GetUInt8()); - creatureTemplate.minrangedmg = fields[39].GetFloat(); - creatureTemplate.maxrangedmg = fields[40].GetFloat(); - creatureTemplate.rangedattackpower = uint32(fields[41].GetUInt16()); - creatureTemplate.type = uint32(fields[42].GetUInt8()); - creatureTemplate.type_flags = fields[43].GetUInt32(); - creatureTemplate.lootid = fields[44].GetUInt32(); - creatureTemplate.pickpocketLootId = fields[45].GetUInt32(); - creatureTemplate.SkinLootId = fields[46].GetUInt32(); - - for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - creatureTemplate.resistance[i] = fields[47 + i -1].GetInt16(); - - for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) - creatureTemplate.spells[i] = fields[53 + i].GetUInt32(); - - creatureTemplate.PetSpellDataId = fields[61].GetUInt32(); - creatureTemplate.VehicleId = fields[62].GetUInt32(); - creatureTemplate.mingold = fields[63].GetUInt32(); - creatureTemplate.maxgold = fields[64].GetUInt32(); - creatureTemplate.AIName = fields[65].GetString(); - creatureTemplate.MovementType = uint32(fields[66].GetUInt8()); - creatureTemplate.InhabitType = uint32(fields[67].GetUInt8()); - creatureTemplate.HoverHeight = fields[68].GetFloat(); - creatureTemplate.ModHealth = fields[69].GetFloat(); - creatureTemplate.ModMana = fields[70].GetFloat(); - creatureTemplate.ModArmor = fields[71].GetFloat(); - creatureTemplate.RacialLeader = fields[72].GetBool(); - - for (uint8 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) - creatureTemplate.questItems[i] = fields[73 + i].GetUInt32(); - - creatureTemplate.movementId = fields[79].GetUInt32(); - creatureTemplate.RegenHealth = fields[80].GetBool(); - creatureTemplate.MechanicImmuneMask = fields[81].GetUInt32(); - creatureTemplate.flags_extra = fields[82].GetUInt32(); - creatureTemplate.ScriptID = GetScriptId(fields[83].GetCString()); - + LoadCreatureTemplate(fields); ++count; } while (result->NextRow()); @@ -517,6 +434,88 @@ void ObjectMgr::LoadCreatureTemplates() TC_LOG_INFO("server.loading", ">> Loaded %u creature definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadCreatureTemplate(Field* fields) +{ + uint32 entry = fields[0].GetUInt32(); + + CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry]; + + creatureTemplate.Entry = entry; + + for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i) + creatureTemplate.DifficultyEntry[i] = fields[1 + i].GetUInt32(); + + for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i) + creatureTemplate.KillCredit[i] = fields[4 + i].GetUInt32(); + + creatureTemplate.Modelid1 = fields[6].GetUInt32(); + creatureTemplate.Modelid2 = fields[7].GetUInt32(); + creatureTemplate.Modelid3 = fields[8].GetUInt32(); + creatureTemplate.Modelid4 = fields[9].GetUInt32(); + creatureTemplate.Name = fields[10].GetString(); + creatureTemplate.SubName = fields[11].GetString(); + creatureTemplate.IconName = fields[12].GetString(); + creatureTemplate.GossipMenuId = fields[13].GetUInt32(); + creatureTemplate.minlevel = fields[14].GetUInt8(); + creatureTemplate.maxlevel = fields[15].GetUInt8(); + creatureTemplate.expansion = uint32(fields[16].GetInt16()); + creatureTemplate.faction = fields[17].GetUInt16(); + creatureTemplate.npcflag = fields[18].GetUInt32(); + creatureTemplate.speed_walk = fields[19].GetFloat(); + creatureTemplate.speed_run = fields[20].GetFloat(); + creatureTemplate.scale = fields[21].GetFloat(); + creatureTemplate.rank = fields[22].GetUInt8(); + creatureTemplate.dmgschool = uint32(fields[23].GetInt8()); + creatureTemplate.BaseAttackTime = fields[24].GetUInt32(); + creatureTemplate.RangeAttackTime = fields[25].GetUInt32(); + creatureTemplate.BaseVariance = fields[26].GetFloat(); + creatureTemplate.RangeVariance = fields[27].GetFloat(); + creatureTemplate.unit_class = fields[28].GetUInt8(); + creatureTemplate.unit_flags = fields[29].GetUInt32(); + creatureTemplate.unit_flags2 = fields[30].GetUInt32(); + creatureTemplate.dynamicflags = fields[31].GetUInt32(); + creatureTemplate.family = fields[32].GetUInt8(); + creatureTemplate.trainer_type = fields[33].GetUInt8(); + creatureTemplate.trainer_spell = fields[34].GetUInt32(); + creatureTemplate.trainer_class = fields[35].GetUInt8(); + creatureTemplate.trainer_race = fields[36].GetUInt8(); + creatureTemplate.type = fields[37].GetUInt8(); + creatureTemplate.type_flags = fields[38].GetUInt32(); + creatureTemplate.lootid = fields[39].GetUInt32(); + creatureTemplate.pickpocketLootId = fields[40].GetUInt32(); + creatureTemplate.SkinLootId = fields[41].GetUInt32(); + + for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) + creatureTemplate.resistance[i] = fields[42 + i - 1].GetInt16(); + + for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) + creatureTemplate.spells[i] = fields[48 + i].GetUInt32(); + + creatureTemplate.PetSpellDataId = fields[56].GetUInt32(); + creatureTemplate.VehicleId = fields[57].GetUInt32(); + creatureTemplate.mingold = fields[58].GetUInt32(); + creatureTemplate.maxgold = fields[59].GetUInt32(); + creatureTemplate.AIName = fields[60].GetString(); + creatureTemplate.MovementType = fields[61].GetUInt8(); + creatureTemplate.InhabitType = fields[62].GetUInt8(); + creatureTemplate.HoverHeight = fields[63].GetFloat(); + creatureTemplate.ModHealth = fields[64].GetFloat(); + creatureTemplate.ModMana = fields[65].GetFloat(); + creatureTemplate.ModArmor = fields[66].GetFloat(); + creatureTemplate.ModDamage = fields[67].GetFloat(); + creatureTemplate.ModExperience = fields[68].GetFloat(); + creatureTemplate.RacialLeader = fields[69].GetBool(); + + for (uint8 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) + creatureTemplate.questItems[i] = fields[70 + i].GetUInt32(); + + creatureTemplate.movementId = fields[76].GetUInt32(); + creatureTemplate.RegenHealth = fields[77].GetBool(); + creatureTemplate.MechanicImmuneMask = fields[78].GetUInt32(); + creatureTemplate.flags_extra = fields[79].GetUInt32(); + creatureTemplate.ScriptID = GetScriptId(fields[80].GetCString()); +} + void ObjectMgr::LoadCreatureTemplateAddons() { uint32 oldMSTime = getMSTime(); @@ -856,11 +855,11 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) const_cast<CreatureTemplate*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL; } - if (cInfo->baseattacktime == 0) - const_cast<CreatureTemplate*>(cInfo)->baseattacktime = BASE_ATTACK_TIME; + if (cInfo->BaseAttackTime == 0) + const_cast<CreatureTemplate*>(cInfo)->BaseAttackTime = BASE_ATTACK_TIME; - if (cInfo->rangeattacktime == 0) - const_cast<CreatureTemplate*>(cInfo)->rangeattacktime = BASE_ATTACK_TIME; + if (cInfo->RangeAttackTime == 0) + const_cast<CreatureTemplate*>(cInfo)->RangeAttackTime = BASE_ATTACK_TIME; if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE) TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong trainer type %u.", cInfo->Entry, cInfo->trainer_type); @@ -955,7 +954,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED; } - const_cast<CreatureTemplate*>(cInfo)->dmg_multiplier *= Creature::_GetDamageMod(cInfo->rank); + const_cast<CreatureTemplate*>(cInfo)->ModDamage *= Creature::_GetDamageMod(cInfo->rank); } void ObjectMgr::LoadCreatureAddons() @@ -2199,7 +2198,7 @@ void ObjectMgr::LoadItemLocales() ItemLocale& data = _itemLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = (LocaleConstant) i; AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.Name); @@ -2207,7 +2206,7 @@ void ObjectMgr::LoadItemLocales() } } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu Item locale strings in %u ms", (unsigned long)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u Item locale strings in %u ms", uint32(_itemLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadItemTemplates() @@ -2841,7 +2840,7 @@ void ObjectMgr::LoadItemSetNameLocales() ItemSetNameLocale& data = _itemSetNameLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Name); } while (result->NextRow()); @@ -4523,7 +4522,7 @@ void ObjectMgr::LoadQuestLocales() QuestLocale& data = _questLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = (LocaleConstant) i; @@ -4540,7 +4539,7 @@ void ObjectMgr::LoadQuestLocales() } } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu Quest locale strings in %u ms", (unsigned long)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u Quest locale strings in %u ms", uint32(_questLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadScripts(ScriptsType type) @@ -5152,11 +5151,11 @@ void ObjectMgr::LoadPageTextLocales() PageTextLocale& data = _pageTextLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Text); } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu PageText locale strings in %u ms", (unsigned long)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u PageText locale strings in %u ms", uint32(_pageTextLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadInstanceTemplate() @@ -5400,10 +5399,10 @@ void ObjectMgr::LoadNpcTextLocales() NpcTextLocale& data = _npcTextLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = (LocaleConstant) i; - for (uint8 j = 0; j < MAX_LOCALES; ++j) + for (uint8 j = 0; j < MAX_GOSSIP_TEXT_OPTIONS; ++j) { AddLocaleString(fields[1 + 8 * 2 * (i - 1) + 2 * j].GetString(), locale, data.Text_0[j]); AddLocaleString(fields[1 + 8 * 2 * (i - 1) + 2 * j + 1].GetString(), locale, data.Text_1[j]); @@ -5411,7 +5410,7 @@ void ObjectMgr::LoadNpcTextLocales() } } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu NpcText locale strings in %u ms", (unsigned long)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u NpcText locale strings in %u ms", uint32(_npcTextLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } //not very fast function but it is called only once a day, or on starting-up @@ -6435,14 +6434,14 @@ void ObjectMgr::LoadGameObjectLocales() GameObjectLocale& data = _gameObjectLocaleStore[entry]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) + { AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Name); - - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) AddLocaleString(fields[i + (TOTAL_LOCALES - 1)].GetString(), LocaleConstant(i), data.CastBarCaption); + } } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %lu gameobject locale strings in %u ms", (unsigned long)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u gameobject locale strings in %u ms", uint32(_gameObjectLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); } inline void CheckGOLockId(GameObjectTemplate const* goInfo, uint32 dataN, uint32 N) @@ -7758,7 +7757,7 @@ bool ObjectMgr::LoadTrinityStrings(const char* table, int32 min_value, int32 max data.Content.resize(1); ++count; - for (uint8 i = 0; i < TOTAL_LOCALES; ++i) + for (int8 i = TOTAL_LOCALES - 1; i >= 0; --i) AddLocaleString(fields[i + 1].GetString(), LocaleConstant(i), data.Content); } while (result->NextRow()); @@ -8780,11 +8779,11 @@ void ObjectMgr::LoadBroadcastTextLocales() continue; } - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = LocaleConstant(i); - ObjectMgr::AddLocaleString(fields[1 + (i - 1)].GetString(), locale, bct->second.MaleText); - ObjectMgr::AddLocaleString(fields[9 + (i - 1)].GetString(), locale, bct->second.FemaleText); + AddLocaleString(fields[1 + (i - 1)].GetString(), locale, bct->second.MaleText); + AddLocaleString(fields[9 + (i - 1)].GetString(), locale, bct->second.FemaleText); } ++count; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 738b99778f8..56ae4a4c6d1 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -961,6 +961,7 @@ class ObjectMgr void LoadCreatureLocales(); void LoadCreatureTemplates(); void LoadCreatureTemplateAddons(); + void LoadCreatureTemplate(Field* fields); void CheckCreatureTemplate(CreatureTemplate const* cInfo); void LoadTempSummons(); void LoadCreatures(); diff --git a/src/server/game/Grids/GridStates.h b/src/server/game/Grids/GridStates.h index af11ab08d5e..330b74ec65e 100644 --- a/src/server/game/Grids/GridStates.h +++ b/src/server/game/Grids/GridStates.h @@ -34,24 +34,24 @@ class GridState class InvalidState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override; }; class ActiveState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override; }; class IdleState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override; }; class RemovalState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override; }; #endif diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index f0061a70621..08f91ca816a 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -129,7 +129,7 @@ class Roll : public LootValidatorRef ~Roll(); void setLoot(Loot* pLoot); Loot* getLoot(); - void targetObjectBuildLink(); + void targetObjectBuildLink() override; uint64 itemGUID; uint32 itemid; diff --git a/src/server/game/Groups/GroupReference.h b/src/server/game/Groups/GroupReference.h index df5683b3edf..dc8480e9463 100644 --- a/src/server/game/Groups/GroupReference.h +++ b/src/server/game/Groups/GroupReference.h @@ -28,9 +28,9 @@ class GroupReference : public Reference<Group, Player> { protected: uint8 iSubGroup; - void targetObjectBuildLink(); - void targetObjectDestroyLink(); - void sourceObjectDestroyLink(); + void targetObjectBuildLink() override; + void targetObjectDestroyLink() override; + void sourceObjectDestroyLink() override; public: GroupReference() : Reference<Group, Player>(), iSubGroup(0) { } ~GroupReference() { unlink(); } diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index ea0b2e44c53..8c7b926a700 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -394,8 +394,8 @@ private: ~EventLogEntry() { } - void SaveToDB(SQLTransaction& trans) const; - void WritePacket(WorldPacket& data) const; + void SaveToDB(SQLTransaction& trans) const override; + void WritePacket(WorldPacket& data) const override; private: GuildEventLogTypes m_eventType; @@ -426,8 +426,8 @@ private: ~BankEventLogEntry() { } - void SaveToDB(SQLTransaction& trans) const; - void WritePacket(WorldPacket& data) const; + void SaveToDB(SQLTransaction& trans) const override; + void WritePacket(WorldPacket& data) const override; private: GuildBankEventLogTypes m_eventType; @@ -604,13 +604,13 @@ private: PlayerMoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) : MoveItemData(guild, player, container, slotId) { } - bool IsBank() const { return false; } - bool InitItem(); - void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount = 0); - Item* StoreItem(SQLTransaction& trans, Item* pItem); - void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const; + bool IsBank() const override { return false; } + bool InitItem() override; + void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount = 0) override; + Item* StoreItem(SQLTransaction& trans, Item* pItem) override; + void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const override; protected: - InventoryResult CanStore(Item* pItem, bool swap); + InventoryResult CanStore(Item* pItem, bool swap) override; }; class BankMoveItemData : public MoveItemData @@ -619,17 +619,17 @@ private: BankMoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) : MoveItemData(guild, player, container, slotId) { } - bool IsBank() const { return true; } - bool InitItem(); - bool HasStoreRights(MoveItemData* pOther) const; - bool HasWithdrawRights(MoveItemData* pOther) const; - void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount); - Item* StoreItem(SQLTransaction& trans, Item* pItem); - void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const; - void LogAction(MoveItemData* pFrom) const; + bool IsBank() const override { return true; } + bool InitItem() override; + bool HasStoreRights(MoveItemData* pOther) const override; + bool HasWithdrawRights(MoveItemData* pOther) const override; + void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount) override; + Item* StoreItem(SQLTransaction& trans, Item* pItem) override; + void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const override; + void LogAction(MoveItemData* pFrom) const override; protected: - InventoryResult CanStore(Item* pItem, bool swap); + InventoryResult CanStore(Item* pItem, bool swap) override; private: Item* _StoreItem(SQLTransaction& trans, BankTab* pTab, Item* pItem, ItemPosCount& pos, bool clone) const; diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index 3bb3edac500..20d89d9efb5 100644 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -311,6 +311,10 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket& recvData) SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE_S); return; } + + // Player cannot be removed during fights + if (arenaTeam->IsFighting()) + return; arenaTeam->DelMember(member->Guid, true); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 4d52eab61d6..b2507877111 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -978,8 +978,8 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) { // not blizz like, we must correctly save and load player instead... if (pCurrChar->getRace() == RACE_NIGHTELF) - pCurrChar->CastSpell(pCurrChar, 20584, true, 0);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) - pCurrChar->CastSpell(pCurrChar, 8326, true, 0); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) + pCurrChar->CastSpell(pCurrChar, 20584, true, nullptr);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) + pCurrChar->CastSpell(pCurrChar, 8326, true, nullptr); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) pCurrChar->SetMovement(MOVE_WATER_WALK); } diff --git a/src/server/game/Handlers/NPCHandler.h b/src/server/game/Handlers/NPCHandler.h index 7210d9a53b5..855536c7d9e 100644 --- a/src/server/game/Handlers/NPCHandler.h +++ b/src/server/game/Handlers/NPCHandler.h @@ -51,10 +51,10 @@ struct PageTextLocale struct NpcTextLocale { - NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); } + NpcTextLocale() { } - std::vector<StringVector> Text_0; - std::vector<StringVector> Text_1; + StringVector Text_0[MAX_GOSSIP_TEXT_OPTIONS]; + StringVector Text_1[MAX_GOSSIP_TEXT_OPTIONS]; }; #endif diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index ba30803e8c2..13f79fb88c5 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -533,7 +533,7 @@ void WorldSession::HandleSelfResOpcode(WorldPacket & /*recvData*/) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL)); if (spellInfo) - _player->CastSpell(_player, spellInfo, false, 0); + _player->CastSpell(_player, spellInfo, false, nullptr); _player->SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); } diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 7dc89935a69..09809d50b10 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -280,8 +280,8 @@ class LootValidatorRef : public Reference<Loot, LootValidatorRef> { public: LootValidatorRef() { } - void targetObjectDestroyLink() { } - void sourceObjectDestroyLink() { } + void targetObjectDestroyLink() override { } + void sourceObjectDestroyLink() override { } }; //===================================================== diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index b0164b77f1c..47cb7504fb8 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2216,7 +2216,7 @@ bool Map::IsOutdoors(float x, float y, float z) const if (!GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId)) return true; - AreaTableEntry const* atEntry = 0; + AreaTableEntry const* atEntry = nullptr; WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); if (wmoEntry) { @@ -2249,8 +2249,8 @@ uint16 Map::GetAreaFlag(float x, float y, float z, bool *isOutdoors) const { uint32 mogpFlags; int32 adtId, rootId, groupId; - WMOAreaTableEntry const* wmoEntry = 0; - AreaTableEntry const* atEntry = 0; + WMOAreaTableEntry const* wmoEntry = nullptr; + AreaTableEntry const* atEntry = nullptr; bool haveAreaInfo = false; if (GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId)) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 70198cb20a3..fd9ec281709 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -334,16 +334,16 @@ class Map : public GridRefManager<NGridType> // can return INVALID_HEIGHT if under z+2 z coord not found height float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const; - ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0) const; + ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = nullptr) const; - uint16 GetAreaFlag(float x, float y, float z, bool *isOutdoors=0) const; + uint16 GetAreaFlag(float x, float y, float z, bool *isOutdoors=nullptr) const; bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const; bool IsOutdoors(float x, float y, float z) const; uint8 GetTerrainType(float x, float y) const; float GetWaterLevel(float x, float y) const; - bool IsInWater(float x, float y, float z, LiquidData* data = 0) const; + bool IsInWater(float x, float y, float z, LiquidData* data = nullptr) const; bool IsUnderWater(float x, float y, float z) const; static uint32 GetAreaIdByAreaFlag(uint16 areaflag, uint32 map_id); @@ -678,23 +678,23 @@ class InstanceMap : public Map public: InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent); ~InstanceMap(); - bool AddPlayerToMap(Player*); - void RemovePlayerFromMap(Player*, bool); - void Update(const uint32); + bool AddPlayerToMap(Player*) override; + void RemovePlayerFromMap(Player*, bool) override; + void Update(const uint32) override; void CreateInstanceData(bool load); bool Reset(uint8 method); uint32 GetScriptId() { return i_script_id; } InstanceScript* GetInstanceScript() { return i_data; } void PermBindAllPlayers(Player* source); - void UnloadAll(); - bool CanEnter(Player* player); + void UnloadAll() override; + bool CanEnter(Player* player) override; void SendResetWarnings(uint32 timeLeft) const; void SetResetSchedule(bool on); uint32 GetMaxPlayers() const; uint32 GetMaxResetDelay() const; - virtual void InitVisibilityDistance(); + virtual void InitVisibilityDistance() override; private: bool m_resetAfterUnload; bool m_unloadWhenEmpty; @@ -708,14 +708,14 @@ class BattlegroundMap : public Map BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode); ~BattlegroundMap(); - bool AddPlayerToMap(Player*); - void RemovePlayerFromMap(Player*, bool); - bool CanEnter(Player* player); + bool AddPlayerToMap(Player*) override; + void RemovePlayerFromMap(Player*, bool) override; + bool CanEnter(Player* player) override; void SetUnload(); //void UnloadAll(bool pForce); - void RemoveAllPlayers(); + void RemoveAllPlayers() override; - virtual void InitVisibilityDistance(); + virtual void InitVisibilityDistance() override; Battleground* GetBG() { return m_bg; } void SetBG(Battleground* bg) { m_bg = bg; } private: diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h index 30aec43cc21..614764dbba3 100644 --- a/src/server/game/Maps/MapInstanced.h +++ b/src/server/game/Maps/MapInstanced.h @@ -33,11 +33,11 @@ class MapInstanced : public Map ~MapInstanced() { } // functions overwrite Map versions - void Update(const uint32); - void DelayedUpdate(const uint32 diff); + void Update(const uint32) override; + void DelayedUpdate(const uint32 diff) override; //void RelocationNotify(); - void UnloadAll(); - bool CanEnter(Player* player); + void UnloadAll() override; + bool CanEnter(Player* player) override; Map* CreateInstanceForPlayer(const uint32 mapId, Player* player); Map* FindInstanceMap(uint32 instanceId) const @@ -61,7 +61,7 @@ class MapInstanced : public Map } InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; } - virtual void InitVisibilityDistance(); + virtual void InitVisibilityDistance() override; private: InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty); diff --git a/src/server/game/Maps/MapReference.h b/src/server/game/Maps/MapReference.h index fe5ceb714c5..2742902d558 100644 --- a/src/server/game/Maps/MapReference.h +++ b/src/server/game/Maps/MapReference.h @@ -25,18 +25,18 @@ class MapReference : public Reference<Map, Player> { protected: - void targetObjectBuildLink() + void targetObjectBuildLink() override { // called from link() getTarget()->m_mapRefManager.insertFirst(this); getTarget()->m_mapRefManager.incSize(); } - void targetObjectDestroyLink() + void targetObjectDestroyLink() override { // called from unlink() if (isValid()) getTarget()->m_mapRefManager.decSize(); } - void sourceObjectDestroyLink() + void sourceObjectDestroyLink() override { // called from invalidate() getTarget()->m_mapRefManager.decSize(); diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index 8d0e97dc765..e6ff1a0b40f 100644 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -160,27 +160,32 @@ namespace Trinity inline uint32 Gain(Player* player, Unit* u) { - uint32 gain; + Creature* creature = u->ToCreature(); + uint32 gain = 0; - if (u->GetTypeId() == TYPEID_UNIT && - (((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() || - (((Creature*)u)->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) || - ((Creature*)u)->GetCreatureTemplate()->type == CREATURE_TYPE_CRITTER)) - gain = 0; - else + if (!creature || (!creature->IsTotem() && !creature->IsPet() && !creature->IsCritter() && + !(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL))) { + float xpMod = 1.0f; + gain = BaseGain(player->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId())); - if (gain != 0 && u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite()) + if (gain && creature) { - // Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus. - if (u->GetMap() && u->GetMap()->IsDungeon()) - gain = uint32(gain * 2.75); - else - gain *= 2; + if (creature->isElite()) + { + // Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus. + if (u->GetMap() && u->GetMap()->IsDungeon()) + xpMod *= 2.75f; + else + xpMod *= 2.0f; + } + + xpMod *= creature->GetCreatureTemplate()->ModExperience; } - gain = uint32(gain * sWorld->getRate(RATE_XP_KILL)); + xpMod *= sWorld->getRate(RATE_XP_KILL); + gain = uint32(gain * xpMod); } sScriptMgr->OnGainCalculation(gain, player, u); diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index ed3bb74ae9d..5309229b0fc 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -529,7 +529,7 @@ enum SpellAttr6 enum SpellAttr7 { SPELL_ATTR7_UNK0 = 0x00000001, // 0 Shaman's new spells (Call of the ...), Feign Death. - SPELL_ATTR7_UNK1 = 0x00000002, // 1 Not set in 3.2.2a. + SPELL_ATTR7_IGNORE_DURATION_MODS = 0x00000002, // 1 Duration is not affected by duration modifiers SPELL_ATTR7_REACTIVATE_AT_RESURRECT = 0x00000004, // 2 Paladin's auras and 65607 only. SPELL_ATTR7_IS_CHEAT_SPELL = 0x00000008, // 3 Cannot cast if caster doesn't have UnitFlag2 & UNIT_FLAG2_ALLOW_CHEAT_SPELLS SPELL_ATTR7_UNK4 = 0x00000010, // 4 Only 47883 (Soulstone Resurrection) and test spell. diff --git a/src/server/game/Movement/FollowerReference.h b/src/server/game/Movement/FollowerReference.h index a97104ce72c..ee6901dc2d7 100644 --- a/src/server/game/Movement/FollowerReference.h +++ b/src/server/game/Movement/FollowerReference.h @@ -27,8 +27,8 @@ class Unit; class FollowerReference : public Reference<Unit, TargetedMovementGeneratorBase> { protected: - void targetObjectBuildLink(); - void targetObjectDestroyLink(); - void sourceObjectDestroyLink(); + void targetObjectBuildLink() override; + void targetObjectDestroyLink() override; + void sourceObjectDestroyLink() override; }; #endif diff --git a/src/server/game/Movement/MovementGenerator.h b/src/server/game/Movement/MovementGenerator.h index 12116b5505d..d87344ba089 100755 --- a/src/server/game/Movement/MovementGenerator.h +++ b/src/server/game/Movement/MovementGenerator.h @@ -51,25 +51,25 @@ template<class T, class D> class MovementGeneratorMedium : public MovementGenerator { public: - void Initialize(Unit* u) + void Initialize(Unit* u) override { //u->AssertIsType<T>(); (static_cast<D*>(this))->DoInitialize(static_cast<T*>(u)); } - void Finalize(Unit* u) + void Finalize(Unit* u) override { //u->AssertIsType<T>(); (static_cast<D*>(this))->DoFinalize(static_cast<T*>(u)); } - void Reset(Unit* u) + void Reset(Unit* u) override { //u->AssertIsType<T>(); (static_cast<D*>(this))->DoReset(static_cast<T*>(u)); } - bool Update(Unit* u, uint32 time_diff) + bool Update(Unit* u, uint32 time_diff) override { //u->AssertIsType<T>(); return (static_cast<D*>(this))->DoUpdate(static_cast<T*>(u), time_diff); @@ -86,7 +86,7 @@ struct MovementGeneratorFactory : public SelectableMovement { MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) { } - MovementGenerator* Create(void *) const; + MovementGenerator* Create(void *) const override; }; typedef FactoryHolder<MovementGenerator, MovementGeneratorType> MovementGeneratorCreator; diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h index ba8e228873f..c3bcfffb2a7 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h @@ -49,9 +49,9 @@ class TimedFleeingMovementGenerator : public FleeingMovementGenerator<Creature> FleeingMovementGenerator<Creature>(fright), i_totalFleeTime(time) { } - MovementGeneratorType GetMovementGeneratorType() { return TIMED_FLEEING_MOTION_TYPE; } - bool Update(Unit*, uint32); - void Finalize(Unit*); + MovementGeneratorType GetMovementGeneratorType() override { return TIMED_FLEEING_MOTION_TYPE; } + bool Update(Unit*, uint32) override; + void Finalize(Unit*) override; private: TimeTracker i_totalFleeTime; diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h index abe97e21536..8e0b0e335c4 100644 --- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h @@ -38,7 +38,7 @@ class HomeMovementGenerator<Creature> : public MovementGeneratorMedium< Creature void DoFinalize(Creature*); void DoReset(Creature*); bool DoUpdate(Creature*, const uint32); - MovementGeneratorType GetMovementGeneratorType() { return HOME_MOTION_TYPE; } + MovementGeneratorType GetMovementGeneratorType() override { return HOME_MOTION_TYPE; } private: void _setTargetLocation(Creature*); diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h index bdf9d52b93a..0cd9b2777b4 100755 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h @@ -25,11 +25,11 @@ class IdleMovementGenerator : public MovementGenerator { public: - void Initialize(Unit*); - void Finalize(Unit*) { } - void Reset(Unit*); - bool Update(Unit*, uint32) { return true; } - MovementGeneratorType GetMovementGeneratorType() { return IDLE_MOTION_TYPE; } + void Initialize(Unit*) override; + void Finalize(Unit*) override { } + void Reset(Unit*) override; + bool Update(Unit*, uint32) override { return true; } + MovementGeneratorType GetMovementGeneratorType() override { return IDLE_MOTION_TYPE; } }; extern IdleMovementGenerator si_idleMovement; @@ -39,11 +39,11 @@ class RotateMovementGenerator : public MovementGenerator public: explicit RotateMovementGenerator(uint32 time, RotateDirection direction) : m_duration(time), m_maxDuration(time), m_direction(direction) { } - void Initialize(Unit*); - void Finalize(Unit*); - void Reset(Unit* owner) { Initialize(owner); } - bool Update(Unit*, uint32); - MovementGeneratorType GetMovementGeneratorType() { return ROTATE_MOTION_TYPE; } + void Initialize(Unit*) override; + void Finalize(Unit*) override; + void Reset(Unit* owner) override { Initialize(owner); } + bool Update(Unit*, uint32) override; + MovementGeneratorType GetMovementGeneratorType() override { return ROTATE_MOTION_TYPE; } private: uint32 m_duration, m_maxDuration; @@ -55,11 +55,11 @@ class DistractMovementGenerator : public MovementGenerator public: explicit DistractMovementGenerator(uint32 timer) : m_timer(timer) { } - void Initialize(Unit*); - void Finalize(Unit*); - void Reset(Unit* owner) { Initialize(owner); } - bool Update(Unit*, uint32); - MovementGeneratorType GetMovementGeneratorType() { return DISTRACT_MOTION_TYPE; } + void Initialize(Unit*) override; + void Finalize(Unit*) override; + void Reset(Unit* owner) override { Initialize(owner); } + bool Update(Unit*, uint32) override; + MovementGeneratorType GetMovementGeneratorType() override { return DISTRACT_MOTION_TYPE; } private: uint32 m_timer; @@ -71,8 +71,8 @@ class AssistanceDistractMovementGenerator : public DistractMovementGenerator AssistanceDistractMovementGenerator(uint32 timer) : DistractMovementGenerator(timer) { } - MovementGeneratorType GetMovementGeneratorType() { return ASSISTANCE_DISTRACT_MOTION_TYPE; } - void Finalize(Unit*); + MovementGeneratorType GetMovementGeneratorType() override { return ASSISTANCE_DISTRACT_MOTION_TYPE; } + void Finalize(Unit*) override; }; #endif diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index c596b406cf3..3c5b33f3736 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -55,8 +55,8 @@ class AssistanceMovementGenerator : public PointMovementGenerator<Creature> AssistanceMovementGenerator(float _x, float _y, float _z) : PointMovementGenerator<Creature>(0, _x, _y, _z, true) { } - MovementGeneratorType GetMovementGeneratorType() { return ASSISTANCE_MOTION_TYPE; } - void Finalize(Unit*); + MovementGeneratorType GetMovementGeneratorType() override { return ASSISTANCE_MOTION_TYPE; } + void Finalize(Unit*) override; }; // Does almost nothing - just doesn't allows previous movegen interrupt current effect. @@ -64,11 +64,11 @@ class EffectMovementGenerator : public MovementGenerator { public: explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) { } - void Initialize(Unit*) { } - void Finalize(Unit*); - void Reset(Unit*) { } - bool Update(Unit*, uint32); - MovementGeneratorType GetMovementGeneratorType() { return EFFECT_MOTION_TYPE; } + void Initialize(Unit*) override { } + void Finalize(Unit*) override; + void Reset(Unit*) override { } + bool Update(Unit*, uint32) override; + MovementGeneratorType GetMovementGeneratorType() override { return EFFECT_MOTION_TYPE; } private: uint32 m_Id; }; diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h index 9b5fe14b9d6..85c39fe0830 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h @@ -72,7 +72,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium< Crea void MovementInform(Creature*); - MovementGeneratorType GetMovementGeneratorType() { return WAYPOINT_MOTION_TYPE; } + MovementGeneratorType GetMovementGeneratorType() override { return WAYPOINT_MOTION_TYPE; } // now path movement implmementation void LoadPath(Creature*); @@ -126,7 +126,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, Flig void DoReset(Player*); void DoFinalize(Player*); bool DoUpdate(Player*, uint32); - MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; } + MovementGeneratorType GetMovementGeneratorType() override { return FLIGHT_MOTION_TYPE; } TaxiPathNodeList const& GetPath() { return *i_path; } uint32 GetPathAtMapEnd() const; diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index 9b1cfa71f96..4d7d818936e 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -218,9 +218,9 @@ class OutdoorPvP : public ZoneScript // setup stuff virtual bool SetupOutdoorPvP() {return true;} - void OnGameObjectCreate(GameObject* go); - void OnGameObjectRemove(GameObject* go); - void OnCreatureCreate(Creature*) { } + void OnGameObjectCreate(GameObject* go) override; + void OnGameObjectRemove(GameObject* go) override; + void OnCreatureCreate(Creature*) override { } // send world state update to all players present void SendUpdateWorldState(uint32 field, uint32 value); diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index a0185bf7709..d036d438926 100644 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -266,7 +266,6 @@ void AddSC_blasted_lands(); void AddSC_burning_steppes(); void AddSC_duskwood(); void AddSC_eastern_plaguelands(); -void AddSC_eversong_woods(); void AddSC_ghostlands(); void AddSC_hinterlands(); void AddSC_isle_of_queldanas(); diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 0d1983ab463..fa83c4b112d 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -32,6 +32,7 @@ #include "CreatureAIImpl.h" #include "Player.h" #include "WorldPacket.h" +#include "WorldSession.h" namespace { @@ -407,44 +408,42 @@ void ScriptMgr::OnSocketOpen(std::shared_ptr<WorldSocket> socket) FOREACH_SCRIPT(ServerScript)->OnSocketOpen(socket); } -void ScriptMgr::OnSocketClose(std::shared_ptr<WorldSocket> socket, bool wasNew) +void ScriptMgr::OnSocketClose(std::shared_ptr<WorldSocket> socket) { ASSERT(socket); - FOREACH_SCRIPT(ServerScript)->OnSocketClose(socket, wasNew); + FOREACH_SCRIPT(ServerScript)->OnSocketClose(socket); } -void ScriptMgr::OnPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket const& packet) +void ScriptMgr::OnPacketReceive(WorldSession* session, WorldPacket const& packet) { - ASSERT(socket); - if (SCR_REG_LST(ServerScript).empty()) return; WorldPacket copy(packet); - FOREACH_SCRIPT(ServerScript)->OnPacketReceive(socket, copy); + FOREACH_SCRIPT(ServerScript)->OnPacketReceive(session, copy); } -void ScriptMgr::OnPacketSend(std::shared_ptr<WorldSocket> socket, WorldPacket const& packet) +void ScriptMgr::OnPacketSend(WorldSession* session, WorldPacket const& packet) { - ASSERT(socket); + ASSERT(session); if (SCR_REG_LST(ServerScript).empty()) return; WorldPacket copy(packet); - FOREACH_SCRIPT(ServerScript)->OnPacketSend(socket, copy); + FOREACH_SCRIPT(ServerScript)->OnPacketSend(session, copy); } -void ScriptMgr::OnUnknownPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket const& packet) +void ScriptMgr::OnUnknownPacketReceive(WorldSession* session, WorldPacket const& packet) { - ASSERT(socket); + ASSERT(session); if (SCR_REG_LST(ServerScript).empty()) return; WorldPacket copy(packet); - FOREACH_SCRIPT(ServerScript)->OnUnknownPacketReceive(socket, copy); + FOREACH_SCRIPT(ServerScript)->OnUnknownPacketReceive(session, copy); } void ScriptMgr::OnOpenStateChange(bool open) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 0b5813a7f58..615b1d3bb06 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -59,6 +59,7 @@ class Vehicle; class WorldPacket; class WorldSocket; class WorldObject; +class WorldSession; struct AchievementCriteriaData; struct AuctionEntry; @@ -197,7 +198,7 @@ class SpellScriptLoader : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Should return a fully valid SpellScript pointer. virtual SpellScript* GetSpellScript() const { return NULL; } @@ -225,19 +226,19 @@ class ServerScript : public ScriptObject // Called when a socket is closed. Do not store the socket object, and do not rely on the connection // being open; it is not. - virtual void OnSocketClose(std::shared_ptr<WorldSocket> /*socket*/, bool /*wasNew*/) { } + virtual void OnSocketClose(std::shared_ptr<WorldSocket> /*socket*/) { } // Called when a packet is sent to a client. The packet object is a copy of the original packet, so reading // and modifying it is safe. - virtual void OnPacketSend(std::shared_ptr<WorldSocket> /*socket*/, WorldPacket& /*packet*/) { } + virtual void OnPacketSend(WorldSession* /*session*/, WorldPacket& /*packet*/) { } // Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so - // reading and modifying it is safe. - virtual void OnPacketReceive(std::shared_ptr<WorldSocket> /*socket*/, WorldPacket& /*packet*/) { } + // reading and modifying it is safe. Make sure to check WorldSession pointer before usage, it might be null in case of auth packets + virtual void OnPacketReceive(WorldSession* /*session*/, WorldPacket& /*packet*/) { } // Called when an invalid (unknown opcode) packet is received by a client. The packet is a reference to the orignal // packet; not a copy. This allows you to actually handle unknown packets (for whatever purpose). - virtual void OnUnknownPacketReceive(std::shared_ptr<WorldSocket> /*socket*/, WorldPacket& /*packet*/) { } + virtual void OnUnknownPacketReceive(WorldSession* /*session*/, WorldPacket& /*packet*/) { } }; class WorldScript : public ScriptObject @@ -355,7 +356,7 @@ class InstanceMapScript : public ScriptObject, public MapScript<InstanceMap> public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Gets an InstanceScript object for this instance. virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return NULL; } @@ -376,7 +377,7 @@ class ItemScript : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when a dummy spell effect is triggered on the item. virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; } @@ -425,7 +426,7 @@ class CreatureScript : public UnitScript, public UpdatableScript<Creature> public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when a dummy spell effect is triggered on the creature. virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Creature* /*target*/) { return false; } @@ -466,7 +467,7 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject> public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when a dummy spell effect is triggered on the gameobject. virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, GameObject* /*target*/) { return false; } @@ -513,7 +514,7 @@ class AreaTriggerScript : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when the area trigger is activated by a player. virtual bool OnTrigger(Player* /*player*/, AreaTriggerEntry const* /*trigger*/) { return false; } @@ -527,7 +528,7 @@ class BattlegroundScript : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Should return a fully valid Battleground object for the type ID. virtual Battleground* GetBattleground() const = 0; @@ -541,7 +542,7 @@ class OutdoorPvPScript : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Should return a fully valid OutdoorPvP object for the type ID. virtual OutdoorPvP* GetOutdoorPvP() const = 0; @@ -567,7 +568,7 @@ class WeatherScript : public ScriptObject, public UpdatableScript<Weather> public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when the weather changes in the zone this script is associated with. virtual void OnChange(Weather* /*weather*/, WeatherState /*state*/, float /*grade*/) { } @@ -602,7 +603,7 @@ class ConditionScript : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when a single condition is checked for a player. virtual bool OnConditionCheck(Condition* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; } @@ -650,7 +651,7 @@ class TransportScript : public ScriptObject, public UpdatableScript<Transport> public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when a player boards the transport. virtual void OnAddPassenger(Transport* /*transport*/, Player* /*player*/) { } @@ -673,7 +674,7 @@ class AchievementCriteriaScript : public ScriptObject public: - bool IsDatabaseBound() const final { return true; } + bool IsDatabaseBound() const final override { return true; } // Called when an additional criteria is checked. virtual bool OnCheck(Player* source, Unit* target) = 0; @@ -805,7 +806,7 @@ class GuildScript : public ScriptObject public: - bool IsDatabaseBound() const final { return false; } + bool IsDatabaseBound() const final override { return false; } // Called when a member is added to the guild. virtual void OnAddMember(Guild* /*guild*/, Player* /*player*/, uint8& /*plRank*/) { } @@ -848,7 +849,7 @@ class GroupScript : public ScriptObject public: - bool IsDatabaseBound() const final { return false; } + bool IsDatabaseBound() const final override { return false; } // Called when a member is added to a group. virtual void OnAddMember(Group* /*group*/, uint64 /*guid*/) { } @@ -909,10 +910,10 @@ class ScriptMgr void OnNetworkStart(); void OnNetworkStop(); void OnSocketOpen(std::shared_ptr<WorldSocket> socket); - void OnSocketClose(std::shared_ptr<WorldSocket> socket, bool wasNew); - void OnPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket const& packet); - void OnPacketSend(std::shared_ptr<WorldSocket> socket, WorldPacket const& packet); - void OnUnknownPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket const& packet); + void OnSocketClose(std::shared_ptr<WorldSocket> socket); + void OnPacketReceive(WorldSession* session, WorldPacket const& packet); + void OnPacketSend(WorldSession* session, WorldPacket const& packet); + void OnUnknownPacketReceive(WorldSession* session, WorldPacket const& packet); public: /* WorldScript */ diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index abb48a63ebf..445e42a7f08 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -225,6 +225,8 @@ void WorldSession::SendPacket(WorldPacket* packet) } #endif // !TRINITY_DEBUG + sScriptMgr->OnPacketSend(this, *packet); + m_Socket->AsyncWrite(*packet); } @@ -288,7 +290,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) { TC_LOG_ERROR("network.opcode", "Received non-existed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() , GetPlayerInfo().c_str()); - sScriptMgr->OnUnknownPacketReceive(m_Socket, *packet); + sScriptMgr->OnUnknownPacketReceive(this, *packet); } else { @@ -318,7 +320,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) } else if (_player->IsInWorld()) { - sScriptMgr->OnPacketReceive(m_Socket, *packet); + sScriptMgr->OnPacketReceive(this, *packet); (this->*opHandle.handler)(*packet); LogUnprocessedTail(packet); } @@ -331,7 +333,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) else { // not expected _player or must checked in packet handler - sScriptMgr->OnPacketReceive(m_Socket, *packet); + sScriptMgr->OnPacketReceive(this, *packet); (this->*opHandle.handler)(*packet); LogUnprocessedTail(packet); } @@ -343,7 +345,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world"); else { - sScriptMgr->OnPacketReceive(m_Socket, *packet); + sScriptMgr->OnPacketReceive(this, *packet); (this->*opHandle.handler)(*packet); LogUnprocessedTail(packet); } @@ -361,7 +363,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) if (packet->GetOpcode() == CMSG_CHAR_ENUM) m_playerRecentlyLogout = false; - sScriptMgr->OnPacketReceive(m_Socket, *packet); + sScriptMgr->OnPacketReceive(this, *packet); (this->*opHandle.handler)(*packet); LogUnprocessedTail(packet); break; @@ -418,7 +420,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) if (m_Socket && !m_Socket->IsOpen()) { expireTime -= expireTime > diff ? diff : expireTime; - if (expireTime < diff || forceExit) + if (expireTime < diff || forceExit || !GetPlayer()) { m_Socket = nullptr; } diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 5cf85596a3a..2e6a699fc7c 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -153,9 +153,9 @@ public: explicit MapSessionFilter(WorldSession* pSession) : PacketFilter(pSession) { } ~MapSessionFilter() { } - virtual bool Process(WorldPacket* packet); + virtual bool Process(WorldPacket* packet) override; //in Map::Update() we do not process player logout! - virtual bool ProcessLogout() const { return false; } + virtual bool ProcessLogout() const override { return false; } }; //class used to filer only thread-unsafe packets from queue @@ -166,7 +166,7 @@ public: explicit WorldSessionFilter(WorldSession* pSession) : PacketFilter(pSession) { } ~WorldSessionFilter() { } - virtual bool Process(WorldPacket* packet); + virtual bool Process(WorldPacket* packet) override; }; // Proxy structure to contain data passed to callback function, @@ -373,22 +373,21 @@ class WorldSession void SetLatency(uint32 latency) { m_latency = latency; } void ResetClientTimeDelay() { m_clientTimeDelay = 0; } - std::atomic<time_t> m_timeOutTime; + std::atomic<int32> m_timeOutTime; void UpdateTimeOutTime(uint32 diff) { - if (time_t(diff) > m_timeOutTime) - m_timeOutTime = 0; - else - m_timeOutTime -= diff; + m_timeOutTime -= int32(diff); } + void ResetTimeOutTime() { - m_timeOutTime = sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME); + m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME)); } + bool IsConnectionIdle() const { - return (m_timeOutTime <= 0 && !m_inQueue); + return m_timeOutTime <= 0 && !m_inQueue; } // Recruit-A-Friend Handling diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 65a424d5d75..5945d9fe868 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -16,13 +16,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <memory> #include "WorldSocket.h" #include "BigNumber.h" #include "Opcodes.h" +#include "Player.h" #include "ScriptMgr.h" #include "SHA1.h" #include "PacketLog.h" +#include <memory> using boost::asio::ip::tcp; @@ -33,6 +34,7 @@ WorldSocket::WorldSocket(tcp::socket&& socket) void WorldSocket::Start() { + sScriptMgr->OnSocketOpen(shared_from_this()); AsyncReadHeader(); HandleSendAuthSession(); } @@ -54,93 +56,95 @@ void WorldSocket::HandleSendAuthSession() AsyncWrite(packet); } -void WorldSocket::ReadHeaderHandler(boost::system::error_code error, size_t transferedBytes) +void WorldSocket::ReadHeaderHandler() { - if (!error && transferedBytes == sizeof(ClientPktHeader)) - { - _authCrypt.DecryptRecv(GetReadBuffer(), sizeof(ClientPktHeader)); + _authCrypt.DecryptRecv(GetHeaderBuffer(), sizeof(ClientPktHeader)); - ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetReadBuffer()); - EndianConvertReverse(header->size); - EndianConvert(header->cmd); + ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetHeaderBuffer()); + EndianConvertReverse(header->size); + EndianConvert(header->cmd); + + if (!header->IsValid()) + { + if (_worldSession) + { + Player* player = _worldSession->GetPlayer(); + TC_LOG_ERROR("network", "WorldSocket::ReadHeaderHandler(): client (account: %u, char [GUID: %u, name: %s]) sent malformed packet (size: %hu, cmd: %u)", + _worldSession->GetAccountId(), player ? player->GetGUIDLow() : 0, player ? player->GetName().c_str() : "<none>", header->size, header->cmd); + } + else + TC_LOG_ERROR("network", "WorldSocket::ReadHeaderHandler(): client %s sent malformed packet (size: %hu, cmd: %u)", + GetRemoteIpAddress().to_string().c_str(), header->size, header->cmd); - AsyncReadData(header->size - sizeof(header->cmd), sizeof(ClientPktHeader)); - } - else CloseSocket(); + return; + } + + AsyncReadData(header->size - sizeof(header->cmd)); } -void WorldSocket::ReadDataHandler(boost::system::error_code error, size_t transferedBytes) +void WorldSocket::ReadDataHandler() { - ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetReadBuffer()); - - if (!error && transferedBytes == (header->size - sizeof(header->cmd))) - { - header->size -= sizeof(header->cmd); + ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetHeaderBuffer()); - uint16 opcode = uint16(header->cmd); + header->size -= sizeof(header->cmd); - std::string opcodeName = GetOpcodeNameForLogging(opcode); + uint16 opcode = uint16(header->cmd); - WorldPacket packet(opcode, header->size); + std::string opcodeName = GetOpcodeNameForLogging(opcode); - if (header->size > 0) - { - packet.resize(header->size); + WorldPacket packet(opcode, MoveData()); - std::memcpy(packet.contents(), &(GetReadBuffer()[sizeof(ClientPktHeader)]), header->size); - } - - if (sPacketLog->CanLogPacket()) - sPacketLog->LogPacket(packet, CLIENT_TO_SERVER, GetRemoteIpAddress(), GetRemotePort()); + if (sPacketLog->CanLogPacket()) + sPacketLog->LogPacket(packet, CLIENT_TO_SERVER, GetRemoteIpAddress(), GetRemotePort()); - TC_LOG_TRACE("network.opcode", "C->S: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(), GetOpcodeNameForLogging(opcode).c_str()); + TC_LOG_TRACE("network.opcode", "C->S: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(), opcodeName.c_str()); - switch (opcode) - { - case CMSG_PING: - HandlePing(packet); + switch (opcode) + { + case CMSG_PING: + HandlePing(packet); + break; + case CMSG_AUTH_SESSION: + if (_worldSession) + { + TC_LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str()); break; - case CMSG_AUTH_SESSION: - if (_worldSession) - { - TC_LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str()); - break; - } + } - sScriptMgr->OnPacketReceive(shared_from_this(), packet); - HandleAuthSession(packet); - break; - case CMSG_KEEP_ALIVE: - TC_LOG_DEBUG("network", "%s", opcodeName.c_str()); - sScriptMgr->OnPacketReceive(shared_from_this(), packet); - break; - default: + HandleAuthSession(packet); + break; + case CMSG_KEEP_ALIVE: + TC_LOG_DEBUG("network", "%s", opcodeName.c_str()); + sScriptMgr->OnPacketReceive(_worldSession, packet); + break; + default: + { + if (!_worldSession) { - if (!_worldSession) - { - TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); - break; - } + TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); + CloseSocket(); + return; + } - // Our Idle timer will reset on any non PING opcodes. - // Catches people idling on the login screen and any lingering ingame connections. - _worldSession->ResetTimeOutTime(); + // Our Idle timer will reset on any non PING opcodes. + // Catches people idling on the login screen and any lingering ingame connections. + _worldSession->ResetTimeOutTime(); - // Copy the packet to the heap before enqueuing - _worldSession->QueuePacket(new WorldPacket(packet)); - break; - } + // Copy the packet to the heap before enqueuing + _worldSession->QueuePacket(new WorldPacket(std::move(packet))); + break; } - - AsyncReadHeader(); } - else - CloseSocket(); + + AsyncReadHeader(); } void WorldSocket::AsyncWrite(WorldPacket& packet) { + if (!IsOpen()) + return; + if (sPacketLog->CanLogPacket()) sPacketLog->LogPacket(packet, SERVER_TO_CLIENT, GetRemoteIpAddress(), GetRemotePort()); @@ -454,3 +458,10 @@ void WorldSocket::HandlePing(WorldPacket& recvPacket) packet << ping; return AsyncWrite(packet); } + +void WorldSocket::CloseSocket() +{ + sScriptMgr->OnSocketClose(shared_from_this()); + + Socket::CloseSocket(); +} diff --git a/src/server/game/Server/WorldSocket.h b/src/server/game/Server/WorldSocket.h index 7275da5ff29..0667c1b090a 100644 --- a/src/server/game/Server/WorldSocket.h +++ b/src/server/game/Server/WorldSocket.h @@ -48,6 +48,8 @@ struct ClientPktHeader { uint16 size; uint32 cmd; + + bool IsValid() const { return size >= 4 && size < 10240 && cmd < NUM_MSG_TYPES; } }; #pragma pack(pop) @@ -104,12 +106,14 @@ public: void Start() override; + void CloseSocket() override; + using Base::AsyncWrite; void AsyncWrite(WorldPacket& packet); protected: - void ReadHeaderHandler(boost::system::error_code error, size_t transferedBytes) override; - void ReadDataHandler(boost::system::error_code error, size_t transferedBytes) override; + void ReadHeaderHandler() override; + void ReadDataHandler() override; private: void HandleSendAuthSession(); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 1894776c990..c78830af43a 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -5005,7 +5005,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod // Glyph of Drain Soul - chance to create an additional Soul Shard if (AuraEffect* aur = caster->GetAuraEffect(58070, 0)) if (roll_chance_i(aur->GetMiscValue())) - caster->CastSpell(caster, 58068, true, 0, aur); // We _could_ simply do ++count here, but Blizz does it this way :) + caster->CastSpell(caster, 58068, true, nullptr, aur); // We _could_ simply do ++count here, but Blizz does it this way :) } } @@ -5390,7 +5390,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const int32 mod = (rage < 100) ? rage : 100; int32 points = target->CalculateSpellDamage(target, GetSpellInfo(), 1); int32 regen = target->GetMaxHealth() * (mod * points / 10) / 1000; - target->CastCustomSpell(target, 22845, ®en, 0, 0, true, 0, this); + target->CastCustomSpell(target, 22845, ®en, nullptr, nullptr, true, nullptr, this); target->SetPower(POWER_RAGE, rage-mod); break; } @@ -5428,12 +5428,12 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const // Feeding Frenzy Rank 1 case 53511: if (target->GetVictim() && target->EnsureVictim()->HealthBelowPct(35)) - target->CastSpell(target, 60096, true, 0, this); + target->CastSpell(target, 60096, true, nullptr, this); return; // Feeding Frenzy Rank 2 case 53512: if (target->GetVictim() && target->EnsureVictim()->HealthBelowPct(35)) - target->CastSpell(target, 60097, true, 0, this); + target->CastSpell(target, 60097, true, nullptr, this); return; default: break; @@ -5709,7 +5709,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) case 53563: { // area aura owner casts the spell - GetBase()->GetUnitOwner()->CastSpell(target, triggeredSpellInfo, true, 0, this, GetBase()->GetUnitOwner()->GetGUID()); + GetBase()->GetUnitOwner()->CastSpell(target, triggeredSpellInfo, true, nullptr, this, GetBase()->GetUnitOwner()->GetGUID()); return; } // Slime Spray - temporary here until preventing default effect works again @@ -5773,7 +5773,7 @@ void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* if (Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target) { int32 basepoints = GetAmount(); - triggerCaster->CastCustomSpell(target, triggerSpellId, &basepoints, &basepoints, &basepoints, true, 0, this); + triggerCaster->CastCustomSpell(target, triggerSpellId, &basepoints, &basepoints, &basepoints, true, nullptr, this); TC_LOG_DEBUG("spells", "AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick: Spell %u Trigger %u", GetId(), triggeredSpellInfo->Id); } } @@ -5869,11 +5869,11 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const { if (roll_chance_i(20)) { - caster->CastSpell(caster, 43836, true, 0, this); + caster->CastSpell(caster, 43836, true, nullptr, this); // Glyph of Drain Soul - chance to create an additional Soul Shard if (AuraEffect* aur = caster->GetAuraEffect(58070, 0)) if (roll_chance_i(aur->GetMiscValue())) - caster->CastSpell(caster, 58068, true, 0, aur); + caster->CastSpell(caster, 58068, true, nullptr, aur); } } } diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 851d992d857..348869075ee 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1295,7 +1295,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b { // instantly heal m_amount% of the absorb-value int32 heal = glyph->GetAmount() * GetEffect(0)->GetAmount()/100; - caster->CastCustomSpell(GetUnitOwner(), 56160, &heal, NULL, NULL, true, 0, GetEffect(0)); + caster->CastCustomSpell(GetUnitOwner(), 56160, &heal, nullptr, nullptr, true, nullptr, GetEffect(0)); } } break; diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 19c77c2ac7e..e578c0ffc3a 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -274,12 +274,12 @@ class UnitAura : public Aura protected: explicit UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID); public: - void _ApplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp); - void _UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp); + void _ApplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) override; + void _UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) override; - void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) override; - void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster); + void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster) override; // Allow Apply Aura Handler to modify and access m_AuraDRGroup void SetDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; } @@ -295,8 +295,8 @@ class DynObjAura : public Aura protected: explicit DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID); public: - void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) override; - void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster); + void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster) override; }; #endif diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index b540fbf4fde..14cf256d98e 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2704,7 +2704,7 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask) if (*i < 0) unit->RemoveAurasDueToSpell(-(*i)); else - unit->CastSpell(unit, *i, true, 0, 0, m_caster->GetGUID()); + unit->CastSpell(unit, *i, true, nullptr, nullptr, m_caster->GetGUID()); } } } @@ -3420,7 +3420,14 @@ void Spell::SendSpellCooldown() { Player* _player = m_caster->ToPlayer(); if (!_player) + { + // Handle pet cooldowns here if needed instead of in PetAI to avoid hidden cooldown restarts + Creature* _creature = m_caster->ToCreature(); + if (_creature && _creature->IsPet()) + _creature->AddCreatureSpellCooldown(m_spellInfo->Id); + return; + } // mana/health/etc potions, disabled by client (until combat out as declarate) if (m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent())) @@ -5081,7 +5088,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_TARGET_UNSKINNABLE; Creature* creature = m_targets.GetUnitTarget()->ToCreature(); - if (creature->GetCreatureType() != CREATURE_TYPE_CRITTER && !creature->loot.isLooted()) + if (!creature->IsCritter() && !creature->loot.isLooted()) return SPELL_FAILED_TARGET_NOT_LOOTED; uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill(); diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 0299717fde6..46203f3e7bb 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -752,9 +752,9 @@ class SpellEvent : public BasicEvent SpellEvent(Spell* spell); virtual ~SpellEvent(); - virtual bool Execute(uint64 e_time, uint32 p_time); - virtual void Abort(uint64 e_time); - virtual bool IsDeletable() const; + virtual bool Execute(uint64 e_time, uint32 p_time) override; + virtual void Abort(uint64 e_time) override; + virtual bool IsDeletable() const override; protected: Spell* m_Spell; }; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 0200d33211f..00b787345d4 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -478,7 +478,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) int chance = (*i)->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster); if (roll_chance_i(chance)) // Mind Trauma - m_caster->CastSpell(unitTarget, 48301, true, 0); + m_caster->CastSpell(unitTarget, 48301, true, nullptr); break; } } diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 43d8a577fa3..756644dbd1b 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -187,7 +187,7 @@ class SpellScript : public _SpellScript public: EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName); std::string ToString(); - bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex); + bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override; void Call(SpellScript* spellScript, SpellEffIndex effIndex); private: SpellEffectFnType pEffectHandlerScript; @@ -206,7 +206,7 @@ class SpellScript : public _SpellScript { public: TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest); - bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex); + bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override; std::string ToString(); uint16 GetTarget() const { return targetType; } protected: @@ -253,7 +253,7 @@ class SpellScript : public _SpellScript #define PrepareSpellScript(CLASSNAME) SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) public: - bool _Validate(SpellInfo const* entry); + bool _Validate(SpellInfo const* entry) override; bool _Load(Spell* spell); void _InitHit(); bool _IsEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventEffectMask & (1 << effIndex)) != 0; } @@ -509,7 +509,7 @@ class AuraScript : public _SpellScript public: EffectBase(uint8 _effIndex, uint16 _effName); std::string ToString(); - bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex); + bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override; }; class EffectPeriodicHandler : public EffectBase { @@ -630,7 +630,7 @@ class AuraScript : public _SpellScript public: AuraScript() : _SpellScript(), m_aura(NULL), m_auraApplication(NULL), m_defaultActionPrevented(false) { } - bool _Validate(SpellInfo const* entry); + bool _Validate(SpellInfo const* entry) override; bool _Load(Aura* aura); void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp = NULL); void _FinishScriptCall(); diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 8bd7a5a5e71..0412128754c 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -180,7 +180,7 @@ void CreatureTextMgr::LoadCreatureTextLocales() { Field* fields = result->Fetch(); CreatureTextLocale& loc = mLocaleTextMap[CreatureTextId(fields[0].GetUInt32(), uint32(fields[1].GetUInt8()), uint32(fields[2].GetUInt8()))]; - for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) { LocaleConstant locale = LocaleConstant(i); ObjectMgr::AddLocaleString(fields[3 + i - 1].GetString(), locale, loc.Text); diff --git a/src/server/game/Warden/WardenMac.h b/src/server/game/Warden/WardenMac.h index 3ea509c75ef..e9ccfe55438 100644 --- a/src/server/game/Warden/WardenMac.h +++ b/src/server/game/Warden/WardenMac.h @@ -34,13 +34,13 @@ class WardenMac : public Warden WardenMac(); ~WardenMac(); - void Init(WorldSession* session, BigNumber* k); - ClientWardenModule* GetModuleForClient(); - void InitializeModule(); - void RequestHash(); - void HandleHashResult(ByteBuffer& buff); - void RequestData(); - void HandleData(ByteBuffer& buff); + void Init(WorldSession* session, BigNumber* k) override; + ClientWardenModule* GetModuleForClient() override; + void InitializeModule() override; + void RequestHash() override; + void HandleHashResult(ByteBuffer& buff) override; + void RequestData() override; + void HandleData(ByteBuffer& buff) override; }; #endif diff --git a/src/server/game/Warden/WardenWin.h b/src/server/game/Warden/WardenWin.h index 47487ba65a2..d760d9ee981 100644 --- a/src/server/game/Warden/WardenWin.h +++ b/src/server/game/Warden/WardenWin.h @@ -76,13 +76,13 @@ class WardenWin : public Warden WardenWin(); ~WardenWin(); - void Init(WorldSession* session, BigNumber* K); - ClientWardenModule* GetModuleForClient(); - void InitializeModule(); - void RequestHash(); - void HandleHashResult(ByteBuffer &buff); - void RequestData(); - void HandleData(ByteBuffer &buff); + void Init(WorldSession* session, BigNumber* K) override; + ClientWardenModule* GetModuleForClient() override; + void InitializeModule() override; + void RequestHash() override; + void HandleHashResult(ByteBuffer &buff) override; + void RequestData() override; + void HandleData(ByteBuffer &buff) override; private: uint32 _serverTicks; diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp index 938c91b0228..6f011ed2954 100644 --- a/src/server/game/Weather/WeatherMgr.cpp +++ b/src/server/game/Weather/WeatherMgr.cpp @@ -50,7 +50,7 @@ namespace Weather* FindWeather(uint32 id) { WeatherMap::const_iterator itr = m_weathers.find(id); - return (itr != m_weathers.end()) ? itr->second.get() : 0; + return (itr != m_weathers.end()) ? itr->second.get() : nullptr; } /// Remove a Weather object for the given zoneid diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 7d3c7694463..0711ead6187 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -623,11 +623,11 @@ class World void SendWorldText(int32 string_id, ...); void SendGlobalText(const char* text, WorldSession* self); void SendGMText(int32 string_id, ...); - void SendGlobalMessage(WorldPacket* packet, WorldSession* self = 0, uint32 team = 0); - void SendGlobalGMMessage(WorldPacket* packet, WorldSession* self = 0, uint32 team = 0); - bool SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = 0, uint32 team = 0); - void SendZoneText(uint32 zone, const char *text, WorldSession* self = 0, uint32 team = 0); void SendServerMessage(ServerMessageType type, const char *text = "", Player* player = NULL); + void SendGlobalMessage(WorldPacket* packet, WorldSession* self = nullptr, uint32 team = 0); + void SendGlobalGMMessage(WorldPacket* packet, WorldSession* self = nullptr, uint32 team = 0); + bool SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = nullptr, uint32 team = 0); + void SendZoneText(uint32 zone, const char *text, WorldSession* self = nullptr, uint32 team = 0); /// Are we in the middle of a shutdown? bool IsShuttingDown() const { return m_ShutdownTimer > 0; } diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index cc5c8e49c69..a90bbd69e24 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -109,21 +109,23 @@ public: return false; } - switch (sWorld->BanCharacter(name, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "")) + std::string author = handler->GetSession() ? handler->GetSession()->GetPlayerName() : "Server"; + + switch (sWorld->BanCharacter(name, durationStr, reasonStr, author)) { case BAN_SUCCESS: { if (atoi(durationStr) > 0) { if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, author.c_str(), name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); else handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); } else { if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), name.c_str(), reasonStr); + sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, author.c_str(), name.c_str(), reasonStr); else handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr); } @@ -195,20 +197,22 @@ public: break; } - switch (sWorld->BanAccount(mode, nameOrIP, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "")) + std::string author = handler->GetSession() ? handler->GetSession()->GetPlayerName() : "Server"; + + switch (sWorld->BanAccount(mode, nameOrIP, durationStr, reasonStr, author)) { case BAN_SUCCESS: if (atoi(durationStr) > 0) { if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, author.c_str(), nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); else handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); } else { if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameOrIP.c_str(), reasonStr); + sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, author.c_str(), nameOrIP.c_str(), reasonStr); else handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr); } diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index ce0bee0d8c5..ed5b39e476d 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -37,7 +37,7 @@ class gobject_commandscript : public CommandScript public: gobject_commandscript() : CommandScript("gobject_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const override { static ChatCommand gobjectAddCommandTable[] = { diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index 4627f6b022e..86213291367 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -34,7 +34,7 @@ class guild_commandscript : public CommandScript public: guild_commandscript() : CommandScript("guild_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const override { static ChatCommand guildCommandTable[] = { diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index dd1366ac09c..f2067e6c70b 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -34,7 +34,7 @@ class message_commandscript : public CommandScript public: message_commandscript() : CommandScript("message_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const override { static ChatCommand channelSetCommandTable[] = { diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 179dc6cd629..a3848c00877 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1459,7 +1459,6 @@ public: std::string raceStr, classStr = "None"; uint8 gender = 0; int8 locale = handler->GetSessionDbcLocale(); - std::string genderStr = handler->GetTrinityString(LANG_ERROR); uint32 totalPlayerTime = 0; uint8 level = 0; std::string alive = handler->GetTrinityString(LANG_ERROR); @@ -1610,16 +1609,7 @@ public: banReason = fields[3].GetString(); } - // Can be used to query data from World database - stmt2 = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP); - stmt2->setUInt8(0, level); - PreparedQueryResult result3 = WorldDatabase.Query(stmt2); - if (result3) - { - Field* fields = result3->Fetch(); - xptotal = fields[0].GetUInt32(); - } // Can be used to query data from Characters database stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP); @@ -1631,6 +1621,7 @@ public: Field* fields = result4->Fetch(); xp = fields[0].GetUInt32(); // Used for "current xp" output and "%u XP Left" calculation uint32 gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all + xptotal = sObjectMgr->GetXPForLevel(level); if (gguid != 0) { @@ -1767,10 +1758,10 @@ public: Player* player = handler->GetSession()->GetPlayer(); // accept only explicitly selected target (not implicitly self targeting case) - Unit* target = handler->getSelectedUnit(); - if (player->GetTarget() && target) + Creature* target = player->GetTarget() ? handler->getSelectedCreature() : nullptr; + if (target) { - if (target->GetTypeId() != TYPEID_UNIT || target->IsPet()) + if (target->IsPet()) { handler->SendSysMessage(LANG_SELECT_CREATURE); handler->SetSentErrorMessage(true); @@ -1778,19 +1769,13 @@ public: } if (target->isDead()) - target->ToCreature()->Respawn(); + target->Respawn(); return true; } - CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - Trinity::RespawnDo u_do; Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do); - - TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); - cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange()); + player->VisitNearbyGridObject(player->GetGridActivationRange(), worker); return true; } @@ -1844,14 +1829,9 @@ public: std::string nameLink = handler->playerLink(targetName); if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD)) - { - sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); - } - else - { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); - } + sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); } else { @@ -1866,10 +1846,11 @@ public: LoginDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); - if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target) - sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, handler->GetSession()->GetPlayerName().c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); - else - handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target) + sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + else + handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + return true; } diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index f39dd0f0616..70aacbfc227 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -47,7 +47,7 @@ class reload_commandscript : public CommandScript public: reload_commandscript() : CommandScript("reload_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const override { static ChatCommand reloadAllCommandTable[] = { @@ -440,7 +440,7 @@ public: continue; } - CreatureTemplate* cInfo = const_cast<CreatureTemplate*>(sObjectMgr->GetCreatureTemplate(entry)); + CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry); if (!cInfo) { handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry); @@ -450,89 +450,7 @@ public: TC_LOG_INFO("misc", "Reloading creature template entry %u", entry); Field* fields = result->Fetch(); - - cInfo->DifficultyEntry[0] = fields[0].GetUInt32(); - cInfo->DifficultyEntry[1] = fields[1].GetUInt32(); - cInfo->DifficultyEntry[2] = fields[2].GetUInt32(); - cInfo->KillCredit[0] = fields[3].GetUInt32(); - cInfo->KillCredit[1] = fields[4].GetUInt32(); - cInfo->Modelid1 = fields[5].GetUInt32(); - cInfo->Modelid2 = fields[6].GetUInt32(); - cInfo->Modelid3 = fields[7].GetUInt32(); - cInfo->Modelid4 = fields[8].GetUInt32(); - cInfo->Name = fields[9].GetString(); - cInfo->SubName = fields[10].GetString(); - cInfo->IconName = fields[11].GetString(); - cInfo->GossipMenuId = fields[12].GetUInt32(); - cInfo->minlevel = fields[13].GetUInt8(); - cInfo->maxlevel = fields[14].GetUInt8(); - cInfo->expansion = fields[15].GetUInt16(); - cInfo->faction = fields[16].GetUInt16(); - cInfo->npcflag = fields[17].GetUInt32(); - cInfo->speed_walk = fields[18].GetFloat(); - cInfo->speed_run = fields[19].GetFloat(); - cInfo->scale = fields[20].GetFloat(); - cInfo->rank = fields[21].GetUInt8(); - cInfo->mindmg = fields[22].GetFloat(); - cInfo->maxdmg = fields[23].GetFloat(); - cInfo->dmgschool = fields[24].GetUInt8(); - cInfo->attackpower = fields[25].GetUInt32(); - cInfo->dmg_multiplier = fields[26].GetFloat(); - cInfo->baseattacktime = fields[27].GetUInt32(); - cInfo->rangeattacktime = fields[28].GetUInt32(); - cInfo->unit_class = fields[29].GetUInt8(); - cInfo->unit_flags = fields[30].GetUInt32(); - cInfo->unit_flags2 = fields[31].GetUInt32(); - cInfo->dynamicflags = fields[32].GetUInt32(); - cInfo->family = fields[33].GetUInt8(); - cInfo->trainer_type = fields[34].GetUInt8(); - cInfo->trainer_spell = fields[35].GetUInt32(); - cInfo->trainer_class = fields[36].GetUInt8(); - cInfo->trainer_race = fields[37].GetUInt8(); - cInfo->minrangedmg = fields[38].GetFloat(); - cInfo->maxrangedmg = fields[39].GetFloat(); - cInfo->rangedattackpower = fields[40].GetUInt16(); - cInfo->type = fields[41].GetUInt8(); - cInfo->type_flags = fields[42].GetUInt32(); - cInfo->lootid = fields[43].GetUInt32(); - cInfo->pickpocketLootId = fields[44].GetUInt32(); - cInfo->SkinLootId = fields[45].GetUInt32(); - - for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - cInfo->resistance[i] = fields[46 + i -1].GetUInt16(); - - cInfo->spells[0] = fields[52].GetUInt32(); - cInfo->spells[1] = fields[53].GetUInt32(); - cInfo->spells[2] = fields[54].GetUInt32(); - cInfo->spells[3] = fields[55].GetUInt32(); - cInfo->spells[4] = fields[56].GetUInt32(); - cInfo->spells[5] = fields[57].GetUInt32(); - cInfo->spells[6] = fields[58].GetUInt32(); - cInfo->spells[7] = fields[59].GetUInt32(); - cInfo->PetSpellDataId = fields[60].GetUInt32(); - cInfo->VehicleId = fields[61].GetUInt32(); - cInfo->mingold = fields[62].GetUInt32(); - cInfo->maxgold = fields[63].GetUInt32(); - cInfo->AIName = fields[64].GetString(); - cInfo->MovementType = fields[65].GetUInt8(); - cInfo->InhabitType = fields[66].GetUInt8(); - cInfo->HoverHeight = fields[67].GetFloat(); - cInfo->ModHealth = fields[68].GetFloat(); - cInfo->ModMana = fields[69].GetFloat(); - cInfo->ModArmor = fields[70].GetFloat(); - cInfo->RacialLeader = fields[71].GetBool(); - cInfo->questItems[0] = fields[72].GetUInt32(); - cInfo->questItems[1] = fields[73].GetUInt32(); - cInfo->questItems[2] = fields[74].GetUInt32(); - cInfo->questItems[3] = fields[75].GetUInt32(); - cInfo->questItems[4] = fields[76].GetUInt32(); - cInfo->questItems[5] = fields[77].GetUInt32(); - cInfo->movementId = fields[78].GetUInt32(); - cInfo->RegenHealth = fields[79].GetBool(); - cInfo->MechanicImmuneMask = fields[80].GetUInt32(); - cInfo->flags_extra = fields[81].GetUInt32(); - cInfo->ScriptID = sObjectMgr->GetScriptId(fields[82].GetCString()); - + sObjectMgr->LoadCreatureTemplate(fields); sObjectMgr->CheckCreatureTemplate(cInfo); } diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index 2f0b53bff68..a2f1c75106b 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -36,7 +36,7 @@ class ticket_commandscript : public CommandScript public: ticket_commandscript() : CommandScript("ticket_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const override { static ChatCommand ticketResponseCommandTable[] = { diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp index f996bcc6f70..e3021ff7a95 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp @@ -47,27 +47,20 @@ class npc_willix : public CreatureScript public: npc_willix() : CreatureScript("npc_willix") { } - bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override - { - if (quest->GetQuestId() == QUEST_WILLIX_THE_IMPORTER) - { - ENSURE_AI(npc_escortAI, (creature->AI()))->Start(true, false, player->GetGUID()); - creature->AI()->Talk(SAY_READY, player); - creature->setFaction(113); - } - - return true; - } - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_willixAI(creature); - } - struct npc_willixAI : public npc_escortAI { npc_willixAI(Creature* creature) : npc_escortAI(creature) { } + void sQuestAccept(Player* player, Quest const* quest) override + { + if (quest->GetQuestId() == QUEST_WILLIX_THE_IMPORTER) + { + Start(true, false, player->GetGUID()); + Talk(SAY_READY, player); + me->setFaction(113); + } + } + void WaypointReached(uint32 waypointId) override { Player* player = GetPlayerForEscort(); @@ -137,6 +130,10 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_willixAI(creature); + } }; enum SnufflenoseGopher @@ -147,18 +144,6 @@ enum SnufflenoseGopher POINT_TUBBER = 0 }; -struct DistanceOrder : public std::binary_function<GameObject, GameObject, bool> -{ - DistanceOrder(Creature* me) : me(me) { } - - bool operator() (GameObject* first, GameObject* second) - { - return me->GetDistanceOrder(first, second); - } - - Creature* me; -}; - struct npc_snufflenose_gopher : public CreatureScript { public: @@ -208,18 +193,14 @@ public: if (tubbersInRange.empty()) return; - tubbersInRange.sort(DistanceOrder(me)); - GameObject* nearestTubber = NULL; - - for (std::list<GameObject*>::const_iterator itr = tubbersInRange.begin(); itr != tubbersInRange.end(); ++itr) + tubbersInRange.remove_if([](GameObject* go) { - if (!(*itr)->isSpawned() && (*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND)) - { - nearestTubber = *itr; - break; - } - } + return go->isSpawned() || !go->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND); + }); + tubbersInRange.sort(Trinity::ObjectDistanceOrderPred(me)); + + GameObject* nearestTubber = tubbersInRange.front(); if (!nearestTubber) return; @@ -259,21 +240,16 @@ class spell_snufflenose_command : public SpellScriptLoader { PrepareSpellScript(spell_snufflenose_commandSpellScript); - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } - - void HandleAfterCast() + void HandleEffect(SpellEffIndex /*effIndex*/) { - if (Unit* target = GetCaster()->ToPlayer()->GetSelectedUnit()) + if (Creature* target = GetHitCreature()) if (target->GetEntry() == NPC_SNUFFLENOSE_GOPHER) - target->ToCreature()->AI()->DoAction(ACTION_FIND_NEW_TUBBER); + target->AI()->DoAction(ACTION_FIND_NEW_TUBBER); } void Register() override { - AfterCast += SpellCastFn(spell_snufflenose_commandSpellScript::HandleAfterCast); + OnEffectHitTarget += SpellEffectFn(spell_snufflenose_commandSpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_DUMMY); } }; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index e1658e564ec..5ef84c7bb40 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -299,6 +299,12 @@ class boss_deathbringer_saurfang : public CreatureScript _introDone = true; + if (GameObject* teleporter = GameObject::GetGameObject(*me, instance->GetData64(GO_SCOURGE_TRANSPORTER_DEATHBRINGER))) + { + instance->HandleGameObject(0, false, teleporter); + teleporter->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + } + Talk(SAY_AGGRO); events.ScheduleEvent(EVENT_SUMMON_BLOOD_BEAST, 30000, 0, PHASE_COMBAT); events.ScheduleEvent(EVENT_BERSERK, IsHeroic() ? 360000 : 480000, 0, PHASE_COMBAT); @@ -538,12 +544,6 @@ class boss_deathbringer_saurfang : public CreatureScript case PHASE_INTRO_A: case PHASE_INTRO_H: { - if (GameObject* teleporter = GameObject::GetGameObject(*me, instance->GetData64(GO_SCOURGE_TRANSPORTER_SAURFANG))) - { - instance->HandleGameObject(0, false, teleporter); - teleporter->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); // controls what events will execute events.SetPhase(uint32(action)); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index 592c44940a4..e85ddc21dda 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -2102,7 +2102,15 @@ class at_icc_shutdown_traps : public AreaTriggerScript bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override { if (InstanceScript* instance = player->GetInstanceScript()) - instance->SetData(DATA_COLDFLAME_JETS, DONE); + { + instance->SetData(DATA_UPPERSPIRE_TELE_ACT, DONE); + uint64 teleporterGUID = instance->GetData64(GO_SCOURGE_TRANSPORTER_UPPERSPIRE); + if (GameObject* go = instance->instance->GetGameObject(teleporterGUID)) + { + go->SetGoState(GO_STATE_ACTIVE); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + } + } return true; } }; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h index da4a8f089cc..fbd3a715fb8 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h @@ -116,7 +116,8 @@ enum DataTypes DATA_HIGHLORD_TIRION_FORDRING = 37, DATA_ARTHAS_PLATFORM = 38, DATA_TERENAS_MENETHIL = 39, - DATA_ENEMY_GUNSHIP = 40 + DATA_ENEMY_GUNSHIP = 40, + DATA_UPPERSPIRE_TELE_ACT = 41, }; enum CreaturesIds @@ -322,6 +323,15 @@ enum CreaturesIds enum GameObjectsIds { + // ICC Teleporters + GO_SCOURGE_TRANSPORTER_LICHKING = 202223, + GO_SCOURGE_TRANSPORTER_UPPERSPIRE = 202235, + GO_SCOURGE_TRANSPORTER_LIGHTSHAMMER = 202242, + GO_SCOURGE_TRANSPORTER_RAMPART = 202243, + GO_SCOURGE_TRANSPORTER_DEATHBRINGER = 202244, + GO_SCOURGE_TRANSPORTER_ORATORY = 202245, + GO_SCOURGE_TRANSPORTER_SINDRAGOSA = 202246, + // Lower Spire Trash GO_SPIRIT_ALARM_1 = 201814, GO_SPIRIT_ALARM_2 = 201815, @@ -359,7 +369,6 @@ enum GameObjectsIds GO_DEATHBRINGER_S_CACHE_25N = 202240, GO_DEATHBRINGER_S_CACHE_10H = 202238, GO_DEATHBRINGER_S_CACHE_25H = 202241, - GO_SCOURGE_TRANSPORTER_SAURFANG = 202244, // Professor Putricide GO_ORANGE_PLAGUE_MONSTER_ENTRANCE = 201371, @@ -404,7 +413,6 @@ enum GameObjectsIds GO_SIGIL_OF_THE_FROSTWING = 202181, // The Lich King - GO_SCOURGE_TRANSPORTER_LK = 202223, GO_ARTHAS_PLATFORM = 202161, GO_ARTHAS_PRECIPICE = 202078, GO_DOODAD_ICECROWN_THRONEFROSTYWIND01 = 202188, diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp index 537c3c7354d..469bfc1d310 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp @@ -31,19 +31,23 @@ class icecrown_citadel_teleport : public GameObjectScript bool OnGossipHello(Player* player, GameObject* go) override { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to Light's Hammer.", GOSSIP_SENDER_ICC_PORT, LIGHT_S_HAMMER_TELEPORT); if (InstanceScript* instance = go->GetInstanceScript()) { if (instance->GetBossState(DATA_LORD_MARROWGAR) == DONE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Oratory of the Damned.", GOSSIP_SENDER_ICC_PORT, ORATORY_OF_THE_DAMNED_TELEPORT); - if (instance->GetBossState(DATA_LADY_DEATHWHISPER) == DONE) + { + if (go->GetEntry() != GO_SCOURGE_TRANSPORTER_LIGHTSHAMMER) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to Light's Hammer.", GOSSIP_SENDER_ICC_PORT, LIGHT_S_HAMMER_TELEPORT); + if (go->GetEntry() != GO_SCOURGE_TRANSPORTER_ORATORY) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Oratory of the Damned.", GOSSIP_SENDER_ICC_PORT, ORATORY_OF_THE_DAMNED_TELEPORT); + } + if (instance->GetBossState(DATA_LADY_DEATHWHISPER) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_RAMPART) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Rampart of Skulls.", GOSSIP_SENDER_ICC_PORT, RAMPART_OF_SKULLS_TELEPORT); - if (instance->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) == DONE) + if (instance->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_DEATHBRINGER) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Deathbringer's Rise.", GOSSIP_SENDER_ICC_PORT, DEATHBRINGER_S_RISE_TELEPORT); - if (instance->GetData(DATA_COLDFLAME_JETS) == DONE) + if (instance->GetData(DATA_UPPERSPIRE_TELE_ACT) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_UPPERSPIRE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to the Upper Spire.", GOSSIP_SENDER_ICC_PORT, UPPER_SPIRE_TELEPORT); /// @todo Gauntlet event before Sindragosa - if (instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == DONE) + if (instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == DONE && go->GetEntry() != GO_SCOURGE_TRANSPORTER_SINDRAGOSA) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to Sindragosa's Lair", GOSSIP_SENDER_ICC_PORT, SINDRAGOSA_S_LAIR_TELEPORT); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp index df5e3b795d5..f7f8e3e2489 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp @@ -127,7 +127,13 @@ class instance_icecrown_citadel : public InstanceMapScript DeathbringerSaurfangDoorGUID = 0; DeathbringerSaurfangEventGUID = 0; DeathbringersCacheGUID = 0; - SaurfangTeleportGUID = 0; + TeleporterLichKingGUID = 0; + TeleporterUpperSpireGUID = 0; + TeleporterLightsHammerGUID = 0; + TeleporterRampartsGUID = 0; + TeleporterDeathBringerGUID = 0; + TeleporterOratoryGUID = 0; + TeleporterSindragosaGUID = 0; PlagueSigilGUID = 0; BloodwingSigilGUID = 0; FrostwingSigilGUID = 0; @@ -164,10 +170,26 @@ class instance_icecrown_citadel : public InstanceMapScript IsNauseaEligible = true; IsOrbWhispererEligible = true; ColdflameJetsState = NOT_STARTED; + UpperSpireTeleporterActiveState = NOT_STARTED; BloodQuickeningState = NOT_STARTED; BloodQuickeningMinutes = 0; } + // A function to help reduce the number of lines for teleporter management. + void SetTeleporterState(GameObject* go, bool usable) + { + if (usable) + { + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + go->SetGoState(GO_STATE_ACTIVE); + } + else + { + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + go->SetGoState(GO_STATE_READY); + } + } + void FillInitialWorldStates(WorldPacket& data) override { data << uint32(WORLDSTATE_SHOW_TIMER) << uint32(BloodQuickeningState == IN_PROGRESS); @@ -542,8 +564,37 @@ class instance_icecrown_citadel : public InstanceMapScript case GO_DEATHBRINGER_S_CACHE_25H: DeathbringersCacheGUID = go->GetGUID(); break; - case GO_SCOURGE_TRANSPORTER_SAURFANG: - SaurfangTeleportGUID = go->GetGUID(); + case GO_SCOURGE_TRANSPORTER_LICHKING: + TeleporterLichKingGUID = go->GetGUID(); + if (GetBossState(DATA_PROFESSOR_PUTRICIDE) == DONE && GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == DONE && GetBossState(DATA_SINDRAGOSA) == DONE) + go->SetGoState(GO_STATE_ACTIVE); + break; + case GO_SCOURGE_TRANSPORTER_UPPERSPIRE: + TeleporterUpperSpireGUID = go->GetGUID(); + if (GetBossState(DATA_DEATHBRINGER_SAURFANG) != DONE || GetData(DATA_UPPERSPIRE_TELE_ACT) != DONE) + SetTeleporterState(go, false); + else + SetTeleporterState(go, true); + break; + case GO_SCOURGE_TRANSPORTER_LIGHTSHAMMER: + TeleporterLightsHammerGUID = go->GetGUID(); + SetTeleporterState(go, GetBossState(DATA_LORD_MARROWGAR) == DONE); + break; + case GO_SCOURGE_TRANSPORTER_RAMPART: + TeleporterRampartsGUID = go->GetGUID(); + SetTeleporterState(go, GetBossState(DATA_LADY_DEATHWHISPER) == DONE); + break; + case GO_SCOURGE_TRANSPORTER_DEATHBRINGER: + TeleporterDeathBringerGUID = go->GetGUID(); + SetTeleporterState(go, GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) == DONE); + break; + case GO_SCOURGE_TRANSPORTER_ORATORY: + TeleporterOratoryGUID = go->GetGUID(); + SetTeleporterState(go, GetBossState(DATA_LORD_MARROWGAR) == DONE); + break; + case GO_SCOURGE_TRANSPORTER_SINDRAGOSA: + TeleporterSindragosaGUID = go->GetGUID(); + SetTeleporterState(go, GetBossState(DATA_VALITHRIA_DREAMWALKER) == DONE); break; case GO_PLAGUE_SIGIL: PlagueSigilGUID = go->GetGUID(); @@ -600,11 +651,6 @@ class instance_icecrown_citadel : public InstanceMapScript go->SetLootRecipient(valithria->GetLootRecipient()); go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE | GO_FLAG_NODESPAWN); break; - case GO_SCOURGE_TRANSPORTER_LK: - TheLichKingTeleportGUID = go->GetGUID(); - if (GetBossState(DATA_PROFESSOR_PUTRICIDE) == DONE && GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == DONE && GetBossState(DATA_SINDRAGOSA) == DONE) - go->SetGoState(GO_STATE_ACTIVE); - break; case GO_ARTHAS_PLATFORM: // this enables movement at The Frozen Throne, when printed this value is 0.000000f // however, when represented as integer client will accept only this value @@ -694,6 +740,8 @@ class instance_icecrown_citadel : public InstanceMapScript return RimefangTrash.size(); case DATA_COLDFLAME_JETS: return ColdflameJetsState; + case DATA_UPPERSPIRE_TELE_ACT: + return UpperSpireTeleporterActiveState; case DATA_TEAM_IN_INSTANCE: return TeamInInstance; case DATA_BLOOD_QUICKENING_STATE: @@ -721,8 +769,20 @@ class instance_icecrown_citadel : public InstanceMapScript return DeathbringerSaurfangEventGUID; case GO_SAURFANG_S_DOOR: return DeathbringerSaurfangDoorGUID; - case GO_SCOURGE_TRANSPORTER_SAURFANG: - return SaurfangTeleportGUID; + case GO_SCOURGE_TRANSPORTER_LICHKING: + return TeleporterLichKingGUID; + case GO_SCOURGE_TRANSPORTER_UPPERSPIRE: + return TeleporterUpperSpireGUID; + case GO_SCOURGE_TRANSPORTER_LIGHTSHAMMER: + return TeleporterLightsHammerGUID; + case GO_SCOURGE_TRANSPORTER_RAMPART: + return TeleporterRampartsGUID; + case GO_SCOURGE_TRANSPORTER_DEATHBRINGER: + return TeleporterDeathBringerGUID; + case GO_SCOURGE_TRANSPORTER_ORATORY: + return TeleporterOratoryGUID; + case GO_SCOURGE_TRANSPORTER_SINDRAGOSA: + return TeleporterSindragosaGUID; case DATA_FESTERGUT: return FestergutGUID; case DATA_ROTFACE: @@ -784,10 +844,24 @@ class instance_icecrown_citadel : public InstanceMapScript switch (type) { + case DATA_LORD_MARROWGAR: + { + if (state == DONE) + { + if (GameObject* teleporter = instance->GetGameObject(TeleporterLightsHammerGUID)) + SetTeleporterState(teleporter, true); + if (GameObject* teleporter = instance->GetGameObject(TeleporterOratoryGUID)) + SetTeleporterState(teleporter, true); + } + break; + } case DATA_LADY_DEATHWHISPER: { if (state == DONE) { + if (GameObject* teleporter = instance->GetGameObject(TeleporterRampartsGUID)) + SetTeleporterState(teleporter, true); + if (GameObject* elevator = instance->GetGameObject(LadyDeathwisperElevatorGUID)) { elevator->SetUInt32Value(GAMEOBJECT_LEVEL, 0); @@ -801,6 +875,9 @@ class instance_icecrown_citadel : public InstanceMapScript case DATA_ICECROWN_GUNSHIP_BATTLE: if (state == DONE) { + if (GameObject* teleporter = instance->GetGameObject(TeleporterDeathBringerGUID)) + SetTeleporterState(teleporter, true); + if (GameObject* loot = instance->GetGameObject(GunshipArmoryGUID)) loot->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE | GO_FLAG_NODESPAWN); } @@ -811,20 +888,28 @@ class instance_icecrown_citadel : public InstanceMapScript switch (state) { case DONE: + { if (GameObject* loot = instance->GetGameObject(DeathbringersCacheGUID)) { if (Creature* deathbringer = instance->GetCreature(DeathbringerSaurfangGUID)) loot->SetLootRecipient(deathbringer->GetLootRecipient()); loot->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE | GO_FLAG_NODESPAWN); } - // no break + + if (GameObject* teleporter = instance->GetGameObject(TeleporterUpperSpireGUID)) + SetTeleporterState(teleporter, true); + + if (GameObject* teleporter = instance->GetGameObject(TeleporterDeathBringerGUID)) + SetTeleporterState(teleporter, true); + break; + } case NOT_STARTED: - if (GameObject* teleporter = instance->GetGameObject(SaurfangTeleportGUID)) - { - HandleGameObject(SaurfangTeleportGUID, true, teleporter); - teleporter->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } + { + if (GameObject* teleporter = instance->GetGameObject(TeleporterDeathBringerGUID)) + SetTeleporterState(teleporter, true); + break; + } default: break; } @@ -894,8 +979,13 @@ class instance_icecrown_citadel : public InstanceMapScript } break; case DATA_VALITHRIA_DREAMWALKER: - if (state == DONE && sPoolMgr->IsSpawnedObject<Quest>(WeeklyQuestData[8].questId[instance->GetSpawnMode() & 1])) - instance->SummonCreature(NPC_VALITHRIA_DREAMWALKER_QUEST, ValithriaSpawnPos); + if (state == DONE) + { + if (sPoolMgr->IsSpawnedObject<Quest>(WeeklyQuestData[8].questId[instance->GetSpawnMode() & 1])) + instance->SummonCreature(NPC_VALITHRIA_DREAMWALKER_QUEST, ValithriaSpawnPos); + if (GameObject* teleporter = instance->GetGameObject(TeleporterSindragosaGUID)) + SetTeleporterState(teleporter, true); + } break; case DATA_SINDRAGOSA: HandleGameObject(FrostwingSigilGUID, state != DONE); @@ -1029,6 +1119,11 @@ class instance_icecrown_citadel : public InstanceMapScript SaveToDB(); break; } + case DATA_UPPERSPIRE_TELE_ACT: + UpperSpireTeleporterActiveState = data; + if (UpperSpireTeleporterActiveState == DONE) + SaveToDB(); + break; default: break; } @@ -1235,7 +1330,7 @@ class instance_icecrown_citadel : public InstanceMapScript std::ostringstream saveStream; saveStream << "I C " << GetBossSaveData() << HeroicAttempts << ' ' - << ColdflameJetsState << ' ' << BloodQuickeningState << ' ' << BloodQuickeningMinutes; + << ColdflameJetsState << ' ' << BloodQuickeningState << ' ' << BloodQuickeningMinutes << ' ' << UpperSpireTeleporterActiveState; OUT_SAVE_INST_DATA_COMPLETE; return saveStream.str(); @@ -1271,11 +1366,17 @@ class instance_icecrown_citadel : public InstanceMapScript uint32 temp = 0; loadStream >> temp; - ColdflameJetsState = temp ? DONE : NOT_STARTED; + if (temp == IN_PROGRESS) + ColdflameJetsState = NOT_STARTED; + else + ColdflameJetsState = temp ? DONE : NOT_STARTED; loadStream >> temp; BloodQuickeningState = temp ? DONE : NOT_STARTED; // DONE means finished (not success/fail) loadStream >> BloodQuickeningMinutes; + + loadStream >> temp; + UpperSpireTeleporterActiveState = temp ? DONE : NOT_STARTED; } else OUT_LOAD_INST_DATA_FAIL; @@ -1416,7 +1517,13 @@ class instance_icecrown_citadel : public InstanceMapScript uint64 DeathbringerSaurfangDoorGUID; uint64 DeathbringerSaurfangEventGUID; // Muradin Bronzebeard or High Overlord Saurfang uint64 DeathbringersCacheGUID; - uint64 SaurfangTeleportGUID; + uint64 TeleporterLichKingGUID; + uint64 TeleporterUpperSpireGUID; + uint64 TeleporterLightsHammerGUID; + uint64 TeleporterRampartsGUID; + uint64 TeleporterDeathBringerGUID; + uint64 TeleporterOratoryGUID; + uint64 TeleporterSindragosaGUID; uint64 PlagueSigilGUID; uint64 BloodwingSigilGUID; uint64 FrostwingSigilGUID; @@ -1453,6 +1560,7 @@ class instance_icecrown_citadel : public InstanceMapScript uint64 PillarsUnchainedGUID; uint32 TeamInInstance; uint32 ColdflameJetsState; + uint32 UpperSpireTeleporterActiveState; std::set<uint32> FrostwyrmGUIDs; std::set<uint32> SpinestalkerTrash; std::set<uint32> RimefangTrash; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index f284aacf996..b769c7e141e 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -15,10 +15,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Cell.h" +#include "CellImpl.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" +#include "SpellAuraEffects.h" #include "ulduar.h" +#include "Vehicle.h" enum Yells { @@ -39,78 +45,1413 @@ enum Yells SAY_BERSERK = 14 }; +enum ComputerYells +{ + SAY_SELF_DESTRUCT_INITIATED = 0, + SAY_SELF_DESTRUCT_TERMINATED = 1, + SAY_SELF_DESTRUCT_10 = 2, + SAY_SELF_DESTRUCT_9 = 3, + SAY_SELF_DESTRUCT_8 = 4, + SAY_SELF_DESTRUCT_7 = 5, + SAY_SELF_DESTRUCT_6 = 6, + SAY_SELF_DESTRUCT_5 = 7, + SAY_SELF_DESTRUCT_4 = 8, + SAY_SELF_DESTRUCT_3 = 9, + SAY_SELF_DESTRUCT_2 = 10, + SAY_SELF_DESTRUCT_1 = 11, + SAY_SELF_DESTRUCT_FINALIZED = 12 +}; + enum Spells { + // Mimiron + SPELL_WELD = 63339, // Idle aura. + SPELL_SEAT_1 = 52391, // Cast on all vehicles, Cycled on MKII + SPELL_SEAT_2 = 63313, // Cast on MKII and VX-001, Cycled on MKII + SPELL_SEAT_3 = 63314, // Cast on MKII, Cycled on MKII + SPELL_SEAT_5 = 63316, // Cast on MKII and VX-001, Cycled on MKII + SPELL_SEAT_6 = 63344, // Cast on MKII + SPELL_SEAT_7 = 63345, // Cast on MKII SPELL_JETPACK = 63341, - SPELL_EMERGENCY_MODE = 64582, - SPELL_SELF_REPAIR = 64383, - SPELL_MAGNETIC_CORE = 64444, + SPELL_DESPAWN_ASSAULT_BOTS = 64463, // only despawns assault bots... no equivalent spell for the other adds... + SPELL_TELEPORT_VISUAL = 41232, + SPELL_SLEEP_VISUAL_1 = 64393, + SPELL_SLEEP_VISUAL_2 = 64394, + // Leviathan MK II SPELL_FLAME_SUPPRESSANT_MK = 64570, SPELL_NAPALM_SHELL = 63666, - SPELL_PLASMA_BLAST = 62977, - SPELL_PROXIMITY_MINES = 63027, + SPELL_FORCE_CAST_NAPALM_SHELL = 64539, + SPELL_PLASMA_BLAST = 62997, + SPELL_SCRIPT_EFFECT_PLASMA_BLAST = 64542, SPELL_SHOCK_BLAST = 63631, - // VX 001 + SPELL_SHOCK_BLAST_AURA = 63632, // Deprecated? It is never cast. + + // VX-001 SPELL_FLAME_SUPPRESSANT_VX = 65192, - SPELL_FROSTBOMB = 64623, - SPELL_HAND_PULSE = 64348, SPELL_SPINNING_UP = 63414, - SPELL_RAPID_BURST = 63387, - SPELL_P3WX2_LASER_BARRAGE = 63293, - SPELL_ROCKET_STRIKE = 63041, - SPELL_HEAT_WAVE = 63677, + SPELL_HEAT_WAVE_AURA = 63679, + SPELL_HAND_PULSE_LEFT = 64348, + SPELL_HAND_PULSE_RIGHT = 64352, + SPELL_MOUNT_MKII = 64387, + SPELL_TORSO_DISABLED = 64120, + // Aerial Command Unit - SPELL_PLASMA_BALL = 63689, - // Additonal spells - SPELL_MAGNETIC_FIELD = 64668, - SPELL_DEAFENING_SIREN = 64616, + SPELL_PLASMA_BALL_P1 = 63689, + SPELL_PLASMA_BALL_P2 = 65647, + SPELL_MOUNT_VX_001 = 64388, + + // Proximity Mines + SPELL_PROXIMITY_MINES = 63027, // Cast by Leviathan MK II + SPELL_PROXIMITY_MINE_EXPLOSION = 66351, + SPELL_PROXIMITY_MINE_TRIGGER = 65346, + SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER = 65345, + SPELL_PERIODIC_PROXIMITY_AURA = 65345, + SPELL_SUMMON_PROXIMITY_MINE = 65347, + + // Rapid Burst + SPELL_RAPID_BURST_LEFT = 63387, + SPELL_RAPID_BURST_RIGHT = 64019, + SPELL_RAPID_BURST = 63382, // Cast by VX-001 + SPELL_RAPID_BURST_TARGET_ME = 64841, // Cast by Burst Target + SPELL_SUMMON_BURST_TARGET = 64840, // Cast by VX-001 + + // Rocket Strike + SPELL_SUMMON_ROCKET_STRIKE = 63036, + SPELL_SCRIPT_EFFECT_ROCKET_STRIKE = 63681, // Cast by Rocket (Mimiron Visual) + SPELL_ROCKET_STRIKE = 64064, // Added in creature_template_addon + SPELL_ROCKET_STRIKE_LEFT = 64402, // Cast by VX-001 + SPELL_ROCKET_STRIKE_BOTH = 65034, // Cast by VX-001 + + // Flames + SPELL_FLAMES_PERIODIC_TRIGGER = 64561, // Added in creature_template_addon + SPELL_SUMMON_FLAMES_SPREAD_TRIGGER = 64562, + SPELL_SUMMON_FLAMES_INITIAL = 64563, + SPELL_SUMMON_FLAMES_SPREAD = 64564, + SPELL_FLAMES = 64566, + SPELL_SCRIPT_EFFECT_SUMMON_FLAMES_INITIAL = 64567, + + // Frost Bomb + SPELL_SCRIPT_EFFECT_FROST_BOMB = 64623, // Cast by VX-001 + SPELL_FROST_BOMB_LINKED = 64624, // Added in creature_template_addon + SPELL_FROST_BOMB_DUMMY = 64625, + SPELL_SUMMON_FROST_BOMB = 64627, // Cast by VX-001 + SPELL_FROST_BOMB_EXPLOSION = 64626, + SPELL_CLEAR_FIRES = 65354, + + // Bots + SPELL_SUMMON_FIRE_BOT = 64622, + SPELL_SUMMON_FIRE_BOT_DUMMY = 64621, + SPELL_SUMMON_FIRE_BOT_TRIGGER = 64620, // Cast by Areal Command Unit + SPELL_DEAFENING_SIREN = 64616, // Added in creature_template_addon + SPELL_FIRE_SEARCH_AURA = 64617, // Added in creature_template_addon + SPELL_FIRE_SEARCH = 64618, SPELL_WATER_SPRAY = 64619, - SPELL_FROST_BOMB_HARD_MODE = 64627, - SPELL_EXPLOSION = 66351, - SPELL_DISARM = 1842, - SPELL_RIDE_VEHICLE = 46598, - SPELL_TRIGGER_MISSILE = 65347, + + SPELL_SUMMON_JUNK_BOT = 63819, + SPELL_SUMMON_JUNK_BOT_TRIGGER = 63820, // Cast by Areal Command Unit + SPELL_SUMMON_JUNK_BOT_DUMMY = 64398, + + SPELL_SUMMON_ASSAULT_BOT_TRIGGER = 64425, // Cast by Areal Command Unit + SPELL_SUMMON_ASSAULT_BOT_DUMMY = 64426, + SPELL_SUMMON_ASSAULT_BOT = 64427, + SPELL_MAGNETIC_FIELD = 64668, + + SPELL_SUMMON_BOMB_BOT = 63811, // Cast by Areal Command Unit + SPELL_BOMB_BOT_AURA = 63767, // Added in creature_template_addon + + // Miscellaneous + SPELL_SELF_DESTRUCTION_AURA = 64610, + SPELL_SELF_DESTRUCTION_VISUAL = 64613, + SPELL_NOT_SO_FRIENDLY_FIRE = 65040, + SPELL_ELEVATOR_KNOCKBACK = 65096, // Cast by worldtrigger. + SPELL_VEHICLE_DAMAGED = 63415, + SPELL_EMERGENCY_MODE = 64582, // mkii, vx001, aerial, assault, junk + SPELL_EMERGENCY_MODE_TURRET = 65101, // Cast by Leviathan MK II, only hits Leviathan MK II turret + SPELL_SELF_REPAIR = 64383, + SPELL_MAGNETIC_CORE = 64436, + SPELL_MAGNETIC_CORE_VISUAL = 64438, + SPELL_HALF_HEAL = 64188, + SPELL_CLEAR_ALL_DEBUFFS = 34098, // TODO: make use of this spell... + SPELL_FREEZE_ANIM_STUN = 63354, // used to prevent mkii from doing stuff?.. + SPELL_FREEZE_ANIM = 16245 // Idle aura. Freezes animation. }; -enum Npc +enum Data { - NPC_ASSAULT_BOT = 34057, - NPC_BOMB_BOT = 33836, - NPC_JUNK_BOT = 33855, - NPC_EMERGENCE_FIRE_BOT = 34147, - NPC_FROST_BOMB = 34149, + DATA_SETUP_MINE, + DATA_SETUP_BOMB, + DATA_SETUP_ROCKET, + DATA_NOT_SO_FRIENDLY_FIRE, + DATA_FIREFIGHTER, + DATA_WATERSPRAY, + DATA_MOVE_NEW }; -class spell_ulduar_proximity_mines : public SpellScriptLoader +enum Events +{ + // Leviathan MK II + EVENT_PROXIMITY_MINE = 1, + EVENT_NAPALM_SHELL, + EVENT_PLASMA_BLAST, + EVENT_SHOCK_BLAST, + EVENT_FLAME_SUPPRESSANT_MK, + EVENT_MOVE_POINT_2, + EVENT_MOVE_POINT_3, + EVENT_MOVE_POINT_5, + + // VX-001 + EVENT_RAPID_BURST, + EVENT_SPINNING_UP, + EVENT_ROCKET_STRIKE, + EVENT_HAND_PULSE, + EVENT_FROST_BOMB, + EVENT_FLAME_SUPPRESSANT_VX, + EVENT_RELOAD, + + // Aerial Command Unit + EVENT_SUMMON_FIRE_BOTS, + EVENT_SUMMON_JUNK_BOT, + EVENT_SUMMON_ASSAULT_BOT, + EVENT_SUMMON_BOMB_BOT, + + // Mimiron + EVENT_SUMMON_FLAMES, + EVENT_INTRO_1, + EVENT_INTRO_2, + EVENT_INTRO_3, + + EVENT_VX001_ACTIVATION_1, + EVENT_VX001_ACTIVATION_2, + EVENT_VX001_ACTIVATION_3, + EVENT_VX001_ACTIVATION_4, + EVENT_VX001_ACTIVATION_5, + EVENT_VX001_ACTIVATION_6, + EVENT_VX001_ACTIVATION_7, + EVENT_VX001_ACTIVATION_8, + EVENT_VX001_ACTIVATION_9, + + EVENT_AERIAL_ACTIVATION_1, + EVENT_AERIAL_ACTIVATION_2, + EVENT_AERIAL_ACTIVATION_3, + EVENT_AERIAL_ACTIVATION_4, + EVENT_AERIAL_ACTIVATION_5, + EVENT_AERIAL_ACTIVATION_6, + + EVENT_VOL7RON_ACTIVATION_1, + EVENT_VOL7RON_ACTIVATION_2, + EVENT_VOL7RON_ACTIVATION_3, + EVENT_VOL7RON_ACTIVATION_4, + EVENT_VOL7RON_ACTIVATION_5, + EVENT_VOL7RON_ACTIVATION_6, + EVENT_VOL7RON_ACTIVATION_7, + + EVENT_OUTTRO_1, + EVENT_OUTTRO_2, + EVENT_OUTTRO_3, + + // Computer + EVENT_SELF_DESTRUCT_10, + EVENT_SELF_DESTRUCT_9, + EVENT_SELF_DESTRUCT_8, + EVENT_SELF_DESTRUCT_7, + EVENT_SELF_DESTRUCT_6, + EVENT_SELF_DESTRUCT_5, + EVENT_SELF_DESTRUCT_4, + EVENT_SELF_DESTRUCT_3, + EVENT_SELF_DESTRUCT_2, + EVENT_SELF_DESTRUCT_1, + EVENT_SELF_DESTRUCT_FINALIZED, + + // Misc + EVENT_MAGNETIC_FIELD, + EVENT_SPREAD_FLAMES, + EVENT_FROST_BOMB_EXPLOSION, + EVENT_FROST_BOMB_CLEAR_FIRES, + EVENT_PROXIMITY_MINE_ARM, + EVENT_PROXIMITY_MINE_DETONATION, + EVENT_SEARCH_FLAMES, + EVENT_WATER_SPRAY +}; + +enum Actions +{ + DO_START_MKII, + DO_HARDMODE_MKII, + + DO_ACTIVATE_VX001, + DO_START_VX001, + DO_HARDMODE_VX001, + + DO_ACTIVATE_AERIAL, + DO_START_AERIAL, + DO_HARDMODE_AERIAL, + DO_DISABLE_AERIAL, + DO_ENABLE_AERIAL, + + DO_ACTIVATE_V0L7R0N_1, + DO_ACTIVATE_V0L7R0N_2, + DO_ASSEMBLED_COMBAT, // All 3 parts use this action, its done on purpose. + + DO_ACTIVATE_HARD_MODE, + DO_ACTIVATE_COMPUTER, + DO_DEACTIVATE_COMPUTER, + DO_ACTIVATE_SELF_DESTRUCT, + + DO_ENCOUNTER_DONE +}; + +enum Phases +{ + // Leviathan MK II + PHASE_LEVIATHAN_SOLO = 1, + PHASE_LEVIATHAN_ASSEMBLED, + + // VX-001 + PHASE_VX001_SOLO, + PHASE_VX001_ASSEMBLED, + + // Aerial Command Unit + PHASE_AERIAL_SOLO, + PHASE_AERIAL_ASSEMBLED +}; + +uint32 const RepairSpells[4] = +{ + SPELL_SEAT_1, + SPELL_SEAT_2, + SPELL_SEAT_3, + SPELL_SEAT_5 +}; + +// 63801 Bomb Bot +class spell_mimiron_bomb_bot : public SpellScriptLoader +{ + public: + spell_mimiron_bomb_bot() : SpellScriptLoader("spell_mimiron_bomb_bot") { } + + class spell_mimiron_bomb_bot_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_bomb_bot_SpellScript); + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (GetHitPlayer()) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* mkii = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_LEVIATHAN_MK_II))) + mkii->AI()->SetData(DATA_SETUP_BOMB, 0); + } + + void HandleDespawn(SpellEffIndex /*effIndex*/) + { + if (Creature* target = GetHitCreature()) + { + target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); + target->DespawnOrUnsummon(1000); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_bomb_bot_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_bomb_bot_SpellScript::HandleDespawn, EFFECT_1, SPELL_EFFECT_APPLY_AURA); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_bomb_bot_SpellScript(); + } +}; + +// 65192 - Flame Suppressant, 65224 - Clear Fires, 65354 - Clear Fires, 64619 - Water Spray +class spell_mimiron_clear_fires : public SpellScriptLoader { public: - spell_ulduar_proximity_mines() : SpellScriptLoader("spell_ulduar_proximity_mines") { } + spell_mimiron_clear_fires() : SpellScriptLoader("spell_mimiron_clear_fires") { } - class spell_ulduar_proximity_minesSpellScript : public SpellScript + class spell_mimiron_clear_fires_SpellScript : public SpellScript { - PrepareSpellScript(spell_ulduar_proximity_minesSpellScript); + PrepareSpellScript(spell_mimiron_clear_fires_SpellScript); + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (GetHitCreature()) + GetHitCreature()->DespawnOrUnsummon(); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_clear_fires_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_clear_fires_SpellScript(); + } +}; + +// 64463 - Despawn Assault Bots +class spell_mimiron_despawn_assault_bots : public SpellScriptLoader +{ + public: + spell_mimiron_despawn_assault_bots() : SpellScriptLoader("spell_mimiron_despawn_assault_bots") { } + + class spell_mimiron_despawn_assault_bots_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_despawn_assault_bots_SpellScript); + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (GetHitCreature()) + GetHitCreature()->DespawnOrUnsummon(); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_despawn_assault_bots_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_despawn_assault_bots_SpellScript(); + } +}; + +// 64618 - Fire Search +class spell_mimiron_fire_search : public SpellScriptLoader +{ + public: + spell_mimiron_fire_search() : SpellScriptLoader("spell_mimiron_fire_search") { } + + class spell_mimiron_fire_search_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_fire_search_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_WATER_SPRAY)) + return false; + return true; + } + + bool Load() override + { + _noTarget = false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + _noTarget = targets.empty(); + if (_noTarget) + return; + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } + + void HandleAftercast() + { + if (_noTarget) + GetCaster()->GetMotionMaster()->MoveRandom(15.0f); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + + if (UnitAI* ai = caster->GetAI()) + { + if (caster->GetDistance2d(GetHitUnit()) <= 15.0f && ai->GetData(DATA_WATERSPRAY)) + { + caster->CastSpell(GetHitUnit(), SPELL_WATER_SPRAY, true); + ai->SetData(DATA_WATERSPRAY, 0); + ai->SetData(DATA_MOVE_NEW, 1); + } + else if (caster->GetAI()->GetData(DATA_MOVE_NEW)) + { + caster->GetMotionMaster()->MoveChase(GetHitUnit()); + ai->SetData(DATA_MOVE_NEW, 0); + } + } + } + + void Register() override + { + AfterCast += SpellCastFn(spell_mimiron_fire_search_SpellScript::HandleAftercast); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_fire_search_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_fire_search_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + + private: + bool _noTarget; + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_fire_search_SpellScript(); + } +}; + +// 64436 - Magnetic Core +class spell_mimiron_magnetic_core : public SpellScriptLoader +{ + public: + spell_mimiron_magnetic_core() : SpellScriptLoader("spell_mimiron_magnetic_core") { } + + class spell_mimiron_magnetic_core_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_magnetic_core_SpellScript); + + void FilterTargets(std::list<WorldObject*>& targets) + { + targets.remove_if([](WorldObject* obj) { return obj->ToUnit() && (obj->ToUnit()->GetVehicleBase() || obj->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)); }); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_magnetic_core_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENTRY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_magnetic_core_SpellScript(); + } + + class spell_mimiron_magnetic_core_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_magnetic_core_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_MAGNETIC_CORE_VISUAL)) + return false; + return true; + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* target = GetTarget()->ToCreature()) + { + target->GetAI()->DoAction(DO_DISABLE_AERIAL); + target->CastSpell(target, SPELL_MAGNETIC_CORE_VISUAL, true); + } + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* target = GetTarget()->ToCreature()) + { + target->GetAI()->DoAction(DO_ENABLE_AERIAL); + target->RemoveAurasDueToSpell(SPELL_MAGNETIC_CORE_VISUAL); + } + } - void HandleScript(SpellEffIndex effIndex) + void OnRemoveSelf(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (TempSummon* summ = GetTarget()->ToTempSummon()) + summ->DespawnOrUnsummon(); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_mimiron_magnetic_core_AuraScript::OnApply, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_mimiron_magnetic_core_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_mimiron_magnetic_core_AuraScript::OnRemoveSelf, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_magnetic_core_AuraScript(); + } +}; + +// 63667 - Napalm Shell +class spell_mimiron_napalm_shell : public SpellScriptLoader +{ + public: + spell_mimiron_napalm_shell() : SpellScriptLoader("spell_mimiron_napalm_shell") { } + + class spell_mimiron_napalm_shell_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_napalm_shell_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_NAPALM_SHELL)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + if (targets.empty()) + return; + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + + targets.remove_if(Trinity::AllWorldObjectsInRange(GetCaster(), 15.0f)); + + if (!targets.empty()) + target = Trinity::Containers::SelectRandomContainerElement(targets); + + targets.clear(); + targets.push_back(target); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetHitUnit(), SPELL_NAPALM_SHELL); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_napalm_shell_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_napalm_shell_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_napalm_shell_SpellScript(); + } +}; + +// 63274 - P3Wx2 Laser Barrage -- HACK! Core will currently not set UNIT_FIELD_CHANNEL_OBJECT automatially if the spell targets more than a single target. +class spell_mimiron_p3wx2_laser_barrage : public SpellScriptLoader +{ + public: + spell_mimiron_p3wx2_laser_barrage() : SpellScriptLoader("spell_mimiron_p3wx2_laser_barrage") { } + + class spell_mimiron_p3wx2_laser_barrage_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_p3wx2_laser_barrage_SpellScript); + + void OnHit(SpellEffIndex /*effIndex*/) + { + GetCaster()->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, GetHitUnit()->GetGUID()); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_p3wx2_laser_barrage_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_p3wx2_laser_barrage_SpellScript(); + } +}; + +// 64542 - Plasma Blast +class spell_mimiron_plasma_blast : public SpellScriptLoader +{ + public: + spell_mimiron_plasma_blast() : SpellScriptLoader("spell_mimiron_plasma_blast") { } + + class spell_mimiron_plasma_blast_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_plasma_blast_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_PLASMA_BLAST)) + return false; + return true; + } + + bool Load() override + { + return GetCaster()->GetVehicleKit() != nullptr; + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* caster = GetCaster()->GetVehicleKit()->GetPassenger(3)) + caster->CastSpell(GetHitUnit(), SPELL_PLASMA_BLAST); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_plasma_blast_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_plasma_blast_SpellScript(); + } +}; + +// 66351 - Explosion +class spell_mimiron_proximity_explosion : public SpellScriptLoader +{ + public: + spell_mimiron_proximity_explosion() : SpellScriptLoader("spell_mimiron_proximity_explosion") { } + + class spell_mimiron_proximity_explosion_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_proximity_explosion_SpellScript); + + void OnHit(SpellEffIndex /*effIndex*/) + { + if (GetHitPlayer()) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* mkII = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_LEVIATHAN_MK_II))) + mkII->AI()->SetData(DATA_SETUP_MINE, 0); + } + + void HandleAura(SpellEffIndex /*effIndex*/) + { + GetCaster()->RemoveAurasDueToSpell(SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_proximity_explosion_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_proximity_explosion_SpellScript::HandleAura, EFFECT_1, SPELL_EFFECT_APPLY_AURA); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_proximity_explosion_SpellScript(); + } +}; + +// 63027 - Proximity Mines +class spell_mimiron_proximity_mines : public SpellScriptLoader +{ + public: + spell_mimiron_proximity_mines() : SpellScriptLoader("spell_mimiron_proximity_mines") { } + + class spell_mimiron_proximity_mines_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_proximity_mines_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_PROXIMITY_MINE)) + return false; + return true; + } + + void HandleScript(SpellEffIndex /*effIndex*/) { - PreventHitDefaultEffect(effIndex); for (uint8 i = 0; i < 10; ++i) - GetCaster()->CastSpell(GetCaster(), SPELL_TRIGGER_MISSILE, true); + GetCaster()->CastSpell(GetCaster(), SPELL_SUMMON_PROXIMITY_MINE, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_proximity_mines_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_proximity_mines_SpellScript(); + } +}; + +// 65346 - Proximity Mine +class spell_mimiron_proximity_trigger : public SpellScriptLoader +{ + public: + spell_mimiron_proximity_trigger() : SpellScriptLoader("spell_mimiron_proximity_trigger") { } + + class spell_mimiron_proximity_trigger_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_proximity_trigger_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_PROXIMITY_MINE_EXPLOSION)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + targets.remove(GetExplTargetWorldObject()); + + if (targets.empty()) + FinishCast(SPELL_FAILED_NO_VALID_TARGETS); + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell((Unit*)NULL, SPELL_PROXIMITY_MINE_EXPLOSION, true); } void Register() override { - OnEffectHitTarget += SpellEffectFn(spell_ulduar_proximity_minesSpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_proximity_trigger_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHit += SpellEffectFn(spell_mimiron_proximity_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; SpellScript* GetSpellScript() const override { - return new spell_ulduar_proximity_minesSpellScript(); + return new spell_mimiron_proximity_trigger_SpellScript(); + } +}; + +// 63382 - Rapid Burst +class spell_mimiron_rapid_burst : public SpellScriptLoader +{ + public: + spell_mimiron_rapid_burst() : SpellScriptLoader("spell_mimiron_rapid_burst") { } + + class spell_mimiron_rapid_burst_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_rapid_burst_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_RAPID_BURST_LEFT) || !sSpellMgr->GetSpellInfo(SPELL_RAPID_BURST_RIGHT)) + return false; + return true; + } + + void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (TempSummon* summ = GetTarget()->ToTempSummon()) + summ->DespawnOrUnsummon(); + } + + void HandleDummyTick(AuraEffect const* aurEff) + { + if (GetCaster()) + GetCaster()->CastSpell(GetTarget(), aurEff->GetTickNumber() % 2 == 0 ? SPELL_RAPID_BURST_RIGHT : SPELL_RAPID_BURST_LEFT, true, NULL, aurEff); + } + + void Register() override + { + AfterEffectRemove += AuraEffectApplyFn(spell_mimiron_rapid_burst_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_mimiron_rapid_burst_AuraScript::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_rapid_burst_AuraScript(); + } +}; + +// 64402 - Rocket Strike, 65034 - Rocket Strike +class spell_mimiron_rocket_strike : public SpellScriptLoader +{ + public: + spell_mimiron_rocket_strike() : SpellScriptLoader("spell_mimiron_rocket_strike") { } + + class spell_mimiron_rocket_strike_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_rocket_strike_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SCRIPT_EFFECT_ROCKET_STRIKE)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + if (targets.empty()) + return; + + if (m_scriptSpellId == SPELL_ROCKET_STRIKE_LEFT && GetCaster()->IsVehicle()) + if (WorldObject* target = GetCaster()->GetVehicleKit()->GetPassenger(6)) + { + targets.clear(); + targets.push_back(target); + } + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell((Unit*)NULL, SPELL_SCRIPT_EFFECT_ROCKET_STRIKE, true, NULL, NULL, GetCaster()->GetGUID()); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_rocket_strike_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_rocket_strike_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_rocket_strike_SpellScript(); + } +}; + +// 63041 - Rocket Strike +class spell_mimiron_rocket_strike_damage : public SpellScriptLoader +{ + public: + spell_mimiron_rocket_strike_damage() : SpellScriptLoader("spell_mimiron_rocket_strike_damage") { } + + class spell_mimiron_rocket_strike_damage_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_rocket_strike_damage_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_NOT_SO_FRIENDLY_FIRE)) + return false; + return true; + } + + void HandleAfterCast() + { + if (TempSummon* summ = GetCaster()->ToTempSummon()) + summ->DespawnOrUnsummon(); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (GetHitPlayer()) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* mkii = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(DATA_LEVIATHAN_MK_II))) + mkii->AI()->SetData(DATA_SETUP_ROCKET, 0); + } + + void HandleFriendlyFire(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell((Unit*)NULL, SPELL_NOT_SO_FRIENDLY_FIRE, true); + } + + void Register() override + { + AfterCast += SpellCastFn(spell_mimiron_rocket_strike_damage_SpellScript::HandleAfterCast); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_rocket_strike_damage_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_rocket_strike_damage_SpellScript::HandleFriendlyFire, EFFECT_1, SPELL_EFFECT_SCHOOL_DAMAGE); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_rocket_strike_damage_SpellScript(); + } +}; + +// 63681 - Rocket Strike +class spell_mimiron_rocket_strike_target_select : public SpellScriptLoader +{ + public: + spell_mimiron_rocket_strike_target_select() : SpellScriptLoader("spell_mimiron_rocket_strike_target_select") { } + + class spell_mimiron_rocket_strike_target_select_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_rocket_strike_target_select_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ROCKET_STRIKE)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + if (targets.empty()) + return; + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + + targets.remove_if(Trinity::AllWorldObjectsInRange(GetCaster(), 15.0f)); + + if (!targets.empty()) + target = Trinity::Containers::SelectRandomContainerElement(targets); + + targets.clear(); + targets.push_back(target); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_ROCKET_STRIKE, true, NULL, NULL, instance->GetData64(DATA_VX_001)); + GetCaster()->SetDisplayId(11686); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_rocket_strike_target_select_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_rocket_strike_target_select_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_rocket_strike_target_select_SpellScript(); + } +}; + +// 64383 - Self Repair +class spell_mimiron_self_repair : public SpellScriptLoader +{ + public: + spell_mimiron_self_repair() : SpellScriptLoader("spell_mimiron_self_repair") { } + + class spell_mimiron_self_repair_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_self_repair_SpellScript); + + void HandleScript() + { + if (GetCaster()->GetAI()) + GetCaster()->GetAI()->DoAction(DO_ASSEMBLED_COMBAT); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_mimiron_self_repair_SpellScript::HandleScript); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_self_repair_SpellScript(); + } +}; + +// 63414 - Spinning Up -- HACK! Core will currently not set UNIT_FIELD_CHANNEL_OBJECT automatially if the spell targets more than a single target. +// eff0 will hit both caster and target due to hack in spellmgr.cpp, it is necessary because caster will interrupt itself if aura is not active on caster. +class spell_mimiron_spinning_up : public SpellScriptLoader +{ + public: + spell_mimiron_spinning_up() : SpellScriptLoader("spell_mimiron_spinning_up") { } + + class spell_mimiron_spinning_up_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_spinning_up_SpellScript); + + void OnHit(SpellEffIndex /*effIndex*/) + { + if (GetHitUnit() != GetCaster()) + GetCaster()->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, GetHitUnit()->GetGUID()); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_spinning_up_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_spinning_up_SpellScript(); + } +}; + +// 64426 - Summon Scrap Bot +class spell_mimiron_summon_assault_bot : public SpellScriptLoader +{ + public: + spell_mimiron_summon_assault_bot() : SpellScriptLoader("spell_mimiron_summon_assault_bot") { } + + class spell_mimiron_summon_assault_bot_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_summon_assault_bot_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ASSAULT_BOT)) + return false; + return true; + } + + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetBossState(BOSS_MIMIRON) == IN_PROGRESS) + caster->CastSpell(caster, SPELL_SUMMON_ASSAULT_BOT, false, NULL, aurEff, instance->GetData64(DATA_AERIAL_COMMAND_UNIT)); + } + + void Register() override + { + OnEffectRemove += AuraEffectRemoveFn(spell_mimiron_summon_assault_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_assault_bot_AuraScript(); + } +}; + +// 64425 - Summon Scrap Bot Trigger +class spell_mimiron_summon_assault_bot_target : public SpellScriptLoader +{ + public: + spell_mimiron_summon_assault_bot_target() : SpellScriptLoader("spell_mimiron_summon_assault_bot_target") { } + + class spell_mimiron_summon_assault_bot_target_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_summon_assault_bot_target_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_ASSAULT_BOT_DUMMY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_ASSAULT_BOT_DUMMY, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_summon_assault_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_assault_bot_target_SpellScript(); + } +}; + +// 64621 - Summon Fire Bot +class spell_mimiron_summon_fire_bot : public SpellScriptLoader +{ + public: + spell_mimiron_summon_fire_bot() : SpellScriptLoader("spell_mimiron_summon_fire_bot") { } + + class spell_mimiron_summon_fire_bot_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_summon_fire_bot_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_FIRE_BOT)) + return false; + + return true; + } + + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetBossState(BOSS_MIMIRON) == IN_PROGRESS) + caster->CastSpell(caster, SPELL_SUMMON_FIRE_BOT, false, NULL, aurEff, instance->GetData64(DATA_AERIAL_COMMAND_UNIT)); + } + + void Register() override + { + OnEffectRemove += AuraEffectRemoveFn(spell_mimiron_summon_fire_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_fire_bot_AuraScript(); + } +}; + +// 64620 - Summon Fire Bot Trigger +class spell_mimiron_summon_fire_bot_target : public SpellScriptLoader +{ + public: + spell_mimiron_summon_fire_bot_target() : SpellScriptLoader("spell_mimiron_summon_fire_bot_target") { } + + class spell_mimiron_summon_fire_bot_target_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_summon_fire_bot_target_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_FIRE_BOT_DUMMY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_FIRE_BOT_DUMMY, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_summon_fire_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_fire_bot_target_SpellScript(); + } +}; + +// 64562 - Summon Flames Spread Trigger +class spell_mimiron_summon_flames_spread : public SpellScriptLoader +{ + public: + spell_mimiron_summon_flames_spread() : SpellScriptLoader("spell_mimiron_summon_flames_spread") { } + + class spell_mimiron_summon_flames_spread_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_summon_flames_spread_SpellScript); + + void FilterTargets(std::list<WorldObject*>& targets) + { + if (targets.empty()) + return; + + // Flames must chase the closest player + WorldObject* target = targets.front(); + + for (std::list<WorldObject*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) + if (GetCaster()->GetDistance2d(*iter) < GetCaster()->GetDistance2d(target)) + target = *iter; + + targets.clear(); + targets.push_back(target); + } + + void OnHit(SpellEffIndex /*effIndex*/) + { + GetCaster()->SetInFront(GetHitUnit()); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_summon_flames_spread_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_summon_flames_spread_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_flames_spread_SpellScript(); + } + + class spell_mimiron_summon_flames_spread_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_summon_flames_spread_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_FLAMES_SPREAD)) + return false; + return true; + } + + void HandleTick(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + if (Unit* caster = GetCaster()) + if (caster->HasAura(SPELL_FLAMES_PERIODIC_TRIGGER)) + caster->CastSpell(GetTarget(), SPELL_SUMMON_FLAMES_SPREAD, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_mimiron_summon_flames_spread_AuraScript::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_flames_spread_AuraScript(); + } +}; + +// 64623 - Frost Bomb +class spell_mimiron_summon_frost_bomb_target : public SpellScriptLoader +{ + public: + spell_mimiron_summon_frost_bomb_target() : SpellScriptLoader("spell_mimiron_summon_frost_bomb_target") { } + + class spell_mimiron_summon_frost_bomb_target_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_summon_frost_bomb_target_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_FROST_BOMB)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + if (targets.empty()) + return; + + targets.remove_if(Trinity::AllWorldObjectsInRange(GetCaster(), 15.0f)); + + if (targets.empty()) + return; + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + + targets.clear(); + targets.push_back(target); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_FROST_BOMB, true); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mimiron_summon_frost_bomb_target_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_mimiron_summon_frost_bomb_target_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_frost_bomb_target_SpellScript(); + } +}; + +// 64398 - Summon Scrap Bot +class spell_mimiron_summon_junk_bot : public SpellScriptLoader +{ + public: + spell_mimiron_summon_junk_bot() : SpellScriptLoader("spell_mimiron_summon_junk_bot") { } + + class spell_mimiron_summon_junk_bot_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_summon_junk_bot_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_JUNK_BOT)) + return false; + return true; + } + + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetBossState(BOSS_MIMIRON) == IN_PROGRESS) + caster->CastSpell(caster, SPELL_SUMMON_JUNK_BOT, false, NULL, aurEff, instance->GetData64(DATA_AERIAL_COMMAND_UNIT)); + } + + void Register() override + { + OnEffectRemove += AuraEffectRemoveFn(spell_mimiron_summon_junk_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_junk_bot_AuraScript(); + } +}; + +// 63820 - Summon Scrap Bot Trigger +class spell_mimiron_summon_junk_bot_target : public SpellScriptLoader +{ + public: + spell_mimiron_summon_junk_bot_target() : SpellScriptLoader("spell_mimiron_summon_junk_bot_target") { } + + class spell_mimiron_summon_junk_bot_target_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mimiron_summon_junk_bot_target_SpellScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_JUNK_BOT_DUMMY)) + return false; + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_JUNK_BOT_DUMMY, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_mimiron_summon_junk_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_junk_bot_target_SpellScript(); + } +}; + +// 63339 - Weld +class spell_mimiron_weld : public SpellScriptLoader +{ + public: + spell_mimiron_weld() : SpellScriptLoader("spell_mimiron_weld") { } + + class spell_mimiron_weld_AuraScript : public AuraScript + { + PrepareAuraScript(spell_mimiron_weld_AuraScript); + + void HandleTick(AuraEffect const* aurEff) + { + Unit* caster = GetTarget(); + if (Unit* vehicle = caster->GetVehicleBase()) + { + if (aurEff->GetTickNumber() % 5 == 0) + caster->CastSpell(vehicle, RepairSpells[urand(0, 3)]); + caster->SetFacingToObject(vehicle); + } + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_mimiron_weld_AuraScript::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_weld_AuraScript(); } }; void AddSC_boss_mimiron() { - new spell_ulduar_proximity_mines(); + new spell_mimiron_bomb_bot(); + new spell_mimiron_clear_fires(); + new spell_mimiron_despawn_assault_bots(); + new spell_mimiron_fire_search(); + new spell_mimiron_magnetic_core(); + new spell_mimiron_napalm_shell(); + new spell_mimiron_p3wx2_laser_barrage(); + new spell_mimiron_plasma_blast(); + new spell_mimiron_proximity_explosion(); + new spell_mimiron_proximity_mines(); + new spell_mimiron_proximity_trigger(); + new spell_mimiron_rapid_burst(); + new spell_mimiron_rocket_strike(); + new spell_mimiron_rocket_strike_damage(); + new spell_mimiron_rocket_strike_target_select(); + new spell_mimiron_self_repair(); + new spell_mimiron_spinning_up(); + new spell_mimiron_summon_assault_bot(); + new spell_mimiron_summon_assault_bot_target(); + new spell_mimiron_summon_fire_bot(); + new spell_mimiron_summon_fire_bot_target(); + new spell_mimiron_summon_flames_spread(); + new spell_mimiron_summon_frost_bomb_target(); + new spell_mimiron_summon_junk_bot(); + new spell_mimiron_summon_junk_bot_target(); + new spell_mimiron_weld(); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 6aa753eac98..79f9283eb40 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -15,13 +15,12 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "InstanceScript.h" +#include "ulduar.h" #include "Player.h" -#include "WorldPacket.h" +#include "ScriptedCreature.h" +#include "ScriptMgr.h" #include "SpellScript.h" -#include "ulduar.h" +#include "WorldPacket.h" static DoorData const doorData[] = { @@ -32,6 +31,9 @@ static DoorData const doorData[] = { GO_HODIR_ENTRANCE, BOSS_HODIR, DOOR_TYPE_ROOM, BOUNDARY_E }, { GO_HODIR_DOOR, BOSS_HODIR, DOOR_TYPE_PASSAGE, BOUNDARY_NONE }, { GO_HODIR_ICE_DOOR, BOSS_HODIR, DOOR_TYPE_PASSAGE, BOUNDARY_W }, + { GO_MIMIRON_DOOR_1, BOSS_MIMIRON, DOOR_TYPE_ROOM, BOUNDARY_W }, + { GO_MIMIRON_DOOR_2, BOSS_MIMIRON, DOOR_TYPE_ROOM, BOUNDARY_E }, + { GO_MIMIRON_DOOR_3, BOSS_MIMIRON, DOOR_TYPE_ROOM, BOUNDARY_S }, { GO_VEZAX_DOOR, BOSS_VEZAX, DOOR_TYPE_PASSAGE, BOUNDARY_E }, { GO_YOGG_SARON_DOOR, BOSS_YOGG_SARON, DOOR_TYPE_ROOM, BOUNDARY_S }, { GO_DOODAD_UL_SIGILDOOR_03, BOSS_ALGALON, DOOR_TYPE_ROOM, BOUNDARY_W }, @@ -70,11 +72,14 @@ class instance_ulduar : public InstanceMapScript uint64 AssemblyGUIDs[3]; uint64 KologarnGUID; uint64 AuriayaGUID; - uint64 MimironGUID; uint64 HodirGUID; uint64 ThorimGUID; uint64 FreyaGUID; uint64 ElderGUIDs[3]; + uint64 MimironGUID; + uint64 MimironVehicleGUIDs[3]; + uint64 MimironComputerGUID; + uint64 MimironWorldTriggerGUID; uint64 VezaxGUID; uint64 YoggSaronGUID; uint64 VoiceOfYoggSaronGUID; @@ -92,6 +97,9 @@ class instance_ulduar : public InstanceMapScript uint64 ThorimChestGUID; uint64 HodirRareCacheGUID; uint64 HodirChestGUID; + uint64 MimironTramGUID; + uint64 MimironElevatorGUID; + uint64 MimironButtonGUID; uint64 BrainRoomDoorGUIDs[3]; uint64 AlgalonSigilDoorGUID[3]; uint64 AlgalonFloorGUID[2]; @@ -126,6 +134,8 @@ class instance_ulduar : public InstanceMapScript KologarnGUID = 0; AuriayaGUID = 0; MimironGUID = 0; + MimironComputerGUID = 0; + MimironWorldTriggerGUID = 0; HodirGUID = 0; ThorimGUID = 0; FreyaGUID = 0; @@ -140,6 +150,9 @@ class instance_ulduar : public InstanceMapScript ThorimChestGUID = 0; HodirRareCacheGUID = 0; HodirChestGUID = 0; + MimironTramGUID = 0; + MimironElevatorGUID = 0; + MimironButtonGUID = 0; LeviathanGateGUID = 0; AlgalonUniverseGUID = 0; AlgalonTrapdoorGUID = 0; @@ -166,6 +179,7 @@ class instance_ulduar : public InstanceMapScript memset(AssemblyGUIDs, 0, sizeof(AssemblyGUIDs)); memset(RazorHarpoonGUIDs, 0, sizeof(RazorHarpoonGUIDs)); memset(ElderGUIDs, 0, sizeof(ElderGUIDs)); + memset(MimironVehicleGUIDs, 0, sizeof(MimironVehicleGUIDs)); memset(BrainRoomDoorGUIDs, 0, sizeof(BrainRoomDoorGUIDs)); memset(KeeperGUIDs, 0, sizeof(KeeperGUIDs)); memset(_summonObservationRingKeeper, false, sizeof(_summonObservationRingKeeper)); @@ -289,9 +303,6 @@ class instance_ulduar : public InstanceMapScript case NPC_AURIAYA: AuriayaGUID = creature->GetGUID(); break; - case NPC_MIMIRON: - MimironGUID = creature->GetGUID(); - break; // Hodir case NPC_HODIR: @@ -354,6 +365,26 @@ class instance_ulduar : public InstanceMapScript creature->DespawnOrUnsummon(); break; + // Mimiron + case NPC_MIMIRON: + MimironGUID = creature->GetGUID(); + break; + case NPC_LEVIATHAN_MKII: + MimironVehicleGUIDs[0] = creature->GetGUID(); + break; + case NPC_VX_001: + MimironVehicleGUIDs[1] = creature->GetGUID(); + break; + case NPC_AERIAL_COMMAND_UNIT: + MimironVehicleGUIDs[2] = creature->GetGUID(); + break; + case NPC_COMPUTER: + MimironComputerGUID = creature->GetGUID(); + break; + case NPC_WORLD_TRIGGER_MIMIRON: + MimironWorldTriggerGUID = creature->GetGUID(); + break; + case NPC_VEZAX: VezaxGUID = creature->GetGUID(); break; @@ -470,6 +501,15 @@ class instance_ulduar : public InstanceMapScript case GO_HODIR_CHEST: HodirChestGUID = gameObject->GetGUID(); break; + case GO_MIMIRON_TRAM: + MimironTramGUID = gameObject->GetGUID(); + break; + case GO_MIMIRON_ELEVATOR: + MimironElevatorGUID = gameObject->GetGUID(); + break; + case GO_MIMIRON_BUTTON: + MimironButtonGUID = gameObject->GetGUID(); + break; case GO_LEVIATHAN_GATE: LeviathanGateGUID = gameObject->GetGUID(); if (GetBossState(BOSS_LEVIATHAN) == DONE) @@ -482,6 +522,9 @@ class instance_ulduar : public InstanceMapScript case GO_HODIR_ENTRANCE: case GO_HODIR_DOOR: case GO_HODIR_ICE_DOOR: + case GO_MIMIRON_DOOR_1: + case GO_MIMIRON_DOOR_2: + case GO_MIMIRON_DOOR_3: case GO_VEZAX_DOOR: case GO_YOGG_SARON_DOOR: AddDoor(gameObject, true); @@ -566,6 +609,9 @@ class instance_ulduar : public InstanceMapScript case GO_HODIR_ENTRANCE: case GO_HODIR_DOOR: case GO_HODIR_ICE_DOOR: + case GO_MIMIRON_DOOR_1: + case GO_MIMIRON_DOOR_2: + case GO_MIMIRON_DOOR_3: case GO_VEZAX_DOOR: case GO_YOGG_SARON_DOOR: case GO_DOODAD_UL_SIGILDOOR_03: @@ -774,6 +820,10 @@ class instance_ulduar : public InstanceMapScript break; case DATA_UNBROKEN: Unbroken = data != 0; + break; + case DATA_MIMIRON_ELEVATOR: + if (GameObject* gameObject = instance->GetGameObject(MimironElevatorGUID)) + gameObject->SetGoState((GOState)data); break; case DATA_ILLUSION: illusion = data; @@ -846,8 +896,6 @@ class instance_ulduar : public InstanceMapScript return KologarnGUID; case BOSS_AURIAYA: return AuriayaGUID; - case BOSS_MIMIRON: - return MimironGUID; case BOSS_HODIR: return HodirGUID; case BOSS_THORIM: @@ -863,6 +911,22 @@ class instance_ulduar : public InstanceMapScript case BOSS_STONEBARK: return ElderGUIDs[2]; + // Mimiron + case BOSS_MIMIRON: + return MimironGUID; + case DATA_LEVIATHAN_MK_II: + return MimironVehicleGUIDs[0]; + case DATA_VX_001: + return MimironVehicleGUIDs[1]; + case DATA_AERIAL_COMMAND_UNIT: + return MimironVehicleGUIDs[2]; + case DATA_COMPUTER: + return MimironComputerGUID; + case DATA_MIMIRON_WORLD_TRIGGER: + return MimironWorldTriggerGUID; + case DATA_MIMIRON_BUTTON: + return MimironButtonGUID; + case BOSS_VEZAX: return VezaxGUID; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h index 3544ff3c079..81cb469318f 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h @@ -18,6 +18,7 @@ #ifndef DEF_ULDUAR_H #define DEF_ULDUAR_H +#include "InstanceScript.h" #include "ObjectMgr.h" #define UlduarScriptName "instance_ulduar" @@ -83,6 +84,18 @@ enum UlduarNPCs NPC_LEVIATHAN_MKII = 33432, NPC_VX_001 = 33651, NPC_AERIAL_COMMAND_UNIT = 33670, + NPC_ASSAULT_BOT = 34057, + NPC_BOMB_BOT = 33836, + NPC_JUNK_BOT = 33855, + NPC_EMERGENCY_FIRE_BOT = 34147, + NPC_FROST_BOMB = 34149, + NPC_BURST_TARGET = 34211, + NPC_FLAME = 34363, + NPC_FLAME_SPREAD = 34121, + NPC_DB_TARGET = 33576, + NPC_ROCKET_MIMIRON_VISUAL = 34050, + NPC_WORLD_TRIGGER_MIMIRON = 21252, + NPC_COMPUTER = 34143, // Freya's Keepers NPC_IRONBRANCH = 32913, @@ -204,6 +217,18 @@ enum UlduarGameObjects GO_THORIM_CHEST_HERO = 194315, GO_THORIM_CHEST = 194314, + // Mimiron + GO_MIMIRON_TRAM = 194675, + GO_MIMIRON_ELEVATOR = 194749, + GO_MIMIRON_BUTTON = 194739, + GO_MIMIRON_DOOR_1 = 194774, + GO_MIMIRON_DOOR_2 = 194775, + GO_MIMIRON_DOOR_3 = 194776, + GO_CACHE_OF_INNOVATION = 194789, + GO_CACHE_OF_INNOVATION_FIREFIGHTER = 194957, + GO_CACHE_OF_INNOVATION_HERO = 194956, + GO_CACHE_OF_INNOVATION_FIREFIGHTER_HERO = 194958, + // Vezax GO_VEZAX_DOOR = 194750, @@ -292,6 +317,16 @@ enum UlduarData // Hodir DATA_HODIR_RARE_CACHE, + // Mimiron + DATA_LEVIATHAN_MK_II, + DATA_VX_001, + DATA_AERIAL_COMMAND_UNIT, + DATA_COMPUTER, + DATA_MIMIRON_WORLD_TRIGGER, + DATA_MIMIRON_ELEVATOR, + DATA_MIMIRON_TRAM, + DATA_MIMIRON_BUTTON, + // Yogg-Saron DATA_VOICE_OF_YOGG_SARON, DATA_SARA, diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index 42be5ba8c90..f82c1f5fb58 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -19,13 +19,11 @@ /* ScriptData SDName: Netherstorm SD%Complete: 80 -SDComment: Quest support: 10337, 10438, 10652 (special flight paths), 10299, 10321, 10322, 10323, 10329, 10330, 10338, 10365(Shutting Down Manaforge), 10198, 10191 +SDComment: Quest support: 10337, 10438, 10652 (special flight paths), 10198, 10191 SDCategory: Netherstorm EndScriptData */ /* ContentData -npc_manaforge_control_console -go_manaforge_control_console npc_commander_dawnforge npc_bessy npc_maxx_a_million @@ -39,323 +37,6 @@ EndContentData */ #include "Player.h" /*###### -## npc_manaforge_control_console -######*/ - -//used by 20209, 20417, 20418, 20440, signed for 20209 -enum ManaforgeConsoleData -{ - EMOTE_START = 0, - EMOTE_60 = 1, - EMOTE_30 = 2, - EMOTE_10 = 3, - EMOTE_COMPLETE = 4, - EMOTE_ABORT = 5, - - ENTRY_BNAAR_C_CONSOLE = 20209, - ENTRY_CORUU_C_CONSOLE = 20417, - ENTRY_DURO_C_CONSOLE = 20418, - ENTRY_ARA_C_CONSOLE = 20440, - - ENTRY_SUNFURY_TECH = 20218, - ENTRY_SUNFURY_PROT = 20436, - - ENTRY_ARA_TECH = 20438, - ENTRY_ARA_ENGI = 20439, - ENTRY_ARA_GORKLONN = 20460, - - SPELL_DISABLE_VISUAL = 35031, - SPELL_INTERRUPT_1 = 35016, //ACID mobs should cast this - SPELL_INTERRUPT_2 = 35176, //ACID mobs should cast this (Manaforge Ara-version) -}; - -class npc_manaforge_control_console : public CreatureScript -{ -public: - npc_manaforge_control_console() : CreatureScript("npc_manaforge_control_console") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_manaforge_control_consoleAI(creature); - } - - struct npc_manaforge_control_consoleAI : public ScriptedAI - { - npc_manaforge_control_consoleAI(Creature* creature) : ScriptedAI(creature) { } - - uint32 Event_Timer; - uint32 Wave_Timer; - uint32 Phase; - bool Wave; - uint64 someplayer; - uint64 goConsole; - Creature* add; - - void Reset() override - { - Event_Timer = 3000; - Wave_Timer = 0; - Phase = 1; - Wave = false; - someplayer = 0; - goConsole = 0; - add = NULL; - } - - void EnterCombat(Unit* /*who*/) override { } - - /*void SpellHit(Unit* caster, const SpellInfo* spell) override - { - //we have no way of telling the Creature was hit by spell -> got aura applied after 10-12 seconds - //then no way for the mobs to actually stop the shutdown as intended. - if (spell->Id == SPELL_INTERRUPT_1) - DoSay("Silence! I kill you!", LANG_UNIVERSAL, NULL); - }*/ - - void JustDied(Unit* /*killer*/) override - { - Talk(EMOTE_ABORT); - - if (someplayer) - { - if (Player* player = ObjectAccessor::GetPlayer(*me, someplayer)) - { - switch (me->GetEntry()) - { - case ENTRY_BNAAR_C_CONSOLE: - player->FailQuest(10299); - player->FailQuest(10329); - break; - case ENTRY_CORUU_C_CONSOLE: - player->FailQuest(10321); - player->FailQuest(10330); - break; - case ENTRY_DURO_C_CONSOLE: - player->FailQuest(10322); - player->FailQuest(10338); - break; - case ENTRY_ARA_C_CONSOLE: - player->FailQuest(10323); - player->FailQuest(10365); - break; - } - } - } - - if (goConsole) - if (GameObject* go = GameObject::GetGameObject(*me, goConsole)) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } - - void DoWaveSpawnForCreature(Creature* creature) - { - switch (creature->GetEntry()) - { - case ENTRY_BNAAR_C_CONSOLE: - if (rand32() % 2) - { - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2933.68f, 4162.55f, 164.00f, 1.60f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2927.36f, 4212.97f, 164.00f); - } - else - { - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2927.36f, 4212.97f, 164.00f, 4.94f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2933.68f, 4162.55f, 164.00f); - } - Wave_Timer = 30000; - break; - case ENTRY_CORUU_C_CONSOLE: - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2445.21f, 2765.26f, 134.49f, 3.93f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2424.21f, 2740.15f, 133.81f); - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2429.86f, 2731.85f, 134.53f, 1.31f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2435.37f, 2766.04f, 133.81f); - Wave_Timer = 20000; - break; - case ENTRY_DURO_C_CONSOLE: - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2986.80f, 2205.36f, 165.37f, 3.74f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2985.15f, 2197.32f, 164.79f); - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2952.91f, 2191.20f, 165.32f, 0.22f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2060.01f, 2185.27f, 164.67f); - Wave_Timer = 15000; - break; - case ENTRY_ARA_C_CONSOLE: - if (rand32() % 2) - { - add = me->SummonCreature(ENTRY_ARA_TECH, 4035.11f, 4038.97f, 194.27f, 2.57f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4003.42f, 4040.19f, 193.49f); - add = me->SummonCreature(ENTRY_ARA_TECH, 4033.66f, 4036.79f, 194.28f, 2.57f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4003.42f, 4040.19f, 193.49f); - add = me->SummonCreature(ENTRY_ARA_TECH, 4037.13f, 4037.30f, 194.23f, 2.57f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4003.42f, 4040.19f, 193.49f); - } - else - { - add = me->SummonCreature(ENTRY_ARA_TECH, 3099.59f, 4049.30f, 194.22f, 0.05f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4028.01f, 4035.17f, 193.59f); - add = me->SummonCreature(ENTRY_ARA_TECH, 3999.72f, 4046.75f, 194.22f, 0.05f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4028.01f, 4035.17f, 193.59f); - add = me->SummonCreature(ENTRY_ARA_TECH, 3996.81f, 4048.26f, 194.22f, 0.05f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4028.01f, 4035.17f, 193.59f); - } - Wave_Timer = 15000; - break; - } - } - void DoFinalSpawnForCreature(Creature* creature) - { - switch (creature->GetEntry()) - { - case ENTRY_BNAAR_C_CONSOLE: - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2946.52f, 4201.42f, 163.47f, 3.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2927.49f, 4192.81f, 163.00f); - break; - case ENTRY_CORUU_C_CONSOLE: - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2453.88f, 2737.85f, 133.27f, 2.59f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2433.96f, 2751.53f, 133.85f); - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2441.62f, 2735.32f, 134.49f, 1.97f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2433.96f, 2751.53f, 133.85f); - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2450.73f, 2754.50f, 134.49f, 3.29f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2433.96f, 2751.53f, 133.85f); - break; - case ENTRY_DURO_C_CONSOLE: - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2956.18f, 2202.85f, 165.32f, 5.45f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2972.27f, 2193.22f, 164.48f); - add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2975.30f, 2211.50f, 165.32f, 4.55f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2972.27f, 2193.22f, 164.48f); - add = me->SummonCreature(ENTRY_SUNFURY_PROT, 2965.02f, 2217.45f, 164.16f, 4.96f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 2972.27f, 2193.22f, 164.48f); - break; - case ENTRY_ARA_C_CONSOLE: - add = me->SummonCreature(ENTRY_ARA_ENGI, 3994.51f, 4020.46f, 192.18f, 0.91f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4008.35f, 4035.04f, 192.70f); - add = me->SummonCreature(ENTRY_ARA_GORKLONN, 4021.56f, 4059.35f, 193.59f, 4.44f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if (add) add->GetMotionMaster()->MovePoint(0, 4016.62f, 4039.89f, 193.46f); - break; - } - } - - void UpdateAI(uint32 diff) override - { - if (Event_Timer <= diff) - { - switch (Phase) - { - case 1: - if (someplayer) - { - Unit* u = ObjectAccessor::GetUnit(*me, someplayer); - if (u && u->GetTypeId() == TYPEID_PLAYER) - Talk(EMOTE_START, u); - } - Event_Timer = 60000; - Wave = true; - ++Phase; - break; - case 2: - Talk(EMOTE_60); - Event_Timer = 30000; - ++Phase; - break; - case 3: - Talk(EMOTE_30); - Event_Timer = 20000; - DoFinalSpawnForCreature(me); - ++Phase; - break; - case 4: - Talk(EMOTE_10); - Event_Timer = 10000; - Wave = false; - ++Phase; - break; - case 5: - Talk(EMOTE_COMPLETE); - if (someplayer) - { - if (Player* player = ObjectAccessor::GetPlayer(*me, someplayer)) - player->KilledMonsterCredit(me->GetEntry(), me->GetGUID()); - DoCast(me, SPELL_DISABLE_VISUAL); - } - - if (goConsole) - if (GameObject* go = GameObject::GetGameObject(*me, goConsole)) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - - ++Phase; - break; - } - } - else - Event_Timer -= diff; - - if (Wave) - { - if (Wave_Timer <= diff) - { - DoWaveSpawnForCreature(me); - } - else - Wave_Timer -= diff; - } - } - }; -}; - -/*###### -## go_manaforge_control_console -######*/ - -/// @todo clean up this workaround when Trinity adds support to do it properly (with gossip selections instead of instant summon) -class go_manaforge_control_console : public GameObjectScript -{ -public: - go_manaforge_control_console() : GameObjectScript("go_manaforge_control_console") { } - - bool OnGossipHello(Player* player, GameObject* go) override - { - if (go->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) - { - player->PrepareQuestMenu(go->GetGUID()); - player->SendPreparedQuest(go->GetGUID()); - } - - Creature* manaforge = NULL; - - switch (go->GetAreaId()) - { - case 3726: //b'naar - if ((player->GetQuestStatus(10299) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10329) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29366)) - manaforge = player->SummonCreature(ENTRY_BNAAR_C_CONSOLE, 2918.95f, 4189.98f, 161.88f, 0.34f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); - break; - case 3730: //coruu - if ((player->GetQuestStatus(10321) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10330) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29396)) - manaforge = player->SummonCreature(ENTRY_CORUU_C_CONSOLE, 2426.77f, 2750.38f, 133.24f, 2.14f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); - break; - case 3734: //duro - if ((player->GetQuestStatus(10322) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10338) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29397)) - manaforge = player->SummonCreature(ENTRY_DURO_C_CONSOLE, 2976.48f, 2183.29f, 163.20f, 1.85f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); - break; - case 3722: //ara - if ((player->GetQuestStatus(10323) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10365) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29411)) - manaforge = player->SummonCreature(ENTRY_ARA_C_CONSOLE, 4013.71f, 4028.76f, 192.10f, 1.25f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); - break; - } - - if (manaforge) - { - ENSURE_AI(npc_manaforge_control_console::npc_manaforge_control_consoleAI, manaforge->AI())->someplayer = player->GetGUID(); - ENSURE_AI(npc_manaforge_control_console::npc_manaforge_control_consoleAI, manaforge->AI())->goConsole = go->GetGUID(); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } - return true; - } -}; - -/*###### ## npc_commander_dawnforge ######*/ @@ -1054,8 +735,6 @@ class go_captain_tyralius_prison : public GameObjectScript void AddSC_netherstorm() { - new go_manaforge_control_console(); - new npc_manaforge_control_console(); new npc_commander_dawnforge(); new at_commander_dawnforge(); new npc_professor_dabiri(); diff --git a/src/server/scripts/Pet/pet_hunter.cpp b/src/server/scripts/Pet/pet_hunter.cpp index 7dbdc7af63f..8fd6cb54b0e 100644 --- a/src/server/scripts/Pet/pet_hunter.cpp +++ b/src/server/scripts/Pet/pet_hunter.cpp @@ -57,7 +57,7 @@ class npc_pet_hunter_snake_trap : public CreatureScript me->SetMaxHealth(uint32(107 * (me->getLevel() - 40) * 0.025f)); // Add delta to make them not all hit the same time uint32 delta = (rand32() % 7) * 100; - me->SetAttackTime(BASE_ATTACK, Info->baseattacktime + delta); + me->SetAttackTime(BASE_ATTACK, Info->BaseAttackTime + delta); //me->SetStatFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER, float(Info->attackpower)); // Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 87c323aa22f..c43b781936c 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -991,7 +991,7 @@ class spell_item_unsated_craving : public SpellScriptLoader return false; Unit* target = procInfo.GetActionTarget(); - if (!target || target->GetTypeId() != TYPEID_UNIT || target->GetCreatureType() == CREATURE_TYPE_CRITTER || (target->GetEntry() != NPC_SINDRAGOSA && target->IsSummon())) + if (!target || target->GetTypeId() != TYPEID_UNIT || target->IsCritter() || (target->GetEntry() != NPC_SINDRAGOSA && target->IsSummon())) return false; return true; diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 7076c1142c7..a128c30ad50 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -800,7 +800,7 @@ class spell_pri_shadow_word_death : public SpellScriptLoader if (AuraEffect* aurEff = GetCaster()->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_PAIN_AND_SUFFERING, EFFECT_1)) AddPct(damage, aurEff->GetAmount()); - GetCaster()->CastCustomSpell(GetCaster(), SPELL_PRIEST_SHADOW_WORD_DEATH, &damage, 0, 0, true); + GetCaster()->CastCustomSpell(GetCaster(), SPELL_PRIEST_SHADOW_WORD_DEATH, &damage, nullptr, nullptr, true); } void Register() override diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 854bc77671b..87661710f53 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -1773,7 +1773,7 @@ class spell_q12847_summon_soul_moveto_bunny : public SpellScriptLoader } }; - SpellScript *GetSpellScript() const + SpellScript *GetSpellScript() const override { return new spell_q12847_summon_soul_moveto_bunny_SpellScript(); } diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 42c1f268715..a04fdba57b9 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -491,7 +491,7 @@ class spell_rog_prey_on_the_weak : public SpellScriptLoader if (!target->HasAura(SPELL_ROGUE_PREY_ON_THE_WEAK)) { int32 bp = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); - target->CastCustomSpell(target, SPELL_ROGUE_PREY_ON_THE_WEAK, &bp, 0, 0, true); + target->CastCustomSpell(target, SPELL_ROGUE_PREY_ON_THE_WEAK, &bp, nullptr, nullptr, true); } } else diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 9b30c073aad..16c2bd4b303 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -871,7 +871,7 @@ class spell_sha_mana_spring_totem : public SpellScriptLoader if (Unit* target = GetHitUnit()) if (Unit* caster = GetCaster()) if (target->getPowerType() == POWER_MANA) - caster->CastCustomSpell(target, SPELL_SHAMAN_MANA_SPRING_TOTEM_ENERGIZE, &damage, 0, 0, true, 0, 0, GetOriginalCaster()->GetGUID()); + caster->CastCustomSpell(target, SPELL_SHAMAN_MANA_SPRING_TOTEM_ENERGIZE, &damage, nullptr, nullptr, true, nullptr, nullptr, GetOriginalCaster()->GetGUID()); } void Register() override diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h index 224ef7fb925..ab268835046 100644 --- a/src/server/shared/Common.h +++ b/src/server/shared/Common.h @@ -19,46 +19,6 @@ #ifndef TRINITYCORE_COMMON_H #define TRINITYCORE_COMMON_H -// config.h needs to be included 1st -/// @todo this thingy looks like hack, but its not, need to -// make separate header however, because It makes mess here. -#ifdef HAVE_CONFIG_H -// Remove Some things that we will define -// This is in case including another config.h -// before trinity config.h -#ifdef PACKAGE -#undef PACKAGE -#endif //PACKAGE -#ifdef PACKAGE_BUGREPORT -#undef PACKAGE_BUGREPORT -#endif //PACKAGE_BUGREPORT -#ifdef PACKAGE_NAME -#undef PACKAGE_NAME -#endif //PACKAGE_NAME -#ifdef PACKAGE_STRING -#undef PACKAGE_STRING -#endif //PACKAGE_STRING -#ifdef PACKAGE_TARNAME -#undef PACKAGE_TARNAME -#endif //PACKAGE_TARNAME -#ifdef PACKAGE_VERSION -#undef PACKAGE_VERSION -#endif //PACKAGE_VERSION -#ifdef VERSION -#undef VERSION -#endif //VERSION - -# include "Config.h" - -#undef PACKAGE -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef VERSION -#endif //HAVE_CONFIG_H - #include "Define.h" #include <unordered_map> @@ -85,6 +45,13 @@ #if PLATFORM == PLATFORM_WINDOWS # include <ws2tcpip.h> + +# if defined(__INTEL_COMPILER) +# if !defined(BOOST_ASIO_HAS_MOVE) +# define BOOST_ASIO_HAS_MOVE +# endif // !defined(BOOST_ASIO_HAS_MOVE) +# endif // if defined(__INTEL_COMPILER) + #else # include <sys/types.h> # include <sys/ioctl.h> diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index 18797b6b12a..5548e44c925 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -35,7 +35,7 @@ class PingOperation : public SQLOperation { //! Operation for idle delaythreads - bool Execute() + bool Execute() override { m_conn->Ping(); return true; @@ -45,6 +45,14 @@ class PingOperation : public SQLOperation template <class T> class DatabaseWorkerPool { + private: + enum InternalIndex + { + IDX_ASYNC, + IDX_SYNCH, + IDX_SIZE + }; + public: /* Activity state */ DatabaseWorkerPool() : _connectionInfo(NULL) @@ -74,34 +82,17 @@ class DatabaseWorkerPool TC_LOG_INFO("sql.driver", "Opening DatabasePool '%s'. Asynchronous connections: %u, synchronous connections: %u.", GetDatabaseName(), async_threads, synch_threads); - //! Open asynchronous connections (delayed operations) - _connections[IDX_ASYNC].resize(async_threads); - for (uint8 i = 0; i < async_threads; ++i) - { - T* t = new T(_queue, *_connectionInfo); - res &= t->Open(); - if (res) // only check mysql version if connection is valid - WPFatal(mysql_get_server_version(t->GetHandle()) >= MIN_MYSQL_SERVER_VERSION, "TrinityCore does not support MySQL versions below 5.1"); - _connections[IDX_ASYNC][i] = t; - ++_connectionCount[IDX_ASYNC]; - } + res = OpenConnections(IDX_ASYNC, async_threads); - //! Open synchronous connections (direct, blocking operations) - _connections[IDX_SYNCH].resize(synch_threads); - for (uint8 i = 0; i < synch_threads; ++i) - { - T* t = new T(*_connectionInfo); - res &= t->Open(); - _connections[IDX_SYNCH][i] = t; - ++_connectionCount[IDX_SYNCH]; - } + if (!res) + return res; + + res = OpenConnections(IDX_SYNCH, synch_threads); if (res) TC_LOG_INFO("sql.driver", "DatabasePool '%s' opened successfully. %u total connections running.", GetDatabaseName(), (_connectionCount[IDX_SYNCH] + _connectionCount[IDX_ASYNC])); - else - TC_LOG_ERROR("sql.driver", "DatabasePool %s NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile " - "for specific errors. Read wiki at http://collab.kpsn.org/display/tc/TrinityCore+Home", GetDatabaseName()); + return res; } @@ -112,8 +103,6 @@ class DatabaseWorkerPool for (uint8 i = 0; i < _connectionCount[IDX_ASYNC]; ++i) { T* t = _connections[IDX_ASYNC][i]; - DatabaseWorker* worker = t->m_worker; - delete worker; t->Close(); //! Closes the actualy MySQL connection. } @@ -442,7 +431,7 @@ class DatabaseWorkerPool if (str.empty()) return; - char* buf = new char[str.size()*2+1]; + char* buf = new char[str.size() * 2 + 1]; EscapeString(buf, str.c_str(), str.size()); str = buf; delete[] buf; @@ -470,6 +459,54 @@ class DatabaseWorkerPool } private: + bool OpenConnections(InternalIndex type, uint8 numConnections) + { + _connections[type].resize(numConnections); + for (uint8 i = 0; i < numConnections; ++i) + { + T* t; + + if (type == IDX_ASYNC) + t = new T(_queue, *_connectionInfo); + else if (type == IDX_SYNCH) + t = new T(*_connectionInfo); + else + ASSERT(false); + + _connections[type][i] = t; + ++_connectionCount[type]; + + bool res = t->Open(); + + if (res) + { + if (mysql_get_server_version(t->GetHandle()) < MIN_MYSQL_SERVER_VERSION) + { + TC_LOG_ERROR("sql.driver", "TrinityCore does not support MySQL versions below 5.1"); + res = false; + } + } + + // Failed to open a connection or invalid version, abort and cleanup + if (!res) + { + TC_LOG_ERROR("sql.driver", "DatabasePool %s NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile " + "for specific errors. Read wiki at http://collab.kpsn.org/display/tc/TrinityCore+Home", GetDatabaseName()); + + while (_connectionCount[type] != 0) + { + T* t = _connections[type][i--]; + delete t; + --_connectionCount[type]; + } + + return false; + } + } + + return true; + } + unsigned long EscapeString(char *to, const char *from, unsigned long length) { if (!to || !from || !length) @@ -507,14 +544,6 @@ class DatabaseWorkerPool return _connectionInfo->database.c_str(); } - private: - enum _internalIndex - { - IDX_ASYNC, - IDX_SYNCH, - IDX_SIZE - }; - ProducerConsumerQueue<SQLOperation*>* _queue; //! Queue shared by async worker threads. std::vector< std::vector<T*> > _connections; uint32 _connectionCount[2]; //! Counter of MySQL connections; diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index 61167681b0b..c73f0df8d00 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -29,7 +29,7 @@ class CharacterDatabaseConnection : public MySQLConnection CharacterDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } //- Loads database type specific prepared statements - void DoPrepareStatements(); + void DoPrepareStatements() override; }; typedef DatabaseWorkerPool<CharacterDatabaseConnection> CharacterDatabaseWorkerPool; diff --git a/src/server/shared/Database/Implementation/LoginDatabase.h b/src/server/shared/Database/Implementation/LoginDatabase.h index 7fa2ff49324..d37149c6a76 100644 --- a/src/server/shared/Database/Implementation/LoginDatabase.h +++ b/src/server/shared/Database/Implementation/LoginDatabase.h @@ -29,7 +29,7 @@ class LoginDatabaseConnection : public MySQLConnection LoginDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } //- Loads database type specific prepared statements - void DoPrepareStatements(); + void DoPrepareStatements() override; }; typedef DatabaseWorkerPool<LoginDatabaseConnection> LoginDatabaseWorkerPool; diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index aa2ca4b7e2e..f5d9913bc5b 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -76,7 +76,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID, "SELECT id FROM waypoint_scripts WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_CREATURE, "DELETE FROM creature WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_COMMANDS, "SELECT name, permission, help FROM command", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH); @@ -89,6 +89,4 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_INS_DISABLES, "INSERT INTO disables (entry, sourceType, flags, comment) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_DISABLES, "SELECT entry FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_ASYNC); - // 0: uint8 - PrepareStatement(WORLD_SEL_REQ_XP, "SELECT xp_for_next_level FROM player_xp_for_level WHERE lvl = ?", CONNECTION_SYNCH); } diff --git a/src/server/shared/Database/Implementation/WorldDatabase.h b/src/server/shared/Database/Implementation/WorldDatabase.h index c8c38d8a629..8a5bd206021 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.h +++ b/src/server/shared/Database/Implementation/WorldDatabase.h @@ -29,7 +29,7 @@ class WorldDatabaseConnection : public MySQLConnection WorldDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { } //- Loads database type specific prepared statements - void DoPrepareStatements(); + void DoPrepareStatements() override; }; typedef DatabaseWorkerPool<WorldDatabaseConnection> WorldDatabaseWorkerPool; @@ -110,7 +110,6 @@ enum WorldDatabaseStatements WORLD_SEL_DISABLES, WORLD_INS_DISABLES, WORLD_DEL_DISABLES, - WORLD_SEL_REQ_XP, MAX_WORLDDATABASE_STATEMENTS }; diff --git a/src/server/shared/Database/MySQLConnection.cpp b/src/server/shared/Database/MySQLConnection.cpp index 8b24f508331..4e46ff0e3a1 100644 --- a/src/server/shared/Database/MySQLConnection.cpp +++ b/src/server/shared/Database/MySQLConnection.cpp @@ -57,12 +57,14 @@ m_connectionFlags(CONNECTION_ASYNC) MySQLConnection::~MySQLConnection() { - ASSERT (m_Mysql); /// MySQL context must be present at this point - for (size_t i = 0; i < m_stmts.size(); ++i) delete m_stmts[i]; - mysql_close(m_Mysql); + if (m_Mysql) + mysql_close(m_Mysql); + + if (m_worker) + delete m_worker; } void MySQLConnection::Close() @@ -112,7 +114,7 @@ bool MySQLConnection::Open() else // generic case { port = atoi(m_connectionInfo.port_or_socket.c_str()); - unix_socket = 0; + unix_socket = nullptr; } #endif diff --git a/src/server/shared/Database/PreparedStatement.h b/src/server/shared/Database/PreparedStatement.h index 16f7a9141d3..5af52cde016 100644 --- a/src/server/shared/Database/PreparedStatement.h +++ b/src/server/shared/Database/PreparedStatement.h @@ -163,7 +163,7 @@ class PreparedStatementTask : public SQLOperation PreparedStatementTask(PreparedStatement* stmt, bool async = false); ~PreparedStatementTask(); - bool Execute(); + bool Execute() override; PreparedQueryResultFuture GetFuture() { return m_result->get_future(); } protected: diff --git a/src/server/shared/Database/QueryHolder.cpp b/src/server/shared/Database/QueryHolder.cpp index bd938561b50..f0dc3c96e4e 100644 --- a/src/server/shared/Database/QueryHolder.cpp +++ b/src/server/shared/Database/QueryHolder.cpp @@ -166,8 +166,16 @@ void SQLQueryHolder::SetSize(size_t size) m_queries.resize(size); } +SQLQueryHolderTask::~SQLQueryHolderTask() +{ + if (!m_executed) + delete m_holder; +} + bool SQLQueryHolderTask::Execute() { + m_executed = true; + if (!m_holder) return false; diff --git a/src/server/shared/Database/QueryHolder.h b/src/server/shared/Database/QueryHolder.h index 37e23ecd653..39e51b591c5 100644 --- a/src/server/shared/Database/QueryHolder.h +++ b/src/server/shared/Database/QueryHolder.h @@ -47,14 +47,16 @@ class SQLQueryHolderTask : public SQLOperation private: SQLQueryHolder* m_holder; QueryResultHolderPromise m_result; + bool m_executed; public: SQLQueryHolderTask(SQLQueryHolder* holder) - : m_holder(holder) { }; + : m_holder(holder), m_executed(false) { } - bool Execute(); - QueryResultHolderFuture GetFuture() { return m_result.get_future(); } + ~SQLQueryHolderTask(); + bool Execute() override; + QueryResultHolderFuture GetFuture() { return m_result.get_future(); } }; -#endif
\ No newline at end of file +#endif diff --git a/src/server/shared/Database/QueryResult.cpp b/src/server/shared/Database/QueryResult.cpp index 06b09d43168..a7b8ec2b107 100644 --- a/src/server/shared/Database/QueryResult.cpp +++ b/src/server/shared/Database/QueryResult.cpp @@ -124,7 +124,7 @@ m_length(NULL) *m_rBind[fIndex].length); break; default: - m_rows[uint32(m_rowPosition)][fIndex].SetByteValue(0, + m_rows[uint32(m_rowPosition)][fIndex].SetByteValue(nullptr, m_rBind[fIndex].buffer_length, m_rBind[fIndex].buffer_type, *m_rBind[fIndex].length); diff --git a/src/server/shared/Database/Transaction.h b/src/server/shared/Database/Transaction.h index c7cbbbbe712..3822c2c82c1 100644 --- a/src/server/shared/Database/Transaction.h +++ b/src/server/shared/Database/Transaction.h @@ -63,7 +63,7 @@ class TransactionTask : public SQLOperation ~TransactionTask(){ }; protected: - bool Execute(); + bool Execute() override; SQLTransaction m_trans; }; diff --git a/src/server/shared/Dynamic/LinkedList.h b/src/server/shared/Dynamic/LinkedList.h index 402aaf3d40c..87bbeaac380 100644 --- a/src/server/shared/Dynamic/LinkedList.h +++ b/src/server/shared/Dynamic/LinkedList.h @@ -150,7 +150,7 @@ class LinkedListHead typedef _Ty& reference; typedef _Ty const & const_reference; - Iterator() : _Ptr(0) + Iterator() : _Ptr(nullptr) { // construct with null node pointer } diff --git a/src/server/shared/Logging/AppenderConsole.h b/src/server/shared/Logging/AppenderConsole.h index b8f15b4fa0f..5b66f86650d 100644 --- a/src/server/shared/Logging/AppenderConsole.h +++ b/src/server/shared/Logging/AppenderConsole.h @@ -51,7 +51,7 @@ class AppenderConsole: public Appender private: void SetColor(bool stdout_stream, ColorTypes color); void ResetColor(bool stdout_stream); - void _write(LogMessage const& message); + void _write(LogMessage const& message) override; bool _colored; ColorTypes _colors[MaxLogLevels]; }; diff --git a/src/server/shared/Logging/AppenderDB.h b/src/server/shared/Logging/AppenderDB.h index 660992261fd..b86252d0d67 100644 --- a/src/server/shared/Logging/AppenderDB.h +++ b/src/server/shared/Logging/AppenderDB.h @@ -31,7 +31,7 @@ class AppenderDB: public Appender private: uint32 realmId; bool enabled; - void _write(LogMessage const& message); + void _write(LogMessage const& message) override; }; #endif diff --git a/src/server/shared/Logging/AppenderFile.h b/src/server/shared/Logging/AppenderFile.h index a600c92d152..37ba2769e19 100644 --- a/src/server/shared/Logging/AppenderFile.h +++ b/src/server/shared/Logging/AppenderFile.h @@ -30,7 +30,7 @@ class AppenderFile: public Appender private: void CloseFile(); - void _write(LogMessage const& message); + void _write(LogMessage const& message) override; FILE* logfile; std::string filename; std::string logDir; diff --git a/src/server/shared/Networking/MessageBuffer.h b/src/server/shared/Networking/MessageBuffer.h new file mode 100644 index 00000000000..c7f8ba31a71 --- /dev/null +++ b/src/server/shared/Networking/MessageBuffer.h @@ -0,0 +1,95 @@ +/* +* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MESSAGEBUFFER_H_ +#define __MESSAGEBUFFER_H_ + +#include "Define.h" +#include <vector> + +class MessageBuffer +{ + typedef std::vector<uint8>::size_type size_type; + +public: + MessageBuffer() : _wpos(0), _storage() { } + + MessageBuffer(MessageBuffer const& right) : _wpos(right._wpos), _storage(right._storage) { } + + MessageBuffer(MessageBuffer&& right) : _wpos(right._wpos), _storage(right.Move()) { } + + void Reset() + { + _storage.clear(); + _wpos = 0; + } + + bool IsMessageReady() const { return _wpos == _storage.size(); } + + size_type GetSize() const { return _storage.size(); } + + size_type GetReadyDataSize() const { return _wpos; } + + size_type GetMissingSize() const { return _storage.size() - _wpos; } + + uint8* Data() { return _storage.data(); } + + void Grow(size_type bytes) + { + _storage.resize(_storage.size() + bytes); + } + + uint8* GetWritePointer() { return &_storage[_wpos]; } + + void WriteCompleted(size_type bytes) { _wpos += bytes; } + + void ResetWritePointer() { _wpos = 0; } + + std::vector<uint8>&& Move() + { + _wpos = 0; + return std::move(_storage); + } + + MessageBuffer& operator=(MessageBuffer& right) + { + if (this != &right) + { + _wpos = right._wpos; + _storage = right._storage; + } + + return *this; + } + + MessageBuffer& operator=(MessageBuffer&& right) + { + if (this != &right) + { + _wpos = right._wpos; + _storage = right.Move(); + } + + return *this; + } + +private: + size_type _wpos; + std::vector<uint8> _storage; +}; + +#endif /* __MESSAGEBUFFER_H_ */ diff --git a/src/server/shared/Networking/Socket.h b/src/server/shared/Networking/Socket.h index 6bf67e06d9c..a13a079ff6c 100644 --- a/src/server/shared/Networking/Socket.h +++ b/src/server/shared/Networking/Socket.h @@ -18,8 +18,9 @@ #ifndef __SOCKET_H__ #define __SOCKET_H__ -#include "Define.h" +#include "MessageBuffer.h" #include "Log.h" +#include <atomic> #include <vector> #include <mutex> #include <queue> @@ -28,19 +29,34 @@ #include <type_traits> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/write.hpp> +#include <boost/asio/read.hpp> using boost::asio::ip::tcp; +#define READ_BLOCK_SIZE 4096 + template<class T, class PacketType> class Socket : public std::enable_shared_from_this<T> { typedef typename std::conditional<std::is_pointer<PacketType>::value, PacketType, PacketType const&>::type WritePacketType; public: - Socket(tcp::socket&& socket, std::size_t headerSize) : _socket(std::move(socket)), _headerSize(headerSize) + Socket(tcp::socket&& socket, std::size_t headerSize) : _socket(std::move(socket)), _remoteAddress(_socket.remote_endpoint().address()), + _remotePort(_socket.remote_endpoint().port()), _readHeaderBuffer(), _readDataBuffer(), _closed(false) + { + _readHeaderBuffer.Grow(headerSize); + } + + virtual ~Socket() { - _remotePort = _socket.remote_endpoint().port(); - _remoteAddress = _socket.remote_endpoint().address(); + boost::system::error_code error; + _socket.close(error); + + while (!_writeQueue.empty()) + { + DeletePacket(_writeQueue.front()); + _writeQueue.pop(); + } } virtual void Start() = 0; @@ -57,25 +73,48 @@ public: void AsyncReadHeader() { - _socket.async_read_some(boost::asio::buffer(_readBuffer, _headerSize), std::bind(&Socket<T, PacketType>::ReadHeaderHandlerInternal, this->shared_from_this(), - std::placeholders::_1, std::placeholders::_2)); + if (!IsOpen()) + return; + + _readHeaderBuffer.ResetWritePointer(); + _readDataBuffer.Reset(); + + AsyncReadMissingHeaderData(); } - void AsyncReadData(std::size_t size, std::size_t bufferOffset) + void AsyncReadData(std::size_t size) { - _socket.async_read_some(boost::asio::buffer(&_readBuffer[bufferOffset], size), std::bind(&Socket<T, PacketType>::ReadDataHandlerInternal, this->shared_from_this(), - std::placeholders::_1, std::placeholders::_2)); + if (!IsOpen()) + return; + + if (!size) + { + // if this is a packet with 0 length body just invoke handler directly + ReadDataHandler(); + return; + } + + _readDataBuffer.Grow(size); + AsyncReadMissingData(); } - void ReadData(std::size_t size, std::size_t bufferOffset) + void ReadData(std::size_t size) { + if (!IsOpen()) + return; + boost::system::error_code error; - _socket.read_some(boost::asio::buffer(&_readBuffer[bufferOffset], size), error); + _readDataBuffer.Grow(size); - if (error) + std::size_t bytesRead = boost::asio::read(_socket, boost::asio::buffer(_readDataBuffer.GetWritePointer(), size), error); + + _readDataBuffer.WriteCompleted(bytesRead); + + if (error || !_readDataBuffer.IsMessageReady()) { - TC_LOG_DEBUG("network", "Socket::ReadData: %s errored with: %i (%s)", GetRemoteIpAddress().to_string().c_str(), error.value(), error.message().c_str()); + TC_LOG_DEBUG("network", "Socket::ReadData: %s errored with: %i (%s)", GetRemoteIpAddress().to_string().c_str(), error.value(), + error.message().c_str()); CloseSocket(); } @@ -83,38 +122,93 @@ public: void AsyncWrite(WritePacketType data) { - boost::asio::async_write(_socket, boost::asio::buffer(data), std::bind(&Socket<T, PacketType>::WriteHandler, this->shared_from_this(), std::placeholders::_1, - std::placeholders::_2)); + boost::asio::async_write(_socket, boost::asio::buffer(data), std::bind(&Socket<T, PacketType>::WriteHandler, this->shared_from_this(), + std::placeholders::_1, std::placeholders::_2)); } - bool IsOpen() const { return _socket.is_open(); } - void CloseSocket() + bool IsOpen() const { return !_closed; } + + virtual void CloseSocket() { + if (_closed.exchange(true)) + return; + boost::system::error_code shutdownError; - _socket.shutdown(boost::asio::socket_base::shutdown_both, shutdownError); + _socket.shutdown(boost::asio::socket_base::shutdown_send, shutdownError); if (shutdownError) TC_LOG_DEBUG("network", "Socket::CloseSocket: %s errored when shutting down socket: %i (%s)", GetRemoteIpAddress().to_string().c_str(), - shutdownError.value(), shutdownError.message().c_str()); - - boost::system::error_code error; - _socket.close(error); - if (error) - TC_LOG_DEBUG("network", "Socket::CloseSocket: %s errored when closing socket: %i (%s)", GetRemoteIpAddress().to_string().c_str(), - error.value(), error.message().c_str()); + shutdownError.value(), shutdownError.message().c_str()); } - uint8* GetReadBuffer() { return _readBuffer; } + virtual bool IsHeaderReady() const { return _readHeaderBuffer.IsMessageReady(); } + virtual bool IsDataReady() const { return _readDataBuffer.IsMessageReady(); } + + uint8* GetHeaderBuffer() { return _readHeaderBuffer.Data(); } + uint8* GetDataBuffer() { return _readDataBuffer.Data(); } + + size_t GetHeaderSize() const { return _readHeaderBuffer.GetReadyDataSize(); } + size_t GetDataSize() const { return _readDataBuffer.GetReadyDataSize(); } + + MessageBuffer&& MoveHeader() { return std::move(_readHeaderBuffer); } + MessageBuffer&& MoveData() { return std::move(_readDataBuffer); } protected: - virtual void ReadHeaderHandler(boost::system::error_code error, size_t transferedBytes) = 0; - virtual void ReadDataHandler(boost::system::error_code error, size_t transferedBytes) = 0; + virtual void ReadHeaderHandler() = 0; + virtual void ReadDataHandler() = 0; std::mutex _writeLock; std::queue<PacketType> _writeQueue; private: - void ReadHeaderHandlerInternal(boost::system::error_code error, size_t transferedBytes) { ReadHeaderHandler(error, transferedBytes); } - void ReadDataHandlerInternal(boost::system::error_code error, size_t transferedBytes) { ReadDataHandler(error, transferedBytes); } + void AsyncReadMissingHeaderData() + { + _socket.async_read_some(boost::asio::buffer(_readHeaderBuffer.GetWritePointer(), std::min<std::size_t>(READ_BLOCK_SIZE, _readHeaderBuffer.GetMissingSize())), + std::bind(&Socket<T, PacketType>::ReadHeaderHandlerInternal, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2)); + } + + void AsyncReadMissingData() + { + _socket.async_read_some(boost::asio::buffer(_readDataBuffer.GetWritePointer(), std::min<std::size_t>(READ_BLOCK_SIZE, _readDataBuffer.GetMissingSize())), + std::bind(&Socket<T, PacketType>::ReadDataHandlerInternal, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2)); + } + + void ReadHeaderHandlerInternal(boost::system::error_code error, size_t transferredBytes) + { + if (error) + { + CloseSocket(); + return; + } + + _readHeaderBuffer.WriteCompleted(transferredBytes); + if (!IsHeaderReady()) + { + // incomplete, read more + AsyncReadMissingHeaderData(); + return; + } + + ReadHeaderHandler(); + } + + void ReadDataHandlerInternal(boost::system::error_code error, size_t transferredBytes) + { + if (error) + { + CloseSocket(); + return; + } + + _readDataBuffer.WriteCompleted(transferredBytes); + if (!IsDataReady()) + { + // incomplete, read more + AsyncReadMissingData(); + return; + } + + ReadDataHandler(); + } void WriteHandler(boost::system::error_code error, size_t /*transferedBytes*/) { @@ -140,12 +234,13 @@ private: tcp::socket _socket; - uint8 _readBuffer[4096]; - - uint16 _remotePort; boost::asio::ip::address _remoteAddress; + uint16 _remotePort; + + MessageBuffer _readHeaderBuffer; + MessageBuffer _readDataBuffer; - std::size_t _headerSize; + std::atomic<bool> _closed; }; #endif // __SOCKET_H__ diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index 86234039a4a..3785d1c29fa 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -17,11 +17,16 @@ */ #include "ByteBuffer.h" +#include "MessageBuffer.h" #include "Common.h" #include "Log.h" #include <sstream> +ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _storage(buffer.Move()) +{ +} + ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize) { diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 9744904f0dc..456223d744d 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -34,13 +34,15 @@ #include <math.h> #include <boost/asio/buffer.hpp> +class MessageBuffer; + // Root of ByteBuffer exception hierarchy class ByteBufferException : public std::exception { public: ~ByteBufferException() throw() { } - char const* what() const throw() { return msg_.c_str(); } + char const* what() const throw() override { return msg_.c_str(); } protected: std::string & message() throw() { return msg_; } @@ -82,14 +84,12 @@ class ByteBuffer } ByteBuffer(ByteBuffer&& buf) : _rpos(buf._rpos), _wpos(buf._wpos), - _storage(std::move(buf._storage)) - { - } + _storage(std::move(buf._storage)) { } ByteBuffer(ByteBuffer const& right) : _rpos(right._rpos), _wpos(right._wpos), - _storage(right._storage) - { - } + _storage(right._storage) { } + + ByteBuffer(MessageBuffer&& buffer); ByteBuffer& operator=(ByteBuffer const& right) { diff --git a/src/server/shared/Packets/WorldPacket.h b/src/server/shared/Packets/WorldPacket.h index 8851b9f3e45..848a00739fe 100644 --- a/src/server/shared/Packets/WorldPacket.h +++ b/src/server/shared/Packets/WorldPacket.h @@ -51,6 +51,8 @@ class WorldPacket : public ByteBuffer return *this; } + WorldPacket(uint16 opcode, MessageBuffer&& buffer) : ByteBuffer(std::move(buffer)), m_opcode(opcode) { } + void Initialize(uint16 opcode, size_t newres=200) { clear(); diff --git a/src/server/shared/Threading/ProducerConsumerQueue.h b/src/server/shared/Threading/ProducerConsumerQueue.h index accb0aebb11..a76b8b0b5c0 100644 --- a/src/server/shared/Threading/ProducerConsumerQueue.h +++ b/src/server/shared/Threading/ProducerConsumerQueue.h @@ -39,10 +39,8 @@ public: void Push(const T& value) { - { - std::lock_guard<std::mutex> lock(_queueLock); - _queue.push(std::move(value)); - } + std::lock_guard<std::mutex> lock(_queueLock); + _queue.push(std::move(value)); _condition.notify_one(); } @@ -72,10 +70,7 @@ public: { std::unique_lock<std::mutex> lock(_queueLock); - while (_queue.empty() && !_shutdown) - { - _condition.wait(lock); - } + _condition.wait(lock, [this]() { return !_queue.empty() || _shutdown; }); if (_queue.empty() || _shutdown) return; diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 3afa9e84e8b..e149902af02 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -87,6 +87,7 @@ bool StartDB(); void StopDB(); void WorldUpdateLoop(); void ClearOnlineAccounts(); +void ShutdownThreadPool(std::vector<std::thread>& threadPool); variables_map GetConsoleArguments(int argc, char** argv, std::string& cfg_file, std::string& cfg_service); /// Launch the Trinity server @@ -179,7 +180,10 @@ extern int main(int argc, char** argv) // Start the databases if (!StartDB()) + { + ShutdownThreadPool(threadPool); return 1; + } // Set server offline (not connectable) LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = (flag & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID); @@ -217,7 +221,7 @@ extern int main(int argc, char** argv) AsyncAcceptor<WorldSocket> worldAcceptor(_ioService, worldListener, worldPort, tcpNoDelay); - sScriptMgr->OnStartup(); + sScriptMgr->OnNetworkStart(); // Set server online (allow connecting now) LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID); @@ -233,16 +237,12 @@ extern int main(int argc, char** argv) TC_LOG_INFO("server.worldserver", "%s (worldserver-daemon) ready...", _FULLVERSION); + sScriptMgr->OnStartup(); + WorldUpdateLoop(); // Shutdown starts here - - _ioService.stop(); - - for (auto& thread : threadPool) - { - thread.join(); - } + ShutdownThreadPool(threadPool); sScriptMgr->OnShutdown(); @@ -281,41 +281,7 @@ extern int main(int argc, char** argv) if (cliThread != nullptr) { #ifdef _WIN32 - - // this only way to terminate CLI thread exist at Win32 (alt. way exist only in Windows Vista API) - //_exit(1); - // send keyboard input to safely unblock the CLI thread - INPUT_RECORD b[4]; - HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE); - b[0].EventType = KEY_EVENT; - b[0].Event.KeyEvent.bKeyDown = TRUE; - b[0].Event.KeyEvent.uChar.AsciiChar = 'X'; - b[0].Event.KeyEvent.wVirtualKeyCode = 'X'; - b[0].Event.KeyEvent.wRepeatCount = 1; - - b[1].EventType = KEY_EVENT; - b[1].Event.KeyEvent.bKeyDown = FALSE; - b[1].Event.KeyEvent.uChar.AsciiChar = 'X'; - b[1].Event.KeyEvent.wVirtualKeyCode = 'X'; - b[1].Event.KeyEvent.wRepeatCount = 1; - - b[2].EventType = KEY_EVENT; - b[2].Event.KeyEvent.bKeyDown = TRUE; - b[2].Event.KeyEvent.dwControlKeyState = 0; - b[2].Event.KeyEvent.uChar.AsciiChar = '\r'; - b[2].Event.KeyEvent.wVirtualKeyCode = VK_RETURN; - b[2].Event.KeyEvent.wRepeatCount = 1; - b[2].Event.KeyEvent.wVirtualScanCode = 0x1c; - - b[3].EventType = KEY_EVENT; - b[3].Event.KeyEvent.bKeyDown = FALSE; - b[3].Event.KeyEvent.dwControlKeyState = 0; - b[3].Event.KeyEvent.uChar.AsciiChar = '\r'; - b[3].Event.KeyEvent.wVirtualKeyCode = VK_RETURN; - b[3].Event.KeyEvent.wVirtualScanCode = 0x1c; - b[3].Event.KeyEvent.wRepeatCount = 1; - DWORD numb; - WriteConsoleInput(hStdIn, b, 4, &numb); + CancelSynchronousIo(cliThread->native_handle()); #endif cliThread->join(); delete cliThread; @@ -330,6 +296,17 @@ extern int main(int argc, char** argv) return World::GetExitCode(); } +void ShutdownThreadPool(std::vector<std::thread>& threadPool) +{ + sScriptMgr->OnNetworkStop(); + + _ioService.stop(); + + for (auto& thread : threadPool) + { + thread.join(); + } +} void WorldUpdateLoop() { diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index 3e2025dace8..c2ca184905e 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -276,7 +276,7 @@ int main(int argc, char** argv) } if (!checkDirectories(debugOutput)) - return silent ? -3 : finish("Press any key to close...", -3); + return silent ? -3 : finish("Press ENTER to close...", -3); MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds, debugOutput, bigBaseUnit, offMeshInputPath); |
