diff options
Diffstat (limited to 'src')
21 files changed, 223 insertions, 177 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index da55a073679..943919451a9 100644 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -23,6 +23,10 @@ #include "ObjectAccessor.h" #include "Player.h" +///////////////// +// AggressorAI +///////////////// + int AggressorAI::Permissible(const Creature* creature) { // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight @@ -40,26 +44,9 @@ void AggressorAI::UpdateAI(uint32 /*diff*/) DoMeleeAttackIfReady(); } -// some day we will delete these useless things -int CombatAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} - -int ArcherAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} - -int TurretAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} - -int VehicleAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} +///////////////// +// CombatAI +///////////////// void CombatAI::InitializeAI() { @@ -118,7 +105,7 @@ void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) } ///////////////// -//CasterAI +// CasterAI ///////////////// void CasterAI::InitializeAI() @@ -182,7 +169,7 @@ void CasterAI::UpdateAI(uint32 diff) } ////////////// -//ArcherAI +// ArcherAI ////////////// ArcherAI::ArcherAI(Creature* c) : CreatureAI(c) @@ -231,7 +218,7 @@ void ArcherAI::UpdateAI(uint32 /*diff*/) } ////////////// -//TurretAI +// TurretAI ////////////// TurretAI::TurretAI(Creature* c) : CreatureAI(c) @@ -269,17 +256,17 @@ void TurretAI::UpdateAI(uint32 /*diff*/) } ////////////// -//VehicleAI +// VehicleAI ////////////// -VehicleAI::VehicleAI(Creature* c) : CreatureAI(c), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) +VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) { LoadConditions(); m_DoDismiss = false; m_DismissTimer = VEHICLE_DISMISS_TIME; } -//NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted +// NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted void VehicleAI::UpdateAI(uint32 diff) { CheckConditions(diff); @@ -289,7 +276,6 @@ void VehicleAI::UpdateAI(uint32 diff) if (m_DismissTimer < diff) { m_DoDismiss = false; - me->SetVisible(false); me->DespawnOrUnsummon(); } else @@ -297,24 +283,16 @@ void VehicleAI::UpdateAI(uint32 diff) } } -void VehicleAI::Reset() -{ - me->SetVisible(true); -} - void VehicleAI::OnCharmed(bool apply) { - if (m_IsVehicleInUse && !apply && !conditions.empty())//was used and has conditions + if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && !conditions.empty()) // was used and has conditions { - m_DoDismiss = true;//needs reset - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE); - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); + m_DoDismiss = true; // needs reset } else if (apply) - m_DoDismiss = false;//in use again + m_DoDismiss = false; // in use again - m_DismissTimer = VEHICLE_DISMISS_TIME;//reset timer - m_IsVehicleInUse = apply; + m_DismissTimer = VEHICLE_DISMISS_TIME; // reset timer } void VehicleAI::LoadConditions() @@ -324,7 +302,7 @@ void VehicleAI::LoadConditions() TC_LOG_DEBUG("condition", "VehicleAI::LoadConditions: loaded %u conditions", uint32(conditions.size())); } -void VehicleAI::CheckConditions(const uint32 diff) +void VehicleAI::CheckConditions(uint32 diff) { if (m_ConditionsTimer < diff) { @@ -339,7 +317,7 @@ void VehicleAI::CheckConditions(const uint32 diff) if (!sConditionMgr->IsObjectMeetToConditions(player, me, conditions)) { player->ExitVehicle(); - return;//check other pessanger in next tick + return; // check other pessanger in next tick } } } diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index 10716627e85..f73daa2d720 100644 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -47,7 +47,9 @@ class CombatAI : public CreatureAI void JustDied(Unit* killer); void UpdateAI(uint32 diff); void SpellInterrupted(uint32 spellId, uint32 unTimeMs); - static int Permissible(const Creature*); + + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + protected: EventMap events; SpellVct spells; @@ -72,7 +74,8 @@ struct ArcherAI : public CreatureAI void AttackStart(Unit* who); void UpdateAI(uint32 diff); - static int Permissible(Creature const*); + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + protected: float m_minRange; }; @@ -85,29 +88,30 @@ struct TurretAI : public CreatureAI void AttackStart(Unit* who); void UpdateAI(uint32 diff); - static int Permissible(Creature const*); + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + protected: float m_minRange; }; #define VEHICLE_CONDITION_CHECK_TIME 1000 #define VEHICLE_DISMISS_TIME 5000 + struct VehicleAI : public CreatureAI { public: - explicit VehicleAI(Creature* c); + explicit VehicleAI(Creature* creature); void UpdateAI(uint32 diff); - static int Permissible(Creature const*); - void Reset(); void MoveInLineOfSight(Unit*) { } void AttackStart(Unit*) { } void OnCharmed(bool apply); + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + private: - bool m_IsVehicleInUse; void LoadConditions(); - void CheckConditions(const uint32 diff); + void CheckConditions(uint32 diff); ConditionList conditions; uint32 m_ConditionsTimer; bool m_DoDismiss; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index bd156381e87..bb806717d97 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1333,7 +1333,6 @@ public: ObjectGuidList(ObjectList* objectList, WorldObject* baseObject) { ASSERT(objectList != NULL); - ASSERT(baseObject != NULL); m_objectList = objectList; m_baseObject = baseObject; m_guidList = new GuidList(); @@ -1346,15 +1345,18 @@ public: ObjectList* GetObjectList() { - //sanitize list using m_guidList - m_objectList->clear(); - - for (GuidList::iterator itr = m_guidList->begin(); itr != m_guidList->end(); ++itr) + if (m_baseObject) { - if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr)) - m_objectList->push_back(obj); - else - TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr); + //sanitize list using m_guidList + m_objectList->clear(); + + for (GuidList::iterator itr = m_guidList->begin(); itr != m_guidList->end(); ++itr) + { + if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr)) + m_objectList->push_back(obj); + else + TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr); + } } return m_objectList; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4b49964ad02..ee4fe9057bd 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -778,7 +778,6 @@ Player::Player(WorldSession* session): Unit(true), phaseMgr(this) m_ArmorProficiency = 0; m_canParry = false; m_canBlock = false; - m_canDualWield = false; m_canTitanGrip = false; m_temporaryUnsummonedPetNumber = 0; @@ -24367,14 +24366,18 @@ void Player::ResurectUsingRequestData() SpawnCorpseBones(); } -void Player::SetClientControl(Unit* target, uint8 allowMove) +void Player::SetClientControl(Unit* target, bool allowMove) { WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1); data.append(target->GetPackGUID()); - data << uint8(allowMove); + data << uint8(allowMove ? 1 : 0); GetSession()->SendPacket(&data); - if (target == this && allowMove == 1) - SetMover(this); + + if (this != target) + SetViewpoint(target, allowMove); + + if (allowMove) + SetMover(target); } void Player::SetMover(Unit* target) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index b3df4ef4fef..5fab7e82cc3 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2306,7 +2306,7 @@ class Player : public Unit, public GridObject<Player> bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const; - void SetClientControl(Unit* target, uint8 allowMove); + void SetClientControl(Unit* target, bool allowMove); void SetMover(Unit* target); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 44c2b4a8da9..9bfb5035802 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -257,6 +257,8 @@ Unit::Unit(bool isWorldObject) : m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); _lastLiquid = NULL; + + _oldFactionId = 0; _isWalkingBeforeCharm = false; } @@ -4601,7 +4603,7 @@ GameObject* Unit::GetGameObject(uint32 spellId) const void Unit::AddGameObject(GameObject* gameObj) { - if (!gameObj || !gameObj->GetOwnerGUID() == 0) + if (!gameObj || gameObj->GetOwnerGUID() != 0) return; m_gameObj.push_back(gameObj); @@ -7755,17 +7757,17 @@ void Unit::SetOwnerGUID(uint64 owner) Unit* Unit::GetOwner() const { - if (uint64 ownerid = GetOwnerGUID()) - { - return ObjectAccessor::GetUnit(*this, ownerid); - } + if (uint64 ownerGUID = GetOwnerGUID()) + return ObjectAccessor::GetUnit(*this, ownerGUID); + return NULL; } Unit* Unit::GetCharmer() const { - if (uint64 charmerid = GetCharmerGUID()) - return ObjectAccessor::GetUnit(*this, charmerid); + if (uint64 charmerGUID = GetCharmerGUID()) + return ObjectAccessor::GetUnit(*this, charmerGUID); + return NULL; } @@ -8095,8 +8097,8 @@ void Unit::SetCharm(Unit* charm, bool apply) charm->SetWalk(_isWalkingBeforeCharm); if (charm->GetTypeId() == TYPEID_PLAYER - || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) - || charm->GetOwnerGUID() != GetGUID()) + || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) + || charm->GetOwnerGUID() != GetGUID()) { m_Controlled.erase(charm); } @@ -11858,9 +11860,8 @@ CharmInfo::~CharmInfo() { } void CharmInfo::RestoreState() { - if (_unit->GetTypeId() == TYPEID_UNIT) - if (Creature* creature = _unit->ToCreature()) - creature->SetReactState(_oldReactState); + if (Creature* creature = _unit->ToCreature()) + creature->SetReactState(_oldReactState); } void CharmInfo::InitPetActionBar() @@ -13897,8 +13898,8 @@ void Unit::SetFeared(bool apply) } } - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetClientControl(this, !apply); + if (Player* player = ToPlayer()) + player->SetClientControl(this, !apply); } void Unit::SetConfused(bool apply) @@ -13919,8 +13920,8 @@ void Unit::SetConfused(bool apply) } } - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetClientControl(this, !apply); + if (Player* player = ToPlayer()) + player->SetClientControl(this, !apply); } bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp) @@ -13966,11 +13967,13 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au CombatStop(); /// @todo CombatStop(true) may cause crash (interrupt spells) DeleteThreatList(); + Player* playerCharmer = charmer->ToPlayer(); + // Charmer stop charming - if (charmer->GetTypeId() == TYPEID_PLAYER) + if (playerCharmer) { - charmer->ToPlayer()->StopCastingCharm(); - charmer->ToPlayer()->StopCastingBindSight(); + playerCharmer->StopCastingCharm(); + playerCharmer->StopCastingBindSight(); } // Charmed stop charming @@ -13992,11 +13995,10 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au if (aurApp && aurApp->GetRemoveMode()) return false; - // Set charmed - Map* map = GetMap(); - if (!IsVehicle() || (IsVehicle() && map && !map->IsBattleground())) - setFaction(charmer->getFaction()); + _oldFactionId = getFaction(); + setFaction(charmer->getFaction()); + // Set charmed charmer->SetCharm(this, true); if (GetTypeId() == TYPEID_UNIT) @@ -14009,7 +14011,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au Player* player = ToPlayer(); if (player->isAFK()) player->ToggleAFK(); - player->SetClientControl(this, 0); + player->SetClientControl(this, false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution @@ -14027,25 +14029,21 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au GetCharmInfo()->InitCharmCreateSpells(); } - if (charmer->GetTypeId() == TYPEID_PLAYER) + if (playerCharmer) { switch (type) { case CHARM_TYPE_VEHICLE: SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - charmer->ToPlayer()->SetClientControl(this, 1); - charmer->ToPlayer()->SetMover(this); - charmer->ToPlayer()->SetViewpoint(this, true); - charmer->ToPlayer()->VehicleSpellInitialize(); + playerCharmer->SetClientControl(this, true); + playerCharmer->VehicleSpellInitialize(); break; case CHARM_TYPE_POSSESS: AddUnitState(UNIT_STATE_POSSESSED); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - charmer->ToPlayer()->SetClientControl(this, 1); - charmer->ToPlayer()->SetMover(this); - charmer->ToPlayer()->SetViewpoint(this, true); - charmer->ToPlayer()->PossessSpellInitialize(); + playerCharmer->SetClientControl(this, true); + playerCharmer->PossessSpellInitialize(); break; case CHARM_TYPE_CHARM: if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) @@ -14064,7 +14062,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped } } - charmer->ToPlayer()->CharmSpellInitialize(); + playerCharmer->CharmSpellInitialize(); break; default: case CHARM_TYPE_CONVERT: @@ -14101,16 +14099,16 @@ void Unit::RemoveCharmedBy(Unit* charmer) CombatStop(); /// @todo CombatStop(true) may cause crash (interrupt spells) getHostileRefManager().deleteReferences(); DeleteThreatList(); - Map* map = GetMap(); - if (!IsVehicle() || (IsVehicle() && map && !map->IsBattleground())) - RestoreFaction(); - GetMotionMaster()->InitDefault(); - if (type == CHARM_TYPE_POSSESS) + if (_oldFactionId) { - ClearUnitState(UNIT_STATE_POSSESSED); - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + setFaction(_oldFactionId); + _oldFactionId = 0; } + else + RestoreFaction(); + + GetMotionMaster()->InitDefault(); if (Creature* creature = ToCreature()) { @@ -14122,8 +14120,6 @@ void Unit::RemoveCharmedBy(Unit* charmer) if (type != CHARM_TYPE_VEHICLE) LastCharmerGUID = charmer->GetGUID(); } - else - ToPlayer()->SetClientControl(this, 1); // If charmer still exists if (!charmer) @@ -14134,24 +14130,23 @@ void Unit::RemoveCharmedBy(Unit* charmer) charmer->SetCharm(this, false); - if (charmer->GetTypeId() == TYPEID_PLAYER) + Player* playerCharmer = charmer->ToPlayer(); + + if (playerCharmer) { switch (type) { case CHARM_TYPE_VEHICLE: - charmer->ToPlayer()->SetClientControl(charmer, 1); - charmer->ToPlayer()->SetViewpoint(this, false); - charmer->ToPlayer()->SetClientControl(this, 0); - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetMover(this); + playerCharmer->SetClientControl(this, false); + playerCharmer->SetClientControl(charmer, true); + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); break; case CHARM_TYPE_POSSESS: - charmer->ToPlayer()->SetClientControl(charmer, 1); - charmer->ToPlayer()->SetViewpoint(this, false); - charmer->ToPlayer()->SetClientControl(this, 0); + playerCharmer->SetClientControl(this, false); + playerCharmer->SetClientControl(charmer, true); charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetMover(this); + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + ClearUnitState(UNIT_STATE_POSSESSED); break; case CHARM_TYPE_CHARM: if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) @@ -14172,9 +14167,12 @@ void Unit::RemoveCharmedBy(Unit* charmer) } } + if (Player* player = ToPlayer()) + player->SetClientControl(this, true); + // a guardian should always have charminfo - if (charmer->GetTypeId() == TYPEID_PLAYER && this != charmer->GetFirstControlled()) - charmer->ToPlayer()->SendRemoveControlBar(); + if (playerCharmer && this != charmer->GetFirstControlled()) + playerCharmer->SendRemoveControlBar(); else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsGuardian())) DeleteCharmInfo(); } @@ -14231,8 +14229,7 @@ void Unit::RemoveVehicleKit() m_updateFlag &= ~UPDATEFLAG_VEHICLE; m_unitTypeMask &= ~UNIT_MASK_VEHICLE; - RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE); + RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE); } bool Unit::IsOnVehicle(const Unit* vehicle) const diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index ed26722931f..abc1d6f6d23 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2260,7 +2260,8 @@ class Unit : public WorldObject bool m_cleanupDone; // lock made to not add stuff after cleanup before delete bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world - bool _isWalkingBeforeCharm; // Are we walking before we were charmed? + uint32 _oldFactionId; ///< faction before charm + bool _isWalkingBeforeCharm; ///< Are we walking before we were charmed? time_t _lastDamagedTime; // Part of Evade mechanics }; @@ -2271,31 +2272,31 @@ namespace Trinity class PowerPctOrderPred { public: - PowerPctOrderPred(Powers power, bool ascending = true) : m_power(power), m_ascending(ascending) { } - bool operator() (const Unit* a, const Unit* b) const + PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) { } + bool operator() (Unit const* a, Unit const* b) const { - float rA = a->GetMaxPower(m_power) ? float(a->GetPower(m_power)) / float(a->GetMaxPower(m_power)) : 0.0f; - float rB = b->GetMaxPower(m_power) ? float(b->GetPower(m_power)) / float(b->GetMaxPower(m_power)) : 0.0f; - return m_ascending ? rA < rB : rA > rB; + float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f; + float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f; + return _ascending ? rA < rB : rA > rB; } private: - const Powers m_power; - const bool m_ascending; + Powers const _power; + bool const _ascending; }; // Binary predicate for sorting Units based on percent value of health class HealthPctOrderPred { public: - HealthPctOrderPred(bool ascending = true) : m_ascending(ascending) { } - bool operator() (const Unit* a, const Unit* b) const + HealthPctOrderPred(bool ascending = true) : _ascending(ascending) { } + bool operator() (Unit const* a, Unit const* b) const { float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f; float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f; - return m_ascending ? rA < rB : rA > rB; + return _ascending ? rA < rB : rA > rB; } private: - const bool m_ascending; + bool const _ascending; }; } #endif diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 12c1a1f09d3..a586b389630 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -1394,7 +1394,7 @@ bool Guild::SetName(std::string const& name) return true; } -void Guild::HandleRoster(WorldSession* session /*= NULL*/) +void Guild::HandleRoster(WorldSession* session) { ByteBuffer memberData(100); // Guess size @@ -1475,16 +1475,8 @@ void Guild::HandleRoster(WorldSession* session /*= NULL*/) data.AppendPackedTime(m_createdDate); data << uint32(0); - if (session) - { - TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str()); - session->SendPacket(&data); - } - else - { - TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [Broadcast]"); - BroadcastPacket(&data); - } + TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str()); + session->SendPacket(&data); } void Guild::HandleQuery(WorldSession* session) diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index 504bc967984..2d9d9085917 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -771,7 +771,7 @@ public: bool SetName(std::string const& name); // Handle client commands - void HandleRoster(WorldSession* session = NULL); + void HandleRoster(WorldSession* session); void HandleQuery(WorldSession* session); void HandleSetMOTD(WorldSession* session, std::string const& motd); void HandleSetInfo(WorldSession* session, std::string const& info); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 6d1a1f3c0e4..0fafac05597 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -2033,6 +2033,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) if (result) if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER), false, false, true); + + Player::LeaveAllArenaTeams(guid); } if (!HasPermission(rbac::RBAC_PERM_TWO_SIDE_ADD_FRIEND)) @@ -2045,12 +2047,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - // Leave Arena Teams - Player::LeaveAllArenaTeams(guid); - // Reset homebind and position stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); stmt->setUInt32(0, lowGuid); diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 6392237f593..fa137d98272 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -396,6 +396,9 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvPacket) if (plrMover) // nothing is charmed, or player charmed { + if (plrMover->IsSitState() && (movementInfo.flags & (MOVEMENTFLAG_MASK_MOVING | MOVEMENTFLAG_MASK_TURNING))) + plrMover->SetStandState(UNIT_STAND_STATE_STAND); + plrMover->UpdateFallInformationIfNeed(movementInfo, opcode); AreaTableEntry const* zone = GetAreaEntryByAreaID(plrMover->GetAreaId()); diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index e37e6847bdd..c46d9002604 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -164,7 +164,11 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId) void InstanceSaveManager::UnloadInstanceSave(uint32 InstanceId) { if (InstanceSave* save = GetInstanceSave(InstanceId)) + { save->UnloadIfEmpty(); + if (save->m_toDelete) + delete save; + } } InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset) diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 7a89e6488f0..1d753ebaa48 100644 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -115,16 +115,16 @@ class InstanceSave but that would depend on a lot of things that can easily change in future */ Difficulty GetDifficulty() const { return m_difficulty; } + typedef std::list<Player*> PlayerListType; + typedef std::list<Group*> GroupListType; + private: + bool UnloadIfEmpty(); /* used to flag the InstanceSave as to be deleted, so the caller can delete it */ void SetToDelete(bool toDelete) { m_toDelete = toDelete; } - typedef std::list<Player*> PlayerListType; - typedef std::list<Group*> GroupListType; - private: - bool UnloadIfEmpty(); /* the only reason the instSave-object links are kept is because the object-instSave links need to be broken at reset time */ /// @todo: Check if maybe it's enough to just store the number of players/groups diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 32802e06105..2e4d831288a 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1223,6 +1223,18 @@ enum TrinityStrings LANG_AUTO_BROADCAST = 11000, LANG_INVALID_REALMID = 11001, + // Show Kick in world + LANG_COMMAND_KICKMESSAGE_WORLD = 11002, + + // Show Mute in world + LANG_COMMAND_MUTEMESSAGE_WORLD = 11003, + + // Show Ban in world + LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD = 11004, + LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD = 11005, + LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD = 11006, + LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD = 11007, + // NOT RESERVED IDS 12000-1999999999 // `db_script_string` table index 2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID) // For other tables maybe 2000010000-2147483647 (max index) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 6014fc00689..e8bc084b835 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -301,7 +301,7 @@ class Spell void EffectKnockBack(SpellEffIndex effIndex); void EffectPullTowards(SpellEffIndex effIndex); void EffectDispelMechanic(SpellEffIndex effIndex); - void EffectSummonDeadPet(SpellEffIndex effIndex); + void EffectResurrectPet(SpellEffIndex effIndex); void EffectDestroyAllTotems(SpellEffIndex effIndex); void EffectDurabilityDamage(SpellEffIndex effIndex); void EffectSkill(SpellEffIndex effIndex); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index f683a3668fb..335957356d9 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -178,7 +178,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectSummonObject, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 &Spell::EffectSummonObject, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 &Spell::EffectDispelMechanic, //108 SPELL_EFFECT_DISPEL_MECHANIC - &Spell::EffectSummonDeadPet, //109 SPELL_EFFECT_SUMMON_DEAD_PET + &Spell::EffectResurrectPet, //109 SPELL_EFFECT_RESURRECT_PET &Spell::EffectDestroyAllTotems, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS &Spell::EffectDurabilityDamage, //111 SPELL_EFFECT_DURABILITY_DAMAGE &Spell::EffectUnused, //112 SPELL_EFFECT_112 @@ -4762,7 +4762,7 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex) } } -void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/) +void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; @@ -4774,9 +4774,9 @@ void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/) if (!player) return; - // Maybe player dismissed dead pet or pet despawned? bool hadPet = true; + if (!player->GetPet()) { // Position passed to SummonPet is irrelevant with current implementation, @@ -4785,13 +4785,8 @@ void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/) hadPet = false; } - // TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends Pet* pet = player->GetPet(); // Attempt to get current pet - if (!pet) - return; - - // TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends - if (pet->IsAlive()) + if (!pet || pet->IsAlive()) return; // If player did have a pet before reviving, teleport it diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 56c62f710cb..e472e975777 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1210,6 +1210,8 @@ void World::LoadConfigSettings(bool reload) m_bool_configs[CONFIG_NO_RESET_TALENT_COST] = sConfigMgr->GetBoolDefault("NoResetTalentsCost", false); m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowKickInWorld", false); + m_bool_configs[CONFIG_SHOW_MUTE_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowMuteInWorld", false); + m_bool_configs[CONFIG_SHOW_BAN_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowBanInWorld", false); m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfigMgr->GetIntDefault("RecordUpdateTimeDiffInterval", 60000); m_int_configs[CONFIG_MIN_LOG_UPDATE] = sConfigMgr->GetIntDefault("MinRecordUpdateTimeDiff", 100); m_int_configs[CONFIG_NUMTHREADS] = sConfigMgr->GetIntDefault("MapUpdate.Threads", 1); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 5a55a3d39e6..6f81c4fae97 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -144,6 +144,8 @@ enum WorldBoolConfigs CONFIG_PVP_TOKEN_ENABLE, CONFIG_NO_RESET_TALENT_COST, CONFIG_SHOW_KICK_IN_WORLD, + CONFIG_SHOW_MUTE_IN_WORLD, + CONFIG_SHOW_BAN_IN_WORLD, CONFIG_CHATLOG_CHANNEL, CONFIG_CHATLOG_WHISPER, CONFIG_CHATLOG_SYSCHAN, diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index c32a03f9bd8..b1a3dd4bca5 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -114,9 +114,19 @@ public: case BAN_SUCCESS: { if (atoi(durationStr) > 0) - handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + { + 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); + else + handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + } else - handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr); + { + 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); + else + handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr); + } break; } case BAN_NOTFOUND: @@ -189,9 +199,19 @@ public: { case BAN_SUCCESS: if (atoi(durationStr) > 0) - handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); - else - handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr); + { + 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); + 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); + else + handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr); + } break; case BAN_SYNTAX_ERROR: return false; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index f571cb38e44..81fc9f9b2b2 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -807,12 +807,16 @@ public: if (handler->HasLowerSecurity(target, 0)) return false; - if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD)) - sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); - else - handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); + char const* kickReason = strtok(NULL, "\r"); + std::string kickReasonStr = "No reason"; + if (kickReason != NULL) + kickReasonStr = kickReason; - target->GetSession()->KickPlayer(); + if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD)) + sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), playerName.c_str(), kickReasonStr.c_str()); + else + handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); + target->GetSession()->KickPlayer(); return true; } @@ -1834,7 +1838,17 @@ public: int64 muteTime = time(NULL) + notSpeakTime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); + 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()); + } } else { @@ -1849,8 +1863,10 @@ public: LoginDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); - 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, 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()); return true; } diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 0bd90e84def..6d0caa707ac 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -2528,6 +2528,23 @@ Guild.AllowMultipleGuildMaster = 0 ShowKickInWorld = 0 +# ShowMuteInWorld +# Description: Determines whether a message is broadcasted to the entire server when a +# player gets muted. +# Default: 0 - (Disabled) +# 1 - (Enabled) + +ShowMuteInWorld = 0 + +# +# ShowBanInWorld +# Description: Determines whether a message is broadcasted to the entire server when a +# player gets banned. +# Default: 0 - (Disabled) +# 1 - (Enabled) + +ShowBanInWorld = 0 + # # RecordUpdateTimeDiffInterval # Description: Time (in milliseconds) update time diff is written to the log file. |