diff options
Diffstat (limited to 'src')
184 files changed, 3313 insertions, 2107 deletions
diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 6e2326ca9d5..90ca7009098 100755 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -40,8 +40,8 @@ bool GuardAI::CanSeeAlways(WorldObject const* obj) if (!obj->isType(TYPEMASK_UNIT)) return false; - std::list<HostileReference*> threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if ((*itr)->getUnitGuid() == obj->GetGUID()) return true; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index e159c1a7d9b..9f2c9a86094 100755 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -60,25 +60,20 @@ void UnitAI::DoMeleeAttackIfReady() bool UnitAI::DoSpellAttackIfReady(uint32 spell) { - if (me->HasUnitState(UNIT_STATE_CASTING)) + if (me->HasUnitState(UNIT_STATE_CASTING) || !me->isAttackReady()) return true; - if (me->isAttackReady()) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) { - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) + if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false))) { - if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false))) - { - me->CastSpell(me->getVictim(), spell, false); - me->resetAttackTimer(); - } - else - return false; + me->CastSpell(me->getVictim(), spell, false); + me->resetAttackTimer(); + return true; } - else - return false; } - return true; + + return false; } Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float dist, bool playerOnly, int32 aura) @@ -101,8 +96,8 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) { if (me->isInCombat()) { - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetTypeId() == TYPEID_PLAYER) @@ -116,8 +111,8 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) { if (me->isInCombat()) { - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 89359372355..b07c766ae0b 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -61,7 +61,7 @@ struct DefaultTargetSelector : public std::unary_function<Unit*, bool> // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit // playerOnly: self explaining // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura - DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} + DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) { } bool operator()(Unit const* target) const { @@ -156,12 +156,12 @@ class UnitAI // predicate shall extend std::unary_function<Unit*, bool> template <class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE const& predicate) { - const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); if (position >= threatlist.size()) return NULL; std::list<Unit*> targetList; - for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) if (predicate((*itr)->getTarget())) targetList.push_back((*itr)->getTarget()); @@ -206,11 +206,11 @@ class UnitAI // predicate shall extend std::unary_function<Unit*, bool> template <class PREDICATE> void SelectTargetList(std::list<Unit*>& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) { - std::list<HostileReference*> const& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); if (threatlist.empty()) return; - for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) if (predicate((*itr)->getTarget())) targetList.push_back((*itr)->getTarget()); diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 1611ae2b85d..200b868670b 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -254,12 +254,11 @@ void ScriptedAI::DoResetThreat() return; } - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); - if (unit && DoGetThreat(unit)) DoModifyThreatPercent(unit, -100); } @@ -299,7 +298,8 @@ void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o if (Player* player = unit->ToPlayer()) player->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); else - sLog->outError(LOG_FILTER_TSCR, "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); + sLog->outError(LOG_FILTER_TSCR, "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", + me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); } void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) @@ -331,6 +331,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range) Trinity::FriendlyCCedInRange u_check(me, range); Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, list, u_check); me->VisitNearbyObject(range, searcher); + return list; } @@ -340,6 +341,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u Trinity::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check); me->VisitNearbyObject(range, searcher); + return list; } @@ -451,7 +453,6 @@ void Scripted_NoMovementAI::AttackStart(Unit* target) } // BossAI - for instanced bosses - BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature), instance(creature->GetInstanceScript()), summons(creature), @@ -503,8 +504,9 @@ void BossAI::TeleportCheaters() { float x, y, z; me->GetPosition(x, y, z); - std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if (Unit* target = (*itr)->getTarget()) if (target->GetTypeId() == TYPEID_PLAYER && !CheckBoundary(target)) target->NearTeleportTo(x, y, z, 0); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 003c9ac9d1c..9c666e7de32 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -438,7 +438,7 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false if (WaypointList.empty()) { - sLog->outError(LOG_FILTER_SQL, "TSCR: EscortAI (script: %s, creature entry: %u) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", + sLog->outError(LOG_FILTER_TSCR, "EscortAI (script: %s, creature entry: %u) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", me->GetScriptName().c_str(), me->GetEntry(), quest ? quest->GetQuestId() : 0); return; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 1e83c203553..ebb734156b4 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -116,7 +116,7 @@ void FollowerAI::MoveInLineOfSight(Unit* who) } } -void FollowerAI::JustDied(Unit* /*pKiller*/) +void FollowerAI::JustDied(Unit* /*killer*/) { if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !m_uiLeaderGUID || !m_pQuestForFollow) return; @@ -305,7 +305,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Qu me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); - sLog->outDebug(LOG_FILTER_TSCR, "FollowerAI start follow %s (GUID " UI64FMTD ")", player->GetName(), m_uiLeaderGUID); + sLog->outDebug(LOG_FILTER_TSCR, "FollowerAI start follow %s (GUID " UI64FMTD ")", player->GetName().c_str(), m_uiLeaderGUID); } Player* FollowerAI::GetLeaderForFollower() diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 6097edf6641..a1fb2147cc2 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -46,13 +46,13 @@ class TrinityStringTextBuilder size_t operator()(WorldPacket* data, LocaleConstant locale) const { std::string text = sObjectMgr->GetTrinityString(_textId, locale); - char const* localizedName = _source->GetNameForLocaleIdx(locale); + std::string localizedName = _source->GetNameForLocaleIdx(locale); *data << uint8(_msgType); *data << uint32(_language); *data << uint64(_source->GetGUID()); *data << uint32(1); // 2.1.0 - *data << uint32(strlen(localizedName)+1); + *data << uint32(localizedName.size() + 1); *data << localizedName; size_t whisperGUIDpos = data->wpos(); *data << uint64(_targetGUID); // Unit Target @@ -154,7 +154,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u mLastInvoker = unit->GetGUID(); if (Unit* tempInvoker = GetLastInvoker()) - sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName(), tempInvoker->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName().c_str(), tempInvoker->GetGUIDLow()); switch (e.GetActionType()) { @@ -198,7 +198,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u mUseTextTimer = true; sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), mTextGUID); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (GuidLow: %u), textGuid: %u", - talker->GetName(), talker->GetGUIDLow(), GUID_LOPART(mTextGUID)); + talker->GetName().c_str(), talker->GetGUIDLow(), GUID_LOPART(mTextGUID)); break; } case SMART_ACTION_SIMPLE_TALK: @@ -216,7 +216,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker->GetGUID() : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, (*itr)->ToPlayer()); } sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: %s (GuidLow: %u), textGroupId: %u", - (*itr)->GetName(), (*itr)->GetGUIDLow(), uint8(e.action.talk.textGroupID)); + (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), uint8(e.action.talk.textGroupID)); } delete targets; @@ -234,7 +234,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToUnit()->HandleEmoteCommand(e.action.emote.emote); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: %s (GuidLow: %u), emote: %u", - (*itr)->GetName(), (*itr)->GetGUIDLow(), e.action.emote.emote); + (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.emote.emote); } } @@ -253,7 +253,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.range > 0 ? true : false); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", - (*itr)->GetName(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.range); + (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.range); } } @@ -366,14 +366,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { if (IsPlayer(*itr)) - { if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest)) { (*itr)->ToPlayer()->AddQuest(q, NULL); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player guidLow %u add quest %u", (*itr)->GetGUIDLow(), e.action.quest.quest); } - } } delete targets; @@ -432,8 +430,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!me) break; - std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) { if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -2348,8 +2346,8 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* { if (me) { - std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) l->push_back(temp); } diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index b666add74b3..2b67acfd6d0 100755 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -176,7 +176,7 @@ AccountOpResult ChangePassword(uint32 accountId, std::string newPassword) return AOR_OK; } -uint32 GetId(std::string username) +uint32 GetId(std::string const& username) { PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_ID_BY_USERNAME); stmt->setString(0, username); @@ -265,7 +265,7 @@ bool normalizeString(std::string& utf8String) return WStrToUtf8(buffer, maxLength, utf8String); } -std::string CalculateShaPassHash(std::string& name, std::string& password) +std::string CalculateShaPassHash(std::string const& name, std::string const& password) { SHA1Hash sha; sha.Initialize(); diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index aaaf4f4f603..c14bcc48bdc 100755 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -42,12 +42,12 @@ namespace AccountMgr AccountOpResult ChangePassword(uint32 accountId, std::string newPassword); bool CheckPassword(uint32 accountId, std::string password); - uint32 GetId(std::string username); + uint32 GetId(std::string const& username); uint32 GetSecurity(uint32 accountId); uint32 GetSecurity(uint32 accountId, int32 realmId); bool GetName(uint32 accountId, std::string& name); uint32 GetCharactersCount(uint32 accountId); - std::string CalculateShaPassHash(std::string& name, std::string& password); + std::string CalculateShaPassHash(std::string const& name, std::string const& password); bool normalizeString(std::string& utf8String); bool IsPlayerAccount(uint32 gmlevel); diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index b2c110b790f..c5aabff7db6 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -906,7 +906,7 @@ void AchievementMgr<T>::SendAchievementEarned(AchievementEntry const* achievemen if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL | ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) { // broadcast realm first reached - WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetOwner()->GetName()) + 1 + 8 + 4 + 4); + WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, GetOwner()->GetName().size() + 1 + 8 + 4 + 4); data << GetOwner()->GetName(); data << uint64(GetOwner()->GetGUID()); data << uint32(achievement->ID); diff --git a/src/server/game/Addons/AddonMgr.cpp b/src/server/game/Addons/AddonMgr.cpp index a0789040e9a..a595c73c7c0 100755 --- a/src/server/game/Addons/AddonMgr.cpp +++ b/src/server/game/Addons/AddonMgr.cpp @@ -44,7 +44,6 @@ void LoadFromDB() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 known addons. DB table `addons` is empty!"); - return; } @@ -64,7 +63,6 @@ void LoadFromDB() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void SaveAddon(AddonInfo const& addon) diff --git a/src/server/game/Addons/AddonMgr.h b/src/server/game/Addons/AddonMgr.h index fd227b258c5..9efbabc8b9f 100755 --- a/src/server/game/Addons/AddonMgr.h +++ b/src/server/game/Addons/AddonMgr.h @@ -25,7 +25,8 @@ struct AddonInfo { AddonInfo(const std::string& name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey) - : Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) {} + : Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) + { } std::string Name; uint8 Enabled; @@ -56,4 +57,3 @@ namespace AddonMgr } #endif - diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index cfc1de4e68e..36193527f13 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -441,7 +441,7 @@ void Battlefield::BroadcastPacketToWar(WorldPacket& data) const player->GetSession()->SendPacket(&data); } -WorldPacket Battlefield::BuildWarningAnnPacket(std::string msg) +WorldPacket Battlefield::BuildWarningAnnPacket(std::string const& msg) { WorldPacket data(SMSG_MESSAGECHAT, 200); diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 00e55283c52..58954792c90 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -316,7 +316,7 @@ class Battlefield : public ZoneScript /// Called when a player enter in battlefield zone virtual void OnPlayerEnterZone(Player* /*player*/) {}; - WorldPacket BuildWarningAnnPacket(std::string msg); + WorldPacket BuildWarningAnnPacket(std::string const& msg); void SendWarningToAllInZone(uint32 entry); //void SendWarningToAllInWar(int32 entry, ...); -- UNUSED void SendWarningToPlayer(Player* player, uint32 entry); diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 9ebe47e61f4..a8526985468 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -36,10 +36,9 @@ ArenaTeam::ArenaTeam() } ArenaTeam::~ArenaTeam() -{ -} +{ } -bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) +bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) { // Check if captain is present if (!ObjectAccessor::FindPlayer(captainGuid)) @@ -284,14 +283,15 @@ void ArenaTeam::SetCaptain(uint64 guid) CharacterDatabase.Execute(stmt); // Enable remove/promote buttons - Player* newCaptain = ObjectAccessor::FindPlayer(guid); - if (newCaptain) + if (Player* newCaptain = ObjectAccessor::FindPlayer(guid)) { newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0); - char const* oldCaptainName = oldCaptain ? oldCaptain->GetName() : ""; - uint32 oldCaptainLowGuid = oldCaptain ? oldCaptain->GetGUIDLow() : 0; - sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", - oldCaptainName, oldCaptainLowGuid, newCaptain->GetName(), newCaptain->GetGUIDLow(), GetId(), GetType()); + if (oldCaptain) + { + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", + oldCaptain->GetName().c_str(), oldCaptain->GetGUIDLow(), newCaptain->GetName().c_str(), + newCaptain->GetGUIDLow(), GetId(), GetType()); + } } } @@ -299,13 +299,11 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb) { // Remove member from team for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) - { if (itr->Guid == guid) { Members.erase(itr); break; } - } // Inform player and remove arena team info from player data if (Player* player = ObjectAccessor::FindPlayer(guid)) @@ -314,7 +312,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb) // delete all info regarding this team for (uint32 i = 0; i < ARENA_TEAM_END; ++i) player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0); - sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] left arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId()); + sLog->outDebug(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] left arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId()); } // Only used for single member deletion, for arena team disband we use a single query for more efficiency @@ -336,10 +334,10 @@ void ArenaTeam::Disband(WorldSession* session) // Broadcast update if (session) { - BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), ""); + BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName().c_str(), GetName(), ""); if (Player* player = session->GetPlayer()) - sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId()); + sLog->outDebug(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId()); } // Update database @@ -481,7 +479,7 @@ void ArenaTeam::BroadcastPacket(WorldPacket* packet) player->GetSession()->SendPacket(packet); } -void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3) +void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3) { WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1+1+1); data << uint8(event); diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 2528ab27141..1c07e377d96 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -120,7 +120,7 @@ class ArenaTeam ArenaTeam(); ~ArenaTeam(); - bool Create(uint64 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor); + bool Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor); void Disband(WorldSession* session); typedef std::list<ArenaTeamMember> MemberList; @@ -130,7 +130,7 @@ class ArenaTeam uint8 GetSlot() const { return GetSlotByType(GetType()); } static uint8 GetSlotByType(uint32 type); uint64 GetCaptain() const { return CaptainGuid; } - std::string GetName() const { return TeamName; } + std::string const& GetName() const { return TeamName; } const ArenaTeamStats& GetStats() const { return Stats; } uint32 GetRating() const { return Stats.Rating; } @@ -150,7 +150,7 @@ class ArenaTeam bool IsMember(uint64 guid) const; ArenaTeamMember* GetMember(uint64 guid); - ArenaTeamMember* GetMember(const std::string& name); + ArenaTeamMember* GetMember(std::string const& name); bool IsFighting() const; @@ -160,7 +160,7 @@ class ArenaTeam void SaveToDB(); void BroadcastPacket(WorldPacket* packet); - void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3); + void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3); void NotifyStatsChanged(); void Roster(WorldSession* session); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 699445f8ccc..1e252b5b705 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -323,7 +323,7 @@ inline void Battleground::_CheckSafePositions(uint32 diff) GetTeamStartLoc(player->GetBGTeam(), x, y, z, o); if (pos.GetExactDistSq(x, y, z) > maxDist) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName(), GetMapId()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId()); player->TeleportTo(GetMapId(), x, y, z, o); } } @@ -796,7 +796,12 @@ void Battleground::EndBattleground(uint32 winner) if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO)) for (Battleground::BattlegroundScoreMap::const_iterator itr = GetPlayerScoresBegin(); itr != GetPlayerScoresEnd(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(itr->first)) - sLog->outDebug(LOG_FILTER_ARENAS, "Statistics match Type: %u for %s (GUID: " UI64FMTD ", Team: %d, IP: %s): %u damage, %u healing, %u killing blows", m_ArenaType, player->GetName(), itr->first, player->GetArenaTeamId(m_ArenaType == 5 ? 2 : m_ArenaType == 3), player->GetSession()->GetRemoteAddress().c_str(), itr->second->DamageDone, itr->second->HealingDone, itr->second->KillingBlows); + { + sLog->outDebug(LOG_FILTER_ARENAS, "Statistics match Type: %u for %s (GUID: " UI64FMTD ", Team: %d, IP: %s): %u damage, %u healing, %u killing blows", + m_ArenaType, player->GetName().c_str(), itr->first, player->GetArenaTeamId(m_ArenaType == 5 ? 2 : m_ArenaType == 3), + player->GetSession()->GetRemoteAddress().c_str(), itr->second->DamageDone, itr->second->HealingDone, + itr->second->KillingBlows); + } } // Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes else @@ -1087,7 +1092,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac if (Transport) player->TeleportToBGEntryPoint(); - sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName()); + sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName().c_str()); } //battleground object will be deleted next Battleground::Update() call @@ -1228,7 +1233,7 @@ void Battleground::AddPlayer(Player* player) AddOrSetPlayerToCorrectBgGroup(player, team); // Log - sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName()); + sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName().c_str()); } // this method adds player to his team's bg group, or sets his correct group if player is already in bg group diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 070f974e65a..c18a8c48f14 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -1219,11 +1219,11 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt uint32 team = player->GetBGTeam(); bg->GetTeamStartLoc(team, x, y, z, O); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Sending %s to map %u, X %f, Y %f, Z %f, O %f (bgType %u)", player->GetName(), mapid, x, y, z, O, bgTypeId); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Sending %s to map %u, X %f, Y %f, Z %f, O %f (bgType %u)", player->GetName().c_str(), mapid, x, y, z, O, bgTypeId); player->TeleportTo(mapid, x, y, z, O); } else - sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName()); + sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName().c_str()); } void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 19e574dc137..25b0f86fbe2 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -476,7 +476,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", - player->GetName(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); + player->GetName().c_str(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); // send status packet sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, player, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, player->GetBattlegroundQueueJoinTime(bgTypeId), ginfo->ArenaType); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index ee25f72b382..e900bc9b1d3 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -648,9 +648,9 @@ void BattlegroundEY::EventPlayerClickedOnFlag(Player* Source, GameObject* target Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (Source->GetTeam() == ALLIANCE) - PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName()); + PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName().c_str()); else - PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName()); + PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName().c_str()); } void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 07fb7fbe020..12eb68b33af 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -86,13 +86,13 @@ bool BattlegroundSA::ResetObjs() for (uint8 i = 0; i < 6; i++) GateStatus[i] = BG_SA_GATE_OK; - for (uint8 i = 0; i < BG_SA_BOAT_ONE; i++) + for (uint8 i = 0; i <= BG_SA_PORTAL_DEFFENDER_RED; i++) { if (!AddObject(i, BG_SA_ObjEntries[i], BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], BG_SA_ObjSpawnlocs[i][2], BG_SA_ObjSpawnlocs[i][3], 0, 0, 0, 0, RESPAWN_ONE_DAY)) return false; } - for (uint8 i = BG_SA_BOAT_ONE; i < BG_SA_SIGIL_1; i++) + for (uint8 i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++) { uint32 boatid = 0; switch (i) @@ -113,7 +113,7 @@ bool BattlegroundSA::ResetObjs() return false; } - for (uint8 i = BG_SA_SIGIL_1; i < BG_SA_CENTRAL_FLAG; i++) + for (uint8 i = BG_SA_SIGIL_1; i <= BG_SA_LEFT_FLAGPOLE; i++) { if (!AddObject(i, BG_SA_ObjEntries[i], BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], @@ -141,7 +141,7 @@ bool BattlegroundSA::ResetObjs() OverrideGunFaction(); DemolisherStartState(true); - for (uint8 i = 0; i <= BG_SA_TITAN_RELIC; i++) + for (uint8 i = 0; i <= BG_SA_PORTAL_DEFFENDER_RED; i++) { SpawnBGObject(i, RESPAWN_IMMEDIATELY); GetBGObject(i)->SetUInt32Value(GAMEOBJECT_FACTION, defF); @@ -182,7 +182,7 @@ bool BattlegroundSA::ResetObjs() } //GY capture points - for (uint8 i = BG_SA_CENTRAL_FLAG; i < BG_SA_PORTAL_DEFFENDER_BLUE; i++) + for (uint8 i = BG_SA_CENTRAL_FLAG; i <= BG_SA_LEFT_FLAG; i++) { AddObject(i, (BG_SA_ObjEntries[i] - (Attackers == TEAM_ALLIANCE ? 1 : 0)), BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], @@ -191,15 +191,6 @@ bool BattlegroundSA::ResetObjs() GetBGObject(i)->SetUInt32Value(GAMEOBJECT_FACTION, atF); } - for (uint8 i = BG_SA_PORTAL_DEFFENDER_BLUE; i < BG_SA_BOMB; i++) - { - AddObject(i, BG_SA_ObjEntries[i], - BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], - BG_SA_ObjSpawnlocs[i][2], BG_SA_ObjSpawnlocs[i][3], - 0, 0, 0, 0, RESPAWN_ONE_DAY); - GetBGObject(i)->SetUInt32Value(GAMEOBJECT_FACTION, defF); - } - for (uint8 i = BG_SA_BOMB; i < BG_SA_MAXOBJ; i++) { AddObject(i, BG_SA_ObjEntries[BG_SA_BOMB], @@ -657,7 +648,7 @@ void BattlegroundSA::DestroyGate(Player* player, GameObject* go) } if (i < 5) - DelObject(i+9); + DelObject(i + 14); UpdatePlayerScore(player, SCORE_DESTROYED_WALL, 1); if (rewardHonor) UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(1)); @@ -974,4 +965,3 @@ void BattlegroundSA::SendTransportsRemove(Player* player) player->GetSession()->SendPacket(&packet); } } - diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 6de3731da50..9089f0c2818 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -228,6 +228,11 @@ enum BG_SA_Objects BG_SA_PURPLE_GATE, BG_SA_ANCIENT_GATE, BG_SA_TITAN_RELIC, + BG_SA_PORTAL_DEFFENDER_BLUE, + BG_SA_PORTAL_DEFFENDER_GREEN, + BG_SA_PORTAL_DEFFENDER_YELLOW, + BG_SA_PORTAL_DEFFENDER_PURPLE, + BG_SA_PORTAL_DEFFENDER_RED, BG_SA_BOAT_ONE, BG_SA_BOAT_TWO, BG_SA_SIGIL_1, @@ -241,11 +246,6 @@ enum BG_SA_Objects BG_SA_CENTRAL_FLAG, BG_SA_RIGHT_FLAG, BG_SA_LEFT_FLAG, - BG_SA_PORTAL_DEFFENDER_BLUE, - BG_SA_PORTAL_DEFFENDER_GREEN, - BG_SA_PORTAL_DEFFENDER_YELLOW, - BG_SA_PORTAL_DEFFENDER_PURPLE, - BG_SA_PORTAL_DEFFENDER_RED, BG_SA_BOMB, BG_SA_MAXOBJ = BG_SA_BOMB+68 }; @@ -259,6 +259,12 @@ float const BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] = { 1214.681f, 81.21f, 53.413f, 5.745f }, { 878.555f, -108.2f, 117.845f, 0.0f }, { 836.5f, -108.8f, 120.219f, 0.0f }, + // Portal + {1468.380005f, -225.798996f, 30.896200f, 0.0f}, //blue + {1394.270020f, 72.551399f, 31.054300f, 0.0f}, //green + {1065.260010f, -89.79501f, 81.073402f, 0.0f}, //yellow + {1216.069946f, 47.904301f, 54.278198f, 0.0f}, //purple + {1255.569946f, -233.548996f, 56.43699f, 0.0f}, //red // Ships { 2679.696777f, -826.891235f, 3.712860f, 5.78367f}, //rot2 1 rot3 0.0002f { 2574.003662f, 981.261475f, 2.603424f, 0.807696f}, @@ -276,12 +282,6 @@ float const BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] = { 1215.108032f, -65.715767f, 70.084267f, -3.124123f}, { 1338.859253f, -153.327316f, 30.895077f, -2.530723f}, { 1309.192017f, 9.416233f, 30.893402f, 1.518436f}, - // Portal - {1468.380005f, -225.798996f, 30.896200f, 0.0f}, //blue - {1394.270020f, 72.551399f, 31.054300f, 0.0f}, //green - {1065.260010f, -89.79501f, 81.073402f, 0.0f}, //yellow - {1216.069946f, 47.904301f, 54.278198f, 0.0f}, //purple - {1255.569946f, -233.548996f, 56.43699f, 0.0f}, //red // Bombs {1333.45f, 211.354f, 31.0538f, 5.03666f}, {1334.29f, 209.582f, 31.0532f, 1.28088f}, @@ -375,6 +375,11 @@ uint32 const BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] = 190723, 192549, 192834, + 192819, + 192819, + 192819, + 192819, + 192819, 0, // Boat 0, // Boat 192687, @@ -388,11 +393,6 @@ uint32 const BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] = 191310, 191306, 191308, - 192819, - 192819, - 192819, - 192819, - 192819, 190753 }; diff --git a/src/server/game/Calendar/Calendar.h b/src/server/game/Calendar/Calendar.h index a2d2dc2ffb7..273db4c3854 100755 --- a/src/server/game/Calendar/Calendar.h +++ b/src/server/game/Calendar/Calendar.h @@ -46,8 +46,8 @@ class CalendarInvite void SetStatusTime(uint32 statusTime) { _statusTime = statusTime; } uint32 GetStatusTime() const { return _statusTime; } - void SetText(std::string text) { _text = text; } - std::string GetText() const { return _text; } + void SetText(std::string const& text) { _text = text; } + std::string const& GetText() const { return _text; } void SetStatus(CalendarInviteStatus status) { _status = status; } CalendarInviteStatus GetStatus() const { return _status; } @@ -89,11 +89,11 @@ class CalendarEvent void SetGuildId(uint32 guildId) { _guildId = guildId; } uint32 GetGuildId() const { return _guildId; } - void SetTitle(std::string title) { _title = title; } - std::string GetTitle() const { return _title; } + void SetTitle(std::string const& title) { _title = title; } + std::string const& GetTitle() const { return _title; } - void SetDescription(std::string description) { _description = description; } - std::string GetDescription() const { return _description; } + void SetDescription(std::string const& description) { _description = description; } + std::string const& GetDescription() const { return _description; } void SetType(CalendarEventType type) { _type = type; } CalendarEventType GetType() const { return _type; } diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 579f322594a..66f964fb4cf 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -24,8 +24,9 @@ #include "DatabaseEnv.h" #include "AccountMgr.h" -Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) - : m_announce(true), m_ownership(true), m_name(name), m_password(""), m_flags(0), m_channelId(channel_id), m_ownerGUID(0), m_Team(Team) +Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) : m_announce(true), + m_ownership(true), m_name(name), m_password(""), m_flags(0), m_channelId(channel_id), + m_ownerGUID(0), m_Team(Team) { m_IsSaved = false; // set special flags if built-in channel @@ -70,10 +71,9 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) if (db_BannedList) { Tokenizer tokens(db_BannedList, ' '); - Tokenizer::const_iterator iter; - for (iter = tokens.begin(); iter != tokens.end(); ++iter) + for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i) { - uint64 banned_guid = atol(*iter); + uint64 banned_guid = atol(*i); if (banned_guid) { sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) loaded banned guid:" UI64FMTD "", name.c_str(), banned_guid); @@ -118,7 +118,6 @@ void Channel::UpdateChannelInDB() const sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) updated in database", m_name.c_str()); } - } void Channel::UpdateChannelUseageInDB() const diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index 28194659e06..bd82a7cfc90 100755 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -172,7 +172,7 @@ class Channel void MakeNotModerator(WorldPacket* data); //? 0x06 void MakePasswordChanged(WorldPacket* data, uint64 guid); //+ 0x07 void MakeOwnerChanged(WorldPacket* data, uint64 guid); //? 0x08 - void MakePlayerNotFound(WorldPacket* data, const std::string& name); //+ 0x09 + void MakePlayerNotFound(WorldPacket* data, std::string const& name); //+ 0x09 void MakeNotOwner(WorldPacket* data); //? 0x0A void MakeChannelOwner(WorldPacket* data); //? 0x0B void MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags); //+ 0x0C @@ -183,15 +183,15 @@ class Channel void MakeBanned(WorldPacket* data); //? 0x13 void MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good); //? 0x14 void MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good); //? 0x15 - void MakePlayerNotBanned(WorldPacket* data, const std::string& name); //? 0x16 + void MakePlayerNotBanned(WorldPacket* data, std::string const& name); //? 0x16 void MakePlayerAlreadyMember(WorldPacket* data, uint64 guid); //+ 0x17 void MakeInvite(WorldPacket* data, uint64 guid); //? 0x18 void MakeInviteWrongFaction(WorldPacket* data); //? 0x19 void MakeWrongFaction(WorldPacket* data); //? 0x1A void MakeInvalidName(WorldPacket* data); //? 0x1B void MakeNotModerated(WorldPacket* data); //? 0x1C - void MakePlayerInvited(WorldPacket* data, const std::string& name); //+ 0x1D - void MakePlayerInviteBanned(WorldPacket* data, const std::string &name);//? 0x1E + void MakePlayerInvited(WorldPacket* data, std::string const& name); //+ 0x1D + void MakePlayerInviteBanned(WorldPacket* data, std::string const& name);//? 0x1E void MakeThrottled(WorldPacket* data); //? 0x1F void MakeNotInArea(WorldPacket* data); //? 0x20 void MakeNotInLfg(WorldPacket* data); //? 0x21 @@ -245,14 +245,14 @@ class Channel public: uint32 m_Team; - Channel(const std::string& name, uint32 channel_id, uint32 Team = 0); - std::string GetName() const { return m_name; } + Channel(std::string const& name, uint32 channel_id, uint32 Team = 0); + std::string const& GetName() const { return m_name; } uint32 GetChannelId() const { return m_channelId; } bool IsConstant() const { return m_channelId != 0; } bool IsAnnounce() const { return m_announce; } bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } - std::string GetPassword() const { return m_password; } - void SetPassword(const std::string& npassword) { m_password = npassword; } + std::string const& GetPassword() const { return m_password; } + void SetPassword(std::string const& npassword) { m_password = npassword; } void SetAnnounce(bool nannounce) { m_announce = nannounce; } uint32 GetNumPlayers() const { return players.size(); } uint8 GetFlags() const { return m_flags; } diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 75436e1eb5f..78b71744e0e 100755 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -20,7 +20,15 @@ #include "World.h" -ChannelMgr* channelMgr(uint32 team) +ChannelMgr::~ChannelMgr() +{ + for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr) + delete itr->second; + + channels.clear(); +} + +ChannelMgr* ChannelMgr::forTeam(uint32 team) { if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); // cross-faction @@ -33,31 +41,25 @@ ChannelMgr* channelMgr(uint32 team) return NULL; } -ChannelMgr::~ChannelMgr() -{ - for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr) - delete itr->second; - - channels.clear(); -} - -Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id) +Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id) { std::wstring wname; Utf8toWStr(name, wname); wstrToLower(wname); - if (channels.find(wname) == channels.end()) + ChannelMap::const_iterator i = channels.find(wname); + + if (i == channels.end()) { Channel* nchan = new Channel(name, channel_id, team); channels[wname] = nchan; return nchan; } - return channels[wname]; + return i->second; } -Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) +Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pkt) { std::wstring wname; Utf8toWStr(name, wname); @@ -71,7 +73,7 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) { WorldPacket data; MakeNotOnPacket(&data, name); - p->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } return NULL; @@ -80,7 +82,7 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) return i->second; } -void ChannelMgr::LeftChannel(std::string name) +void ChannelMgr::LeftChannel(std::string const& name) { std::wstring wname; Utf8toWStr(name, wname); @@ -100,7 +102,7 @@ void ChannelMgr::LeftChannel(std::string name) } } -void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string name) +void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name) { data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size (*data) << (uint8)0x05 << name; diff --git a/src/server/game/Chat/Channels/ChannelMgr.h b/src/server/game/Chat/Channels/ChannelMgr.h index 887e53f49a5..c1d1793c446 100755 --- a/src/server/game/Chat/Channels/ChannelMgr.h +++ b/src/server/game/Chat/Channels/ChannelMgr.h @@ -29,23 +29,29 @@ class ChannelMgr { + typedef std::map<std::wstring, Channel*> ChannelMap; + public: - uint32 team; - typedef std::map<std::wstring, Channel*> ChannelMap; - ChannelMgr() {team = 0;} + ChannelMgr() : team(0) + { } + ~ChannelMgr(); - Channel* GetJoinChannel(std::string name, uint32 channel_id); - Channel* GetChannel(std::string name, Player* p, bool pkt = true); - void LeftChannel(std::string name); + static ChannelMgr * forTeam(uint32 team); + void setTeam(uint32 newTeam) { team = newTeam; } + + Channel* GetJoinChannel(std::string const& name, uint32 channel_id); + Channel* GetChannel(std::string const& name, Player* p, bool pkt = true); + void LeftChannel(std::string const& name); + private: ChannelMap channels; - void MakeNotOnPacket(WorldPacket* data, std::string name); + uint32 team; + + void MakeNotOnPacket(WorldPacket* data, std::string const& name); }; class AllianceChannelMgr : public ChannelMgr {}; class HordeChannelMgr : public ChannelMgr {}; -ChannelMgr* channelMgr(uint32 team); - #endif diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index c4ea71f7c4e..638d9208597 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -350,8 +350,8 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, co Player* p = m_session->GetPlayer(); uint64 sel_guid = p->GetSelection(); sLog->outCommand(m_session->GetAccountId(), "Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected %s: %s (GUID: %u)]", - fullcmd.c_str(), p->GetName(), m_session->GetAccountId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), p->GetMapId(), - GetLogNameForGuid(sel_guid), (p->GetSelectedUnit()) ? p->GetSelectedUnit()->GetName() : "", GUID_LOPART(sel_guid)); + fullcmd.c_str(), p->GetName().c_str(), m_session->GetAccountId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), p->GetMapId(), + GetLogNameForGuid(sel_guid), (p->GetSelectedUnit()) ? p->GetSelectedUnit()->GetName().c_str() : "", GUID_LOPART(sel_guid)); } } } @@ -370,7 +370,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, co return false; } -bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand) +bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, uint32 security, std::string const& help, std::string const& fullcommand) { std::string cmd = ""; @@ -425,7 +425,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, const char* text, return false; } -int ChatHandler::ParseCommands(const char* text) +int ChatHandler::ParseCommands(char const* text) { ASSERT(text); ASSERT(*text); @@ -465,7 +465,7 @@ int ChatHandler::ParseCommands(const char* text) return 1; } -bool ChatHandler::isValidChatMessage(const char* message) +bool ChatHandler::isValidChatMessage(char const* message) { /* Valid examples: @@ -663,7 +663,7 @@ void ChatHandler::FillMessageData(WorldPacket* data, WorldSession* session, uint { *data << uint64(speaker->GetGUID()); *data << uint32(0); // 2.1.0 - *data << uint32(strlen(speaker->GetName()) + 1); + *data << uint32(speaker->GetName().size() + 1); *data << speaker->GetName(); uint64 listener_guid = 0; *data << uint64(listener_guid); @@ -1034,7 +1034,7 @@ uint64 ChatHandler::extractGuidFromLink(char* text) if (!normalizePlayerName(name)) return 0; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) return player->GetGUID(); if (uint64 guid = sObjectMgr->GetPlayerGUIDByName(name)) @@ -1092,7 +1092,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe return false; } - Player* pl = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pl = sObjectAccessor->FindPlayerByName(name); // if allowed player pointer if (player) @@ -1227,7 +1227,7 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &player return false; } - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); if (offline) guid = sObjectMgr->GetPlayerGUIDByName(name.c_str()); } diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index bbb9870338c..473d000d808 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -128,7 +128,7 @@ class ChatHandler protected: explicit ChatHandler() : m_session(NULL), sentErrorMessage(false) {} // for CLI subclass static bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand); - bool ExecuteCommandInTable(ChatCommand* table, const char* text, const std::string& fullcmd); + bool ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd); bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd); private: diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 7a4c6b6bdce..383c8c14186 100755 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -253,25 +253,29 @@ Unit* HostileReference::getSourceUnit() void ThreatContainer::clearReferences() { - for (std::list<HostileReference*>::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { (*i)->unlink(); delete (*i); } + iThreatList.clear(); } //============================================================ // Return the HostileReference of NULL, if not found -HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) +HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const { if (!victim) return NULL; - uint64 guid = victim->GetGUID(); - for (std::list<HostileReference*>::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) - if ((*i) && (*i)->getUnitGuid() == guid) - return (*i); + uint64 const guid = victim->GetGUID(); + for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + { + HostileReference *ref = (*i); + if (ref && ref->getUnitGuid() == guid) + return ref; + } return NULL; } @@ -310,16 +314,16 @@ void ThreatContainer::update() // return the next best victim // could be the current victim -HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) +HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) const { HostileReference* currentRef = NULL; bool found = false; bool noPriorityTargetFound = false; - std::list<HostileReference*>::const_iterator lastRef = iThreatList.end(); + ThreatContainer::StorageType::const_iterator lastRef = iThreatList.end(); --lastRef; - for (std::list<HostileReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) + for (ThreatContainer::StorageType::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) { currentRef = (*iter); @@ -577,17 +581,15 @@ bool ThreatManager::isNeedUpdateToClient(uint32 time) return false; } -// Reset all aggro without modifying the threadlist. +// Reset all aggro without modifying the threatlist. void ThreatManager::resetAllAggro() { - std::list<HostileReference*> &threatList = getThreatList(); + ThreatContainer::StorageType &threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; - for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) - { + for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) (*itr)->setThreat(0); - } setDirty(true); } diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index e5badcd24ce..665acd6d751 100755 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -142,39 +142,57 @@ class ThreatManager; class ThreatContainer { - private: - std::list<HostileReference*> iThreatList; - bool iDirty; - protected: friend class ThreatManager; - void remove(HostileReference* hostileRef) { iThreatList.remove(hostileRef); } - void addReference(HostileReference* hostileRef) { iThreatList.push_back(hostileRef); } - void clearReferences(); - - // Sort the list if necessary - void update(); public: - ThreatContainer() { iDirty = false; } + typedef std::list<HostileReference*> StorageType; + + ThreatContainer(): iDirty(false) { } + ~ThreatContainer() { clearReferences(); } HostileReference* addThreat(Unit* victim, float threat); void modifyThreatPercent(Unit* victim, int32 percent); - HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim); + HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim) const; void setDirty(bool isDirty) { iDirty = isDirty; } bool isDirty() const { return iDirty; } - bool empty() const { return iThreatList.empty(); } + bool empty() const + { + return iThreatList.empty(); + } - HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } + HostileReference* getMostHated() const + { + return iThreatList.empty() ? NULL : iThreatList.front(); + } + + HostileReference* getReferenceByTarget(Unit* victim) const; - HostileReference* getReferenceByTarget(Unit* victim); + StorageType const & getThreatList() const { return iThreatList; } - std::list<HostileReference*>& getThreatList() { return iThreatList; } + private: + void remove(HostileReference* hostileRef) + { + iThreatList.remove(hostileRef); + } + + void addReference(HostileReference* hostileRef) + { + iThreatList.push_back(hostileRef); + } + + void clearReferences(); + + // Sort the list if necessary + void update(); + + StorageType iThreatList; + bool iDirty; }; //================================================= @@ -198,15 +216,15 @@ class ThreatManager float getThreat(Unit* victim, bool alsoSearchOfflineList = false); - bool isThreatListEmpty() { return iThreatContainer.empty(); } + bool isThreatListEmpty() const { return iThreatContainer.empty(); } void processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent); bool isNeedUpdateToClient(uint32 time); - HostileReference* getCurrentVictim() { return iCurrentVictim; } + HostileReference* getCurrentVictim() const { return iCurrentVictim; } - Unit* getOwner() { return iOwner; } + Unit* getOwner() const { return iOwner; } Unit* getHostilTarget(); @@ -223,11 +241,11 @@ class ThreatManager // Reset all aggro of unit in threadlist satisfying the predicate. template<class PREDICATE> void resetAggro(PREDICATE predicate) { - std::list<HostileReference*> &threatList = getThreatList(); + ThreatContainer::StorageType &threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; - for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { HostileReference* ref = (*itr); @@ -241,8 +259,8 @@ class ThreatManager // methods to access the lists from the outside to do some dirty manipulation (scriping and such) // I hope they are used as little as possible. - std::list<HostileReference*>& getThreatList() { return iThreatContainer.getThreatList(); } - std::list<HostileReference*>& getOfflineThreatList() { return iThreatOfflineContainer.getThreatList(); } + ThreatContainer::StorageType const & getThreatList() const { return iThreatContainer.getThreatList(); } + ThreatContainer::StorageType const & getOfflineThreatList() const { return iThreatOfflineContainer.getThreatList(); } ThreatContainer& getOnlineContainer() { return iThreatContainer; } ThreatContainer& getOfflineContainer() { return iThreatOfflineContainer; } private: @@ -273,4 +291,3 @@ namespace Trinity }; } #endif - diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 16fa33fc7a5..9f4fc78d879 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -662,7 +662,7 @@ ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureId, uint CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId); if (itr != VehicleSpellConditionStore.end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId); + ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId); if (i != (*itr).second.end()) { cond = (*i).second; diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index cf5b7bd53a2..a640fae92d4 100755 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -60,7 +60,6 @@ void LoadDisables() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 disables. DB table `disables` is empty!"); - return; } @@ -134,10 +133,12 @@ void LoadDisables() case MAP_INSTANCE: case MAP_RAID: if (flags & DUNGEON_STATUSFLAG_HEROIC && !GetMapDifficultyData(entry, DUNGEON_DIFFICULTY_HEROIC)) - isFlagInvalid = true; - else if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC)) - isFlagInvalid = true; - else if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC)) + flags -= DUNGEON_STATUSFLAG_HEROIC; + if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC)) + flags -= RAID_STATUSFLAG_10MAN_HEROIC; + if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC)) + flags -= RAID_STATUSFLAG_25MAN_HEROIC; + if (!flags) isFlagInvalid = true; break; case MAP_BATTLEGROUND: @@ -229,7 +230,6 @@ void LoadDisables() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime)); - } void CheckQuestDisables() @@ -240,7 +240,6 @@ void CheckQuestDisables() if (!count) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Checked 0 quest disables."); - return; } @@ -260,7 +259,6 @@ void CheckQuestDisables() } sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Checked %u quest disables in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags) diff --git a/src/server/game/DungeonFinding/LFG.h b/src/server/game/DungeonFinding/LFG.h index abdb0ffa511..6ad30547670 100755 --- a/src/server/game/DungeonFinding/LFG.h +++ b/src/server/game/DungeonFinding/LFG.h @@ -49,7 +49,7 @@ enum LfgUpdateType LFG_UPDATETYPE_GROUP_FOUND = 10, LFG_UPDATETYPE_ADDED_TO_QUEUE = 12, LFG_UPDATETYPE_PROPOSAL_BEGIN = 13, - LFG_UPDATETYPE_CLEAR_LOCK_LIST = 14, + LFG_UPDATETYPE_UPDATE_STATUS = 14, LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15, LFG_UPDATETYPE_GROUP_DISBAND_UNK16 = 16, // FIXME: Sometimes at group disband }; diff --git a/src/server/game/DungeonFinding/LFGGroupData.cpp b/src/server/game/DungeonFinding/LFGGroupData.cpp index 712ae5132b0..a4ee230b5eb 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.cpp +++ b/src/server/game/DungeonFinding/LFGGroupData.cpp @@ -93,11 +93,16 @@ LfgState LfgGroupData::GetOldState() const return m_OldState; } -const LfgGuidSet &LfgGroupData::GetPlayers() const +LfgGuidSet const& LfgGroupData::GetPlayers() const { return m_Players; } +uint8 LfgGroupData::GetPlayerCount() const +{ + return m_Players.size(); +} + uint64 LfgGroupData::GetLeader() const { return m_Leader; diff --git a/src/server/game/DungeonFinding/LFGGroupData.h b/src/server/game/DungeonFinding/LFGGroupData.h index 43cd64f97c3..2054e776282 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.h +++ b/src/server/game/DungeonFinding/LFGGroupData.h @@ -54,6 +54,7 @@ class LfgGroupData LfgState GetState() const; LfgState GetOldState() const; LfgGuidSet const& GetPlayers() const; + uint8 GetPlayerCount() const; uint64 GetLeader() const; // Dungeon diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index a1084e8807e..c91be00080e 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -40,7 +40,7 @@ LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1), LFGMgr::~LFGMgr() { - for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr) + for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr) delete itr->second; } @@ -52,8 +52,9 @@ void LFGMgr::_LoadFromDB(Field* fields, uint64 guid) if (!IS_GROUP(guid)) return; - uint32 dungeon = fields[16].GetUInt32(); + SetLeader(guid, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER)); + uint32 dungeon = fields[16].GetUInt32(); uint8 state = fields[17].GetUInt8(); if (!dungeon || !state) @@ -141,7 +142,7 @@ std::string LFGMgr::GetRolesString(uint8 roles) return rolesstr; } -char const * LFGMgr::GetStateString(LfgState state) +std::string LFGMgr::GetStateString(LfgState state) { int32 entry = LANG_LFG_ERROR; switch (state) @@ -171,8 +172,8 @@ char const * LFGMgr::GetStateString(LfgState state) entry = LANG_LFG_STATE_RAIDBROWSER; break; } - char const * const str = sObjectMgr->GetTrinityStringForDBCLocale(entry); - return str; + + return std::string(sObjectMgr->GetTrinityStringForDBCLocale(entry)); } /// Load rewards for completing dungeons @@ -180,9 +181,9 @@ void LFGMgr::LoadRewards() { uint32 oldMSTime = getMSTime(); - for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr) + for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr) delete itr->second; - m_RewardMap.clear(); + RewardMapStore.clear(); // ORDER BY is very important for GetRandomDungeonReward! QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC"); @@ -232,7 +233,7 @@ void LFGMgr::LoadRewards() otherQuestId = 0; } - m_RewardMap.insert(LfgRewardMap::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar))); + RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar))); ++count; } while (result->NextRow()); @@ -241,23 +242,23 @@ void LFGMgr::LoadRewards() LFGDungeonData const* LFGMgr::GetLFGDungeon(uint32 id) { - LFGDungeonMap::const_iterator itr = m_LfgDungeonMap.find(id); - if (itr != m_LfgDungeonMap.end()) + LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id); + if (itr != LfgDungeonStore.end()) return &(itr->second); return NULL; } -LFGDungeonMap & LFGMgr::GetLFGDungeonMap() +LFGDungeonContainer & LFGMgr::GetLFGDungeonMap() { - return m_LfgDungeonMap; + return LfgDungeonStore; } void LFGMgr::LoadLFGDungeons(bool reload /* = false */) { uint32 oldMSTime = getMSTime(); - m_LfgDungeonMap.clear(); + LfgDungeonStore.clear(); // Initialize Dungeon map with data from dbcs for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i) @@ -272,7 +273,7 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) case LFG_TYPE_HEROIC: case LFG_TYPE_RAID: case LFG_TYPE_RANDOM: - m_LfgDungeonMap[dungeon->ID] = LFGDungeonData(dungeon); + LfgDungeonStore[dungeon->ID] = LFGDungeonData(dungeon); break; } } @@ -292,8 +293,8 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) { Field* fields = result->Fetch(); uint32 dungeonId = fields[0].GetUInt32(); - LFGDungeonMap::iterator dungeonItr = m_LfgDungeonMap.find(dungeonId); - if (dungeonItr == m_LfgDungeonMap.end()) + LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId); + if (dungeonItr == LfgDungeonStore.end()) { sLog->outError(LOG_FILTER_SQL, "table `lfg_entrances` contains coordinates for wrong dungeon %u", dungeonId); continue; @@ -312,7 +313,7 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg entrance positions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); // Fill all other teleport coords from areatriggers - for (LFGDungeonMap::iterator itr = m_LfgDungeonMap.begin(); itr != m_LfgDungeonMap.end(); ++itr) + for (LFGDungeonContainer::iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr) { LFGDungeonData& dungeon = itr->second; @@ -334,15 +335,15 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) } if (dungeon.type != LFG_TYPE_RANDOM) - m_CachedDungeonMap[dungeon.group].insert(dungeon.id); - m_CachedDungeonMap[0].insert(dungeon.id); + CachedDungeonMapStore[dungeon.group].insert(dungeon.id); + CachedDungeonMapStore[0].insert(dungeon.id); } if (reload) { - m_CachedDungeonMap.clear(); + CachedDungeonMapStore.clear(); // Recalculate locked dungeons - for (LfgPlayerDataMap::const_iterator it = m_Players.begin(); it != m_Players.end(); ++it) + for (LfgPlayerDataContainer::const_iterator it = PlayersStore.begin(); it != PlayersStore.end(); ++it) if (Player* player = ObjectAccessor::FindPlayer(it->first)) InitializeLockedDungeons(player); } @@ -356,9 +357,9 @@ void LFGMgr::Update(uint32 diff) time_t currTime = time(NULL); // Remove obsolete role checks - for (LfgRoleCheckMap::iterator it = m_RoleChecks.begin(); it != m_RoleChecks.end();) + for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();) { - LfgRoleCheckMap::iterator itRoleCheck = it++; + LfgRoleCheckContainer::iterator itRoleCheck = it++; LfgRoleCheck& roleCheck = itRoleCheck->second; if (currTime < roleCheck.cancelTime) continue; @@ -372,26 +373,26 @@ void LFGMgr::Update(uint32 diff) if (guid == roleCheck.leader) SendLfgJoinResult(guid, LfgJoinResultData(LFG_JOIN_FAILED, LFG_ROLECHECK_MISSING_ROLE)); } - m_RoleChecks.erase(itRoleCheck); + RoleChecksStore.erase(itRoleCheck); } // Remove obsolete proposals - for (LfgProposalMap::iterator it = m_Proposals.begin(); it != m_Proposals.end();) + for (LfgProposalContainer::iterator it = ProposalsStore.begin(); it != ProposalsStore.end();) { - LfgProposalMap::iterator itRemove = it++; + LfgProposalContainer::iterator itRemove = it++; if (itRemove->second.cancelTime < currTime) RemoveProposal(itRemove, LFG_UPDATETYPE_PROPOSAL_FAILED); } // Remove obsolete kicks - for (LfgPlayerBootMap::iterator it = m_Boots.begin(); it != m_Boots.end();) + for (LfgPlayerBootContainer::iterator it = BootsStore.begin(); it != BootsStore.end();) { - LfgPlayerBootMap::iterator itBoot = it++; + LfgPlayerBootContainer::iterator itBoot = it++; LfgPlayerBoot& boot = itBoot->second; if (boot.cancelTime < currTime) { boot.inProgress = false; - for (LfgAnswerMap::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) + for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { uint64 pguid = itVotes->first; if (pguid != boot.victim) @@ -399,26 +400,26 @@ void LFGMgr::Update(uint32 diff) SetState(pguid, LFG_STATE_DUNGEON); } SetState(itBoot->first, LFG_STATE_DUNGEON); - m_Boots.erase(itBoot); + BootsStore.erase(itBoot); } } uint32 lastProposalId = m_lfgProposalId; // Check if a proposal can be formed with the new groups being added - for (LfgQueueMap::iterator it = m_Queues.begin(); it != m_Queues.end(); ++it) + for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it) if (uint8 newProposals = it->second.FindGroups()) sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Update: Found %u new groups in queue %u", newProposals, it->first); if (lastProposalId != m_lfgProposalId) { // FIXME lastProposalId ? lastProposalId +1 ? - for (LfgProposalMap::const_iterator itProposal = m_Proposals.find(m_lfgProposalId); itProposal != m_Proposals.end(); ++itProposal) + for (LfgProposalContainer::const_iterator itProposal = ProposalsStore.find(m_lfgProposalId); itProposal != ProposalsStore.end(); ++itProposal) { uint32 proposalId = itProposal->first; - LfgProposal& proposal = m_Proposals[proposalId]; + LfgProposal& proposal = ProposalsStore[proposalId]; uint64 guid = 0; - for (LfgProposalPlayerMap::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) + for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) { guid = itPlayers->first; SetState(guid, LFG_STATE_PROPOSAL); @@ -442,7 +443,7 @@ void LFGMgr::Update(uint32 diff) { m_QueueTimer = 0; time_t currTime = time(NULL); - for (LfgQueueMap::iterator it = m_Queues.begin(); it != m_Queues.end(); ++it) + for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it) it->second.UpdateQueueTimers(currTime); } else @@ -562,7 +563,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const } else // Remove from queue and rejoin { - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.RemoveFromQueue(gguid); } } @@ -673,7 +674,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const if (grp) // Begin rolecheck { // Create new rolecheck - LfgRoleCheck& roleCheck = m_RoleChecks[gguid]; + LfgRoleCheck& roleCheck = RoleChecksStore[gguid]; roleCheck.cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK; roleCheck.state = LFG_ROLECHECK_INITIALITING; roleCheck.leader = guid; @@ -711,7 +712,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const { LfgRolesMap rolesMap; rolesMap[guid] = roles; - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.AddQueueData(guid, time_t(time(NULL)), dungeons, rolesMap); if (!isContinue) @@ -757,7 +758,7 @@ void LFGMgr::LeaveLfg(uint64 guid) case LFG_STATE_QUEUED: if (gguid) { - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.RemoveFromQueue(gguid); RestoreState(gguid, "Leave queue"); const LfgGuidSet& players = GetPlayers(gguid); @@ -770,7 +771,7 @@ void LFGMgr::LeaveLfg(uint64 guid) } else { - LfgQueue& queue = GetQueue(guid); + LFGQueue& queue = GetQueue(guid); queue.RemoveFromQueue(guid); SendLfgUpdatePlayer(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE)); ClearState(guid, "Leave queue"); @@ -783,11 +784,11 @@ void LFGMgr::LeaveLfg(uint64 guid) case LFG_STATE_PROPOSAL: { // Remove from Proposals - LfgProposalMap::iterator it = m_Proposals.begin(); + LfgProposalContainer::iterator it = ProposalsStore.begin(); uint64 pguid = gguid == guid ? GetLeader(gguid) : guid; - while (it != m_Proposals.end()) + while (it != ProposalsStore.end()) { - LfgProposalPlayerMap::iterator itPlayer = it->second.players.find(pguid); + LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid); if (itPlayer != it->second.players.end()) { // Mark the player/leader of group who left as didn't accept the proposal @@ -798,7 +799,7 @@ void LFGMgr::LeaveLfg(uint64 guid) } // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue - if (it != m_Proposals.end()) + if (it != ProposalsStore.end()) RemoveProposal(it, LFG_UPDATETYPE_PROPOSAL_DECLINED); break; } @@ -820,8 +821,8 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* return; LfgRolesMap check_roles; - LfgRoleCheckMap::iterator itRoleCheck = m_RoleChecks.find(gguid); - if (itRoleCheck == m_RoleChecks.end()) + LfgRoleCheckContainer::iterator itRoleCheck = RoleChecksStore.find(gguid); + if (itRoleCheck == RoleChecksStore.end()) return; LfgRoleCheck& roleCheck = itRoleCheck->second; @@ -884,14 +885,14 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* if (roleCheck.state == LFG_ROLECHECK_FINISHED) { SetState(gguid, LFG_STATE_QUEUED); - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.AddQueueData(gguid, time_t(time(NULL)), roleCheck.dungeons, roleCheck.roles); - m_RoleChecks.erase(itRoleCheck); + RoleChecksStore.erase(itRoleCheck); } else if (roleCheck.state != LFG_ROLECHECK_INITIALITING) { RestoreState(gguid, "Rolecheck Failed"); - m_RoleChecks.erase(itRoleCheck); + RoleChecksStore.erase(itRoleCheck); } } @@ -949,19 +950,19 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true if (it->second == PLAYER_ROLE_NONE) return false; - if (it->second & PLAYER_ROLE_TANK) + if (it->second & PLAYER_ROLE_DAMAGE) { - if (it->second != PLAYER_ROLE_TANK) + if (it->second != PLAYER_ROLE_DAMAGE) { - it->second -= PLAYER_ROLE_TANK; + it->second -= PLAYER_ROLE_DAMAGE; if (CheckGroupRoles(groles, false)) return true; - it->second += PLAYER_ROLE_TANK; + it->second += PLAYER_ROLE_DAMAGE; } - else if (tank == LFG_TANKS_NEEDED) + else if (damage == LFG_DPS_NEEDED) return false; else - tank++; + damage++; } if (it->second & PLAYER_ROLE_HEALER) @@ -979,19 +980,19 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true healer++; } - if (it->second & PLAYER_ROLE_DAMAGE) + if (it->second & PLAYER_ROLE_TANK) { - if (it->second != PLAYER_ROLE_DAMAGE) + if (it->second != PLAYER_ROLE_TANK) { - it->second -= PLAYER_ROLE_DAMAGE; + it->second -= PLAYER_ROLE_TANK; if (CheckGroupRoles(groles, false)) return true; - it->second += PLAYER_ROLE_DAMAGE; + it->second += PLAYER_ROLE_TANK; } - else if (damage == LFG_DPS_NEEDED) + else if (tank == LFG_TANKS_NEEDED) return false; else - damage++; + tank++; } } return (tank + healer + damage) == uint8(groles.size()); @@ -1006,7 +1007,7 @@ void LFGMgr::MakeNewGroup(const LfgProposal& proposal) LfgGuidList players; LfgGuidList playersToTeleport; - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 guid = it->first; if (guid == proposal.leader) @@ -1071,7 +1072,7 @@ void LFGMgr::MakeNewGroup(const LfgProposal& proposal) uint32 LFGMgr::AddProposal(LfgProposal const& proposal) { - m_Proposals[++m_lfgProposalId] = proposal; + ProposalsStore[++m_lfgProposalId] = proposal; return m_lfgProposalId; } @@ -1085,14 +1086,14 @@ uint32 LFGMgr::AddProposal(LfgProposal const& proposal) void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) { // Check if the proposal exists - LfgProposalMap::iterator itProposal = m_Proposals.find(proposalId); - if (itProposal == m_Proposals.end()) + LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId); + if (itProposal == ProposalsStore.end()) return; LfgProposal& proposal = itProposal->second; // Check if proposal have the current player - LfgProposalPlayerMap::iterator itProposalPlayer = proposal.players.find(guid); + LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid); if (itProposalPlayer == proposal.players.end()) return; @@ -1108,13 +1109,13 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) // check if all have answered and reorder players (leader first) bool allAnswered = true; - for (LfgProposalPlayerMap::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) + for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0) allAnswered = false; if (!allAnswered) { - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 guid = it->first; SendLfgUpdateProposal(guid, proposalId, proposal); @@ -1126,9 +1127,9 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) proposal.state = LFG_PROPOSAL_SUCCESS; time_t joinTime = time_t(time(NULL)); - LfgQueue& queue = GetQueue(guid); + LFGQueue& queue = GetQueue(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 pguid = it->first; uint64 gguid = it->second.group; @@ -1170,7 +1171,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) break; } - m_teleport.push_back(pguid); + teleportStore.push_back(pguid); SetState(pguid, LFG_STATE_DUNGEON); } @@ -1179,7 +1180,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) queue.RemoveFromQueue(*it); MakeNewGroup(proposal); - m_Proposals.erase(itProposal); + ProposalsStore.erase(itProposal); } /** @@ -1188,7 +1189,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) @param[in] itProposal Iterator to the proposal to remove @param[in] type Type of removal (LFG_UPDATETYPE_PROPOSAL_FAILED, LFG_UPDATETYPE_PROPOSAL_DECLINED) */ -void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type) +void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type) { LfgProposal& proposal = itProposal->second; proposal.state = LFG_PROPOSAL_FAILED; @@ -1196,13 +1197,13 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemoveProposal: Proposal %u, state FAILED, UpdateType %u", itProposal->first, type); // Mark all people that didn't answered as no accept if (type == LFG_UPDATETYPE_PROPOSAL_FAILED) - for (LfgProposalPlayerMap::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) if (it->second.accept == LFG_ANSWER_PENDING) it->second.accept = LFG_ANSWER_DENY; // Mark players/groups to be removed LfgGuidSet toRemove; - for (LfgProposalPlayerMap::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { if (it->second.accept == LFG_ANSWER_AGREE) continue; @@ -1217,7 +1218,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t } // Notify players - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 guid = it->first; uint64 gguid = it->second.group ? it->second.group : guid; @@ -1260,7 +1261,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t } } - LfgQueue& queue = GetQueue(proposal.players.begin()->first); + LFGQueue& queue = GetQueue(proposal.players.begin()->first); // Remove players/groups from queue for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it) { @@ -1276,7 +1277,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t queue.AddToQueue(guid); } - m_Proposals.erase(itProposal); + ProposalsStore.erase(itProposal); } /** @@ -1291,7 +1292,7 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co { SetState(gguid, LFG_STATE_BOOT); - LfgPlayerBoot& boot = m_Boots[gguid]; + LfgPlayerBoot& boot = BootsStore[gguid]; boot.inProgress = true; boot.cancelTime = time_t(time(NULL)) + LFG_TIME_BOOT; boot.reason = reason; @@ -1327,8 +1328,8 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) if (!gguid) return; - LfgPlayerBootMap::iterator itBoot = m_Boots.find(gguid); - if (itBoot == m_Boots.end()) + LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid); + if (itBoot == BootsStore.end()) return; LfgPlayerBoot& boot = itBoot->second; @@ -1340,7 +1341,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) uint8 votesNum = 0; uint8 agreeNum = 0; - for (LfgAnswerMap::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) + for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { if (itVotes->second != LFG_ANSWER_PENDING) { @@ -1356,7 +1357,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) // Send update info to all players boot.inProgress = false; - for (LfgAnswerMap::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) + for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { uint64 pguid = itVotes->first; if (pguid != boot.victim) @@ -1373,7 +1374,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG); DecreaseKicksLeft(gguid); } - m_Boots.erase(itBoot); + BootsStore.erase(itBoot); } /** @@ -1385,16 +1386,24 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) */ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/) { - Group* grp = player->GetGroup(); - uint64 gguid = grp->GetGUID(); - LFGDungeonData const* dungeon = GetLFGDungeon(GetDungeon(gguid)); + LFGDungeonData const* dungeon = NULL; + Group* group = player->GetGroup(); + + if (group && group->isLFGGroup()) + dungeon = GetLFGDungeon(GetDungeon(group->GetGUID())); + if (!dungeon) + { + sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s not in group/lfggroup or dungeon not found!", + player->GetName().c_str()); + player->GetSession()->SendLfgTeleportError(uint8(LFG_TELEPORTERROR_INVALID_LOCATION)); return; + } if (out) { sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s is being teleported out. Current Map %u - Expected Map %u", - player->GetName(), player->GetMapId(), uint32(dungeon->map)); + player->GetName().c_str(), player->GetMapId(), uint32(dungeon->map)); if (player->GetMapId() == uint32(dungeon->map)) { player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); @@ -1406,9 +1415,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* LfgTeleportError error = LFG_TELEPORTERROR_OK; - if (!grp || !grp->isLFGGroup()) // should never happen, but just in case... - error = LFG_TELEPORTERROR_INVALID_LOCATION; - else if (!player->isAlive()) + if (!player->isAlive()) error = LFG_TELEPORTERROR_PLAYER_DEAD; else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING)) error = LFG_TELEPORTERROR_FALLING; @@ -1429,7 +1436,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* if (!fromOpcode) { // Select a player inside to be teleported to - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) + for (GroupReference* itr = group->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) { Player* plrg = itr->getSource(); if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map)) @@ -1439,6 +1446,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* y = plrg->GetPositionY(); z = plrg->GetPositionZ(); orientation = plrg->GetOrientation(); + break; } } } @@ -1466,7 +1474,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* player->GetSession()->SendLfgTeleportError(uint8(error)); sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s is being teleported in. Result: %u", - player->GetName(), error); + player->GetName().c_str(), error); } /** @@ -1560,7 +1568,7 @@ const LfgDungeonSet& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) { LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon); uint32 group = dungeon ? dungeon->group : 0; - return m_CachedDungeonMap[group]; + return CachedDungeonMapStore[group]; } /** @@ -1573,8 +1581,8 @@ const LfgDungeonSet& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) LfgReward const* LFGMgr::GetRandomDungeonReward(uint32 dungeon, uint8 level) { LfgReward const* rew = NULL; - LfgRewardMapBounds bounds = m_RewardMap.equal_range(dungeon & 0x00FFFFFF); - for (LfgRewardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF); + for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { rew = itr->second; // ordered properly at loading @@ -1604,9 +1612,9 @@ LfgState LFGMgr::GetState(uint64 guid) { LfgState state; if (IS_GROUP(guid)) - state = m_Groups[guid].GetState(); + state = GroupsStore[guid].GetState(); else - state = m_Players[guid].GetState(); + state = PlayersStore[guid].GetState(); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetState: [" UI64FMTD "] = %u", guid, state); return state; @@ -1614,29 +1622,41 @@ LfgState LFGMgr::GetState(uint64 guid) uint32 LFGMgr::GetDungeon(uint64 guid, bool asId /*= true */) { - uint32 dungeon = m_Groups[guid].GetDungeon(asId); + uint32 dungeon = GroupsStore[guid].GetDungeon(asId); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetDungeon: [" UI64FMTD "] asId: %u = %u", guid, asId, dungeon); return dungeon; } +uint32 LFGMgr::GetDungeonMapId(uint64 guid) +{ + uint32 dungeonId = GroupsStore[guid].GetDungeon(true); + uint32 mapId = 0; + if (dungeonId) + if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId)) + mapId = dungeon->map; + + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetDungeonMapId: [" UI64FMTD "] = %u (DungeonId = %u)", guid, mapId, dungeonId); + return mapId; +} + uint8 LFGMgr::GetRoles(uint64 guid) { - uint8 roles = m_Players[guid].GetRoles(); + uint8 roles = PlayersStore[guid].GetRoles(); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetRoles: [" UI64FMTD "] = %u", guid, roles); return roles; } const std::string& LFGMgr::GetComment(uint64 guid) { - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetComment: [" UI64FMTD "] = %s", guid, m_Players[guid].GetComment().c_str()); - return m_Players[guid].GetComment(); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetComment: [" UI64FMTD "] = %s", guid, PlayersStore[guid].GetComment().c_str()); + return PlayersStore[guid].GetComment(); } bool LFGMgr::IsTeleported(uint64 pguid) { - if (std::find(m_teleport.begin(), m_teleport.end(), pguid) != m_teleport.end()) + if (std::find(teleportStore.begin(), teleportStore.end(), pguid) != teleportStore.end()) { - m_teleport.remove(pguid); + teleportStore.remove(pguid); return true; } return false; @@ -1645,37 +1665,46 @@ bool LFGMgr::IsTeleported(uint64 pguid) const LfgDungeonSet& LFGMgr::GetSelectedDungeons(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid); - return m_Players[guid].GetSelectedDungeons(); + return PlayersStore[guid].GetSelectedDungeons(); } const LfgLockMap& LFGMgr::GetLockedDungeons(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetLockedDungeons: [" UI64FMTD "]", guid); - return m_Players[guid].GetLockedDungeons(); + return PlayersStore[guid].GetLockedDungeons(); } uint8 LFGMgr::GetKicksLeft(uint64 guid) { - uint8 kicks = m_Groups[guid].GetKicksLeft(); + uint8 kicks = GroupsStore[guid].GetKicksLeft(); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetKicksLeft: [" UI64FMTD "] = %u", guid, kicks); return kicks; } void LFGMgr::RestoreState(uint64 guid, char const *debugMsg) { - LfgGroupData& data = m_Groups[guid]; - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s), State: %s, oldState: %s", guid, debugMsg, ps, os); + LfgGroupData& data = GroupsStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s) State: %s, oldState: %s", + guid, debugMsg, ps.c_str(), os.c_str()); + } + data.RestoreState(); } void LFGMgr::ClearState(uint64 guid, char const *debugMsg) { - LfgPlayerData& data = m_Players[guid]; - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", guid, debugMsg, ps, os); + LfgPlayerData& data = PlayersStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", + guid, debugMsg, ps.c_str(), os.c_str()); + } data.ClearState(); } @@ -1683,20 +1712,28 @@ void LFGMgr::SetState(uint64 guid, LfgState state) { if (IS_GROUP(guid)) { - LfgGroupData& data = m_Groups[guid]; - char const * const ns = GetStateString(state); - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns, ps, os); + LfgGroupData& data = GroupsStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ns = GetStateString(state); + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", + guid, ns.c_str(), ps.c_str(), os.c_str()); + } data.SetState(state); } else { - LfgPlayerData& data = m_Players[guid]; - char const * const ns = GetStateString(state); - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns, ps, os); + LfgPlayerData& data = PlayersStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ns = GetStateString(state); + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", + guid, ns.c_str(), ps.c_str(), os.c_str()); + } data.SetState(state); } } @@ -1704,73 +1741,83 @@ void LFGMgr::SetState(uint64 guid, LfgState state) void LFGMgr::SetDungeon(uint64 guid, uint32 dungeon) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetDungeon: [" UI64FMTD "] dungeon %u", guid, dungeon); - m_Groups[guid].SetDungeon(dungeon); + GroupsStore[guid].SetDungeon(dungeon); } void LFGMgr::SetRoles(uint64 guid, uint8 roles) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetRoles: [" UI64FMTD "] roles: %u", guid, roles); - m_Players[guid].SetRoles(roles); + PlayersStore[guid].SetRoles(roles); } void LFGMgr::SetComment(uint64 guid, const std::string& comment) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetComment: [" UI64FMTD "] comment: %s", guid, comment.c_str()); - m_Players[guid].SetComment(comment); + PlayersStore[guid].SetComment(comment); } void LFGMgr::SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetSelectedDungeons: [" UI64FMTD "]", guid); - m_Players[guid].SetSelectedDungeons(dungeons); + PlayersStore[guid].SetSelectedDungeons(dungeons); } void LFGMgr::SetLockedDungeons(uint64 guid, const LfgLockMap& lock) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid); - m_Players[guid].SetLockedDungeons(lock); + PlayersStore[guid].SetLockedDungeons(lock); } void LFGMgr::DecreaseKicksLeft(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::DecreaseKicksLeft: [" UI64FMTD "]", guid); - m_Groups[guid].DecreaseKicksLeft(); + GroupsStore[guid].DecreaseKicksLeft(); } void LFGMgr::RemovePlayerData(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemovePlayerData: [" UI64FMTD "]", guid); - LfgPlayerDataMap::iterator it = m_Players.find(guid); - if (it != m_Players.end()) - m_Players.erase(it); + LfgPlayerDataContainer::iterator it = PlayersStore.find(guid); + if (it != PlayersStore.end()) + PlayersStore.erase(it); } void LFGMgr::RemoveGroupData(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemoveGroupData: [" UI64FMTD "]", guid); - LfgGroupDataMap::iterator it = m_Groups.find(guid); - if (it != m_Groups.end()) - m_Groups.erase(it); + LfgGroupDataContainer::iterator it = GroupsStore.find(guid); + if (it == GroupsStore.end()) + return; + + LfgGuidSet const& players = it->second.GetPlayers(); + for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it) + { + uint64 guid = (*it); + ClearState(*it, "Group Disband"); + SetGroup(*it, 0); + SendLfgUpdateParty(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE)); + } + GroupsStore.erase(it); } uint8 LFGMgr::GetTeam(uint64 guid) { - return m_Players[guid].GetTeam(); + return PlayersStore[guid].GetTeam(); } uint8 LFGMgr::RemovePlayerFromGroup(uint64 gguid, uint64 guid) { - return m_Groups[gguid].RemovePlayer(guid); + return GroupsStore[gguid].RemovePlayer(guid); } void LFGMgr::AddPlayerToGroup(uint64 gguid, uint64 guid) { - m_Groups[gguid].AddPlayer(guid); + GroupsStore[gguid].AddPlayer(guid); } void LFGMgr::SetLeader(uint64 gguid, uint64 leader) { - m_Groups[gguid].SetLeader(leader); + GroupsStore[gguid].SetLeader(leader); } void LFGMgr::SetTeam(uint64 guid, uint8 team) @@ -1778,27 +1825,32 @@ void LFGMgr::SetTeam(uint64 guid, uint8 team) if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) team = 0; - m_Players[guid].SetTeam(team); + PlayersStore[guid].SetTeam(team); } uint64 LFGMgr::GetGroup(uint64 guid) { - return m_Players[guid].GetGroup(); + return PlayersStore[guid].GetGroup(); } void LFGMgr::SetGroup(uint64 guid, uint64 group) { - m_Players[guid].SetGroup(group); + PlayersStore[guid].SetGroup(group); } -const LfgGuidSet& LFGMgr::GetPlayers(uint64 guid) +LfgGuidSet const& LFGMgr::GetPlayers(uint64 guid) { - return m_Groups[guid].GetPlayers(); + return GroupsStore[guid].GetPlayers(); +} + +uint8 LFGMgr::GetPlayerCount(uint64 guid) +{ + return GroupsStore[guid].GetPlayerCount(); } uint64 LFGMgr::GetLeader(uint64 guid) { - return m_Groups[guid].GetLeader(); + return GroupsStore[guid].GetLeader(); } bool LFGMgr::HasIgnore(uint64 guid1, uint64 guid2) @@ -1816,43 +1868,43 @@ void LFGMgr::SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles) player->GetSession()->SendLfgRoleChosen(pguid, roles); } -void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, const LfgRoleCheck& roleCheck) +void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgRoleCheckUpdate(roleCheck); } -void LFGMgr::SendLfgUpdatePlayer(uint64 guid, const LfgUpdateData& data) +void LFGMgr::SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdatePlayer(data); } -void LFGMgr::SendLfgUpdateParty(uint64 guid, const LfgUpdateData& data) +void LFGMgr::SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdateParty(data); } -void LFGMgr::SendLfgJoinResult(uint64 guid, const LfgJoinResultData& data) +void LFGMgr::SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgJoinResult(data); } -void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, const LfgPlayerBoot& boot) +void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgBootProposalUpdate(boot); } -void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, const LfgProposal& proposal) +void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, LfgProposal const& proposal) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdateProposal(proposalId, proposal); } -void LFGMgr::SendLfgQueueStatus(uint64 guid, const LfgQueueStatusData& data) +void LFGMgr::SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgQueueStatus(data); @@ -1860,10 +1912,10 @@ void LFGMgr::SendLfgQueueStatus(uint64 guid, const LfgQueueStatusData& data) bool LFGMgr::IsLfgGroup(uint64 guid) { - return guid && IS_GROUP(guid) && m_Groups[guid].IsLfgGroup(); + return guid && IS_GROUP(guid) && GroupsStore[guid].IsLfgGroup(); } -LfgQueue& LFGMgr::GetQueue(uint64 guid) +LFGQueue& LFGMgr::GetQueue(uint64 guid) { uint8 queueId = 0; if (IS_GROUP(guid)) @@ -1875,10 +1927,10 @@ LfgQueue& LFGMgr::GetQueue(uint64 guid) } else queueId = GetTeam(guid); - return m_Queues[queueId]; + return QueuesStore[queueId]; } -bool LFGMgr::AllQueued(const LfgGuidList& check) +bool LFGMgr::AllQueued(LfgGuidList const& check) { if (check.empty()) return false; @@ -1892,7 +1944,7 @@ bool LFGMgr::AllQueued(const LfgGuidList& check) // Only for debugging purposes void LFGMgr::Clean() { - m_Queues.clear(); + QueuesStore.clear(); } bool LFGMgr::isOptionEnabled(uint32 option) @@ -1910,6 +1962,13 @@ void LFGMgr::SetOptions(uint32 options) m_options = options; } +LfgState LFGMgr::GetLfgStatus(uint64 guid, LfgUpdateData& data) +{ + LfgPlayerData& playerData = PlayersStore[guid]; + data.dungeons = playerData.GetSelectedDungeons(); + return playerData.GetState(); +} + bool LFGMgr::IsSeasonActive(uint32 dungeonId) { switch (dungeonId) @@ -1926,24 +1985,28 @@ bool LFGMgr::IsSeasonActive(uint32 dungeonId) return false; } -std::string LFGMgr::DumpQueueInfo(bool /*full*/) +std::string LFGMgr::DumpQueueInfo(bool full) { - uint32 size = uint32(m_Queues.size()); + uint32 size = uint32(QueuesStore.size()); std::ostringstream o; o << "Number of Queues: " << size << "\n"; - for (LfgQueueMap::const_iterator itr = m_Queues.begin(); itr != m_Queues.end(); ++itr) + for (LfgQueueContainer::const_iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr) { std::string const& queued = itr->second.DumpQueueInfo(); - std::string const& compatibles = itr->second.DumpCompatibleInfo(); + std::string const& compatibles = itr->second.DumpCompatibleInfo(full); o << queued << compatibles; - /* - if (full) - { - LfgCompatibleMap const& compatibles = itr->second.GetCompatibleMap(); - } - */ } return o.str(); } + +void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid) +{ + LfgDungeonSet dungeons; + dungeons.insert(GetDungeon(gguid)); + SetSelectedDungeons(guid, dungeons); + SetState(guid, GetState(gguid)); + SetGroup(guid, gguid); + AddPlayerToGroup(gguid, guid); +} diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 457412a976f..84d8af88984 100644 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -129,18 +129,18 @@ struct LfgProposal; struct LfgProposalPlayer; struct LfgPlayerBoot; -typedef std::map<uint8, LfgQueue> LfgQueueMap; -typedef std::multimap<uint32, LfgReward const*> LfgRewardMap; -typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds; -typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonMap; -typedef std::map<uint64, LfgAnswer> LfgAnswerMap; -typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckMap; -typedef std::map<uint32, LfgProposal> LfgProposalMap; -typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerMap; -typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootMap; -typedef std::map<uint64, LfgGroupData> LfgGroupDataMap; -typedef std::map<uint64, LfgPlayerData> LfgPlayerDataMap; -typedef UNORDERED_MAP<uint32, LFGDungeonData> LFGDungeonMap; +typedef std::map<uint8, LFGQueue> LfgQueueContainer; +typedef std::multimap<uint32, LfgReward const*> LfgRewardContainer; +typedef std::pair<LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator> LfgRewardContainerBounds; +typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonContainer; +typedef std::map<uint64, LfgAnswer> LfgAnswerContainer; +typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckContainer; +typedef std::map<uint32, LfgProposal> LfgProposalContainer; +typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerContainer; +typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootContainer; +typedef std::map<uint64, LfgGroupData> LfgGroupDataContainer; +typedef std::map<uint64, LfgPlayerData> LfgPlayerDataContainer; +typedef UNORDERED_MAP<uint32, LFGDungeonData> LFGDungeonContainer; // Data needed by SMSG_LFG_JOIN_RESULT struct LfgJoinResultData @@ -156,7 +156,7 @@ struct LfgJoinResultData struct LfgUpdateData { LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT): updateType(_type), comment("") {} - LfgUpdateData(LfgUpdateType _type, LfgDungeonSet const& _dungeons, std::string _comment): + LfgUpdateData(LfgUpdateType _type, LfgDungeonSet const& _dungeons, std::string const& _comment): updateType(_type), dungeons(_dungeons), comment(_comment) {} LfgUpdateType updateType; @@ -231,7 +231,7 @@ struct LfgProposal uint32 encounters; ///< Dungeon Encounters bool isNew; ///< Determines if it's new group or not LfgGuidList queues; ///< Queue Ids to remove/readd - LfgProposalPlayerMap players; ///< Players data + LfgProposalPlayerContainer players; ///< Players data }; /// Stores all rolecheck info of a group that wants to join @@ -250,7 +250,7 @@ struct LfgPlayerBoot { time_t cancelTime; ///< Time left to vote bool inProgress; ///< Vote in progress - LfgAnswerMap votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree) + LfgAnswerContainer votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree) uint64 victim; ///< Player guid to be kicked (can't vote) std::string reason; ///< kick reason }; @@ -328,7 +328,6 @@ class LFGMgr void SetGroup(uint64 guid, uint64 group); void SetLeader(uint64 gguid, uint64 leader); void SetState(uint64 guid, LfgState state); - void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); void _LoadFromDB(Field* fields, uint64 guid); void _SaveToDB(uint64 guid, uint32 db_guid); @@ -341,6 +340,7 @@ class LFGMgr LfgLockMap const& GetLockedDungeons(uint64 guid); LfgDungeonSet const& GetSelectedDungeons(uint64 guid); uint32 GetDungeon(uint64 guid, bool asId = true); + uint32 GetDungeonMapId(uint64 guid); LfgState GetState(uint64 guid); uint8 GetKicksLeft(uint64 gguid); uint64 GetLeader(uint64 guid); @@ -348,6 +348,7 @@ class LFGMgr uint8 GetRoles(uint64 guid); std::string const& GetComment(uint64 gguid); LfgGuidSet const& GetPlayers(uint64 guid); + uint8 GetPlayerCount(uint64 guid); bool IsTeleported(uint64 guid); @@ -360,32 +361,35 @@ class LFGMgr bool isOptionEnabled(uint32 option); uint32 GetOptions(); void SetOptions(uint32 options); + LfgState GetLfgStatus(uint64 guid, LfgUpdateData& data); bool IsSeasonActive(uint32 dungeonId); std::string DumpQueueInfo(bool full = false); static std::string ConcatenateDungeons(LfgDungeonSet const& dungeons); static std::string GetRolesString(uint8 roles); - static char const * GetStateString(LfgState state); + static std::string GetStateString(LfgState state); void LoadLFGDungeons(bool reload = false); LFGDungeonData const* GetLFGDungeon(uint32 id); - LFGDungeonMap& GetLFGDungeonMap(); - private: + LFGDungeonContainer& GetLFGDungeonMap(); + void SetupGroupMember(uint64 guid, uint64 gguid); + uint64 GetGroup(uint64 guid); + private: uint8 GetTeam(uint64 guid); - uint64 GetGroup(uint64 guid); void RestoreState(uint64 guid, char const *debugMsg); void ClearState(uint64 guid, char const *debugMsg); void SetDungeon(uint64 guid, uint32 dungeon); + void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); void SetLockedDungeons(uint64 guid, LfgLockMap const& lock); void DecreaseKicksLeft(uint64 guid); // Proposals - void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type); + void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type); void MakeNewGroup(LfgProposal const& proposal); // Generic - LfgQueue &GetQueue(uint64 guid); + LFGQueue &GetQueue(uint64 guid); LfgDungeonSet const& GetDungeonsByRandom(uint32 randomdungeon); LfgType GetDungeonType(uint32 dungeon); @@ -402,18 +406,18 @@ class LFGMgr uint32 m_lfgProposalId; ///< used as internal counter for proposals uint32 m_options; ///< Stores config options - LfgQueueMap m_Queues; ///< Queues - LfgCachedDungeonMap m_CachedDungeonMap; ///< Stores all dungeons by groupType + LfgQueueContainer QueuesStore; ///< Queues + LfgCachedDungeonContainer CachedDungeonMapStore; ///< Stores all dungeons by groupType // Reward System - LfgRewardMap m_RewardMap; ///< Stores rewards for random dungeons - LFGDungeonMap m_LfgDungeonMap; + LfgRewardContainer RewardMapStore; ///< Stores rewards for random dungeons + LFGDungeonContainer LfgDungeonStore; // Rolecheck - Proposal - Vote Kicks - LfgRoleCheckMap m_RoleChecks; ///< Current Role checks - LfgProposalMap m_Proposals; ///< Current Proposals - LfgPlayerBootMap m_Boots; ///< Current player kicks - LfgPlayerDataMap m_Players; ///< Player data - LfgGroupDataMap m_Groups; ///< Group data - LfgGuidList m_teleport; ///< Players being teleported + LfgRoleCheckContainer RoleChecksStore; ///< Current Role checks + LfgProposalContainer ProposalsStore; ///< Current Proposals + LfgPlayerBootContainer BootsStore; ///< Current player kicks + LfgPlayerDataContainer PlayersStore; ///< Player data + LfgGroupDataContainer GroupsStore; ///< Group data + LfgGuidList teleportStore; ///< Players being teleported }; #define sLFGMgr ACE_Singleton<LFGMgr, ACE_Null_Mutex>::instance() diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index 131a3e7a992..8b69b537102 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -51,7 +51,7 @@ std::string ConcatenateGuids(LfgGuidList const& check) return o.str(); } -char const * GetCompatibleString(LfgCompatibility compatibles) +char const* GetCompatibleString(LfgCompatibility compatibles) { switch (compatibles) { @@ -80,83 +80,102 @@ char const * GetCompatibleString(LfgCompatibility compatibles) } } -void LfgQueue::AddToQueue(uint64 guid) +void LFGQueue::AddToQueue(uint64 guid) { - LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(guid); - if (itQueue == m_QueueDataMap.end()) + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); + if (itQueue == QueueDataStore.end()) { - sLog->outError(LOG_FILTER_LFG, "LfgQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); + sLog->outError(LOG_FILTER_LFG, "LFGQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); return; } AddToNewQueue(guid); } -void LfgQueue::RemoveFromQueue(uint64 guid) +void LFGQueue::RemoveFromQueue(uint64 guid) { RemoveFromNewQueue(guid); RemoveFromCurrentQueue(guid); RemoveFromCompatibles(guid); - RemoveQueueData(guid); + + std::ostringstream o; + o << guid; + std::string sguid = o.str(); + + LfgQueueDataContainer::iterator itDelete = QueueDataStore.end(); + for (LfgQueueDataContainer::iterator itr = QueueDataStore.begin(); itr != QueueDataStore.end(); ++itr) + if (itr->first != guid) + { + if (std::string::npos != itr->second.bestCompatible.find(sguid)) + { + itr->second.bestCompatible.clear(); + FindBestCompatibleInQueue(itr); + } + } + else + itDelete = itr; + + if (itDelete != QueueDataStore.end()) + QueueDataStore.erase(itDelete); } -void LfgQueue::AddToNewQueue(uint64 guid) +void LFGQueue::AddToNewQueue(uint64 guid) { - m_newToQueue.push_back(guid); + newToQueueStore.push_back(guid); } -void LfgQueue::RemoveFromNewQueue(uint64 guid) +void LFGQueue::RemoveFromNewQueue(uint64 guid) { - m_newToQueue.remove(guid); + newToQueueStore.remove(guid); } -void LfgQueue::AddToCurrentQueue(uint64 guid) +void LFGQueue::AddToCurrentQueue(uint64 guid) { - m_currentQueue.push_back(guid); + currentQueueStore.push_back(guid); } -void LfgQueue::RemoveFromCurrentQueue(uint64 guid) +void LFGQueue::RemoveFromCurrentQueue(uint64 guid) { - m_currentQueue.remove(guid); + currentQueueStore.remove(guid); } -void LfgQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap) +void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap) { - m_QueueDataMap[guid] = LfgQueueData(joinTime, dungeons, rolesMap); + QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap); AddToQueue(guid); } -void LfgQueue::RemoveQueueData(uint64 guid) +void LFGQueue::RemoveQueueData(uint64 guid) { - LfgQueueDataMap::iterator it = m_QueueDataMap.find(guid); - if (it != m_QueueDataMap.end()) - m_QueueDataMap.erase(it); + LfgQueueDataContainer::iterator it = QueueDataStore.find(guid); + if (it != QueueDataStore.end()) + QueueDataStore.erase(it); } -void LfgQueue::UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesAvg[dungeonId]; + LfgWaitTime &wt = waitTimesAvgStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesTank[dungeonId]; + LfgWaitTime &wt = waitTimesTankStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesHealer[dungeonId]; + LfgWaitTime &wt = waitTimesHealerStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesDps[dungeonId]; + LfgWaitTime &wt = waitTimesDpsStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } @@ -166,61 +185,76 @@ void LfgQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) @param[in] guid Guid to remove from compatible cache */ -void LfgQueue::RemoveFromCompatibles(uint64 guid) +void LFGQueue::RemoveFromCompatibles(uint64 guid) { std::stringstream out; out << guid; std::string strGuid = out.str(); - sLog->outDebug(LOG_FILTER_LFG, "LfgQueue::RemoveFromCompatibles: Removing [" UI64FMTD "]", guid); - for (LfgCompatibleMap::iterator itNext = m_CompatibleMap.begin(); itNext != m_CompatibleMap.end();) + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::RemoveFromCompatibles: Removing [" UI64FMTD "]", guid); + for (LfgCompatibleContainer::iterator itNext = CompatibleMapStore.begin(); itNext != CompatibleMapStore.end();) { - LfgCompatibleMap::iterator it = itNext++; - if (it->first.find(strGuid) != std::string::npos) // Found, remove it - m_CompatibleMap.erase(it); + LfgCompatibleContainer::iterator it = itNext++; + if (std::string::npos != it->first.find(strGuid)) + CompatibleMapStore.erase(it); } } - /** Stores the compatibility of a list of guids @param[in] key String concatenation of guids (| used as separator) @param[in] compatibles type of compatibility */ -void LfgQueue::SetCompatibles(const std::string &key, LfgCompatibility compatibles) +void LFGQueue::SetCompatibles(std::string const& key, LfgCompatibility compatibles) +{ + LfgCompatibilityData& data = CompatibleMapStore[key]; + data.compatibility = compatibles; +} + +void LFGQueue::SetCompatibilityData(std::string const& key, LfgCompatibilityData const& data) { - m_CompatibleMap[key] = compatibles; + CompatibleMapStore[key] = data; } + /** Get the compatibility of a group of guids @param[in] key String concatenation of guids (| used as separator) @return LfgCompatibility type of compatibility */ -LfgCompatibility LfgQueue::GetCompatibles(std::string const& key) +LfgCompatibility LFGQueue::GetCompatibles(std::string const& key) { - LfgCompatibleMap::iterator it = m_CompatibleMap.find(key); - if (it != m_CompatibleMap.end()) - return it->second; + LfgCompatibleContainer::iterator itr = CompatibleMapStore.find(key); + if (itr != CompatibleMapStore.end()) + return itr->second.compatibility; return LFG_COMPATIBILITY_PENDING; } -uint8 LfgQueue::FindGroups() +LfgCompatibilityData* LFGQueue::GetCompatibilityData(std::string const& key) +{ + LfgCompatibleContainer::iterator itr = CompatibleMapStore.find(key); + if (itr != CompatibleMapStore.end()) + return &(itr->second); + + return NULL; +} + +uint8 LFGQueue::FindGroups() { uint8 proposals = 0; LfgGuidList firstNew; - while (!m_newToQueue.empty()) + while (!newToQueueStore.empty()) { - uint64 frontguid = m_newToQueue.front(); - sLog->outDebug(LOG_FILTER_LFG, "LfgQueue::FindGroups: checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(m_newToQueue.size()), uint32(m_currentQueue.size())); + uint64 frontguid = newToQueueStore.front(); + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindGroups: checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(newToQueueStore.size()), uint32(currentQueueStore.size())); firstNew.clear(); firstNew.push_back(frontguid); RemoveFromNewQueue(frontguid); - LfgGuidList temporalList = m_currentQueue; + LfgGuidList temporalList = currentQueueStore; LfgCompatibility compatibles = FindNewGroups(firstNew, temporalList); if (compatibles == LFG_COMPATIBLES_MATCH) @@ -238,15 +272,22 @@ uint8 LfgQueue::FindGroups() @param[in] all List of all other guids in main queue to match against @return LfgCompatibility type of compatibility between groups */ -LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) +LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) { std::string strGuids = ConcatenateGuids(check); LfgCompatibility compatibles = GetCompatibles(strGuids); sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindNewGroup: (%s): %s - all(%s)", strGuids.c_str(), GetCompatibleString(compatibles), ConcatenateGuids(all).c_str()); - if (compatibles == LFG_COMPATIBILITY_PENDING || compatibles == LFG_COMPATIBLES_BAD_STATES) // Not previously cached, calculate + if (compatibles == LFG_COMPATIBILITY_PENDING) // Not previously cached, calculate compatibles = CheckCompatibility(check); + if (compatibles == LFG_COMPATIBLES_BAD_STATES && sLFGMgr->AllQueued(check)) + { + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindNewGroup: (%s) compatibles (cached) changed from bad states to match", strGuids.c_str()); + SetCompatibles(strGuids, LFG_COMPATIBLES_MATCH); + return LFG_COMPATIBLES_MATCH; + } + if (compatibles != LFG_COMPATIBLES_WITH_LESS_PLAYERS) return compatibles; @@ -269,7 +310,7 @@ LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) @param[in] check List of guids to check compatibilities @return LfgCompatibility type of compatibility */ -LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) +LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check) { std::string strGuids = ConcatenateGuids(check); LfgProposal proposal; @@ -284,10 +325,6 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_INCOMPATIBLES_WRONG_GROUP_SIZE; } - // Player joining alone always compatible - if (check.size() == 1 && IS_PLAYER_GUID(check.front())) - return LFG_COMPATIBLES_WITH_LESS_PLAYERS; - // Check all-but-new compatiblitity if (check.size() > 2) { @@ -311,8 +348,8 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) for (LfgGuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it) { uint64 guid = (*it); - LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(guid); - if (itQueue == m_QueueDataMap.end()) + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); + if (itQueue == QueueDataStore.end()) { sLog->outError(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: [" UI64FMTD "] is not queued but listed as queued!", guid); RemoveFromQueue(guid); @@ -337,6 +374,14 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) if (check.size() == 1 && numPlayers != MAXGROUPSIZE) { sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: (%s) sigle group. Compatibles", strGuids.c_str()); + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front()); + + LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); + data.roles = itQueue->second.roles; + LFGMgr::CheckGroupRoles(data.roles); + + UpdateBestCompatibleInQueue(itQueue, strGuids, data.roles); + SetCompatibilityData(strGuids, data); return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } @@ -359,14 +404,14 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) { for (LfgGuidList::const_iterator it = check.begin(); it != check.end(); ++it) { - const LfgRolesMap &roles = m_QueueDataMap[(*it)].roles; + const LfgRolesMap &roles = QueueDataStore[(*it)].roles; for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles) { LfgRolesMap::const_iterator itPlayer; for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer) { if (itRoles->first == itPlayer->first) - sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); + sLog->outError(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); else if (sLFGMgr->HasIgnore(itRoles->first, itPlayer->first)) break; } @@ -382,7 +427,7 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_INCOMPATIBLES_HAS_IGNORES; } - LfgRolesMap debugRoles = proposalRoles; // DEBUG + LfgRolesMap debugRoles = proposalRoles; if (!LFGMgr::CheckGroupRoles(proposalRoles)) { std::ostringstream o; @@ -395,13 +440,13 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) } LfgGuidList::iterator itguid = check.begin(); - proposalDungeons = m_QueueDataMap[*itguid].dungeons; + proposalDungeons = QueueDataStore[*itguid].dungeons; std::ostringstream o; o << ", " << *itguid << ": (" << sLFGMgr->ConcatenateDungeons(proposalDungeons) << ")"; for (++itguid; itguid != check.end(); ++itguid) { LfgDungeonSet temporal; - LfgDungeonSet &dungeons = m_QueueDataMap[*itguid].dungeons; + LfgDungeonSet &dungeons = QueueDataStore[*itguid].dungeons; o << ", " << *itguid << ": (" << sLFGMgr->ConcatenateDungeons(dungeons) << ")"; std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin())); proposalDungeons = temporal; @@ -417,7 +462,7 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) else { uint64 gguid = *check.begin(); - const LfgQueueData &queue = m_QueueDataMap[gguid]; + const LfgQueueData &queue = QueueDataStore[gguid]; proposalDungeons = queue.dungeons; proposalRoles = queue.roles; LFGMgr::CheckGroupRoles(proposalRoles); // assing new roles @@ -427,7 +472,15 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) if (numPlayers != MAXGROUPSIZE) { sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: (%s) Compatibles but not enough players(%u)", strGuids.c_str(), numPlayers); - SetCompatibles(strGuids, LFG_COMPATIBLES_WITH_LESS_PLAYERS); + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front()); + + LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); + data.roles = proposalRoles; + + for (LfgGuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr) + UpdateBestCompatibleInQueue(QueueDataStore.find(*itr), strGuids, data.roles); + + SetCompatibilityData(strGuids, data); return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } @@ -488,19 +541,20 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_COMPATIBLES_MATCH; } -void LfgQueue::UpdateQueueTimers(time_t currTime) +void LFGQueue::UpdateQueueTimers(time_t currTime) { - for (LfgQueueDataMap::const_iterator itQueue = m_QueueDataMap.begin(); itQueue != m_QueueDataMap.end(); ++itQueue) + sLog->outTrace(LOG_FILTER_LFG, "Updating queue timers..."); + for (LfgQueueDataContainer::iterator itQueue = QueueDataStore.begin(); itQueue != QueueDataStore.end(); ++itQueue) { - const LfgQueueData &queueinfo = itQueue->second; + LfgQueueData& queueinfo = itQueue->second; uint32 dungeonId = (*queueinfo.dungeons.begin()); uint32 queuedTime = uint32(currTime - queueinfo.joinTime); uint8 role = PLAYER_ROLE_NONE; int32 waitTime = -1; - int32 wtTank = m_waitTimesTank[dungeonId].time; - int32 wtHealer = m_waitTimesHealer[dungeonId].time; - int32 wtDps = m_waitTimesDps[dungeonId].time; - int32 wtAvg = m_waitTimesAvg[dungeonId].time; + int32 wtTank = waitTimesTankStore[dungeonId].time; + int32 wtHealer = waitTimesHealerStore[dungeonId].time; + int32 wtDps = waitTimesDpsStore[dungeonId].time; + int32 wtAvg = waitTimesAvgStore[dungeonId].time; for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer) role |= itPlayer->second; @@ -525,6 +579,9 @@ void LfgQueue::UpdateQueueTimers(time_t currTime) break; } + if (queueinfo.bestCompatible.empty()) + FindBestCompatibleInQueue(itQueue); + LfgQueueStatusData queueData(dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.tanks, queueinfo.healers, queueinfo.dps); for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer) { @@ -534,17 +591,12 @@ void LfgQueue::UpdateQueueTimers(time_t currTime) } } -time_t LfgQueue::GetJoinTime(uint64 guid) +time_t LFGQueue::GetJoinTime(uint64 guid) { - return m_QueueDataMap[guid].joinTime; + return QueueDataStore[guid].joinTime; } -LfgCompatibleMap const& LfgQueue::GetCompatibleMap() -{ - return m_CompatibleMap; -} - -std::string LfgQueue::DumpQueueInfo() const +std::string LFGQueue::DumpQueueInfo() const { uint32 players = 0; uint32 groups = 0; @@ -552,30 +604,77 @@ std::string LfgQueue::DumpQueueInfo() const for (uint8 i = 0; i < 2; ++i) { - LfgGuidList const& queue = i ? m_newToQueue : m_currentQueue; + LfgGuidList const& queue = i ? newToQueueStore : currentQueueStore; for (LfgGuidList::const_iterator it = queue.begin(); it != queue.end(); ++it) { uint64 guid = *it; if (IS_GROUP(guid)) { groups++; - if (Group const* group = sGroupMgr->GetGroupByGUID(GUID_LOPART(guid))) - playersInGroup += group->GetMembersCount(); - else - playersInGroup += 2; // Shouldn't happen but just in case + playersInGroup += sLFGMgr->GetPlayerCount(guid); } else players++; } } std::ostringstream o; - o << "Queued Players: " << players << "(in group: " << playersInGroup << ") Groups: " << groups << "\n"; + o << "Queued Players: " << players << " (in group: " << playersInGroup << ") Groups: " << groups << "\n"; return o.str(); } -std::string LfgQueue::DumpCompatibleInfo() const +std::string LFGQueue::DumpCompatibleInfo(bool full /* = false */) const { std::ostringstream o; - o << "Compatible Map size: " << m_CompatibleMap.size() << "\n"; + o << "Compatible Map size: " << CompatibleMapStore.size() << "\n"; + if (full) + for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr) + o << "(" << itr->first << "): " << GetCompatibleString(itr->second.compatibility) << "\n"; + return o.str(); } + +void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue) +{ + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindBestCompatibleInQueue: " UI64FMTD, itrQueue->first); + std::ostringstream o; + o << itrQueue->first; + std::string sguid = o.str(); + + for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr) + if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && + std::string::npos != itr->first.find(sguid)) + { + UpdateBestCompatibleInQueue(itrQueue, itr->first, itr->second.roles); + } +} + +void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles) +{ + LfgQueueData& queueData = itrQueue->second; + + uint8 storedSize = queueData.bestCompatible.empty() ? 0 : + std::count(queueData.bestCompatible.begin(), queueData.bestCompatible.end(), '|') + 1; + + uint8 size = std::count(key.begin(), key.end(), '|') + 1; + + if (size <= storedSize) + return; + + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::UpdateBestCompatibleInQueue: Changed (%s) to (%s) as best compatible group for " UI64FMTD, + queueData.bestCompatible.c_str(), key.c_str(), itrQueue->first); + + queueData.bestCompatible = key; + queueData.tanks = LFG_TANKS_NEEDED; + queueData.healers = LFG_HEALERS_NEEDED; + queueData.dps = LFG_DPS_NEEDED; + for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it) + { + uint8 role = it->second; + if (role & PLAYER_ROLE_TANK) + --queueData.tanks; + else if (role & PLAYER_ROLE_HEALER) + --queueData.healers; + else + --queueData.dps; + } +}
\ No newline at end of file diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index f08199d725a..f937ac0d21a 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -34,6 +34,17 @@ enum LfgCompatibility LFG_COMPATIBLES_MATCH // Must be the last one }; +struct LfgCompatibilityData +{ + LfgCompatibilityData(): compatibility(LFG_COMPATIBILITY_PENDING) { } + LfgCompatibilityData(LfgCompatibility _compatibility): compatibility(_compatibility) { } + LfgCompatibilityData(LfgCompatibility _compatibility, LfgRolesMap const& _roles): + compatibility(_compatibility), roles(_roles) { } + + LfgCompatibility compatibility; + LfgRolesMap roles; +}; + /// Stores player or group queue info struct LfgQueueData { @@ -41,26 +52,10 @@ struct LfgQueueData healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) { } - LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, const LfgRolesMap &_roles) - { - joinTime = _joinTime; - dungeons = _dungeons; - roles = _roles; - tanks = LFG_TANKS_NEEDED; - healers = LFG_HEALERS_NEEDED; - dps = LFG_DPS_NEEDED; - - for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it) - { - uint8 role = it->second; - if (role & PLAYER_ROLE_TANK) - --tanks; - else if (role & PLAYER_ROLE_HEALER) - --healers; - else - --dps; - } - } + LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, LfgRolesMap const& _roles): + joinTime(_joinTime), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), + dps(LFG_DPS_NEEDED), dungeons(_dungeons), roles(_roles) + { } time_t joinTime; ///< Player queue join time (to calculate wait times) uint8 tanks; ///< Tanks needed @@ -68,6 +63,7 @@ struct LfgQueueData uint8 dps; ///< Dps needed LfgDungeonSet dungeons; ///< Selected Player/Group Dungeon/s LfgRolesMap roles; ///< Selected Player Role/s + std::string bestCompatible; ///< Best compatible combination of people queued }; struct LfgWaitTime @@ -77,14 +73,14 @@ struct LfgWaitTime uint32 number; ///< Number of people used to get that wait time }; -typedef std::map<uint32, LfgWaitTime> LfgWaitTimesMap; -typedef std::map<std::string, LfgCompatibility> LfgCompatibleMap; -typedef std::map<uint64, LfgQueueData> LfgQueueDataMap; +typedef std::map<uint32, LfgWaitTime> LfgWaitTimesContainer; +typedef std::map<std::string, LfgCompatibilityData> LfgCompatibleContainer; +typedef std::map<uint64, LfgQueueData> LfgQueueDataContainer; /** Stores all data related to queue */ -class LfgQueue +class LFGQueue { public: @@ -108,10 +104,13 @@ class LfgQueue uint8 FindGroups(); // Just for debugging purposes - LfgCompatibleMap const& GetCompatibleMap(); std::string DumpQueueInfo() const; - std::string DumpCompatibleInfo() const; + std::string DumpCompatibleInfo(bool full = false) const; + private: + void SetQueueUpdateData(std::string const& strGuids, LfgRolesMap const& proposalRoles); + LfgRolesMap const& RemoveFromQueueUpdateData(uint64 guid); + void AddToNewQueue(uint64 guid); void AddToCurrentQueue(uint64 guid); void RemoveFromNewQueue(uint64 guid); @@ -121,19 +120,24 @@ class LfgQueue LfgCompatibility GetCompatibles(std::string const& key); void RemoveFromCompatibles(uint64 guid); + void SetCompatibilityData(std::string const& key, LfgCompatibilityData const& compatibles); + LfgCompatibilityData* GetCompatibilityData(std::string const& key); + void FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue); + void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles); + LfgCompatibility FindNewGroups(LfgGuidList& check, LfgGuidList& all); LfgCompatibility CheckCompatibility(LfgGuidList check); // Queue - LfgQueueDataMap m_QueueDataMap; ///< Queued groups - LfgCompatibleMap m_CompatibleMap; ///< Compatible dungeons - - LfgWaitTimesMap m_waitTimesAvg; ///< Average wait time to find a group queuing as multiple roles - LfgWaitTimesMap m_waitTimesTank; ///< Average wait time to find a group queuing as tank - LfgWaitTimesMap m_waitTimesHealer; ///< Average wait time to find a group queuing as healer - LfgWaitTimesMap m_waitTimesDps; ///< Average wait time to find a group queuing as dps - LfgGuidList m_currentQueue; ///< Ordered list. Used to find groups - LfgGuidList m_newToQueue; ///< New groups to add to queue + LfgQueueDataContainer QueueDataStore; ///< Queued groups + LfgCompatibleContainer CompatibleMapStore; ///< Compatible dungeons + + LfgWaitTimesContainer waitTimesAvgStore; ///< Average wait time to find a group queuing as multiple roles + LfgWaitTimesContainer waitTimesTankStore; ///< Average wait time to find a group queuing as tank + LfgWaitTimesContainer waitTimesHealerStore; ///< Average wait time to find a group queuing as healer + LfgWaitTimesContainer waitTimesDpsStore; ///< Average wait time to find a group queuing as dps + LfgGuidList currentQueueStore; ///< Ordered list. Used to find groups + LfgGuidList newToQueueStore; ///< New groups to add to queue }; #endif diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 522ded70550..91314e64285 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -60,6 +60,21 @@ void LFGPlayerScript::OnLogin(Player* player) if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; + // Temporal: Trying to determine when group data and LFG data gets desynched + uint64 guid = player->GetGUID(); + uint64 gguid = sLFGMgr->GetGroup(guid); + + if (Group const* group = player->GetGroup()) + { + uint64 gguid2 = group->GetGUID(); + if (gguid != gguid2) + { + sLog->outError(LOG_FILTER_LFG, "%s on group %u but LFG has group %u saved... Fixing.", + player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid)); + sLFGMgr->SetupGroupMember(guid, group->GetGUID()); + } + } + sLFGMgr->InitializeLockedDungeons(player); sLFGMgr->SetTeam(player->GetGUID(), player->GetTeam()); // TODO - Restore LfgPlayerData and send proper status to player if it was in a group @@ -94,7 +109,7 @@ void LFGGroupScript::OnAddMember(Group* group, uint64 guid) LfgState gstate = sLFGMgr->GetState(gguid); LfgState state = sLFGMgr->GetState(guid); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "] gstate: %u, state: %u", gguid, guid, leader, gstate, state); - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_CLEAR_LOCK_LIST); + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { if (Player* plrg = itr->getSource()) diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 3e7dfc125f9..b4aa4d1c54f 100755 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -79,7 +79,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner) if (!IsPositionValid()) { sLog->outError(LOG_FILTER_PLAYER, "Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", - guidlow, owner->GetName(), owner->GetPositionX(), owner->GetPositionY()); + guidlow, owner->GetName().c_str(), owner->GetPositionX(), owner->GetPositionY()); return false; } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 152c6974255..8076372df43 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1608,7 +1608,8 @@ void Creature::Respawn(bool force) if (m_DBTableGuid) GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid); - sLog->outDebug(LOG_FILTER_UNITS, "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", GetName(), GetGUIDLow(), GetGUID(), GetEntry()); + sLog->outDebug(LOG_FILTER_UNITS, "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", + GetName().c_str(), GetGUIDLow(), GetGUID(), GetEntry()); m_respawnTime = 0; lootForPickPocketed = false; lootForBody = false; @@ -2453,7 +2454,7 @@ TrainerSpellData const* Creature::GetTrainerSpells() const } // overwrite WorldObject function for proper name localization -const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const +std::string const & Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const { if (loc_idx != DEFAULT_LOCALE) { @@ -2462,7 +2463,7 @@ const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const if (cl) { if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty()) - return cl->Name[uloc_idx].c_str(); + return cl->Name[uloc_idx]; } } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index db3c423e6b6..4a410f4a41d 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -579,7 +579,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId, language, TargetGuid); } // override WorldObject function for proper name localization - const char* GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; void setDeathState(DeathState s); // override virtual Unit::setDeathState diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 52a9de09f30..fa1b11d12d6 100755 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -142,9 +142,9 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20 - for (uint32 iI = 0; iI < _questMenu.GetMenuItemCount(); ++iI) + for (uint8 i = 0; i < _questMenu.GetMenuItemCount(); ++i) { - QuestMenuItem const& item = _questMenu.GetItem(iI); + QuestMenuItem const& item = _questMenu.GetItem(i); uint32 questID = item.QuestId; Quest const* quest = sObjectMgr->GetQuestTemplate(questID); @@ -155,7 +155,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation std::string title = quest->GetTitle(); - int locale = _session->GetSessionDbLocaleIndex(); + int32 locale = _session->GetSessionDbLocaleIndex(); if (locale >= 0) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) ObjectMgr::GetLocaleString(localeData->Title, locale, title); @@ -262,10 +262,10 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title { std::string title = quest->GetTitle(); - int loc_idx = _session->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - if (QuestLocale const* ql = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(ql->Title, loc_idx, title); + int32 locale = _session->GetSessionDbLocaleIndex(); + if (locale >= 0) + if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) + ObjectMgr::GetLocaleString(localeData->Title, locale, title); data << uint32(questID); data << uint32(qmi.QuestIcon); @@ -364,7 +364,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const std::string questTurnTargetName = quest->GetQuestTurnTargetName(); std::string questObjectiveText[QUEST_OBJECTIVES_COUNT]; - for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) questObjectiveText[i] = quest->ObjectiveText[i]; int32 locale = _session->GetSessionDbLocaleIndex(); @@ -382,7 +382,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow); ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName); - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]); } } @@ -434,38 +434,38 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) { - for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) data << uint32(0) << uint32(0); - for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) data << uint32(0) << uint32(0); } else { - for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) { data << uint32(quest->RewardItemId[i]); data << uint32(quest->RewardItemIdCount[i]); } - for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { data << uint32(quest->RewardChoiceItemId[i]); data << uint32(quest->RewardChoiceItemCount[i]); } } - for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids + for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids data << uint32(quest->RewardFactionId[i]); - for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc? + for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc? data << int32(quest->RewardFactionValueId[i]); - for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unknown usage + for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unknown usage data << int32(quest->RewardFactionValueIdOverride[i]); - data << quest->GetPointMapId(); - data << quest->GetPointX(); - data << quest->GetPointY(); - data << quest->GetPointOpt(); + data << uint32(quest->GetPointMapId()); + data << float(quest->GetPointX()); + data << float(quest->GetPointY()); + data << uint32(quest->GetPointOpt()); data << questTitle; data << questObjectives; @@ -473,7 +473,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const data << questEndText; data << questCompletedText; - for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { if (quest->RequiredNpcOrGo[i] < 0) data << uint32((quest->RequiredNpcOrGo[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000) @@ -485,7 +485,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const data << uint32(quest->RequiredSourceItemCount[i]); } - for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { data << uint32(quest->RequiredItemId[i]); data << uint32(quest->RequiredItemCount[i]); @@ -493,7 +493,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const data << uint32(quest->GetRequiredSpell()); // Is it required to be cast, learned or what? - for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) data << questObjectiveText[i]; for (uint32 i = 0; i < QUEST_REWARD_CURRENCY_COUNT; ++i) @@ -528,7 +528,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b std::string questTurnTextWindow = quest->GetQuestTurnTextWindow(); std::string questTurnTargetName = quest->GetQuestTurnTargetName(); - int locale = _session->GetSessionDbLocaleIndex(); + int32 locale = _session->GetSessionDbLocaleIndex(); if (locale >= 0) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 6f84e50d81f..8b1311a1800 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -33,7 +33,7 @@ #include "GameObjectModel.h" #include "DynamicTree.h" -GameObject::GameObject() : WorldObject(false), m_model(NULL), m_goValue(new GameObjectValue), m_AI(NULL) +GameObject::GameObject(): WorldObject(false), m_model(NULL), m_goValue(), m_AI(NULL) { m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; @@ -65,7 +65,6 @@ GameObject::GameObject() : WorldObject(false), m_model(NULL), m_goValue(new Game GameObject::~GameObject() { - delete m_goValue; delete m_AI; delete m_model; //if (m_uint32Values) // field array can be not exist if GameOBject not loaded @@ -226,8 +225,8 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa switch (goinfo->type) { case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: - m_goValue->Building.Health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits; - m_goValue->Building.MaxHealth = m_goValue->Building.Health; + m_goValue.Building.Health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits; + m_goValue.Building.MaxHealth = m_goValue.Building.Health; SetGoAnimProgress(255); SetUInt32Value(GAMEOBJECT_PARENTROTATION, m_goInfo->building.destructibleData); break; @@ -1643,7 +1642,7 @@ void GameObject::Use(Unit* user) default: if (GetGoType() >= MAX_GAMEOBJECT_TYPE) sLog->outError(LOG_FILTER_GENERAL, "GameObject::Use(): unit (type: %u, guid: %u, name: %s) tries to use object (guid: %u, entry: %u, name: %s) of unknown type (%u)", - user->GetTypeId(), user->GetGUIDLow(), user->GetName(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType()); + user->GetTypeId(), user->GetGUIDLow(), user->GetName().c_str(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType()); break; } @@ -1757,14 +1756,14 @@ void GameObject::EventInform(uint32 eventId) } // overwrite WorldObject function for proper name localization -const char* GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const +std::string const & GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const { if (loc_idx != DEFAULT_LOCALE) { uint8 uloc_idx = uint8(loc_idx); if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry())) if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty()) - return cl->Name[uloc_idx].c_str(); + return cl->Name[uloc_idx]; } return GetName(); @@ -1802,22 +1801,22 @@ void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, uint32 spellId /*= 0*/) { - if (!GetGOValue()->Building.MaxHealth || !change) + if (!m_goValue.Building.MaxHealth || !change) return; // prevent double destructions of the same object - if (change < 0 && !GetGOValue()->Building.Health) + if (change < 0 && !m_goValue.Building.Health) return; - if (int32(GetGOValue()->Building.Health) + change <= 0) - GetGOValue()->Building.Health = 0; - else if (int32(GetGOValue()->Building.Health) + change >= int32(GetGOValue()->Building.MaxHealth)) - GetGOValue()->Building.Health = GetGOValue()->Building.MaxHealth; + if (int32(m_goValue.Building.Health) + change <= 0) + m_goValue.Building.Health = 0; + else if (int32(m_goValue.Building.Health) + change >= int32(m_goValue.Building.MaxHealth)) + m_goValue.Building.Health = m_goValue.Building.MaxHealth; else - GetGOValue()->Building.Health += change; + m_goValue.Building.Health += change; // Set the health bar, value = 255 * healthPct; - SetGoAnimProgress(GetGOValue()->Building.Health * 255 / GetGOValue()->Building.MaxHealth); + SetGoAnimProgress(m_goValue.Building.Health * 255 / m_goValue.Building.MaxHealth); Player* player = attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself(); @@ -1836,11 +1835,11 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u GameObjectDestructibleState newState = GetDestructibleState(); - if (!GetGOValue()->Building.Health) + if (!m_goValue.Building.Health) newState = GO_DESTRUCTIBLE_DESTROYED; - else if (GetGOValue()->Building.Health <= GetGOInfo()->building.damagedNumHits) + else if (m_goValue.Building.Health <= GetGOInfo()->building.damagedNumHits) newState = GO_DESTRUCTIBLE_DAMAGED; - else if (GetGOValue()->Building.Health == GetGOValue()->Building.MaxHealth) + else if (m_goValue.Building.Health == m_goValue.Building.MaxHealth) newState = GO_DESTRUCTIBLE_INTACT; if (newState == GetDestructibleState()) @@ -1861,7 +1860,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* SetDisplayId(m_goInfo->displayId); if (setHealth) { - m_goValue->Building.Health = m_goValue->Building.MaxHealth; + m_goValue.Building.Health = m_goValue.Building.MaxHealth; SetGoAnimProgress(255); } EnableCollision(true); @@ -1885,12 +1884,12 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* if (setHealth) { - m_goValue->Building.Health = m_goInfo->building.damagedNumHits; - uint32 maxHealth = m_goValue->Building.MaxHealth; + m_goValue.Building.Health = m_goInfo->building.damagedNumHits; + uint32 maxHealth = m_goValue.Building.MaxHealth; // in this case current health is 0 anyway so just prevent crashing here if (!maxHealth) maxHealth = 1; - SetGoAnimProgress(m_goValue->Building.Health * 255 / maxHealth); + SetGoAnimProgress(m_goValue.Building.Health * 255 / maxHealth); } break; } @@ -1918,7 +1917,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* if (setHealth) { - m_goValue->Building.Health = 0; + m_goValue.Building.Health = 0; SetGoAnimProgress(0); } EnableCollision(false); @@ -1938,7 +1937,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* // restores to full health if (setHealth) { - m_goValue->Building.Health = m_goValue->Building.MaxHealth; + m_goValue.Building.Health = m_goValue.Building.MaxHealth; SetGoAnimProgress(255); } EnableCollision(true); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 41501827dca..46e23ad2d2e 100755 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -629,7 +629,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> static GameObject* GetGameObject(WorldObject& object, uint64 guid); GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectData const* GetGOData() const { return m_goData; } - GameObjectValue * GetGOValue() const { return m_goValue; } + GameObjectValue const* GetGOValue() const { return &m_goValue; } bool IsTransport() const; bool IsDynTransport() const; @@ -646,7 +646,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId, language, TargetGuid); } // overwrite WorldObject function for proper name localization - const char* GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); @@ -827,7 +827,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid GameObjectTemplate const* m_goInfo; GameObjectData const* m_goData; - GameObjectValue * const m_goValue; + GameObjectValue m_goValue; uint64 m_rotation; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index ac1679c241f..e3ea4f77344 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -93,7 +93,8 @@ WorldObject::~WorldObject() { if (GetTypeId() == TYPEID_CORPSE) { - sLog->outFatal(LOG_FILTER_GENERAL, "Object::~Object Corpse guid="UI64FMTD", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry()); + sLog->outFatal(LOG_FILTER_GENERAL, "Object::~Object Corpse guid="UI64FMTD", type=%d, entry=%u deleted but still in map!!", + GetGUID(), ((Corpse*)this)->GetType(), GetEntry()); ASSERT(false); } ResetMap(); @@ -911,23 +912,6 @@ void Object::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) cons BuildValuesUpdateBlockForPlayer(&iter->second, iter->first); } -void Object::_LoadIntoDataField(char const* data, uint32 startOffset, uint32 count) -{ - if (!data) - return; - - Tokenizer tokens(data, ' ', count); - - if (tokens.size() != count) - return; - - for (uint32 index = 0; index < count; ++index) - { - m_uint32Values[startOffset + index] = atol(tokens[index]); - _changedFields[startOffset + index] = true; - } -} - void Object::GetUpdateFieldData(Player const* target, uint32*& flags, bool& isOwner, bool& isItemOwner, bool& hasSpecialInfo, bool& isPartyMember) const { // This function assumes updatefield index is always valid @@ -988,6 +972,23 @@ bool Object::IsUpdateFieldVisible(uint32 flags, bool isSelf, bool isOwner, bool return false; } +void Object::_LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count) +{ + if (data.empty()) + return; + + Tokenizer tokens(data, ' ', count); + + if (tokens.size() != count) + return; + + for (uint32 index = 0; index < count; ++index) + { + m_uint32Values[startOffset + index] = atol(tokens[index]); + _changedFields[startOffset + index] = true; + } +} + void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const { bool* indexes = _changedFields; @@ -2276,13 +2277,13 @@ void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisp player->GetSession()->SendPacket(&data); } -void WorldObject::BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 targetGuid) const +void WorldObject::BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, std::string const &name, uint64 targetGuid) const { *data << (uint8)msgtype; *data << (uint32)language; *data << (uint64)GetGUID(); *data << (uint32)0; // 2.1.0 - *data << (uint32)(strlen(name)+1); + *data << (uint32)(name.size()+1); *data << name; *data << (uint64)targetGuid; // Unit Target if (targetGuid && !IS_PLAYER_GUID(targetGuid)) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index dcf14ead81d..6de2185210e 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -51,7 +51,7 @@ enum TypeMask TYPEMASK_OBJECT = 0x0001, TYPEMASK_ITEM = 0x0002, TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004 - TYPEMASK_UNIT = 0x0008, // creature + TYPEMASK_UNIT = 0x0008, // creature TYPEMASK_PLAYER = 0x0010, TYPEMASK_GAMEOBJECT = 0x0020, TYPEMASK_DYNAMICOBJECT = 0x0040, @@ -385,7 +385,7 @@ class Object void _InitValues(); void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh); std::string _ConcatFields(uint16 startIndex, uint16 size) const; - void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count); + void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count); void GetUpdateFieldData(Player const* target, uint32*& flags, bool& isOwner, bool& isItemOwner, bool& hasSpecialInfo, bool& isPartyMember) const; @@ -733,10 +733,10 @@ class WorldObject : public Object, public WorldLocation InstanceScript* GetInstanceScript(); - const char* GetName() const { return m_name.c_str(); } - void SetName(const std::string& newname) { m_name=newname; } + std::string const& GetName() const { return m_name; } + void SetName(std::string const& newname) { m_name=newname; } - virtual const char* GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return GetName(); } + virtual std::string const& GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return m_name; } float GetDistance(const WorldObject* obj) const { @@ -822,7 +822,7 @@ class WorldObject : public Object, public WorldLocation void MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false); void MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper = false); void MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid); - void BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 TargetGuid) const; + void BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, std::string const& name, uint64 TargetGuid) const; void PlayDistanceSound(uint32 sound_id, Player* target = NULL); void PlayDirectSound(uint32 sound_id, Player* target = NULL); diff --git a/src/server/game/Entities/Object/ObjectDefines.h b/src/server/game/Entities/Object/ObjectDefines.h index 07f98831c67..ccc596fabfe 100755 --- a/src/server/game/Entities/Object/ObjectDefines.h +++ b/src/server/game/Entities/Object/ObjectDefines.h @@ -133,4 +133,3 @@ inline char const* GetLogNameForGuid(uint64 guid) } } #endif - diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 1b7cfb9e0bf..c431ee2c772 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -34,9 +34,9 @@ #define PET_XP_FACTOR 0.05f Pet::Pet(Player* owner, PetType type) : Guardian(NULL, owner, true), -m_usedTalentCount(0), m_removed(false), m_owner(owner), -m_petType(type), m_duration(0), -m_auraRaidUpdateMask(0), m_loading(false), m_declinedname(NULL) + m_usedTalentCount(0), m_removed(false), m_owner(owner), + m_petType(type), m_duration(0), + m_auraRaidUpdateMask(0), m_loading(false), m_declinedname(NULL) { m_unitTypeMask |= UNIT_MASK_PET; if (type == HUNTER_PET) @@ -77,7 +77,6 @@ void Pet::AddToWorld() GetCharmInfo()->SetIsFollowing(false); GetCharmInfo()->SetIsReturning(false); } - } void Pet::RemoveFromWorld() @@ -453,7 +452,7 @@ void Pet::SavePetToDB(PetSaveMode mode) for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i) { ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' ' - << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' '; + << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' '; }; ss << "', " @@ -553,7 +552,7 @@ void Pet::Update(uint32 diff) { if (owner->GetPetGUID() != GetGUID()) { - sLog->outError(LOG_FILTER_PETS, "Pet %u is not pet of owner %s, removed", GetEntry(), m_owner->GetName()); + sLog->outError(LOG_FILTER_PETS, "Pet %u is not pet of owner %s, removed", GetEntry(), m_owner->GetName().c_str()); Remove(getPetType() == HUNTER_PET?PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT); return; } diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index f1170f728f5..6e00fcbfe83 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -214,7 +214,7 @@ class Pet : public Guardian bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved) - Player* GetOwner() { return m_owner; } + Player* GetOwner() const { return m_owner; } protected: Player* m_owner; PetType m_petType; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 3dabb81a98b..65050753bb2 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -180,16 +180,14 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level SetTaximaskNode(213); //Shattered Sun Staging Area } -void PlayerTaxi::LoadTaxiMask(const char* data) +void PlayerTaxi::LoadTaxiMask(std::string const &data) { - Tokenizer Tokenizer(data, ' '); + Tokenizer tokens(data, ' '); - uint8 index; - Tokenizer::const_iterator iter; - for (iter = Tokenizer.begin(), index = 0; - (index < TaxiMaskSize) && (iter != Tokenizer.end()); ++iter, ++index) + uint8 index = 0; + for (Tokenizer::const_iterator iter = tokens.begin(); index < TaxiMaskSize && iter != tokens.end(); ++iter, ++index) { - // load and set bits only for existed taxi nodes + // load and set bits only for existing taxi nodes m_taximask[index] = sTaxiNodesMask[index] & uint32(atol(*iter)); } } @@ -1564,7 +1562,7 @@ void Player::Update(uint32 p_time) // check every second if (now > m_Last_tick + 1) UpdateSoulboundTradeItems(); - + // If mute expired, remove it from the DB if (GetSession()->m_muteTime && GetSession()->m_muteTime < now) { @@ -1738,7 +1736,7 @@ void Player::Update(uint32 p_time) { // m_nextSave reseted in SaveToDB call SaveToDB(); - sLog->outDebug(LOG_FILTER_PLAYER, "Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow()); + sLog->outDebug(LOG_FILTER_PLAYER, "Player '%s' (GUID: %u) saved", GetName().c_str(), GetGUIDLow()); } else m_nextSave -= p_time; @@ -1827,7 +1825,7 @@ void Player::setDeathState(DeathState s) { if (!cur) { - sLog->outError(LOG_FILTER_PLAYER, "setDeathState: attempt to kill a dead player %s(%d)", GetName(), GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "setDeathState: attempt to kill a dead player %s(%d)", GetName().c_str(), GetGUIDLow()); return; } @@ -2137,13 +2135,13 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) { sLog->outError(LOG_FILTER_MAPS, "TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (GUID: %u, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).", - mapid, x, y, z, orientation, GetGUIDLow(), GetName(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + mapid, x, y, z, orientation, GetGUIDLow(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this)) { - sLog->outError(LOG_FILTER_MAPS, "Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName(), mapid); + sLog->outError(LOG_FILTER_MAPS, "Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName().c_str(), mapid); SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED); return false; } @@ -2161,7 +2159,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // client without expansion support if (GetSession()->Expansion() < mEntry->Expansion()) { - sLog->outDebug(LOG_FILTER_MAPS, "Player %s using client without required expansion tried teleport to non accessible map %u", GetName(), mapid); + sLog->outDebug(LOG_FILTER_MAPS, "Player %s using client without required expansion tried teleport to non accessible map %u", GetName().c_str(), mapid); if (GetTransport()) { @@ -2178,7 +2176,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return false; // normal client can't teleport to this map... } else - sLog->outDebug(LOG_FILTER_MAPS, "Player %s is being teleported to map %u", GetName(), mapid); + sLog->outDebug(LOG_FILTER_MAPS, "Player %s is being teleported to map %u", GetName().c_str(), mapid); if (m_vehicle) ExitVehicle(); @@ -2505,7 +2503,8 @@ void Player::RemoveFromWorld() { if (WorldObject* viewpoint = GetViewpoint()) { - sLog->outError(LOG_FILTER_PLAYER, "Player %s has viewpoint %u %u when removed from world", GetName(), viewpoint->GetEntry(), viewpoint->GetTypeId()); + sLog->outError(LOG_FILTER_PLAYER, "Player %s has viewpoint %u %u when removed from world", + GetName().c_str(), viewpoint->GetEntry(), viewpoint->GetTypeId()); SetViewpoint(viewpoint, false); } } @@ -2882,7 +2881,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes return go; sLog->outDebug(LOG_FILTER_MAPS, "IsGameObjectOfTypeInRange: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name.c_str(), - go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this)); + go->GetGUIDLow(), GetName().c_str(), GetGUIDLow(), go->GetDistance(this)); } } return NULL; @@ -5116,7 +5115,7 @@ void Player::BuildPlayerRepop() // the player cannot have a corpse already, only bones which are not returned by GetCorpse if (GetCorpse()) { - sLog->outError(LOG_FILTER_PLAYER, "BuildPlayerRepop: player %s(%d) already has a corpse", GetName(), GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "BuildPlayerRepop: player %s(%d) already has a corpse", GetName().c_str(), GetGUIDLow()); return; } @@ -5125,7 +5124,7 @@ void Player::BuildPlayerRepop() Corpse* corpse = GetCorpse(); if (!corpse) { - sLog->outError(LOG_FILTER_PLAYER, "Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "Error creating corpse for Player %s [%u]", GetName().c_str(), GetGUIDLow()); return; } GetMap()->AddToMap(corpse); @@ -5614,7 +5613,7 @@ void Player::CleanupChannels() Channel* ch = *m_channels.begin(); m_channels.erase(m_channels.begin()); // remove from player's channel list ch->Leave(GetGUID(), false); // not send to client, not remove from player's channel list - if (ChannelMgr* cMgr = channelMgr(GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam())) cMgr->LeftChannel(ch->GetName()); // deleted channel if empty } sLog->outDebug(LOG_FILTER_CHATSYS, "Player: channels cleaned up!"); @@ -5629,7 +5628,7 @@ void Player::UpdateLocalChannels(uint32 newZone) if (!current_zone) return; - ChannelMgr* cMgr = channelMgr(GetTeam()); + ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam()); if (!cMgr) return; @@ -6620,13 +6619,13 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) { if (button >= MAX_ACTION_BUTTONS) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Action %u not added into button %u for player %s: button must be < %u", action, button, GetName(), MAX_ACTION_BUTTONS); + sLog->outError(LOG_FILTER_PLAYER, "Action %u not added into button %u for player %s: button must be < %u", action, button, GetName().c_str(), MAX_ACTION_BUTTONS ); return false; } if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Action %u not added into button %u for player %s: action must be < %u", action, button, GetName(), MAX_ACTION_BUTTON_ACTION_VALUE); + sLog->outError(LOG_FILTER_PLAYER, "Action %u not added into button %u for player %s: action must be < %u", action, button, GetName().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); return false; } @@ -6635,25 +6634,31 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) case ACTION_BUTTON_SPELL: if (!sSpellMgr->GetSpellInfo(action)) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Spell action %u not added into button %u for player %s: spell not exist", action, button, GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Spell action %u not added into button %u for player %s: spell not exist", action, button, GetName().c_str()); return false; } if (!HasSpell(action)) { - sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::IsActionButtonDataValid Spell action %u not added into button %u for player %s: player don't known this spell", action, button, GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Spell action %u not added into button %u for player %s: player don't known this spell", action, button, GetName().c_str()); return false; } break; case ACTION_BUTTON_ITEM: if (!sObjectMgr->GetItemTemplate(action)) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Item action %u not added into button %u for player %s: item not exist", action, button, GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Item action %u not added into button %u for player %s: item not exist", action, button, GetName().c_str()); return false; } break; + case ACTION_BUTTON_C: + case ACTION_BUTTON_CMACRO: + case ACTION_BUTTON_MACRO: + case ACTION_BUTTON_EQSET: + break; default: - break; // other cases not checked at this moment + sLog->outError(LOG_FILTER_PLAYER, "Unknown action type %u", type); + return false; // other cases not checked at this moment } return true; @@ -6670,7 +6675,7 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) // set data and update to CHANGED if not NEW ab.SetActionAndType(action, ActionButtonType(type)); - sLog->outInfo(LOG_FILTER_PLAYER_LOADING, "Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, type, button); + sLog->outDebug(LOG_FILTER_PLAYER, "Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, type, button); return &ab; } @@ -6685,7 +6690,7 @@ void Player::removeActionButton(uint8 button) else buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save - sLog->outInfo(LOG_FILTER_PLAYER_LOADING, "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow()); + sLog->outDebug(LOG_FILTER_PLAYER, "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow()); } ActionButton const* Player::GetActionButton(uint8 button) @@ -7199,7 +7204,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto if (sWorld->getBoolConfig(CONFIG_PVP_TOKEN_ENABLE) && pvptoken) { - if (!victim || victim == this || victim ->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + if (!victim || victim == this || victim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) return true; if (victim->GetTypeId() == TYPEID_PLAYER) @@ -7809,7 +7814,7 @@ void Player::DuelComplete(DuelCompleteType type) if (!duel) return; - sLog->outDebug(LOG_FILTER_UNITS, "Duel Complete %s %s", GetName(), duel->opponent->GetName()); + sLog->outDebug(LOG_FILTER_UNITS, "Duel Complete %s %s", GetName().c_str(), duel->opponent->GetName().c_str()); WorldPacket data(SMSG_DUEL_COMPLETE, (1)); data << (uint8)((type != DUEL_INTERRUPTED) ? 1 : 0); @@ -8562,7 +8567,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 if (!spellInfo) { sLog->outError(LOG_FILTER_PLAYER_ITEMS, "Player::CastItemCombatSpell(GUID: %u, name: %s, enchant: %i): unknown spell %i is casted, ignoring...", - GetGUIDLow(), GetName(), pEnchant->ID, pEnchant->spellid[s]); + GetGUIDLow(), GetName().c_str(), pEnchant->ID, pEnchant->spellid[s]); continue; } @@ -11410,7 +11415,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest if(pItem->IsCurrencyToken()) { sLog->outError(LOG_FILTER_PLAYER, "Possible hacking attempt: Player %s [guid: %u] tried to move token [guid: %u, entry: %u] out of the currency bag!", - GetName(), GetGUIDLow(), pItem->GetGUIDLow(), pProto->ItemId); + GetName().c_str(), GetGUIDLow(), pItem->GetGUIDLow(), pProto->ItemId); return EQUIP_ERR_CANT_SWAP; } @@ -15659,7 +15664,7 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) phaseMgr.NotifyConditionChanged(phaseUdateData); uint32 zone = 0, area = 0; - + SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(quest_id); if (saBounds.first != saBounds.second) { @@ -15670,7 +15675,7 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) if (!HasAura(itr->second->spellId)) CastSpell(this, itr->second->spellId, true); } - + saBounds = sSpellMgr->GetSpellAreaForQuestEndMapBounds(quest_id); if (saBounds.first != saBounds.second) { @@ -16924,7 +16929,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) { if (GetSession()->Expansion() < mapEntry->Expansion()) { - sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player %s using client without required expansion tried login at non accessible map %u", GetName(), mapId); + sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player %s using client without required expansion tried login at non accessible map %u", GetName().c_str(), mapId); RelocateToHomebind(); } @@ -16979,7 +16984,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); else { - sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), mapId); + sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName().c_str(), GetGUIDLow(), mapId); RelocateToHomebind(); } } @@ -17014,7 +17019,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) SetTalentResetCost(fields[24].GetUInt32()); SetTalentResetTime(time_t(fields[25].GetUInt32())); - m_taxi.LoadTaxiMask(fields[17].GetCString()); // must be before InitTaxiNodesForLevel + m_taxi.LoadTaxiMask(fields[17].GetString()); // must be before InitTaxiNodesForLevel uint32 extraflags = fields[32].GetUInt16(); @@ -17099,7 +17104,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) if (GetSpecsCount() > MAX_TALENT_SPECS || GetActiveSpec() > MAX_TALENT_SPEC || GetSpecsCount() < MIN_TALENT_SPECS) { SetActiveSpec(0); - sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName(), GetGUIDLow(), GetSpecsCount(), GetActiveSpec()); + sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName().c_str(), GetGUIDLow(), GetSpecsCount(), GetActiveSpec()); } _LoadTalents(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADTALENTS)); @@ -17297,7 +17302,7 @@ void Player::_LoadCUFProfiles(PreparedQueryResult result) if (id > MAX_CUF_PROFILES) { - sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadCUFProfiles - Player (GUID: %u, name: %s) has an CUF profile with invalid id (id: %u), max is %i.", GetGUIDLow(), GetName(), id, MAX_CUF_PROFILES); + sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadCUFProfiles - Player (GUID: %u, name: %s) has an CUF profile with invalid id (id: %u), max is %i.", GetGUIDLow(), GetName().c_str(), id, MAX_CUF_PROFILES); continue; } @@ -17588,7 +17593,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) which doesnt have a valid bag (Bag GUID: %u, slot: %u). Possible cheat?", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot); item->DeleteFromInventoryDB(trans); delete item; continue; @@ -17602,7 +17607,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) which can't be loaded into inventory (Bag GUID: %u, slot: %u) by reason %u. Item will be sent by mail.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot, err); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot, err); item->DeleteFromInventoryDB(trans); problematicItems.push_back(item); } @@ -17649,25 +17654,25 @@ void Player::_LoadVoidStorage(PreparedQueryResult result) if (!itemId) { - sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid id (item id: " UI64FMTD ", entry: %u).", GetGUIDLow(), GetName(), itemId, itemEntry); + sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid id (item id: " UI64FMTD ", entry: %u).", GetGUIDLow(), GetName().c_str(), itemId, itemEntry); continue; } if (!sObjectMgr->GetItemTemplate(itemEntry)) { - sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid entry (item id: " UI64FMTD ", entry: %u).", GetGUIDLow(), GetName(), itemId, itemEntry); + sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid entry (item id: " UI64FMTD ", entry: %u).", GetGUIDLow(), GetName().c_str(), itemId, itemEntry); continue; } if (slot >= VOID_STORAGE_MAX_SLOT) { - sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid slot (item id: " UI64FMTD ", entry: %u, slot: %u).", GetGUIDLow(), GetName(), itemId, itemEntry, slot); + sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid slot (item id: " UI64FMTD ", entry: %u, slot: %u).", GetGUIDLow(), GetName().c_str(), itemId, itemEntry, slot); continue; } if (!sObjectMgr->GetPlayerByLowGUID(creatorGuid)) { - sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid creator guid, set to 0 (item id: " UI64FMTD ", entry: %u, creatorGuid: %u).", GetGUIDLow(), GetName(), itemId, itemEntry, creatorGuid); + sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid creator guid, set to 0 (item id: " UI64FMTD ", entry: %u, creatorGuid: %u).", GetGUIDLow(), GetName().c_str(), itemId, itemEntry, creatorGuid); creatorGuid = 0; } @@ -17693,14 +17698,14 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zoneId)) { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s', map: %u) has item (GUID: %u, entry: %u) limited to another map (%u). Deleting item.", - GetGUIDLow(), GetName(), GetMapId(), item->GetGUIDLow(), item->GetEntry(), zoneId); + GetGUIDLow(), GetName().c_str(), GetMapId(), item->GetGUIDLow(), item->GetEntry(), zoneId); remove = true; } // "Conjured items disappear if you are logged out for more than 15 minutes" else if (timeDiff > 15 * MINUTE && proto->Flags & ITEM_PROTO_FLAG_CONJURED) { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s', diff: %u) has conjured item (GUID: %u, entry: %u) with expired lifetime (15 minutes). Deleting item.", - GetGUIDLow(), GetName(), timeDiff, item->GetGUIDLow(), item->GetEntry()); + GetGUIDLow(), GetName().c_str(), timeDiff, item->GetGUIDLow(), item->GetEntry()); remove = true; } else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE)) @@ -17708,7 +17713,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F if (item->GetPlayedTime() > (2 * HOUR)) { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with expired refund time (%u). Deleting refund data and removing refundable flag.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry(), item->GetPlayedTime()); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), item->GetPlayedTime()); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); stmt->setUInt32(0, item->GetGUIDLow()); @@ -17731,7 +17736,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with refundable flags, but without data in item_refund_instance. Removing flag.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry()); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry()); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE); } } @@ -17753,7 +17758,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with ITEM_FLAG_BOP_TRADEABLE flag, but without data in item_soulbound_trade_data. Removing flag.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry()); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry()); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); } } @@ -17775,7 +17780,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has broken item (GUID: %u, entry: %u) in inventory. Deleting item.", - GetGUIDLow(), GetName(), itemGuid, itemEntry); + GetGUIDLow(), GetName().c_str(), itemGuid, itemEntry); remove = true; } // Remove item from inventory if necessary @@ -17790,7 +17795,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has unknown item (entry: %u) in inventory. Deleting item.", - GetGUIDLow(), GetName(), itemEntry); + GetGUIDLow(), GetName().c_str(), itemEntry); Item::DeleteFromInventoryDB(trans, itemGuid); Item::DeleteFromDB(trans, itemGuid); } @@ -17957,7 +17962,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) { questStatusData.Status = QUEST_STATUS_INCOMPLETE; sLog->outError(LOG_FILTER_PLAYER, "Player %s (GUID: %u) has invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", - GetName(), GetGUIDLow(), quest_id, qstatus); + GetName().c_str(), GetGUIDLow(), quest_id, qstatus); } questStatusData.Explored = (fields[2].GetUInt8() > 0); @@ -18211,12 +18216,12 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsDungeon()) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed or not dungeon map %d", GetName(), GetGUIDLow(), mapId); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed or not dungeon map %d", GetName().c_str(), GetGUIDLow(), mapId); deleteInstance = true; } else if (difficulty >= MAX_DIFFICULTY) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName().c_str(), GetGUIDLow(), difficulty, mapId); deleteInstance = true; } else @@ -18224,12 +18229,12 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) MapDifficulty const* mapDiff = GetMapDifficultyData(mapId, Difficulty(difficulty)); if (!mapDiff) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName().c_str(), GetGUIDLow(), difficulty, mapId); deleteInstance = true; } else if (!perm && group) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d, %d, %d", GetName(), GetGUIDLow(), GUID_LOPART(group->GetGUID()), mapId, instanceId, difficulty); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d, %d, %d", GetName().c_str(), GetGUIDLow(), GUID_LOPART(group->GetGUID()), mapId, instanceId, difficulty); deleteInstance = true; } } @@ -18354,7 +18359,7 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, b bind.save = save; bind.perm = permanent; if (!load) - sLog->outDebug(LOG_FILTER_MAPS, "Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + sLog->outDebug(LOG_FILTER_MAPS, "Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName().c_str(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); sScriptMgr->OnPlayerBindToInstance(this, save->GetDifficulty(), save->GetMapId(), permanent); return &bind; } @@ -18584,7 +18589,8 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); if (!info) { - sLog->outError(LOG_FILTER_PLAYER, "Player (Name %s) has incorrect race/class (%u/%u) pair. Can't be loaded.", GetName(), uint32(getRace()), uint32(getClass())); + sLog->outError(LOG_FILTER_PLAYER, "Player (Name %s) has incorrect race/class (%u/%u) pair. Can't be loaded.", + GetName().c_str(), uint32(getRace()), uint32(getClass())); return false; } @@ -19130,7 +19136,7 @@ void Player::_SaveInventory(SQLTransaction& trans) uint32 bagTestGUID = 0; if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot())) bagTestGUID = test2->GetGUIDLow(); - sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState()); + sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState()); // according to the test that was just performed nothing should be in this slot, delete stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_BAG_SLOT); stmt->setUInt32(0, bagTestGUID); @@ -19146,7 +19152,7 @@ void Player::_SaveInventory(SQLTransaction& trans) } else if (test != item) { - sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u are incorrect, the item with guid %u is there instead!", lowGuid, GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u are incorrect, the item with guid %u is there instead!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); // save all changes to the item... if (item->GetState() != ITEM_NEW) // only for existing items, no dupes item->SaveToDB(trans); @@ -20048,7 +20054,7 @@ void Player::StopCastingCharm() if (GetCharmGUID()) { - sLog->outFatal(LOG_FILTER_PLAYER, "Player %s (GUID: " UI64FMTD " is not able to uncharm unit (GUID: " UI64FMTD " Entry: %u, Type: %u)", GetName(), GetGUID(), GetCharmGUID(), charm->GetEntry(), charm->GetTypeId()); + sLog->outFatal(LOG_FILTER_PLAYER, "Player %s (GUID: " UI64FMTD " is not able to uncharm unit (GUID: " UI64FMTD " Entry: %u, Type: %u)", GetName().c_str(), GetGUID(), GetCharmGUID(), charm->GetEntry(), charm->GetTypeId()); if (charm->GetCharmerGUID()) { sLog->outFatal(LOG_FILTER_PLAYER, "Charmed unit has charmer guid " UI64FMTD, charm->GetCharmerGUID()); @@ -20136,7 +20142,7 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) GetSession()->SendPacket(&data); } else // announce to player that player he is whispering to is dnd and cannot receive his message - ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str()); + ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str()); if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster()) { @@ -20146,7 +20152,7 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) // announce to player that player he is whispering to is afk if (rPlayer->isAFK()) - ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->afkMsg.c_str()); + ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str()); // if player whisper someone, auto turn of dnd to be able to receive an answer if (isDND() && !rPlayer->isGameMaster()) @@ -21387,7 +21393,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 uint32 maxCount = MAX_MONEY_AMOUNT / pProto->BuyPrice; if ((uint32)count > maxCount) { - sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to buy %u item id %u, causing overflow", GetName(), (uint32)count, pProto->ItemId); + sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to buy %u item id %u, causing overflow", GetName().c_str(), (uint32)count, pProto->ItemId); count = (uint8)maxCount; } price = pProto->BuyPrice * count; //it should not exceed MAX_MONEY_AMOUNT @@ -21492,7 +21498,7 @@ void Player::UpdateHomebindTime(uint32 time) data << uint32(m_HomebindTimer); data << uint32(1); GetSession()->SendPacket(&data); - sLog->outDebug(LOG_FILTER_MAPS, "PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(), GetGUIDLow()); + sLog->outDebug(LOG_FILTER_MAPS, "PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName().c_str(), GetGUIDLow()); } } @@ -23735,11 +23741,11 @@ void Player::SetViewpoint(WorldObject* target, bool apply) { if (apply) { - sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName(), target->GetEntry(), target->GetTypeId()); + sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName().c_str(), target->GetEntry(), target->GetTypeId()); if (!AddUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) { - sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName()); + sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName().c_str()); return; } @@ -23751,11 +23757,11 @@ void Player::SetViewpoint(WorldObject* target, bool apply) } else { - sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s remove seer", GetName()); + sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s remove seer", GetName().c_str()); if (!RemoveUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) { - sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName()); + sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName().c_str()); return; } @@ -25097,7 +25103,7 @@ void Player::SetEquipmentSet(uint32 index, EquipmentSet eqset) if (!found) // something wrong... { - sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to save equipment set "UI64FMTD" (index %u), but that equipment set not found!", GetName(), eqset.Guid, index); + sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to save equipment set "UI64FMTD" (index %u), but that equipment set not found!", GetName().c_str(), eqset.Guid, index); return; } } @@ -25571,8 +25577,7 @@ void Player::SetReputation(uint32 factionentry, uint32 value) { GetReputationMgr().SetReputation(sFactionStore.LookupEntry(factionentry), value); } - -uint32 Player::GetReputation(uint32 factionentry) +uint32 Player::GetReputation(uint32 factionentry) const { return GetReputationMgr().GetReputation(sFactionStore.LookupEntry(factionentry)); } @@ -25952,7 +25957,7 @@ void Player::AddVoidStorageItemAtSlot(uint8 slot, const VoidStorageItem& item) if (_voidStorageItems[slot]) { - sLog->outError(LOG_FILTER_GENERAL, "Player::AddVoidStorageItemAtSlot - Player (GUID: %u, name: %s) tried to add an item to an used slot (item id: " UI64FMTD ", entry: %u, slot: %u).", GetGUIDLow(), GetName(), _voidStorageItems[slot]->ItemId, _voidStorageItems[slot]->ItemEntry, slot); + sLog->outError(LOG_FILTER_GENERAL, "Player::AddVoidStorageItemAtSlot - Player (GUID: %u, name: %s) tried to add an item to an used slot (item id: " UI64FMTD ", entry: %u, slot: %u).", GetGUIDLow(), GetName().c_str(), _voidStorageItems[slot]->ItemId, _voidStorageItems[slot]->ItemEntry, slot); GetSession()->SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INTERNAL_ERROR_1); return; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index f19e2f197b3..406552f78f5 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1024,7 +1024,7 @@ class PlayerTaxi ~PlayerTaxi() {} // Nodes void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level); - void LoadTaxiMask(const char* data); + void LoadTaxiMask(std::string const& data); bool IsTaximaskNodeKnown(uint32 nodeidx) const { @@ -1047,7 +1047,7 @@ class PlayerTaxi void AppendTaximaskTo(ByteBuffer& data, bool all); // Destinations - bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team); + bool LoadTaxiDestinationsFromString(std::string const& values, uint32 team); std::string SaveTaxiDestinationsToString(); void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } @@ -1383,12 +1383,12 @@ class Player : public Unit, public GridObject<Player> PhaseMgr& GetPhaseMgr() { return phaseMgr; } - void Say(const std::string& text, const uint32 language); - void Yell(const std::string& text, const uint32 language); - void TextEmote(const std::string& text); - void Whisper(const std::string& text, const uint32 language, uint64 receiver); - void WhisperAddon(const std::string& text, const std::string& prefix, Player* receiver); - void BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string& text, uint32 language, const char* addonPrefix = NULL) const; + void Say(std::string const& text, const uint32 language); + void Yell(std::string const& text, const uint32 language); + void TextEmote(std::string const& text); + void Whisper(std::string const& text, const uint32 language, uint64 receiver); + void WhisperAddon(std::string const& text, std::string const& prefix, Player* receiver); + void BuildPlayerChat(WorldPacket* data, uint8 msgtype, std::string const& text, uint32 language, const char* addonPrefix = NULL) const; /*********************************************************/ /*** STORAGE SYSTEM ***/ @@ -1877,7 +1877,7 @@ class Player : public Unit, public GridObject<Player> void AddTemporarySpell(uint32 spellId); void RemoveTemporarySpell(uint32 spellId); void SetReputation(uint32 factionentry, uint32 value); - uint32 GetReputation(uint32 factionentry); + uint32 GetReputation(uint32 factionentry) const; std::string GetGuildName(); // Talents diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index 1ded8cda81b..bc16a7f42a2 100755 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -182,9 +182,9 @@ void PlayerSocial::SendSocialList(Player* player) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_CONTACT_LIST"); } -bool PlayerSocial::HasFriend(uint32 friend_guid) +bool PlayerSocial::HasFriend(uint32 friendGuid) { - PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid); + PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid); if (itr != m_playerSocialMap.end()) return itr->second.Flags & SOCIAL_FLAG_FRIEND; return false; @@ -231,7 +231,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (pFriend && pFriend->GetName() && + if (pFriend && (!AccountMgr::IsPlayerAccount(security) || ((pFriend->GetTeam() == team || allowTwoSideWhoList) && (pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList))) && pFriend->IsVisibleGloballyFor(player)) @@ -249,18 +249,18 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data) { - data->Initialize(SMSG_FRIEND_STATUS, 5); + data->Initialize(SMSG_FRIEND_STATUS, 9); *data << uint8(result); *data << uint64(guid); } -void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast) +void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friendGuid, bool broadcast) { FriendInfo fi; WorldPacket data; - MakeFriendStatusPacket(result, friend_guid, &data); - GetFriendInfo(player, friend_guid, fi); + MakeFriendStatusPacket(result, friendGuid, &data); + GetFriendInfo(player, friendGuid, fi); switch (result) { case FRIEND_ADDED_OFFLINE: @@ -329,7 +329,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) if (!result) return social; - uint32 friend_guid = 0; + uint32 friendGuid = 0; uint8 flags = 0; std::string note = ""; @@ -337,11 +337,11 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) { Field* fields = result->Fetch(); - friend_guid = fields[0].GetUInt32(); + friendGuid = fields[0].GetUInt32(); flags = fields[1].GetUInt8(); note = fields[2].GetString(); - social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note); + social->m_playerSocialMap[friendGuid] = FriendInfo(flags, note); // client's friends list and ignore list limit if (social->m_playerSocialMap.size() >= (SOCIALMGR_FRIEND_LIMIT + SOCIALMGR_IGNORE_LIMIT)) @@ -351,4 +351,3 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) return social; } - diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 99a40d6110f..85daf369f69 100755 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -55,12 +55,10 @@ struct FriendInfo std::string Note; FriendInfo() : Status(FRIEND_STATUS_OFFLINE), Flags(0), Area(0), Level(0), Class(0), Note() - { - } + { } - FriendInfo(uint8 flags, const std::string& note) : Status(FRIEND_STATUS_OFFLINE), Flags(flags), Area(0), Level(0), Class(0), Note(note) - { - } + FriendInfo(uint8 flags, std::string const& note) : Status(FRIEND_STATUS_OFFLINE), Flags(flags), Area(0), Level(0), Class(0), Note(note) + { } }; typedef std::map<uint32, FriendInfo> PlayerSocialMap; @@ -149,4 +147,3 @@ class SocialMgr #define sSocialMgr ACE_Singleton<SocialMgr, ACE_Null_Mutex>::instance() #endif - diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 345a07ae966..117b93e8d90 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -507,7 +507,7 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) bool Transport::AddPassenger(Player* passenger) { if (m_passengers.insert(passenger).second) - sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s boarded transport %s.", passenger->GetName(), GetName()); + sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s boarded transport %s.", passenger->GetName().c_str(), GetName().c_str()); sScriptMgr->OnAddPassenger(this, passenger); return true; @@ -516,7 +516,7 @@ bool Transport::AddPassenger(Player* passenger) bool Transport::RemovePassenger(Player* passenger) { if (m_passengers.erase(passenger)) - sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s removed from transport %s.", passenger->GetName(), GetName()); + sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s removed from transport %s.", passenger->GetName().c_str(), GetName().c_str()); sScriptMgr->OnRemovePassenger(this, passenger); return true; @@ -605,7 +605,7 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure { if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID) { - sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.first, GetName()); + sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.first, GetName().c_str()); GetMap()->ScriptsStart(sEventScripts, eventid, this, this); EventInform(eventid); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 879b6bcf078..a9f9cb763a5 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6369,7 +6369,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere victim->CastCustomSpell(beaconTarget, triggered_spell_id, &basepoints0, NULL, NULL, true, 0, triggeredByAura); return true; } - + return false; } // Judgements of the Wise @@ -8180,11 +8180,11 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const if (GetGUID() != guid) { if (Player const* player = ToPlayer()) - sLog->outError(LOG_FILTER_UNITS, "Player %s has invalid faction (faction template id) #%u", player->GetName(), getFaction()); + sLog->outError(LOG_FILTER_UNITS, "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), getFaction()); else if (Creature const* creature = ToCreature()) sLog->outError(LOG_FILTER_UNITS, "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction()); else - sLog->outError(LOG_FILTER_UNITS, "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName(), uint32(GetTypeId()), getFaction()); + sLog->outError(LOG_FILTER_UNITS, "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), getFaction()); guid = GetGUID(); } @@ -8930,7 +8930,7 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { if (!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) - sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to charm unit %u, but it already has a charmed unit " UI64FMTD "", GetName(), charm->GetEntry(), GetCharmGUID()); + sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to charm unit %u, but it already has a charmed unit " UI64FMTD "", GetName().c_str(), charm->GetEntry(), GetCharmGUID()); charm->m_ControlledByPlayer = true; // TODO: maybe we can use this flag to check if controlled by player @@ -8959,7 +8959,7 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { if (!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) - sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to uncharm unit %u, but it has another charmed unit " UI64FMTD "", GetName(), charm->GetEntry(), GetCharmGUID()); + sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to uncharm unit %u, but it has another charmed unit " UI64FMTD "", GetName().c_str(), charm->GetEntry(), GetCharmGUID()); } if (!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) @@ -16747,11 +16747,11 @@ void Unit::SendThreatListUpdate() WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8); data.append(GetPackGUID()); data << uint32(count); - std::list<HostileReference*>& tlist = getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) + ThreatContainer::StorageType const &tlist = getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data.appendPackGUID((*itr)->getUnitGuid()); - data << uint32((*itr)->getThreat() * 100); + data << uint32((*itr)->getThreat()*100); } SendMessageToSet(&data, false); } @@ -16768,8 +16768,8 @@ void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) data.append(GetPackGUID()); data.appendPackGUID(pHostileReference->getUnitGuid()); data << uint32(count); - std::list<HostileReference*>& tlist = getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) + ThreatContainer::StorageType const &tlist = getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data.appendPackGUID((*itr)->getUnitGuid()); data << uint32((*itr)->getThreat()); @@ -16858,7 +16858,7 @@ void Unit::StopAttackFaction(uint32 faction_id) void Unit::OutDebugInfo() const { sLog->outError(LOG_FILTER_UNITS, "Unit::OutDebugInfo"); - sLog->outInfo(LOG_FILTER_UNITS, "GUID "UI64FMTD", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName()); + sLog->outInfo(LOG_FILTER_UNITS, "GUID "UI64FMTD", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName().c_str()); sLog->outInfo(LOG_FILTER_UNITS, "OwnerGUID "UI64FMTD", MinionGUID "UI64FMTD", CharmerGUID "UI64FMTD", CharmedGUID "UI64FMTD, GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID()); sLog->outInfo(LOG_FILTER_UNITS, "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask); if (IsInWorld()) diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 77c52a9bbba..7b9a99405e5 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -323,7 +323,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) ASSERT(!seat->second.Passenger); } - sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); + sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); seat->second.Passenger = unit->GetGUID(); if (seat->second.SeatInfo->CanEnterOrExit()) @@ -396,7 +396,7 @@ void Vehicle::RemovePassenger(Unit* unit) SeatMap::iterator seat = GetSeatIteratorForPassenger(unit); ASSERT(seat != Seats.end()); - sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); + sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); seat->second.Passenger = 0; if (seat->second.SeatInfo->CanEnterOrExit()) diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 81a132a40d8..b19abc778a9 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -163,7 +163,7 @@ Unit* ObjectAccessor::FindUnit(uint64 guid) return GetObjectInWorld(guid, (Unit*)NULL); } -Player* ObjectAccessor::FindPlayerByName(const char* name) +Player* ObjectAccessor::FindPlayerByName(std::string const& name) { TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); std::string nameStr = name; diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index 0a1b41eb292..41a7abc9a24 100755 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -74,12 +74,11 @@ class HashMapHolder static LockType* GetLock() { return &i_lock; } private: - //Non instanceable only static HashMapHolder() {} static LockType i_lock; - static MapType m_objectMap; + static MapType m_objectMap; }; class ObjectAccessor @@ -120,9 +119,7 @@ class ObjectAccessor static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/) { Player* player = HashMapHolder<Player>::Find(guid); - if (player && player->IsInWorld()) - return player; - return NULL; + return player && player->IsInWorld() ? player : NULL; } static Unit* GetObjectInWorld(uint64 guid, Unit* /*typeSpecifier*/) @@ -193,7 +190,7 @@ class ObjectAccessor static Player* FindPlayer(uint64); static Creature* FindCreature(uint64); static Unit* FindUnit(uint64); - static Player* FindPlayerByName(const char* name); + static Player* FindPlayerByName(std::string const& name); // when using this, you must use the hashmapholder's lock static HashMapHolder<Player>::MapType const& GetPlayers() diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 87f4a0e6dbf..146654d69af 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1874,7 +1874,7 @@ Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const } // name must be checked to correctness (if received) before call this function -uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const +uint64 ObjectMgr::GetPlayerGUIDByName(std::string const& name) const { uint64 guid = 0; @@ -7036,7 +7036,7 @@ void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_ cell_guids.corpses.erase(player_guid); } -void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string table, bool starter, bool go) +void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go) { uint32 oldMSTime = getMSTime(); @@ -7049,7 +7049,6 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string table, if (!result) { sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 quest relations from `%s`, table is empty.", table.c_str()); - return; } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 496d5ae224f..e7575bec5d8 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -661,11 +661,11 @@ class ObjectMgr void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const; - uint64 GetPlayerGUIDByName(std::string name) const; + uint64 GetPlayerGUIDByName(std::string const& name) const; bool GetPlayerNameByGUID(uint64 guid, std::string &name) const; uint32 GetPlayerTeamByGUID(uint64 guid) const; uint32 GetPlayerAccountIdByGUID(uint64 guid) const; - uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const; + uint32 GetPlayerAccountIdByPlayerName(std::string const& name) const; uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 team); void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost); @@ -1054,12 +1054,12 @@ class ObjectMgr // reserved names void LoadReservedPlayersNames(); - bool IsReservedName(const std::string& name) const; + bool IsReservedName(std::string const& name) const; // name with valid structure and symbols - static uint8 CheckPlayerName(const std::string& name, bool create = false); - static PetNameInvalidReason CheckPetName(const std::string& name); - static bool IsValidCharterName(const std::string& name); + static uint8 CheckPlayerName(std::string const& name, bool create = false); + static PetNameInvalidReason CheckPetName(std::string const& name); + static bool IsValidCharterName(std::string const& name); static bool CheckDeclinedNames(std::wstring w_ownname, DeclinedName const& names); @@ -1069,10 +1069,10 @@ class ObjectMgr if (itr == _gameTeleStore.end()) return NULL; return &itr->second; } - GameTele const* GetGameTele(const std::string& name) const; + GameTele const* GetGameTele(std::string const& name) const; GameTeleContainer const& GetGameTeleMap() const { return _gameTeleStore; } bool AddGameTele(GameTele& data); - bool DeleteGameTele(const std::string& name); + bool DeleteGameTele(std::string const& name); TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const { @@ -1127,7 +1127,7 @@ class ObjectMgr // for wintergrasp only GraveYardContainer GraveYardStore; - static void AddLocaleString(const std::string& s, LocaleConstant locale, StringVector& data); + static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data); static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value) { if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) @@ -1236,7 +1236,7 @@ class ObjectMgr private: void LoadScripts(ScriptsType type); void CheckScripts(ScriptsType type, std::set<int32>& ids); - void LoadQuestRelationsHelper(QuestRelations& map, std::string table, bool starter, bool go); + void LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go); void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count); MailLevelRewardContainer _mailLevelRewardStore; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index a02c18ca008..1cd442e48f9 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -81,18 +81,22 @@ void VisibleChangesNotifier::Visit(PlayerMapType &m) iter->getSource()->UpdateVisibilityOf(&i_object); - if (!iter->getSource()->GetSharedVisionList().empty()) + if (iter->getSource()->HasSharedVision()) + { for (SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin(); i != iter->getSource()->GetSharedVisionList().end(); ++i) + { if ((*i)->m_seer == iter->getSource()) (*i)->UpdateVisibilityOf(&i_object); + } + } } } void VisibleChangesNotifier::Visit(CreatureMapType &m) { for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) - if (!iter->getSource()->GetSharedVisionList().empty()) + if (iter->getSource()->HasSharedVision()) for (SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin(); i != iter->getSource()->GetSharedVisionList().end(); ++i) if ((*i)->m_seer == iter->getSource()) @@ -154,7 +158,7 @@ void PlayerRelocationNotifier::Visit(CreatureMapType &m) void CreatureRelocationNotifier::Visit(PlayerMapType &m) { - for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Player* player = iter->getSource(); @@ -170,7 +174,7 @@ void CreatureRelocationNotifier::Visit(CreatureMapType &m) if (!i_creature.isAlive()) return; - for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Creature* c = iter->getSource(); CreatureUnitRelocationWorker(&i_creature, c); @@ -249,7 +253,7 @@ void MessageDistDeliverer::Visit(PlayerMapType &m) continue; // Send packet to all who are sharing the player's vision - if (!target->GetSharedVisionList().empty()) + if (target->HasSharedVision()) { SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); for (; i != target->GetSharedVisionList().end(); ++i) @@ -274,7 +278,7 @@ void MessageDistDeliverer::Visit(CreatureMapType &m) continue; // Send packet to all who are sharing the creature's vision - if (!target->GetSharedVisionList().empty()) + if (target->HasSharedVision()) { SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); for (; i != target->GetSharedVisionList().end(); ++i) diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 6fb15cb7756..527b7801a72 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -104,12 +104,15 @@ bool Group::Create(Player* leader) m_leaderGuid = leaderGuid; m_leaderName = leader->GetName(); - m_groupType = (isBGGroup() || isBFGroup()) ? GROUPTYPE_BGRAID : GROUPTYPE_NORMAL; + if (isBGGroup() || isBFGroup()) + m_groupType = GROUPTYPE_BGRAID; if (m_groupType & GROUPTYPE_RAID) _initRaidSubGroupsCounter(); - m_lootMethod = GROUP_LOOT; + if (!isLFGGroup()) + m_lootMethod = GROUP_LOOT; + m_lootThreshold = ITEM_QUALITY_UNCOMMON; m_looterGuid = leaderGuid; @@ -219,13 +222,7 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, SubGroupCounterIncrease(subgroup); - if (isLFGGroup()) - { - LfgDungeonSet Dungeons; - Dungeons.insert(sLFGMgr->GetDungeon(GetGUID())); - sLFGMgr->SetSelectedDungeons(member.guid, Dungeons); - sLFGMgr->SetState(member.guid, sLFGMgr->GetState(GetGUID())); - } + sLFGMgr->SetupGroupMember(member.guid, GetGUID()); } void Group::ConvertToLFG() @@ -630,9 +627,9 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV if (isLFGGroup() && GetMembersCount() == 1) { - Player* Leader = ObjectAccessor::FindPlayer(GetLeaderGUID()); - LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(sLFGMgr->GetDungeon(GetGUID())); - if ((Leader && dungeon && Leader->isAlive() && Leader->GetMapId() != uint32(dungeon->map)) || !dungeon) + Player* leader = ObjectAccessor::FindPlayer(GetLeaderGUID()); + uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID()); + if (!mapId || !leader || (leader->isAlive() && leader->GetMapId() != mapId)) { Disband(); return false; @@ -2139,7 +2136,7 @@ void Group::BroadcastGroupUpdate(void) { pp->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2); pp->ForceValuesUpdateAtIndex(UNIT_FIELD_FACTIONTEMPLATE); - sLog->outDebug(LOG_FILTER_GENERAL, "-- Forced group value update for '%s'", pp->GetName()); + sLog->outDebug(LOG_FILTER_GENERAL, "-- Forced group value update for '%s'", pp->GetName().c_str()); } } } @@ -2147,12 +2144,12 @@ void Group::BroadcastGroupUpdate(void) void Group::ResetMaxEnchantingLevel() { m_maxEnchantingLevel = 0; - Player* pMember = NULL; + Player* member = NULL; for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { - pMember = ObjectAccessor::FindPlayer(citr->guid); - if (pMember && m_maxEnchantingLevel < pMember->GetSkillValue(SKILL_ENCHANTING)) - m_maxEnchantingLevel = pMember->GetSkillValue(SKILL_ENCHANTING); + member = ObjectAccessor::FindPlayer(citr->guid); + if (member && m_maxEnchantingLevel < member->GetSkillValue(SKILL_ENCHANTING)) + m_maxEnchantingLevel = member->GetSkillValue(SKILL_ENCHANTING); } } diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 9bd9fb4ffb9..ec9e6d7d1e2 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -923,7 +923,7 @@ void Guild::BankMoveItemData::LogAction(MoveItemData* pFrom) const if (!pFrom->IsBank() && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE) && !AccountMgr::IsPlayerAccount(m_pPlayer->GetSession()->GetSecurity())) // TODO: move to scripts sLog->outCommand(m_pPlayer->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", - m_pPlayer->GetName(), m_pPlayer->GetSession()->GetAccountId(), + m_pPlayer->GetName().c_str(), m_pPlayer->GetSession()->GetAccountId(), pFrom->GetItem()->GetTemplate()->Name1.c_str(), pFrom->GetItem()->GetEntry(), pFrom->GetItem()->GetCount(), m_pGuild->GetId()); } @@ -1094,7 +1094,7 @@ bool Guild::Create(Player* pLeader, const std::string& name) _CreateLogHolders(); sLog->outDebug(LOG_FILTER_GUILD, "GUILD: creating guild [%s] for leader %s (%u)", - name.c_str(), pLeader->GetName(), GUID_LOPART(m_leaderGuid)); + name.c_str(), pLeader->GetName().c_str(), GUID_LOPART(m_leaderGuid)); PreparedStatement* stmt = NULL; SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -1464,7 +1464,7 @@ void Guild::HandleSetLeader(WorldSession* session, const std::string& name) { _SetLeaderGUID(pNewLeader); pOldLeader->ChangeRank(GR_OFFICER); - _BroadcastEvent(GE_LEADER_CHANGED, 0, player->GetName(), name.c_str()); + _BroadcastEvent(GE_LEADER_CHANGED, 0, player->GetName().c_str(), name.c_str()); } } else @@ -1540,9 +1540,9 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId) SendBankList(session, tabId, false, true); } -void Guild::HandleInviteMember(WorldSession* session, const std::string& name) +void Guild::HandleInviteMember(WorldSession* session, std::string const& name) { - Player* pInvitee = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pInvitee = sObjectAccessor->FindPlayerByName(name); if (!pInvitee) { SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PLAYER_NOT_FOUND_S, name); @@ -1578,7 +1578,7 @@ void Guild::HandleInviteMember(WorldSession* session, const std::string& name) return; } - sLog->outDebug(LOG_FILTER_GUILD, "Player %s invited %s to join his Guild", player->GetName(), name.c_str()); + sLog->outDebug(LOG_FILTER_GUILD, "Player %s invited %s to join his Guild", player->GetName().c_str(), name.c_str()); pInvitee->SetGuildIdInvited(m_id); _LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUIDLow(), pInvitee->GetGUIDLow()); @@ -1611,7 +1611,7 @@ void Guild::HandleInviteMember(WorldSession* session, const std::string& name) data.WriteBit(oldGuildGuid[3]); data.WriteBit(oldGuildGuid[0]); data.WriteBit(newGuildGuid[5]); - data.WriteBits(strlen(player->GetName()), 7); + data.WriteBits(player->GetName().size(), 7); data.WriteBit(newGuildGuid[4]); data.FlushBits(); @@ -1657,7 +1657,7 @@ void Guild::HandleAcceptMember(WorldSession* session) if (AddMember(player->GetGUID())) { _LogEvent(GUILD_EVENT_LOG_JOIN_GUILD, player->GetGUIDLow()); - _BroadcastEvent(GE_JOINED, player->GetGUID(), player->GetName()); + _BroadcastEvent(GE_JOINED, player->GetGUID(), player->GetName().c_str()); sGuildFinderMgr->RemoveMembershipRequest(player->GetGUIDLow(), GUID_LOPART(this->GetGUID())); } } @@ -1682,7 +1682,7 @@ void Guild::HandleLeaveMember(WorldSession* session) DeleteMember(player->GetGUID(), false, false); _LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUIDLow()); - _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName()); + _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str()); SendCommandResult(session, GUILD_QUIT_S, ERR_GUILD_COMMAND_SUCCESS, m_name); } @@ -1711,7 +1711,7 @@ void Guild::HandleRemoveMember(WorldSession* session, uint64 guid) // After call to DeleteMember pointer to member becomes invalid DeleteMember(guid, false, true); _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid)); - _BroadcastEvent(GE_REMOVED, 0, removedPlayer->GetName(), player->GetName()); + _BroadcastEvent(GE_REMOVED, 0, removedPlayer->GetName().c_str(), player->GetName().c_str()); } } else if (removedPlayer) @@ -1767,7 +1767,7 @@ void Guild::HandleUpdateMemberRank(WorldSession* session, uint64 targetGuid, boo uint32 newRankId = member->GetRankId() + (demote ? 1 : -1); member->ChangeRank(newRankId); _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUIDLow(), GUID_LOPART(member->GetGUID()), newRankId); - _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, 0, player->GetName(), member->GetName().c_str(), _GetRankName(newRankId).c_str()); + _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, 0, player->GetName().c_str(), member->GetName().c_str(), _GetRankName(newRankId).c_str()); } } @@ -1858,7 +1858,7 @@ void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount, bool { sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)", - player->GetName(), player->GetSession()->GetAccountId(), amount, m_id); + player->GetName().c_str(), player->GetSession()->GetAccountId(), amount, m_id); } // Log guild bank event _LogBankEvent(trans, cashFlow ? GUILD_BANK_LOG_CASH_FLOW_DEPOSIT : GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUIDLow(), amount); @@ -1919,7 +1919,7 @@ void Guild::HandleMemberLogout(WorldSession* session) member->SetStats(player); member->UpdateLogoutTime(); } - _BroadcastEvent(GE_SIGNED_OFF, player->GetGUID(), player->GetName()); + _BroadcastEvent(GE_SIGNED_OFF, player->GetGUID(), player->GetName().c_str()); SaveToDB(); } @@ -2124,10 +2124,10 @@ void Guild::SendLoginInfo(WorldSession* session) const HandleGuildRanks(session); - _BroadcastEvent(GE_SIGNED_ON, session->GetPlayer()->GetGUID(), session->GetPlayer()->GetName()); + _BroadcastEvent(GE_SIGNED_ON, session->GetPlayer()->GetGUID(), session->GetPlayer()->GetName().c_str()); // Send to self separately, player is not in world yet and is not found by _BroadcastEvent - data.Initialize(SMSG_GUILD_EVENT, 1 + 1 + strlen(session->GetPlayer()->GetName()) + 8); + data.Initialize(SMSG_GUILD_EVENT, 1 + 1 + session->GetPlayer()->GetName().size() + 8); data << uint8(GE_SIGNED_ON); data << uint8(1); data << session->GetPlayer()->GetName(); diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index f39cd386a96..5ac170a9cb8 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -323,11 +323,11 @@ private: Member(uint32 guildId, uint64 guid, uint32 rankId) : m_guildId(guildId), m_guid(guid), m_logoutTime(::time(NULL)), m_rankId(rankId) { } void SetStats(Player* player); - void SetStats(const std::string& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId); + void SetStats(std::string const& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId); bool CheckStats() const; - void SetPublicNote(const std::string& publicNote); - void SetOfficerNote(const std::string& officerNote); + void SetPublicNote(std::string const& publicNote); + void SetOfficerNote(std::string const& officerNote); std::string GetPublicNote() { return m_publicNote; }; std::string GetOfficerNote() { return m_officerNote; }; @@ -336,7 +336,7 @@ private: void SaveToDB(SQLTransaction& trans) const; uint64 GetGUID() const { return m_guid; } - std::string GetName() const { return m_name; } + std::string const& GetName() const { return m_name; } uint32 GetAccountId() const { return m_accountId; } uint32 GetRankId() const { return m_rankId; } uint8 GetClass() const { return m_class; } @@ -515,7 +515,7 @@ private: { public: RankInfo(uint32 guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } - RankInfo(uint32 guildId, uint32 rankId, const std::string& name, uint32 rights, uint32 money) : + RankInfo(uint32 guildId, uint32 rankId, std::string const& name, uint32 rights, uint32 money) : m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights), m_bankMoneyPerDay(money) { } void LoadFromDB(Field* fields); @@ -523,8 +523,8 @@ private: uint32 GetId() const { return m_rankId; } - std::string GetName() const { return m_name; } - void SetName(const std::string& name); + std::string const& GetName() const { return m_name; } + void SetName(std::string const& name); uint32 GetRights() const { return m_rights; } void SetRights(uint32 rights); @@ -678,13 +678,13 @@ private: typedef std::vector<BankTab*> BankTabs; public: - static void SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, const std::string& param = ""); + static void SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, std::string const& param = ""); static void SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode); Guild(); ~Guild(); - bool Create(Player* pLeader, const std::string& name); + bool Create(Player* pLeader, std::string const& name); void Disband(); void SaveToDB(); @@ -693,29 +693,29 @@ public: uint32 GetId() const { return m_id; } uint64 GetGUID() const { return MAKE_NEW_GUID(m_id, 0, HIGHGUID_GUILD); } uint64 GetLeaderGUID() const { return m_leaderGuid; } - const std::string& GetName() const { return m_name; } - const std::string& GetMOTD() const { return m_motd; } - const std::string& GetInfo() const { return m_info; } + std::string const& GetName() const { return m_name; } + std::string const& GetMOTD() const { return m_motd; } + std::string const& GetInfo() const { return m_info; } // Handle client commands void HandleRoster(WorldSession* session = NULL); // NULL = broadcast void HandleQuery(WorldSession* session); void HandleGuildRanks(WorldSession* session) const; - void HandleSetMOTD(WorldSession* session, const std::string& motd); - void HandleSetInfo(WorldSession* session, const std::string& info); + void HandleSetMOTD(WorldSession* session, std::string const& motd); + void HandleSetInfo(WorldSession* session, std::string const& info); void HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo); - void HandleSetLeader(WorldSession* session, const std::string& name); - void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, const std::string& name, const std::string& icon); + void HandleSetLeader(WorldSession* session, std::string const& name); + void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string const& name, std::string const& icon); void HandleSetMemberNote(WorldSession* session, std::string const& note, uint64 guid, bool isPublic); - void HandleSetRankInfo(WorldSession* session, uint32 rankId, const std::string& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec rightsAndSlots); + void HandleSetRankInfo(WorldSession* session, uint32 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec rightsAndSlots); void HandleBuyBankTab(WorldSession* session, uint8 tabId); - void HandleInviteMember(WorldSession* session, const std::string& name); + void HandleInviteMember(WorldSession* session, std::string const& name); void HandleAcceptMember(WorldSession* session); void HandleLeaveMember(WorldSession* session); void HandleRemoveMember(WorldSession* session, uint64 guid); void HandleUpdateMemberRank(WorldSession* session, uint64 targetGuid, bool demote); void HandleSetMemberRank(WorldSession* session, uint64 targetGuid, uint64 setterGuid, uint32 rank); - void HandleAddNewRank(WorldSession* session, const std::string& name); + void HandleAddNewRank(WorldSession* session, std::string const& name); void HandleRemoveRank(WorldSession* session, uint32 rankId); void HandleMemberDepositMoney(WorldSession* session, uint32 amount, bool cashFlow = false); bool HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair = false); @@ -746,8 +746,8 @@ public: bool Validate(); // Broadcasts - void BroadcastToGuild(WorldSession* session, bool officerOnly, const std::string& msg, uint32 language = LANG_UNIVERSAL) const; - void BroadcastAddonToGuild(WorldSession* session, bool officerOnly, const std::string& msg, const std::string& prefix) const; + void BroadcastToGuild(WorldSession* session, bool officerOnly, std::string const& msg, uint32 language = LANG_UNIVERSAL) const; + void BroadcastAddonToGuild(WorldSession* session, bool officerOnly, std::string const& msg, std::string const& prefix) const; void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const; void BroadcastPacket(WorldPacket* packet) const; @@ -773,7 +773,7 @@ public: void SwapItemsWithInventory(Player* player, bool toChar, uint8 tabId, uint8 slotId, uint8 playerBag, uint8 playerSlotId, uint32 splitedAmount); // Bank tabs - void SetBankTabText(uint8 tabId, const std::string& text); + void SetBankTabText(uint8 tabId, std::string const& text); AchievementMgr<Guild>& GetAchievementMgr() { return m_achievementMgr; } AchievementMgr<Guild> const& GetAchievementMgr() const { return m_achievementMgr; } @@ -836,7 +836,7 @@ private: Members::iterator itr = m_members.find(GUID_LOPART(guid)); return itr != m_members.end() ? itr->second : NULL; } - inline Member* GetMember(WorldSession* session, const std::string& name) + inline Member* GetMember(WorldSession* session, std::string const& name) { for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) if (itr->second->GetName() == name) @@ -859,7 +859,7 @@ private: // Creates default guild ranks with names in given locale void _CreateDefaultGuildRanks(LocaleConstant loc); // Creates new rank - void _CreateRank(const std::string& name, uint32 rights); + void _CreateRank(std::string const& name, uint32 rights); // Update account number when member added/removed from guild void _UpdateAccountsNumber(); bool _IsLeader(Player* player) const; diff --git a/src/server/game/Guilds/GuildMgr.h b/src/server/game/Guilds/GuildMgr.h index 24c1a4c0d5d..dea0fee8d8d 100644 --- a/src/server/game/Guilds/GuildMgr.h +++ b/src/server/game/Guilds/GuildMgr.h @@ -33,7 +33,7 @@ public: Guild* GetGuildByLeader(uint64 guid) const; Guild* GetGuildById(uint32 guildId) const; Guild* GetGuildByGuid(uint64 guid) const; - Guild* GetGuildByName(const std::string& guildName) const; + Guild* GetGuildByName(std::string const& guildName) const; std::string GetGuildNameById(uint32 guildId) const; void LoadGuildXpForLevel(); diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index 27ec8433fe1..0790acb4ae6 100755 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -90,7 +90,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData) if (!normalizePlayerName(invitedName)) return; - player = sObjectAccessor->FindPlayerByName(invitedName.c_str()); + player = sObjectAccessor->FindPlayerByName(invitedName); } if (!player) @@ -140,7 +140,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData) return; } - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName(), invitedName.c_str()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName().c_str(), invitedName.c_str()); player->SetArenaTeamIdInvited(arenaTeam->GetId()); diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 53cf3fe7caf..ac440b23d65 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -288,7 +288,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData) sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) " "to auctioneer %u with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u", - _player->GetName(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), + _player->GetName().c_str(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); sAuctionMgr->AddAItem(item); auctionHouse->AddAuction(AH); @@ -337,7 +337,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData) sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to " "auctioneer %u with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u", - _player->GetName(), _player->GetGUIDLow(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), + _player->GetName().c_str(), _player->GetGUIDLow(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUIDLow(), AH->auctioneer, newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); sAuctionMgr->AddAItem(newItem); auctionHouse->AddAuction(AH); diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 62ab55f70f8..f9eeb52a09a 100755 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -208,7 +208,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData) SendPacket(&data); sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", - bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); + bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName().c_str()); } else { @@ -257,11 +257,10 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData) WorldPacket data; // send status packet (in queue) sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, member, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, ginfo->ArenaType); member->GetSession()->SendPacket(&data); - - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", + bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str()); } sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: group end"); - } sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); @@ -387,7 +386,7 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket& recvData) BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId); if (!bl) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId, _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId, _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -432,7 +431,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) if (!_player->InBattlegroundQueue()) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (Name: %s, GUID: %u), he is not in bg_queue.", _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (Name: %s, GUID: %u), he is not in bg_queue.", _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -487,13 +486,13 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) sBattlegroundMgr->BuildStatusFailedPacket(&data2, bg, _player, 0, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS); _player->GetSession()->SendPacket(&data2); action = 0; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow()); } //if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue if (_player->getLevel() > bg->GetMaxLevel()) { sLog->outError(LOG_FILTER_NETWORKIO, "Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!", - _player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); + _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); action = 0; } } @@ -538,7 +537,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); // add only in HandleMoveWorldPortAck() // bg->AddPlayer(_player, team); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); break; case 0: // leave queue if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE) @@ -563,7 +562,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) if (!ginfo.ArenaType) sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); SendPacket(&data); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId); break; default: sLog->outError(LOG_FILTER_NETWORKIO, "Battleground port: unknown action %u", action); @@ -767,7 +766,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena join as group start"); if (isRated) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), matchmakerRating, arenatype); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName().c_str(), matchmakerRating, arenatype); bg->SetRated(true); } else @@ -797,8 +796,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData) WorldPacket data; // send status packet (in queue) sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, member, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, arenatype); member->GetSession()->SendPacket(&data); - - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str()); } } else @@ -810,8 +808,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData) WorldPacket data; // send status packet (in queue) sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, GetPlayer(), queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, arenatype); SendPacket(&data); - - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName().c_str()); } sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } @@ -828,7 +825,7 @@ void WorldSession::HandleReportPvPAFK(WorldPacket & recvData) return; } - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName(), reportedPlayer->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName().c_str(), reportedPlayer->GetName().c_str()); reportedPlayer->ReportedAfkBy(_player); } diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index d1209eead22..0cecd3d615a 100755 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -404,7 +404,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) uint32 team = 0; recvData >> eventId >> inviteId >> name >> status >> rank; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) { invitee = player->GetGUID(); team = player->GetTeam(); diff --git a/src/server/game/Handlers/ChannelHandler.cpp b/src/server/game/Handlers/ChannelHandler.cpp index 1fb0f8a2f32..7db49e50fa2 100755 --- a/src/server/game/Handlers/ChannelHandler.cpp +++ b/src/server/game/Handlers/ChannelHandler.cpp @@ -52,9 +52,9 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) if (channelName.empty()) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { - cMgr->team = _player->GetTeam(); + cMgr->setTeam(_player->GetTeam()); if (Channel* chn = cMgr->GetJoinChannel(channelName, channelId)) chn->Join(_player->GetGUID(), pass.c_str()); } @@ -73,7 +73,7 @@ void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket) if (channelname.empty()) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Leave(_player->GetGUID(), true); @@ -88,7 +88,7 @@ void WorldSession::HandleChannelList(WorldPacket& recvPacket) uint32 length = recvPacket.ReadBits(8); std::string channelname = recvPacket.ReadString(length); - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->List(_player); } @@ -102,7 +102,7 @@ void WorldSession::HandleChannelPassword(WorldPacket& recvPacket) std::string channelname = recvPacket.ReadString(nameLength); std::string pass = recvPacket.ReadString(passLength); - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Password(_player->GetGUID(), pass.c_str()); } @@ -120,7 +120,7 @@ void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket) if (!normalizePlayerName(newp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SetOwner(_player->GetGUID(), newp.c_str()); } @@ -131,7 +131,7 @@ void WorldSession::HandleChannelOwner(WorldPacket& recvPacket) uint32 length = recvPacket.ReadBits(8); std::string channelname = recvPacket.ReadString(length); - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SendWhoOwner(_player->GetGUID()); } @@ -149,7 +149,7 @@ void WorldSession::HandleChannelModerator(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SetModerator(_player->GetGUID(), otp.c_str()); } @@ -167,7 +167,7 @@ void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->UnsetModerator(_player->GetGUID(), otp.c_str()); } @@ -184,7 +184,7 @@ void WorldSession::HandleChannelMute(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SetMute(_player->GetGUID(), otp.c_str()); } @@ -202,7 +202,7 @@ void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->UnsetMute(_player->GetGUID(), otp.c_str()); } @@ -219,7 +219,7 @@ void WorldSession::HandleChannelInvite(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Invite(_player->GetGUID(), otp.c_str()); } @@ -236,7 +236,7 @@ void WorldSession::HandleChannelKick(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Kick(_player->GetGUID(), otp.c_str()); } @@ -256,7 +256,7 @@ void WorldSession::HandleChannelBan(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Ban(_player->GetGUID(), otp.c_str()); } @@ -274,7 +274,7 @@ void WorldSession::HandleChannelUnban(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->UnBan(_player->GetGUID(), otp.c_str()); } @@ -286,7 +286,7 @@ void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket) uint32 length = recvPacket.ReadBits(8); std::string channelname = recvPacket.ReadString(length); - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Announce(_player->GetGUID()); } @@ -302,7 +302,7 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket) sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); std::string channelname; recvPacket >> channelname; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { if (Channel* chn = cMgr->GetChannel(channelname, _player)) { @@ -324,4 +324,3 @@ void WorldSession::HandleSetChannelWatch(WorldPacket& recvPacket) if (Channel* chn = cMgr->GetChannel(channelName, _player)) chn->JoinNotify(_player->GetGUID());*/ } - diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 77d1c05abf2..04334315427 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -686,7 +686,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte std::string IP_str = GetRemoteAddress(); sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); sScriptMgr->OnPlayerCreate(&newChar); - sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel()); + sWorld->AddCharacterNameData(newChar.GetGUIDLow(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel()); newChar.CleanupsBeforeDelete(); delete createInfo; @@ -975,17 +975,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) } } - if (Group* group = pCurrChar->GetGroup()) - { - if (group->isLFGGroup()) - { - LfgDungeonSet Dungeons; - Dungeons.insert(sLFGMgr->GetDungeon(group->GetGUID())); - sLFGMgr->SetSelectedDungeons(pCurrChar->GetGUID(), Dungeons); - sLFGMgr->SetState(pCurrChar->GetGUID(), sLFGMgr->GetState(group->GetGUID())); - } - } - if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); @@ -996,7 +985,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) } sObjectAccessor->AddObject(pCurrChar); - //sLog->outDebug(LOG_FILTER_GENERAL, "Player %s added to Map.", pCurrChar->GetName()); + //sLog->outDebug("Player %s added to Map.", pCurrChar->GetName().c_str()); if (pCurrChar->GetGuildId() != 0) { @@ -1005,7 +994,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) else { // remove wrong guild data - sLog->outError(LOG_FILTER_GENERAL, "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); + sLog->outError(LOG_FILTER_GENERAL, "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); pCurrChar->SetInGuild(0); } } @@ -1092,7 +1081,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) std::string IP_str = GetRemoteAddress(); sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d", - GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel()); + GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel()); if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED)) pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); @@ -1171,14 +1160,14 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recvData) void WorldSession::HandleShowingHelmOpcode(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_HELM for %s", _player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_HELM for %s", _player->GetName().c_str()); recvData.read_skip<uint8>(); // unknown, bool? _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); } void WorldSession::HandleShowingCloakOpcode(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_CLOAK for %s", _player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_CLOAK for %s", _player->GetName().c_str()); recvData.read_skip<uint8>(); // unknown, bool? _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); } @@ -1235,7 +1224,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData) _charRenameCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } -void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string newName) +void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string const& newName) { if (!result) { @@ -1703,7 +1692,6 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData) void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) { - // TODO: Move queries to prepared statements uint64 guid; std::string newname; uint8 gender, skin, face, hairStyle, hairColor, facialHair, race; @@ -1820,391 +1808,387 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race); - TeamId team = TEAM_ALLIANCE; - - // Search each faction is targeted - switch (race) + if (oldRace != race) { - case RACE_ORC: - case RACE_GOBLIN: - case RACE_TAUREN: - case RACE_UNDEAD_PLAYER: - case RACE_TROLL: - case RACE_BLOODELF: - team = TEAM_HORDE; - break; - default: - break; - } - - // Switch Languages - // delete all languages first - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); - - // Now add them back - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); - stmt->setUInt32(0, lowGuid); - - // Faction specific languages - if (team == TEAM_HORDE) - stmt->setUInt16(1, 109); - else - stmt->setUInt16(1, 98); - - trans->Append(stmt); - - // Race specific languages - if (race != RACE_ORC && race != RACE_HUMAN) - { - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); - stmt->setUInt32(0, lowGuid); + TeamId team = TEAM_ALLIANCE; + // Search each faction is targeted switch (race) { - case RACE_DWARF: - stmt->setUInt16(1, 111); - break; - case RACE_DRAENEI: - stmt->setUInt16(1, 759); - break; - case RACE_GNOME: - stmt->setUInt16(1, 313); - break; - case RACE_NIGHTELF: - stmt->setUInt16(1, 113); - break; - case RACE_WORGEN: - stmt->setUInt16(1, 791); - break; - case RACE_UNDEAD_PLAYER: - stmt->setUInt16(1, 673); - break; + case RACE_ORC: case RACE_TAUREN: - stmt->setUInt16(1, 115); - break; + case RACE_UNDEAD_PLAYER: case RACE_TROLL: - stmt->setUInt16(1, 315); - break; case RACE_BLOODELF: - stmt->setUInt16(1, 137); + team = TEAM_HORDE; break; - case RACE_GOBLIN: - stmt->setUInt16(1, 792); + default: break; } + // Switch Languages + // delete all languages first + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - if (recvData.GetOpcode() == CMSG_CHAR_FACTION_CHANGE) - { - // Delete all Flypaths - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH); + // Now add them back + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); stmt->setUInt32(0, lowGuid); + + // Faction specific languages + if (team == TEAM_HORDE) + stmt->setUInt16(1, 109); + else + stmt->setUInt16(1, 98); + trans->Append(stmt); - if (level > 7) + // Race specific languages + if (race != RACE_ORC && race != RACE_HUMAN) { - // Update Taxi path - // this doesn't seem to be 100% blizzlike... but it can't really be helped. - std::ostringstream taximaskstream; - uint32 numFullTaximasks = level / 7; - if (numFullTaximasks > 11) - numFullTaximasks = 11; - if (team == TEAM_ALLIANCE) - { - if (playerClass != CLASS_DEATH_KNIGHT) - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sAllianceTaxiNodesMask[i]) << ' '; - } - else - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sAllianceTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; - } - } - else + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); + stmt->setUInt32(0, lowGuid); + + switch (race) { - if (playerClass != CLASS_DEATH_KNIGHT) - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sHordeTaxiNodesMask[i]) << ' '; - } - else - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sHordeTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; - } + case RACE_DWARF: + stmt->setUInt16(1, 111); + break; + case RACE_DRAENEI: + stmt->setUInt16(1, 759); + break; + case RACE_GNOME: + stmt->setUInt16(1, 313); + break; + case RACE_NIGHTELF: + stmt->setUInt16(1, 113); + break; + case RACE_UNDEAD_PLAYER: + stmt->setUInt16(1, 673); + break; + case RACE_TAUREN: + stmt->setUInt16(1, 115); + break; + case RACE_TROLL: + stmt->setUInt16(1, 315); + break; + case RACE_BLOODELF: + stmt->setUInt16(1, 137); + break; } - uint32 numEmptyTaximasks = 11 - numFullTaximasks; - for (uint8 i = 0; i < numEmptyTaximasks; ++i) - taximaskstream << "0 "; - taximaskstream << '0'; - std::string taximask = taximaskstream.str(); - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK); - stmt->setString(0, taximask); - stmt->setUInt32(1, lowGuid); trans->Append(stmt); } - // Delete all current quests - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); - stmt->setUInt32(0, GUID_LOPART(guid)); - trans->Append(stmt); - - // Delete record of the faction old completed quests + if (recvData.GetOpcode() == CMSG_CHAR_FACTION_CHANGE) { - std::ostringstream quests; - ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates(); - for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + // Delete all Flypaths + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); + + if (level > 7) { - Quest *qinfo = iter->second; - uint32 requiredRaces = qinfo->GetRequiredRaces(); + // Update Taxi path + // this doesn't seem to be 100% blizzlike... but it can't really be helped. + std::ostringstream taximaskstream; + uint32 numFullTaximasks = level / 7; + if (numFullTaximasks > 11) + numFullTaximasks = 11; if (team == TEAM_ALLIANCE) { - if (requiredRaces & RACEMASK_ALLIANCE) + if (playerClass != CLASS_DEATH_KNIGHT) + { + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sAllianceTaxiNodesMask[i]) << ' '; + } + else { - quests << uint32(qinfo->GetQuestId()); - quests << ','; + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sAllianceTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; } } - else // if (team == TEAM_HORDE) + else { - if (requiredRaces & RACEMASK_HORDE) + if (playerClass != CLASS_DEATH_KNIGHT) { - quests << uint32(qinfo->GetQuestId()); - quests << ','; + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sHordeTaxiNodesMask[i]) << ' '; + } + else + { + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sHordeTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; } } - } - std::string questsStr = quests.str(); - questsStr = questsStr.substr(0, questsStr.length() - 1); + uint32 numEmptyTaximasks = 11 - numFullTaximasks; + for (uint8 i = 0; i < numEmptyTaximasks; ++i) + taximaskstream << "0 "; + taximaskstream << '0'; + std::string taximask = taximaskstream.str(); - if (!questsStr.empty()) - trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str()); - } + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK); + stmt->setString(0, taximask); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); + } - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) - { - // Reset guild - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); + // Delete all current quests + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); + stmt->setUInt32(0, GUID_LOPART(guid)); + trans->Append(stmt); - stmt->setUInt32(0, lowGuid); + // Delete record of the faction old completed quests + { + std::ostringstream quests; + ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates(); + for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + { + Quest *qinfo = iter->second; + uint32 requiredRaces = qinfo->GetRequiredRaces(); + if (team == TEAM_ALLIANCE) + { + if (requiredRaces & RACEMASK_ALLIANCE) + { + quests << uint32(qinfo->GetQuestId()); + quests << ','; + } + } + else // if (team == TEAM_HORDE) + { + if (requiredRaces & RACEMASK_HORDE) + { + quests << uint32(qinfo->GetQuestId()); + quests << ','; + } + } + } - PreparedQueryResult result = CharacterDatabase.Query(stmt); - if (result) - if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) - guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); - } + std::string questsStr = quests.str(); + questsStr = questsStr.substr(0, questsStr.length() - 1); - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) - { - // Delete Friend List - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!questsStr.empty()) + trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str()); + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) + { + // Reset guild + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); - } + stmt->setUInt32(0, lowGuid); - // Leave Arena Teams - Player::LeaveAllArenaTeams(guid); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + if (result) + if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) + guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); + } - // Reset homebind and position - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) + { + // Delete Friend List + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); - stmt->setUInt32(0, lowGuid); - if (team == TEAM_ALLIANCE) - { - stmt->setUInt16(1, 0); - stmt->setUInt16(2, 1519); - stmt->setFloat (3, -8867.68f); - stmt->setFloat (4, 673.373f); - stmt->setFloat (5, 97.9034f); - Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); - } - else - { - stmt->setUInt16(1, 1); - stmt->setUInt16(2, 1637); - stmt->setFloat (3, 1633.33f); - stmt->setFloat (4, -4439.11f); - stmt->setFloat (5, 15.7588f); - Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); - } - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); - // Achievement conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it) - { - uint32 achiev_alliance = it->first; - uint32 achiev_horde = it->second; + } - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); - stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + // Leave Arena Teams + Player::LeaveAllArenaTeams(guid); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT); - stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); - stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance)); - stmt->setUInt32(2, lowGuid); + // Reset homebind and position + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - // Item conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it) - { - uint32 item_alliance = it->first; - uint32 item_horde = it->second; - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde)); - stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance)); - stmt->setUInt32(2, guid); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); + stmt->setUInt32(0, lowGuid); + if (team == TEAM_ALLIANCE) + { + stmt->setUInt16(1, 0); + stmt->setUInt16(2, 1519); + stmt->setFloat (3, -8867.68f); + stmt->setFloat (4, 673.373f); + stmt->setFloat (5, 97.9034f); + Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); + } + else + { + stmt->setUInt16(1, 1); + stmt->setUInt16(2, 1637); + stmt->setFloat (3, 1633.33f); + stmt->setFloat (4, -4439.11f); + stmt->setFloat (5, 15.7588f); + Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); + } trans->Append(stmt); - } - // Spell conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it) - { - uint32 spell_alliance = it->first; - uint32 spell_horde = it->second; + // Achievement conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it) + { + uint32 achiev_alliance = it->first; + uint32 achiev_horde = it->second; - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); + stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); - stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance)); - stmt->setUInt32(2, lowGuid); - trans->Append(stmt); - } + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT); + stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); + stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance)); + stmt->setUInt32(2, lowGuid); + trans->Append(stmt); + } - // Reputation conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it) - { - uint32 reputation_alliance = it->first; - uint32 reputation_horde = it->second; - uint32 newReputation = (team == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde; - uint32 oldReputation = (team == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance; - - // select old standing set in db - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, oldReputation); - stmt->setUInt32(1, lowGuid); - PreparedQueryResult result = CharacterDatabase.Query(stmt); - - if (!result) + // Item conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it) { - WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); - data << uint8(CHAR_CREATE_ERROR); - SendPacket(&data); - return; + uint32 item_alliance = it->first; + uint32 item_horde = it->second; + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde)); + stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance)); + stmt->setUInt32(2, guid); + trans->Append(stmt); } - Field* fields = result->Fetch(); - int32 oldDBRep = fields[0].GetInt32(); - FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation); + // Spell conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it) + { + uint32 spell_alliance = it->first; + uint32 spell_horde = it->second; - // old base reputation - int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - // new base reputation - int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); + stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance)); + stmt->setUInt32(2, lowGuid); + trans->Append(stmt); + } - // final reputation shouldnt change - int32 FinalRep = oldDBRep + oldBaseRep; - int32 newDBRep = FinalRep - newBaseRep; + // Reputation conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it) + { + uint32 reputation_alliance = it->first; + uint32 reputation_horde = it->second; + uint32 newReputation = (team == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde; + uint32 oldReputation = (team == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance; + + // select old standing set in db + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); + stmt->setUInt32(0, oldReputation); + stmt->setUInt32(1, lowGuid); + PreparedQueryResult result = CharacterDatabase.Query(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, newReputation); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + if (!result) + { + WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); + data << uint8(CHAR_CREATE_ERROR); + SendPacket(&data); + return; + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); - stmt->setUInt16(0, uint16(newReputation)); - stmt->setInt32(1, newDBRep); - stmt->setUInt16(2, uint16(oldReputation)); - stmt->setUInt32(3, lowGuid); - trans->Append(stmt); - } + Field* fields = result->Fetch(); + int32 oldDBRep = fields[0].GetInt32(); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation); - // Title conversion - if (knownTitlesStr) - { - const uint32 ktcount = KNOWN_TITLES_SIZE * 2; - uint32 knownTitles[ktcount]; - Tokenizer tokens(knownTitlesStr, ' ', ktcount); + // old base reputation + int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass); - if (tokens.size() != ktcount) - return; + // new base reputation + int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass); - for (uint32 index = 0; index < ktcount; ++index) - knownTitles[index] = atol(tokens[index]); + // final reputation shouldnt change + int32 FinalRep = oldDBRep + oldBaseRep; + int32 newDBRep = FinalRep - newBaseRep; - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it) + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION); + stmt->setUInt32(0, newReputation); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); + stmt->setUInt16(0, uint16(newReputation)); + stmt->setInt32(1, newDBRep); + stmt->setUInt16(2, uint16(oldReputation)); + stmt->setUInt32(3, lowGuid); + trans->Append(stmt); + } + + // Title conversion + if (knownTitlesStr) { - uint32 title_alliance = it->first; - uint32 title_horde = it->second; + const uint32 ktcount = KNOWN_TITLES_SIZE * 2; + uint32 knownTitles[ktcount]; + Tokenizer tokens(knownTitlesStr, ' ', ktcount); - CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance); - CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde); - // new team - if (team == TEAM_ALLIANCE) + if (tokens.size() != ktcount) + return; + + for (uint32 index = 0; index < ktcount; ++index) + knownTitles[index] = atol(tokens[index]); + + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it) { - uint32 bitIndex = htitleInfo->bit_index; - uint32 index = bitIndex / 32; - uint32 old_flag = 1 << (bitIndex % 32); - uint32 new_flag = 1 << (atitleInfo->bit_index % 32); - if (knownTitles[index] & old_flag) + uint32 title_alliance = it->first; + uint32 title_horde = it->second; + + CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance); + CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde); + // new team + if (team == TEAM_ALLIANCE) { - knownTitles[index] &= ~old_flag; - // use index of the new title - knownTitles[atitleInfo->bit_index / 32] |= new_flag; + uint32 bitIndex = htitleInfo->bit_index; + uint32 index = bitIndex / 32; + uint32 old_flag = 1 << (bitIndex % 32); + uint32 new_flag = 1 << (atitleInfo->bit_index % 32); + if (knownTitles[index] & old_flag) + { + knownTitles[index] &= ~old_flag; + // use index of the new title + knownTitles[atitleInfo->bit_index / 32] |= new_flag; + } } - } - else - { - uint32 bitIndex = atitleInfo->bit_index; - uint32 index = bitIndex / 32; - uint32 old_flag = 1 << (bitIndex % 32); - uint32 new_flag = 1 << (htitleInfo->bit_index % 32); - if (knownTitles[index] & old_flag) + else { - knownTitles[index] &= ~old_flag; - // use index of the new title - knownTitles[htitleInfo->bit_index / 32] |= new_flag; + uint32 bitIndex = atitleInfo->bit_index; + uint32 index = bitIndex / 32; + uint32 old_flag = 1 << (bitIndex % 32); + uint32 new_flag = 1 << (htitleInfo->bit_index % 32); + if (knownTitles[index] & old_flag) + { + knownTitles[index] &= ~old_flag; + // use index of the new title + knownTitles[htitleInfo->bit_index / 32] |= new_flag; + } } - } - std::ostringstream ss; - for (uint32 index = 0; index < ktcount; ++index) - ss << knownTitles[index] << ' '; + std::ostringstream ss; + for (uint32 index = 0; index < ktcount; ++index) + ss << knownTitles[index] << ' '; - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); - stmt->setString(0, ss.str().c_str()); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); + stmt->setString(0, ss.str().c_str()); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - // unset any currently chosen title - stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + // unset any currently chosen title + stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); + } } } } @@ -2212,7 +2196,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) CharacterDatabase.CommitTransaction(trans); std::string IP_str = GetRemoteAddress(); - sLog->outDebug(LOG_FILTER_UNITS, "Account: %d (IP: %s), Character guid: %u Change Race/Faction to: %s", GetAccountId(), IP_str.c_str(), lowGuid, newname.c_str()); + sLog->outDebug(LOG_FILTER_PLAYER, "%s (IP: %s) changed race from %u to %u", GetPlayerInfo().c_str(), IP_str.c_str(), oldRace, race); WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1 + 8 + (newname.size() + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1); data << uint8(RESPONSE_SUCCESS); diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index 66388631dde..c6a46d6d39b 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -24,7 +24,6 @@ #include "WorldPacket.h" #include "WorldSession.h" #include "DatabaseEnv.h" - #include "CellImpl.h" #include "Chat.h" #include "ChannelMgr.h" @@ -52,8 +51,8 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && AccountMgr::IsPlayerAccount(GetSecurity()) && !ChatHandler(this).isValidChatMessage(msg.c_str())) { - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName(), - GetPlayer()->GetGUIDLow(), msg.c_str()); + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName().c_str(), + GetPlayer()->GetGUIDLow(), msg.c_str()); if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK)) KickPlayer(); return false; @@ -231,7 +230,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (sender->HasAura(1852) && type != CHAT_MSG_WHISPER) { recvData.rfinish(); - SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName()); + SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName().c_str()); return; } @@ -321,7 +320,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) break; } - Player* receiver = sObjectAccessor->FindPlayerByName(to.c_str()); + Player* receiver = sObjectAccessor->FindPlayerByName(to); bool senderIsPlayer = AccountMgr::IsPlayerAccount(GetSecurity()); bool receiverIsPlayer = AccountMgr::IsPlayerAccount(receiver ? receiver->GetSession()->GetSecurity() : SEC_PLAYER); if (!receiver || (senderIsPlayer && !receiverIsPlayer && !receiver->isAcceptWhispers() && !receiver->IsInWhisperWhiteList(sender->GetGUID()))) @@ -339,7 +338,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (GetPlayer()->HasAura(1852) && !receiver->isGameMaster()) { - SendNotification(GetTrinityString(LANG_GM_SILENCE), GetPlayer()->GetName()); + SendNotification(GetTrinityString(LANG_GM_SILENCE), GetPlayer()->GetName().c_str()); return; } @@ -456,13 +455,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) } } - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { - if (Channel* chn = cMgr->GetChannel(channel, _player)) { sScriptMgr->OnPlayerChat(_player, type, lang, msg, chn); - chn->Say(_player->GetGUID(), msg.c_str(), lang); } } @@ -647,7 +644,7 @@ void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recvData) } } -void WorldSession::HandleEmoteOpcode(WorldPacket & recvData) +void WorldSession::HandleEmoteOpcode(WorldPacket& recvData) { if (!GetPlayer()->isAlive() || GetPlayer()->HasUnitState(UNIT_STATE_DIED)) return; @@ -668,18 +665,18 @@ namespace Trinity void operator()(WorldPacket& data, LocaleConstant loc_idx) { - char const* nam = i_target ? i_target->GetNameForLocaleIdx(loc_idx) : NULL; - uint32 namlen = (nam ? strlen(nam) : 0) + 1; + std::string const name(i_target ? i_target->GetNameForLocaleIdx(loc_idx) : ""); + uint32 namlen = name.size(); - data.Initialize(SMSG_TEXT_EMOTE, (20+namlen)); + data.Initialize(SMSG_TEXT_EMOTE, 20 + namlen); data << i_player.GetGUID(); - data << (uint32)i_text_emote; - data << i_emote_num; - data << (uint32)namlen; + data << uint32(i_text_emote); + data << uint32(i_emote_num); + data << uint32(namlen); if (namlen > 1) - data.append(nam, namlen); + data << name; else - data << (uint8)0x00; + data << uint8(0x00); } private: @@ -690,7 +687,7 @@ namespace Trinity }; } // namespace Trinity -void WorldSession::HandleTextEmoteOpcode(WorldPacket & recvData) +void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) { if (!GetPlayer()->isAlive()) return; @@ -782,7 +779,7 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recvData) return; WorldPacket data; - ChatHandler::FillMessageData(&data, this, CHAT_MSG_IGNORED, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), GetPlayer()->GetName(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_IGNORED, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), GetPlayer()->GetName().c_str(), NULL); player->GetSession()->SendPacket(&data); } @@ -791,14 +788,14 @@ void WorldSession::HandleChannelDeclineInvite(WorldPacket &recvPacket) sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); } -void WorldSession::SendPlayerNotFoundNotice(std::string name) +void WorldSession::SendPlayerNotFoundNotice(std::string const& name) { WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, name.size()+1); data << name; SendPacket(&data); } -void WorldSession::SendPlayerAmbiguousNotice(std::string name) +void WorldSession::SendPlayerAmbiguousNotice(std::string const& name) { WorldPacket data(SMSG_CHAT_PLAYER_AMBIGUOUS, name.size()+1); data << name; diff --git a/src/server/game/Handlers/DuelHandler.cpp b/src/server/game/Handlers/DuelHandler.cpp index 1b3f71c8cf1..bdfb2369198 100755 --- a/src/server/game/Handlers/DuelHandler.cpp +++ b/src/server/game/Handlers/DuelHandler.cpp @@ -42,8 +42,8 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) return; //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_DUEL_ACCEPTED"); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName().c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName().c_str()); time_t now = time(NULL); player->duel->startTimer = now; diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 69056cbf4c8..16645ffadf2 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -107,7 +107,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recvData) return; } - Player* player = sObjectAccessor->FindPlayerByName(memberName.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(memberName); // no player if (!player) @@ -181,7 +181,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recvData) data.WriteBit(invitedGuid[4]); - data.WriteBits(strlen(GetPlayer()->GetName()), 7); // Inviter name length + data.WriteBits(GetPlayer()->GetName().size(), 7); // Inviter name length data.WriteBits(0, 24); // Count 2 @@ -283,7 +283,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recvData) data.WriteBit(invitedGuid[4]); - data.WriteBits(strlen(GetPlayer()->GetName()), 7); // Inviter name length + data.WriteBits(GetPlayer()->GetName().size(), 7); // Inviter name length data.WriteBits(0, 24); // Count 2 @@ -346,7 +346,7 @@ void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recvData) if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } @@ -394,7 +394,7 @@ void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recvData) return; // report - WorldPacket data(SMSG_GROUP_DECLINE, strlen(GetPlayer()->GetName())); + WorldPacket data(SMSG_GROUP_DECLINE, GetPlayer()->GetName().size()); data << GetPlayer()->GetName(); leader->GetSession()->SendPacket(&data); } @@ -412,7 +412,8 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } @@ -462,7 +463,8 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recvData) // can't uninvite yourself if (GetPlayer()->GetName() == membername) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } @@ -795,7 +797,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData) if (!group->HasFreeSlotSubGroup(groupNr)) return; - Player* movedPlayer = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* movedPlayer = sObjectAccessor->FindPlayerByName(name); uint64 guid; if (movedPlayer) diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 5180e543bec..5e568a90d85 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -1482,7 +1482,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) if (count >= EQUIPMENT_SLOT_END) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) sent a wrong count (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName(), count); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) sent a wrong count (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), count); recvData.rfinish(); return; } @@ -1554,7 +1554,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) // slot of the transmogrified item if (slots[i] >= EQUIPMENT_SLOT_END) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an item (lowguid: %u) with a wrong slot (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName(), GUID_LOPART(itemGuids[i]), slots[i]); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an item (lowguid: %u) with a wrong slot (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGuids[i]), slots[i]); return; } @@ -1564,7 +1564,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) ItemTemplate const* proto = sObjectMgr->GetItemTemplate(newEntries[i]); if (!proto) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify to an invalid item (entry: %u).", player->GetGUIDLow(), player->GetName(), newEntries[i]); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify to an invalid item (entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), newEntries[i]); return; } } @@ -1576,7 +1576,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) itemTransmogrifier = player->GetItemByGuid(itemGuids[i]); if (!itemTransmogrifier) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (lowguid: %u).", player->GetGUIDLow(), player->GetName(), GUID_LOPART(itemGuids[i])); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (lowguid: %u).", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGuids[i])); return; } } @@ -1585,7 +1585,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i]); if (!itemTransmogrified) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUIDLow(), player->GetName(), slots[i]); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUIDLow(), player->GetName().c_str(), slots[i]); return; } @@ -1593,14 +1593,14 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) //// has to be able to equip item transmogrified item //if (!player->CanEquipItem(slots[i], tempDest, itemTransmogrified, true, true)) //{ - // sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) can't equip the item to be transmogrified (slot: %u, entry: %u).", player->GetGUIDLow(), player->GetName(), slots[i], itemTransmogrified->GetEntry()); + // sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) can't equip the item to be transmogrified (slot: %u, entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), slots[i], itemTransmogrified->GetEntry()); // return; //} // //// has to be able to equip item transmogrifier item //if (!player->CanEquipItem(slots[i], tempDest, itemTransmogrifier, true, true)) //{ - // sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) can't equip the transmogrifier item (slot: %u, entry: %u).", player->GetGUIDLow(), player->GetName(), slots[i], itemTransmogrifier->GetEntry()); + // sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) can't equip the transmogrifier item (slot: %u, entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), slots[i], itemTransmogrifier->GetEntry()); // return; //} @@ -1613,7 +1613,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) { if (!Item::CanTransmogrifyItemWithItem(itemTransmogrified, itemTransmogrifier)) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); return; } @@ -1690,7 +1690,7 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData) if (!item) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an invalid/non-existant item.", player->GetGUIDLow(), player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an invalid/non-existant item.", player->GetGUIDLow(), player->GetName().c_str()); SendReforgeResult(false); return; } @@ -1708,7 +1708,7 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData) ItemReforgeEntry const* stats = sItemReforgeStore.LookupEntry(reforgeEntry); if (!stats) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an item with invalid reforge entry (%u).", player->GetGUIDLow(), player->GetName(), reforgeEntry); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an item with invalid reforge entry (%u).", player->GetGUIDLow(), player->GetName().c_str(), reforgeEntry); SendReforgeResult(false); return; } diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index f95e7489870..995a2e9e42f 100755 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -65,7 +65,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) recvData >> numDungeons; if (!numDungeons) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); recvData.rfinish(); return; } @@ -81,7 +81,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) std::string comment; recvData >> comment; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); } @@ -91,7 +91,7 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/) uint64 guid = GetPlayer()->GetGUID(); uint64 gguid = grp ? grp->GetGUID() : guid; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); // Check cheating - only leader can leave the queue if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID()) @@ -105,7 +105,7 @@ void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recvData) recvData >> lfgGroupID; recvData >> accept; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); sLFGMgr->UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept); } @@ -117,11 +117,11 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recvData) Group* grp = GetPlayer()->GetGroup(); if (!grp) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); return; } uint64 gguid = grp->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); sLFGMgr->UpdateRoleCheck(gguid, guid, roles); } @@ -130,7 +130,7 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recvData) std::string comment; recvData >> comment; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); sLFGMgr->SetComment(guid, comment); } @@ -141,7 +141,7 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData) recvData >> agree; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); sLFGMgr->UpdateBoot(guid, agree); } @@ -150,22 +150,22 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recvData) bool out; recvData >> out; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); sLFGMgr->TeleportPlayer(GetPlayer(), out, true); } void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); // Get Random dungeons that can be done at a certain level and expansion LfgDungeonSet randomDungeons; uint8 level = GetPlayer()->getLevel(); uint8 expansion = GetPlayer()->GetSession()->Expansion(); - LFGDungeonMap& LfgDungeons = sLFGMgr->GetLFGDungeonMap(); - for (LFGDungeonMap::const_iterator itr = LfgDungeons.begin(); itr != LfgDungeons.end(); ++itr) + LFGDungeonContainer& LfgDungeons = sLFGMgr->GetLFGDungeonMap(); + for (LFGDungeonContainer::const_iterator itr = LfgDungeons.begin(); itr != LfgDungeons.end(); ++itr) { LFGDungeonData const& dungeon = itr->second; if ((dungeon.type == LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id))) @@ -178,7 +178,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData* uint32 rsize = uint32(randomDungeons.size()); uint32 lsize = uint32(lock.size()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4)); data << uint8(randomDungeons.size()); // Random Dungeon count @@ -236,7 +236,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData* void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); Group* grp = GetPlayer()->GetGroup(); if (!grp) @@ -261,7 +261,7 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData* for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4 + 4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); BuildPartyLockDungeonBlock(data, lockMap); SendPacket(&data); @@ -271,7 +271,7 @@ void WorldSession::HandleLfrJoinOpcode(WorldPacket& recv_data) { uint32 entry; // Raid id to search recv_data >> entry; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); //SendLfrUpdateListOpcode(entry); } @@ -279,7 +279,7 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recvData) { uint32 dungeonId; // Raid id queue to leave recvData >> dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); //sLFGMgr->LeaveLfr(GetPlayer(), dungeonId); } @@ -297,7 +297,9 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) queued = true; extrainfo = true; break; - //case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: extrainfo = true; break; @@ -305,7 +307,7 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -342,8 +344,9 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) join = true; queued = true; break; - case LFG_UPDATETYPE_CLEAR_LOCK_LIST: - // join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + join = true; queued = true; break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: @@ -354,7 +357,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -378,7 +381,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4); data << uint64(guid); // Guid @@ -395,7 +398,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) else dungeons = roleCheck.dungeons; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1)); data << uint32(roleCheck.state); // Check result @@ -445,7 +448,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4 + 4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size); data << uint32(joinData.result); // Check Result data << uint32(joinData.state); // Check Value @@ -456,7 +459,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", GetPlayer()->GetGUID(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4); @@ -480,7 +483,7 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4)); data << uint32(rdungeonEntry); // Random Dungeon Finished data << uint32(sdungeonEntry); // Dungeon Finished @@ -512,7 +515,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) uint8 votesNum = 0; uint8 agreeNum = 0; uint32 secsleft = uint8((boot.cancelTime - time(NULL)) / 1000); - for (LfgAnswerMap::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it) + for (LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it) { if (it->second != LFG_ANSWER_PENDING) { @@ -521,7 +524,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) ++agreeNum; } } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", guid, uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), boot.victim, votesNum, agreeNum, secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length()); data << uint8(boot.inProgress); // Vote in progress @@ -544,7 +547,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p bool silent = !proposal.isNew && gguid == proposal.group; uint32 dungeonEntry = proposal.dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1)); // show random dungeon if player selected random dungeon and it's not lfg group @@ -565,7 +568,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p data << uint8(silent); // Show proposal window data << uint8(proposal.players.size()); // Group size - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { LfgProposalPlayer const& player = it->second; data << uint32(player.role); // Role @@ -588,7 +591,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p void WorldSession::SendLfgLfrList(bool update) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1); data << uint8(update); // In Lfg Queue? SendPacket(&data); @@ -596,14 +599,14 @@ void WorldSession::SendLfgLfrList(bool update) void WorldSession::SendLfgDisabled() { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_DISABLED, 0); SendPacket(&data); } void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4); data << uint32(dungeonEntry); SendPacket(&data); @@ -611,12 +614,44 @@ void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) void WorldSession::SendLfgTeleportError(uint8 err) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4); data << uint32(err); // Error SendPacket(&data); } +void WorldSession::HandleLfgGetStatus(WorldPacket& /*recv_data*/) +{ + uint64 guid = GetPlayer()->GetGUID(); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_GET_STATUS [" UI64FMTD "]", guid); + + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); + LfgState state = sLFGMgr->GetLfgStatus(guid, updateData); + + if (state == LFG_STATE_NONE || updateData.dungeons.empty()) + { + SendLfgUpdatePlayer(updateData); + SendLfgUpdateParty(updateData); + return; + } + + if (state != LFG_STATE_QUEUED) + return; + + if (GetPlayer()->GetGroup()) + { + SendLfgUpdateParty(updateData); + updateData.dungeons.clear(); + SendLfgUpdatePlayer(updateData); + } + else + { + SendLfgUpdatePlayer(updateData); + updateData.dungeons.clear(); + SendLfgUpdateParty(updateData); + } +} + /* void WorldSession::SendLfrUpdateListOpcode(uint32 dungeonEntry) { diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 43242e6a54a..5f3e3d58da5 100755 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -454,7 +454,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) if (!target) return; - sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName().c_str()); if (_player->GetLootGUID() != lootguid) return; @@ -483,7 +483,8 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) if (slotid >= loot->items.size() + loot->quest_items.size()) { - sLog->outDebug(LOG_FILTER_LOOT, "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", GetPlayer()->GetName(), slotid, (unsigned long)loot->items.size()); + sLog->outDebug(LOG_FILTER_LOOT, "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", + GetPlayer()->GetName().c_str(), slotid, (unsigned long)loot->items.size()); return; } diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 1947baa43b6..d1bf36b885b 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -60,7 +60,7 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_REPOP_REQUEST Message"); - recvData.read_skip<uint8>(); // FromLua ? + recvData.read_skip<uint8>(); if (GetPlayer()->isAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) return; @@ -75,7 +75,8 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recvData) // release spirit after he's killed but before he is updated if (GetPlayer()->getDeathState() == JUST_DIED) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); GetPlayer()->KillPlayer(); } @@ -544,7 +545,8 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recvData) if (!normalizePlayerName(friendName)) return; - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", GetPlayer()->GetName(), friendName.c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", + GetPlayer()->GetName().c_str(), friendName.c_str()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME); @@ -554,7 +556,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recvData) _addFriendCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } -void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string friendNote) +void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string const& friendNote) { if (!GetPlayer()) return; @@ -595,7 +597,7 @@ void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std if (!GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) { friendResult = FRIEND_LIST_FULL; - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s's friend list is full.", GetPlayer()->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s's friend list is full.", GetPlayer()->GetName().c_str()); } } GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); @@ -635,7 +637,7 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recvData) return; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to Ignore: '%s'", - GetPlayer()->GetName(), ignoreName.c_str()); + GetPlayer()->GetName().c_str(), ignoreName.c_str()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_BY_NAME); @@ -819,7 +821,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) if (player->isInFlight()) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u", - player->GetName(), player->GetGUIDLow(), triggerId); + player->GetName().c_str(), player->GetGUIDLow(), triggerId); return; } @@ -827,14 +829,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) if (!atEntry) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u", - player->GetName(), player->GetGUIDLow(), triggerId); + player->GetName().c_str(), player->GetGUIDLow(), triggerId); return; } if (player->GetMapId() != atEntry->mapid) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", - player->GetName(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId); + player->GetName().c_str(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId); return; } @@ -848,7 +850,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) if (dist > atEntry->radius + delta) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u", - player->GetName(), player->GetGUIDLow(), atEntry->radius, dist, triggerId); + player->GetName().c_str(), player->GetGUIDLow(), atEntry->radius, dist, triggerId); return; } } @@ -879,7 +881,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) (fabs(dz) > atEntry->box_z / 2 + delta)) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u", - player->GetName(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); + player->GetName().c_str(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); return; } } @@ -1040,43 +1042,15 @@ int32 WorldSession::HandleEnableNagleAlgorithm() void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_ACTION_BUTTON"); uint8 button; uint32 packetData; recvData >> button >> packetData; + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SET_ACTION_BUTTON Button: %u Data: %u", button, packetData); - uint32 action = ACTION_BUTTON_ACTION(packetData); - uint8 type = ACTION_BUTTON_TYPE(packetData); - - sLog->outInfo(LOG_FILTER_NETWORKIO, "BUTTON: %u ACTION: %u TYPE: %u", button, action, type); if (!packetData) - { - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Remove action from button %u", button); GetPlayer()->removeActionButton(button); - } else - { - switch (type) - { - case ACTION_BUTTON_MACRO: - case ACTION_BUTTON_CMACRO: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added Macro %u into button %u", action, button); - break; - case ACTION_BUTTON_EQSET: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added EquipmentSet %u into button %u", action, button); - break; - case ACTION_BUTTON_SPELL: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added Spell %u into button %u", action, button); - break; - case ACTION_BUTTON_ITEM: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added Item %u into button %u", action, button); - break; - default: - sLog->outError(LOG_FILTER_NETWORKIO, "MISC: Unknown action button type %u for action %u into button %u for player %s (GUID: %u)", type, action, button, _player->GetName(), _player->GetGUIDLow()); - return; - } - GetPlayer()->addActionButton(button, action, type); - } + GetPlayer()->addActionButton(button, ACTION_BUTTON_ACTION(packetData), ACTION_BUTTON_TYPE(packetData)); } void WorldSession::HandleCompleteCinematic(WorldPacket& /*recvData*/) @@ -1331,11 +1305,13 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recvData) if (GetPlayer()->isInFlight()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) in flight, ignore worldport command.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) in flight, ignore worldport command.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_WORLD_TELEPORT: Player = %s, Time = %u, map = %u, x = %f, y = %f, z = %f, o = %f", GetPlayer()->GetName(), time, mapid, PositionX, PositionY, PositionZ, Orientation); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_WORLD_TELEPORT: Player = %s, Time = %u, map = %u, x = %f, y = %f, z = %f, o = %f", + GetPlayer()->GetName().c_str(), time, mapid, PositionX, PositionY, PositionZ, Orientation); if (AccountMgr::IsAdminAccount(GetSecurity())) GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation); @@ -1361,7 +1337,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recvData) return; } - Player* player = sObjectAccessor->FindPlayerByName(charname.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(charname); if (!player) { @@ -1400,7 +1376,8 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recvData) data << msg; SendPacket(&data); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Received whois command from player %s for character %s", + GetPlayer()->GetName().c_str(), charname.c_str()); } void WorldSession::HandleComplainOpcode(WorldPacket& recvData) @@ -1482,7 +1459,7 @@ void WorldSession::HandleFarSightOpcode(WorldPacket& recvData) if (WorldObject* target = _player->GetViewpoint()) _player->SetSeer(target); else - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s requests non-existing seer " UI64FMTD, _player->GetName(), _player->GetUInt64Value(PLAYER_FARSIGHT)); + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s requests non-existing seer " UI64FMTD, _player->GetName().c_str(), _player->GetUInt64Value(PLAYER_FARSIGHT)); break; default: sLog->outDebug(LOG_FILTER_NETWORKIO, "Unhandled mode in CMSG_FAR_SIGHT: %u", apply); @@ -1519,7 +1496,7 @@ void WorldSession::HandleTimeSyncResp(WorldPacket& recvData) recvData >> clientTicks >> counter; if (counter != _player->m_timeSyncCounter - 1) - sLog->outDebug(LOG_FILTER_NETWORKIO, "Wrong time sync counter from player %s (cheater?)", _player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Wrong time sync counter from player %s (cheater?)", _player->GetName().c_str()); sLog->outDebug(LOG_FILTER_NETWORKIO, "Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient); @@ -1564,7 +1541,8 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) Map* map = _player->FindMap(); if (map && map->IsDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", _player->GetName(), _player->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", + _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -1584,7 +1562,8 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) if (groupGuy->GetMap()->IsNonRaidDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", _player->GetGUIDLow(), groupGuy->GetName(), groupGuy->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", + _player->GetGUIDLow(), groupGuy->GetName().c_str(), groupGuy->GetGUIDLow()); return; } } @@ -1719,6 +1698,7 @@ void WorldSession::HandleQueryInspectAchievements(WorldPacket& recvData) uint64 guid; recvData.readPackGUID(guid); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_QUERY_INSPECT_ACHIEVEMENTS [" UI64FMTD "] Inspected Player [" UI64FMTD "]", _player->GetGUID(), guid); Player* player = ObjectAccessor::FindPlayer(guid); if (!player) return; @@ -1802,14 +1782,14 @@ void WorldSession::SendSetPhaseShift(std::set<uint32> const& phaseIds, std::set< } // Battlefield and Battleground -void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data) +void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY"); Battleground* bg = _player->GetBattleground(); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) @@ -1825,14 +1805,14 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data) bf->SendAreaSpiritHealerQueryOpcode(_player,guid); } -void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data) +void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE"); Battleground* bg = _player->GetBattleground(); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) @@ -1875,7 +1855,8 @@ void WorldSession::HandleInstanceLockResponse(WorldPacket& recvPacket) if (!_player->HasPendingBind()) { - sLog->outInfo(LOG_FILTER_NETWORKIO, "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!", _player->GetName(), _player->GetGUIDLow()); + sLog->outInfo(LOG_FILTER_NETWORKIO, "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!", + _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -2012,7 +1993,7 @@ void WorldSession::HandleObjectUpdateFailedOpcode(WorldPacket& recvPacket) recvPacket.ReadByteSeq(guid[5]); WorldObject* obj = ObjectAccessor::GetWorldObject(*GetPlayer(), guid); - sLog->outError(LOG_FILTER_NETWORKIO, "Object update failed for object "UI64FMTD" (%s) for player %s (%u)", uint64(guid), obj ? obj->GetName() : "object-not-found", GetPlayerName().c_str(), GetGuidLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "Object update failed for object " UI64FMTD " (%s) for player %s (%u)", uint64(guid), obj ? obj->GetName().c_str() : "object-not-found", GetPlayerName().c_str(), GetGuidLow()); } void WorldSession::HandleSaveCUFProfiles(WorldPacket& recvPacket) diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 43da34fa451..73232320d43 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -47,7 +47,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SetSemaphoreTeleportFar(false); // get the teleport destination - WorldLocation const loc = GetPlayer()->GetTeleportDest(); + WorldLocation const& loc = GetPlayer()->GetTeleportDest(); // possible errors in the coordinate validity check if (!MapManager::IsValidMapCoord(loc)) @@ -67,7 +67,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() Map* oldMap = GetPlayer()->GetMap(); if (GetPlayer()->IsInWorld()) { - sLog->outError(LOG_FILTER_NETWORKIO, "Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId()); + sLog->outError(LOG_FILTER_NETWORKIO, "Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName().c_str(), oldMap->GetId(), loc.GetMapId()); oldMap->RemovePlayerFromMap(GetPlayer(), false); } @@ -90,7 +90,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SendInitialPacketsBeforeAddToMap(); if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer())) { - sLog->outError(LOG_FILTER_NETWORKIO, "WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); + sLog->outError(LOG_FILTER_NETWORKIO, "WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); GetPlayer()->ResetMap(); GetPlayer()->SetMap(oldMap); GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); @@ -487,13 +488,13 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct { sLog->outError(LOG_FILTER_NETWORKIO, "%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", - move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); + move_type_name[move_type], _player->GetName().c_str(), _player->GetSpeed(move_type), newspeed); _player->SetSpeed(move_type, _player->GetSpeedRate(move_type), true); } else // must be lesser - cheating { sLog->outDebug(LOG_FILTER_GENERAL, "Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", - _player->GetName(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); + _player->GetName().c_str(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); _player->GetSession()->KickPlayer(); } } diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index db077011ee0..598205fbceb 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -44,7 +44,7 @@ void WorldSession::HandleDismissCritter(WorldPacket& recvData) if (!pet) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Vanitypet (guid: %u) does not exist - player '%s' (guid: %u / account: %u) attempted to dismiss it (possibly lagged out)", - uint32(GUID_LOPART(guid)), GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), GetAccountId()); + uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), GetAccountId()); return; } @@ -78,13 +78,13 @@ void WorldSession::HandlePetAction(WorldPacket & recvData) if (!pet) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) doesn't exist for player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) doesn't exist for player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str()); return; } if (pet != GetPlayer()->GetFirstControlled()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) does not belong to player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) does not belong to player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str()); return; } @@ -132,7 +132,8 @@ void WorldSession::HandlePetStopAttack(WorldPacket &recvData) if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", + uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } @@ -445,11 +446,9 @@ void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) return; } - std::string name = pet->GetName(); - - WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1)); + WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+pet->GetName().size()+1)); data << uint32(petnumber); - data << name.c_str(); + data << pet->GetName(); data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); if (pet->isPet() && ((Pet*)pet)->GetDeclinedNames()) @@ -569,7 +568,8 @@ void WorldSession::HandlePetSetAction(WorldPacket & recvData) uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]); uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]); - sLog->outInfo(LOG_FILTER_NETWORKIO, "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state)); + sLog->outInfo(LOG_FILTER_NETWORKIO, "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", + _player->GetName().c_str(), position[i], spell_id, uint32(act_state)); //if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id))) @@ -726,7 +726,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) if (!pet || (pet != _player->GetGuardianPet() && pet != _player->GetCharm())) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } @@ -771,7 +771,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) if (!caster || (caster != _player->GetGuardianPet() && caster != _player->GetCharm())) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index 263aa8846ee..69100f74d81 100755 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -269,7 +269,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) if (!result) { - sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName()); + sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str()); return; } Field* fields = result->Fetch(); @@ -479,7 +479,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData) if (!result) { - sLog->outError(LOG_FILTER_NETWORKIO, "Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str()); return; } @@ -506,7 +506,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData) { if (_player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName().c_str(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S); return; } @@ -516,13 +516,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData) if (_player->GetArenaTeamId(slot)) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_IN_ARENA_TEAM_S); return; } if (_player->GetArenaTeamIdInvited()) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } } @@ -530,12 +530,12 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData) { if (_player->GetGuildId()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName().c_str()); return; } if (_player->GetGuildIdInvited()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName().c_str()); return; } } @@ -573,7 +573,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData) CharacterDatabase.Execute(stmt); - sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName(), playerGuid, GetAccountId()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName().c_str(), playerGuid, GetAccountId()); WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4)); data << uint64(petitionGuid); @@ -667,7 +667,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData) if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { // player is too low level to join an arena team - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "", ERR_ARENA_TEAM_TARGET_TOO_LOW_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName().c_str(), "", ERR_ARENA_TEAM_TARGET_TOO_LOW_S); return; } @@ -678,13 +678,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData) if (player->GetArenaTeamId(slot)) { // player is already in an arena team - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "", ERR_ALREADY_IN_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName().c_str(), "", ERR_ALREADY_IN_ARENA_TEAM_S); return; } if (player->GetArenaTeamIdInvited()) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } } @@ -692,13 +692,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData) { if (player->GetGuildId()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName().c_str()); return; } if (player->GetGuildIdInvited()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName().c_str()); return; } } @@ -767,7 +767,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData) } else { - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid)); + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName().c_str(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid)); return; } diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 7ca8aa750eb..cc4a410e413 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -289,7 +289,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) if (reward >= QUEST_REWARD_CHOICES_COUNT) { - sLog->outError(LOG_FILTER_NETWORKIO, "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (probably packet hacking)", _player->GetName(), _player->GetGUIDLow(), reward); + sLog->outError(LOG_FILTER_NETWORKIO, "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (probably packet hacking)", _player->GetName().c_str(), _player->GetGUIDLow(), reward); return; } @@ -316,7 +316,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE && !quest->IsAutoComplete())) { sLog->outError(LOG_FILTER_NETWORKIO, "HACK ALERT: Player %s (guid: %u) is trying to complete quest (id: %u) but he has no right to do it!", - _player->GetName(), _player->GetGUIDLow(), questId); + _player->GetName().c_str(), _player->GetGUIDLow(), questId); return; } @@ -517,14 +517,14 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData) if (autoCompleteMode && !quest->HasFlag(QUEST_FLAGS_AUTO_SUBMIT)) { sLog->outError(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [playerGuid: %u] tried to complete questId [entry: %u] by auto-submit flag for quest witch not suport it.", - _player->GetName(), _player->GetGUIDLow(), questId); + _player->GetName().c_str(), _player->GetGUIDLow(), questId); return; } if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE) { sLog->outError(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [playerGuid: %u] tried to complete questId [entry: %u] without being in possession of the questId!", - _player->GetName(), _player->GetGUIDLow(), questId); + _player->GetName().c_str(), _player->GetGUIDLow(), questId); return; } // TODO: need a virtual function diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index cd3b4fae75f..9bfc5ffa87e 100755 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -230,7 +230,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) { pUser->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, NULL); sLog->outError(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!", - pUser->GetName(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId); + pUser->GetName().c_str(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId); return; } @@ -501,13 +501,13 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket) if (!pet) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %u by player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %u by player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Pet %u is not a pet of player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Pet %u is not a pet of player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 5213dff2f56..41e834d84e8 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -86,7 +86,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) sTicketMgr->AddTicket(ticket); sTicketMgr->UpdateLastChange(); - sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId()); + sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName().c_str(), ticket->GetId()); response = GMTICKET_RESPONSE_CREATE_SUCCESS; } @@ -108,7 +108,7 @@ void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recvData) ticket->SetMessage(message); ticket->SaveToDB(trans); - sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->GetId()); + sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName().c_str(), ticket->GetId()); response = GMTICKET_RESPONSE_UPDATE_SUCCESS; } @@ -126,7 +126,7 @@ void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket & /*recvData*/) data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); SendPacket(&data); - sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->GetId()); + sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName().c_str(), ticket->GetId()); sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID()); sTicketMgr->SendTicket(this, NULL); diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 13cddaff7ea..210e65ce2a3 100755 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -216,9 +216,9 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (!AccountMgr::IsPlayerAccount(_player->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", - _player->GetName(), _player->GetSession()->GetAccountId(), + _player->GetName().c_str(), _player->GetSession()->GetAccountId(), myItems[i]->GetTemplate()->Name1.c_str(), myItems[i]->GetEntry(), myItems[i]->GetCount(), - trader->GetName(), trader->GetSession()->GetAccountId()); + trader->GetName().c_str(), trader->GetSession()->GetAccountId()); } // adjust time (depends on /played) @@ -234,9 +234,9 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (!AccountMgr::IsPlayerAccount(trader->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", - trader->GetName(), trader->GetSession()->GetAccountId(), + trader->GetName().c_str(), trader->GetSession()->GetAccountId(), hisItems[i]->GetTemplate()->Name1.c_str(), hisItems[i]->GetEntry(), hisItems[i]->GetCount(), - _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetName().c_str(), _player->GetSession()->GetAccountId()); } // adjust time (depends on /played) @@ -524,16 +524,16 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) if (!AccountMgr::IsPlayerAccount(_player->GetSession()->GetSecurity()) && my_trade->GetMoney() > 0) { sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: " UI64FMTD ") to player: %s (Account: %u)", - _player->GetName(), _player->GetSession()->GetAccountId(), + _player->GetName().c_str(), _player->GetSession()->GetAccountId(), my_trade->GetMoney(), - trader->GetName(), trader->GetSession()->GetAccountId()); + trader->GetName().c_str(), trader->GetSession()->GetAccountId()); } if (!AccountMgr::IsPlayerAccount(trader->GetSession()->GetSecurity()) && his_trade->GetMoney() > 0) { sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: " UI64FMTD ") to player: %s (Account: %u)", - trader->GetName(), trader->GetSession()->GetAccountId(), + trader->GetName().c_str(), trader->GetSession()->GetAccountId(), his_trade->GetMoney(), - _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetName().c_str(), _player->GetSession()->GetAccountId()); } } diff --git a/src/server/game/Handlers/VoidStorageHandler.cpp b/src/server/game/Handlers/VoidStorageHandler.cpp index 8171a30cc3a..1310a65d179 100644 --- a/src/server/game/Handlers/VoidStorageHandler.cpp +++ b/src/server/game/Handlers/VoidStorageHandler.cpp @@ -68,7 +68,7 @@ void WorldSession::HandleVoidStorageUnlock(WorldPacket& recvData) if (player->IsVoidStorageUnlocked()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageUnlock - Player (GUID: %u, name: %s) tried to unlock void storage a 2nd time.", player->GetGUIDLow(), player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageUnlock - Player (GUID: %u, name: %s) tried to unlock void storage a 2nd time.", player->GetGUIDLow(), player->GetName().c_str()); return; } @@ -109,7 +109,7 @@ void WorldSession::HandleVoidStorageQuery(WorldPacket& recvData) if (!player->IsVoidStorageUnlocked()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageQuery - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageQuery - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName().c_str()); return; } @@ -199,7 +199,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData) if (countDeposit > 9) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit more than 9 items (%u).", player->GetGUIDLow(), player->GetName(), countDeposit); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit more than 9 items (%u).", player->GetGUIDLow(), player->GetName().c_str(), countDeposit); return; } @@ -227,7 +227,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData) if (countWithdraw > 9) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to withdraw more than 9 items (%u).", player->GetGUIDLow(), player->GetName(), countWithdraw); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to withdraw more than 9 items (%u).", player->GetGUIDLow(), player->GetName().c_str(), countWithdraw); return; } @@ -291,7 +291,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData) if (!player->IsVoidStorageUnlocked()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName().c_str()); return; } @@ -332,7 +332,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData) Item* item = player->GetItemByGuid(*itr); if (!item) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit an invalid item (item guid: " UI64FMTD ").", player->GetGUIDLow(), player->GetName(), uint64(*itr)); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit an invalid item (item guid: " UI64FMTD ").", player->GetGUIDLow(), player->GetName().c_str(), uint64(*itr)); continue; } @@ -357,7 +357,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData) VoidStorageItem* itemVS = player->GetVoidStorageItem(*itr, slot); if (!itemVS) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) tried to withdraw an invalid item (id: " UI64FMTD ")", player->GetGUIDLow(), player->GetName(), uint64(*itr)); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) tried to withdraw an invalid item (id: " UI64FMTD ")", player->GetGUIDLow(), player->GetName().c_str(), uint64(*itr)); continue; } @@ -366,7 +366,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData) if (msg != EQUIP_ERR_OK) { SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INVENTORY_FULL); - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) couldn't withdraw item id " UI64FMTD " because inventory was full.", player->GetGUIDLow(), player->GetName(), uint64(*itr)); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) couldn't withdraw item id " UI64FMTD " because inventory was full.", player->GetGUIDLow(), player->GetName().c_str(), uint64(*itr)); return; } @@ -528,14 +528,14 @@ void WorldSession::HandleVoidSwapItem(WorldPacket& recvData) if (!player->IsVoidStorageUnlocked()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName().c_str()); return; } uint8 oldSlot; if (!player->GetVoidStorageItem(itemId, oldSlot)) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) requested swapping an invalid item (slot: %u, itemid: " UI64FMTD ").", player->GetGUIDLow(), player->GetName(), newSlot, uint64(itemId)); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) requested swapping an invalid item (slot: %u, itemid: " UI64FMTD ").", player->GetGUIDLow(), player->GetName().c_str(), newSlot, uint64(itemId)); return; } diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 212a0dc8a94..a514315f748 100755 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -119,7 +119,7 @@ class MailDraft explicit MailDraft(uint16 mailTemplateId, bool need_items = true) : m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0) {} - MailDraft(std::string subject, std::string body) + MailDraft(std::string const& subject, std::string const& body) : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_subject(subject), m_body(body), m_money(0), m_COD(0) {} public: // Accessors uint16 GetMailTemplateId() const { return m_mailTemplateId; } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index d0ad280404d..f3c1a335f5e 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -715,7 +715,7 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell)) { - sLog->outDebug(LOG_FILTER_MAPS, "Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); + sLog->outDebug(LOG_FILTER_MAPS, "Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); player->RemoveFromGrid(); @@ -1016,7 +1016,7 @@ void Map::RemoveAllPlayers() if (!player->IsBeingTeleportedFar()) { // this is happening for bg - sLog->outError(LOG_FILTER_MAPS, "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName(), GetId()); + sLog->outError(LOG_FILTER_MAPS, "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName().c_str(), GetId()); player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation()); } } @@ -2311,7 +2311,7 @@ bool InstanceMap::CanEnter(Player* player) { if (player->GetMapRef().getTarget() == this) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); ASSERT(false); return false; } @@ -2324,7 +2324,7 @@ bool InstanceMap::CanEnter(Player* player) uint32 maxPlayers = GetMaxPlayers(); if (GetPlayersCountExceptGMs() >= maxPlayers) { - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName().c_str()); player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS); return false; } @@ -2405,7 +2405,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // cannot enter other instances if bound permanently if (playerBind->save != mapSave) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is permanently bound to instance %d, %d, %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d, %d, %d", player->GetName(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is permanently bound to instance %d, %d, %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d, %d, %d", player->GetName().c_str(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset()); return false; } } @@ -2417,7 +2417,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) InstanceGroupBind* groupBind = group->GetBoundInstance(this); if (playerBind && playerBind->save != mapSave) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d, %d, %d, %d but he is in group %d and is bound to instance %d, %d, %d, %d, %d, %d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), GUID_LOPART(group->GetLeaderGUID()), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d, %d, %d, %d but he is in group %d and is bound to instance %d, %d, %d, %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), GUID_LOPART(group->GetLeaderGUID()), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset()); if (groupBind) sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: the group is bound to the instance %d, %d, %d, %d, %d, %d", groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(), groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset()); //ASSERT(false); @@ -2431,7 +2431,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // cannot jump to a different instance without resetting it if (groupBind->save != mapSave) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %d which is bound to instance %d, %d, %d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(group->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %d which is bound to instance %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(group->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); if (mapSave) sLog->outError(LOG_FILTER_MAPS, "MapSave players: %d, group count: %d", mapSave->GetPlayerCount(), mapSave->GetGroupCount()); else @@ -2479,7 +2479,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // first player enters (no players yet) SetResetSchedule(false); - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Player '%s' entered instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Player '%s' entered instance '%u' of map '%s'", player->GetName().c_str(), GetInstanceId(), GetMapName()); // initialize unload state m_unloadTimer = 0; m_resetAfterUnload = false; @@ -2505,7 +2505,7 @@ void InstanceMap::Update(const uint32 t_diff) void InstanceMap::RemovePlayerFromMap(Player* player, bool remove) { - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName().c_str(), GetInstanceId(), GetMapName()); //if last player set unload timer if (!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); @@ -2600,7 +2600,7 @@ void InstanceMap::PermBindAllPlayers(Player* source) InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); if (!save) { - sLog->outError(LOG_FILTER_MAPS, "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUIDLow(), source->GetName(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId()); + sLog->outError(LOG_FILTER_MAPS, "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUIDLow(), source->GetName().c_str(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId()); return; } @@ -2744,7 +2744,7 @@ bool BattlegroundMap::AddPlayerToMap(Player* player) void BattlegroundMap::RemovePlayerFromMap(Player* player, bool remove) { - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName().c_str(), GetInstanceId(), GetMapName()); Map::RemovePlayerFromMap(player, remove); } diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 4c272430266..71f45a8b04e 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -192,7 +192,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) // probably there must be special opcode, because client has this string constant in GlobalStrings.lua // TODO: this is not a good place to send the message player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetTrinityString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName); - sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName(), mapName); + sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName().c_str(), mapName); return false; } } @@ -216,15 +216,15 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) { WorldPacket data(SMSG_CORPSE_NOT_IN_INSTANCE); player->GetSession()->SendPacket(&data); - sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' does not have a corpse in instance '%s' and cannot enter.", player->GetName(), mapName); + sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' does not have a corpse in instance '%s' and cannot enter.", player->GetName().c_str(), mapName); return false; } - sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName(), mapName); + sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName().c_str(), mapName); player->ResurrectPlayer(0.5f, false); player->SpawnCorpseBones(); } else - sLog->outDebug(LOG_FILTER_MAPS, "Map::CanPlayerEnter - player '%s' is dead but does not have a corpse!", player->GetName()); + sLog->outDebug(LOG_FILTER_MAPS, "Map::CanPlayerEnter - player '%s' is dead but does not have a corpse!", player->GetName().c_str()); } //Get instance where player's group is bound & its map diff --git a/src/server/game/Maps/PhaseMgr.cpp b/src/server/game/Maps/PhaseMgr.cpp index 5e0989c1cad..194c89fc5c8 100644 --- a/src/server/game/Maps/PhaseMgr.cpp +++ b/src/server/game/Maps/PhaseMgr.cpp @@ -174,7 +174,7 @@ void PhaseMgr::UnRegisterPhasingAuraEffect(AuraEffect const* auraEffect) void PhaseMgr::SendDebugReportToPlayer(Player* const debugger) { - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_REPORT_STATUS, player->GetName(), player->GetZoneId(), player->getLevel(), player->GetTeamId(), _UpdateFlags); + ChatHandler(debugger).PSendSysMessage(LANG_PHASING_REPORT_STATUS, player->GetName().c_str(), player->GetZoneId(), player->getLevel(), player->GetTeamId(), _UpdateFlags); PhaseDefinitionStore::const_iterator itr = _PhaseDefinitionStore->find(player->GetZoneId()); if (itr == _PhaseDefinitionStore->end()) diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 26e83773228..488dbfc9159 100755 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -44,7 +44,8 @@ void MotionMaster::Initialize() { MovementGenerator *curr = top(); pop(); - if (curr) DirectDelete(curr); + if (curr) + DirectDelete(curr); } InitDefault(); @@ -488,14 +489,14 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) { if (path < sTaxiPathNodesByPath.size()) { - sLog->outDebug(LOG_FILTER_GENERAL, "%s taxi to (Path %u node %u)", _owner->GetName(), path, pathnode); + sLog->outDebug(LOG_FILTER_GENERAL, "%s taxi to (Path %u node %u)", _owner->GetName().c_str(), path, pathnode); FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode); Mutate(mgen, MOTION_SLOT_CONTROLLED); } else { sLog->outError(LOG_FILTER_GENERAL, "%s attempt taxi to (not existed Path %u node %u)", - _owner->GetName(), path, pathnode); + _owner->GetName().c_str(), path, pathnode); } } else diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 6de76a1d9bc..a217bedb1b0 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -41,7 +41,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature &creature) if (!i_path) { // No movement found for entry - sLog->outError(LOG_FILTER_SQL, "WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature.GetName(), creature.GetEntry(), creature.GetGUIDLow(), path_id); + sLog->outError(LOG_FILTER_SQL, "WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature.GetName().c_str(), creature.GetEntry(), creature.GetGUIDLow(), path_id); return; } @@ -285,7 +285,7 @@ void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry { if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID) { - sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName()); + sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName().c_str()); player.GetMap()->ScriptsStart(sEventScripts, eventid, &player, &player); } } diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 6985cb92804..5e3d37acb71 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -29,12 +29,11 @@ #include "GridNotifiersImpl.h" #include "CellImpl.h" -OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp) : -m_capturePointGUID(0), m_capturePoint(NULL), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), -m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), -m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) -{ -} +OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp): + m_capturePointGUID(0), m_capturePoint(NULL), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), + m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), + m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) +{ } bool OPvPCapturePoint::HandlePlayerEnter(Player* player) { @@ -44,14 +43,14 @@ bool OPvPCapturePoint::HandlePlayerEnter(Player* player) player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } - return m_activePlayers[player->GetTeamId()].insert(player).second; + return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second; } void OPvPCapturePoint::HandlePlayerLeave(Player* player) { if (m_capturePoint) player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0); - m_activePlayers[player->GetTeamId()].erase(player); + m_activePlayers[player->GetTeamId()].erase(player->GetGUID()); } void OPvPCapturePoint::SendChangePhase() @@ -243,7 +242,7 @@ OutdoorPvP::~OutdoorPvP() void OutdoorPvP::HandlePlayerEnterZone(Player* player, uint32 /*zone*/) { - m_players[player->GetTeamId()].insert(player); + m_players[player->GetTeamId()].insert(player->GetGUID()); } void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/) @@ -254,8 +253,8 @@ void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/) // remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones) if (!player->GetSession()->PlayerLogout()) SendRemoveWorldStates(player); - m_players[player->GetTeamId()].erase(player); - sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", player->GetName()); + m_players[player->GetTeamId()].erase(player->GetGUID()); + sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", player->GetName().c_str()); } void OutdoorPvP::HandlePlayerResurrects(Player* /*player*/, uint32 /*zone*/) @@ -281,15 +280,10 @@ bool OPvPCapturePoint::Update(uint32 diff) float radius = (float)m_capturePoint->GetGOInfo()->capturePoint.radius; for (uint32 team = 0; team < 2; ++team) - { - for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) - { - Player* player = *itr; - ++itr; - if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) - HandlePlayerLeave(player); - } - } + for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) + if (Player* player = ObjectAccessor::FindPlayer(*itr)) + if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) + HandlePlayerLeave(player); std::list<Player*> players; Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius); @@ -298,9 +292,10 @@ bool OPvPCapturePoint::Update(uint32 diff) for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) { - if ((*itr)->IsOutdoorPvPActive()) + Player* const player = *itr; + if (player->IsOutdoorPvPActive()) { - if (m_activePlayers[(*itr)->GetTeamId()].insert(*itr).second) + if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second) HandlePlayerEnter(*itr); } } @@ -397,7 +392,8 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value) if (m_sendUpdate) for (int i = 0; i < 2; ++i) for (PlayerSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) - (*itr)->SendUpdateWorldState(field, value); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->SendUpdateWorldState(field, value); } void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) @@ -406,9 +402,8 @@ void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) { // send to all players present in the area for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) - { - (*itr)->SendUpdateWorldState(field, value); - } + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->SendUpdateWorldState(field, value); } } @@ -429,7 +424,8 @@ void OPvPCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid) // send to all players present in the area for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) - (*itr)->KilledMonsterCredit(id, guid); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->KilledMonsterCredit(id, guid); } void OutdoorPvP::HandleKill(Player* killer, Unit* killed) @@ -476,7 +472,8 @@ bool OutdoorPvP::IsInsideObjective(Player* player) const bool OPvPCapturePoint::IsInsideObjective(Player* player) const { - return m_activePlayers[player->GetTeamId()].find(player) != m_activePlayers[player->GetTeamId()].end(); + PlayerSet const &plSet = m_activePlayers[player->GetTeamId()]; + return plSet.find(player->GetGUID()) != plSet.end(); } bool OutdoorPvP::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go) @@ -566,7 +563,8 @@ void OutdoorPvP::BroadcastPacket(WorldPacket &data) const // This is faster than sWorld->SendZoneMessage for (uint32 team = 0; team < 2; ++team) for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) - (*itr)->GetSession()->SendPacket(&data); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->GetSession()->SendPacket(&data); } void OutdoorPvP::RegisterZone(uint32 zoneId) @@ -574,19 +572,26 @@ void OutdoorPvP::RegisterZone(uint32 zoneId) sOutdoorPvPMgr->AddZone(zoneId, this); } -bool OutdoorPvP::HasPlayer(Player* player) const +bool OutdoorPvP::HasPlayer(Player const* player) const { - return m_players[player->GetTeamId()].find(player) != m_players[player->GetTeamId()].end(); + PlayerSet const &plSet = m_players[player->GetTeamId()]; + return plSet.find(player->GetGUID()) != plSet.end(); } void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId) { if (spellId > 0) + { for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) - (*itr)->CastSpell(*itr, (uint32)spellId, true); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->CastSpell(player, (uint32)spellId, true); + } else + { for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) - (*itr)->RemoveAura((uint32)-spellId); // by stack? + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->RemoveAura((uint32)-spellId); // by stack? + } } void OutdoorPvP::TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2) diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index e993797d867..8cad3178b9c 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -18,7 +18,7 @@ #ifndef OUTDOOR_PVP_H_ #define OUTDOOR_PVP_H_ -#include "Utilities/Util.h" +#include "Util.h" #include "SharedDefines.h" #include "ZoneScript.h" @@ -84,7 +84,7 @@ class Unit; struct GossipMenuItems; class OutdoorPvP; -typedef std::set<Player*> PlayerSet; +typedef std::set<uint64> PlayerSet; class OPvPCapturePoint { @@ -284,7 +284,7 @@ class OutdoorPvP : public ZoneScript void RegisterZone(uint32 zoneid); - bool HasPlayer(Player* player) const; + bool HasPlayer(Player const * player) const; void TeamCastSpell(TeamId team, int32 spellId); }; diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 8719a710497..c540e4a669d 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -246,17 +246,17 @@ class Quest uint32 GetSrcItemId() const { return SourceItemId; } uint32 GetSrcItemCount() const { return SourceItemIdCount; } uint32 GetSrcSpell() const { return SourceSpellid; } - std::string GetTitle() const { return Title; } - std::string GetDetails() const { return Details; } - std::string GetObjectives() const { return Objectives; } - std::string GetOfferRewardText() const { return OfferRewardText; } - std::string GetRequestItemsText() const { return RequestItemsText; } - std::string GetEndText() const { return EndText; } - std::string GetCompletedText() const { return CompletedText; } - std::string GetQuestGiverTextWindow() const { return QuestGiverTextWindow; } - std::string GetQuestGiverTargetName() const { return QuestGiverTargetName; } - std::string GetQuestTurnTextWindow() const { return QuestTurnTextWindow; } - std::string GetQuestTurnTargetName() const { return QuestTurnTargetName; } + std::string const& GetTitle() const { return Title; } + std::string const& GetDetails() const { return Details; } + std::string const& GetObjectives() const { return Objectives; } + std::string const& GetOfferRewardText() const { return OfferRewardText; } + std::string const& GetRequestItemsText() const { return RequestItemsText; } + std::string const& GetEndText() const { return EndText; } + std::string const& GetCompletedText() const { return CompletedText; } + std::string const& GetQuestGiverTextWindow() const { return QuestGiverTextWindow; } + std::string const& GetQuestGiverTargetName() const { return QuestGiverTargetName; } + std::string const& GetQuestTurnTextWindow() const { return QuestTurnTextWindow; } + std::string const& GetQuestTurnTargetName() const { return QuestTurnTargetName; } int32 GetRewOrReqMoney() const; uint32 GetRewHonorAddition() const { return RewardHonor; } float GetRewHonorMultiplier() const { return RewardHonorMultiplier; } diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index edb4c0c1cf4..d4dad387b1d 100755 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -45,7 +45,7 @@ bool ReputationMgr::IsAtWar(uint32 faction_id) const if (!factionEntry) { - sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::IsAtWar: Can't get AtWar flag of %s for unknown faction (faction id) #%u.", _player->GetName(), faction_id); + sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::IsAtWar: Can't get AtWar flag of %s for unknown faction (faction id) #%u.", _player->GetName().c_str(), faction_id); return 0; } @@ -68,7 +68,7 @@ int32 ReputationMgr::GetReputation(uint32 faction_id) const if (!factionEntry) { - sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", _player->GetName(), faction_id); + sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", _player->GetName().c_str(), faction_id); return 0; } diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 41ae9fb705f..6c2315ddc69 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -61,6 +61,7 @@ void AddSC_guild_commandscript(); void AddSC_honor_commandscript(); void AddSC_instance_commandscript(); void AddSC_learn_commandscript(); +void AddSC_lfg_commandscript(); void AddSC_list_commandscript(); void AddSC_lookup_commandscript(); void AddSC_message_commandscript(); @@ -89,6 +90,7 @@ void AddSC_npc_innkeeper(); void AddSC_npcs_special(); void AddSC_npc_taxi(); void AddSC_achievement_scripts(); +void AddSC_event_scripts(); //eastern kingdoms void AddSC_alterac_valley(); //Alterac Valley @@ -673,6 +675,7 @@ void AddCommandScripts() AddSC_instance_commandscript(); AddSC_learn_commandscript(); AddSC_lookup_commandscript(); + AddSC_lfg_commandscript(); AddSC_list_commandscript(); AddSC_message_commandscript(); AddSC_misc_commandscript(); @@ -703,6 +706,7 @@ void AddWorldScripts() AddSC_npc_taxi(); AddSC_achievement_scripts(); AddSC_chat_log(); + AddSC_event_scripts(); #endif } diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 022faa11b27..5a2ea0f5746 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -298,7 +298,7 @@ void OpcodeTable::Initialize() DEFINE_OPCODE_HANDLER(CMSG_LEARN_PREVIEW_TALENTS_PET, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLearnPreviewTalentsPet ); DEFINE_OPCODE_HANDLER(CMSG_LEARN_TALENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLearnTalentOpcode ); DEFINE_OPCODE_HANDLER(CMSG_LEAVE_CHANNEL, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLeaveChannel ); - DEFINE_OPCODE_HANDLER(CMSG_LFG_GET_STATUS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); + DEFINE_OPCODE_HANDLER(CMSG_LFG_GET_STATUS, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleLfgGetStatus ); DEFINE_OPCODE_HANDLER(CMSG_LFG_JOIN, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleLfgJoinOpcode ); DEFINE_OPCODE_HANDLER(CMSG_LFG_LEAVE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleLfgLeaveOpcode ); DEFINE_OPCODE_HANDLER(CMSG_LFG_LFR_JOIN, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 12372e1f396..3bdd8e54fc0 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -46,6 +46,12 @@ #include "WardenWin.h" #include "WardenMac.h" +namespace { + +std::string const DefaultPlayerName = "<none>"; + +} // namespace + bool MapSessionFilter::Process(WorldPacket* packet) { Opcodes opcode = DropHighBytes(packet->GetOpcode()); @@ -163,29 +169,20 @@ WorldSession::~WorldSession() delete _compressionStream; } -/// Get the player name -std::string WorldSession::GetPlayerName(bool simple /* = true */) const - { - std::string name = "[Player: "; - uint32 guidLow = 0; +std::string const & WorldSession::GetPlayerName() const +{ + return _player != NULL ? _player->GetName() : DefaultPlayerName; +} - if (Player* player = GetPlayer()) - { - name.append(player->GetName()); - guidLow = player->GetGUIDLow(); - } - else - name.append("<none>"); +std::string WorldSession::GetPlayerInfo() const +{ + std::ostringstream ss; - if (!simple) - { - std::ostringstream ss; - ss << " (Guid: " << guidLow << ", Account: " << GetAccountId() << ")"; - name.append(ss.str()); - } + ss << "[Player: " << GetPlayerName() + << " (Guid: " << (_player != NULL ? _player->GetGUID() : 0) + << ", Account: " << GetAccountId() << ")]"; - name.append("]"); - return name; + return ss.str(); } /// Get player guid if available. Use for logging purposes only @@ -202,12 +199,12 @@ void WorldSession::SendPacket(WorldPacket const* packet, bool forced /*= false*/ if (packet->GetOpcode() == NULL_OPCODE) { - sLog->outError(LOG_FILTER_OPCODES, "Prevented sending of NULL_OPCODE to %s", GetPlayerName(false).c_str()); + sLog->outError(LOG_FILTER_OPCODES, "Prevented sending of NULL_OPCODE to %s", GetPlayerInfo().c_str()); return; } else if (packet->GetOpcode() == UNKNOWN_OPCODE) { - sLog->outError(LOG_FILTER_OPCODES, "Prevented sending of UNKNOWN_OPCODE to %s", GetPlayerName(false).c_str()); + sLog->outError(LOG_FILTER_OPCODES, "Prevented sending of UNKNOWN_OPCODE to %s", GetPlayerInfo().c_str()); return; } @@ -216,7 +213,7 @@ void WorldSession::SendPacket(WorldPacket const* packet, bool forced /*= false*/ OpcodeHandler const* handler = opcodeTable[packet->GetOpcode()]; if (!handler || handler->Status == STATUS_UNHANDLED) { - sLog->outError(LOG_FILTER_OPCODES, "Prevented sending disabled opcode %s to %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerName(false).c_str()); + sLog->outError(LOG_FILTER_OPCODES, "Prevented sending disabled opcode %s to %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); return; } } @@ -269,14 +266,14 @@ void WorldSession::QueuePacket(WorldPacket* new_packet) void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason) { sLog->outError(LOG_FILTER_OPCODES, "Received unexpected opcode %s Status: %s Reason: %s from %s", - GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), status, reason, GetPlayerName(false).c_str()); + GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), status, reason, GetPlayerInfo().c_str()); } /// Logging helper for unexpected opcodes void WorldSession::LogUnprocessedTail(WorldPacket* packet) { sLog->outError(LOG_FILTER_OPCODES, "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", - uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerName(false).c_str()); + uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); packet->print_storage(); } @@ -387,11 +384,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) break; case STATUS_NEVER: sLog->outError(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() - , GetPlayerName(false).c_str()); + , GetPlayerInfo().c_str()); break; case STATUS_UNHANDLED: sLog->outError(LOG_FILTER_OPCODES, "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() - , GetPlayerName(false).c_str()); + , GetPlayerInfo().c_str()); break; } } @@ -584,7 +581,8 @@ void WorldSession::LogoutPlayer(bool Save) // e.g if he got disconnected during a transfer to another map // calls to GetMap in this case may cause crashes _player->CleanupsBeforeDelete(); - sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow(), _player->getLevel()); + sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", + GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel()); if (Map* _map = _player->FindMap()) _map->RemovePlayerFromMap(_player, true); @@ -664,25 +662,25 @@ const char *WorldSession::GetTrinityString(int32 entry) const void WorldSession::Handle_NULL(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received unhandled opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_EarlyProccess(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received opcode %s that must be processed in WorldSocket::OnRead from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_ServerSide(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received server-side opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_Deprecated(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received deprecated opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::SendAuthWaitQue(uint32 position) @@ -749,7 +747,7 @@ void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask) while (result->NextRow()); } -void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string data) +void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string const& data) { uint32 id = 0; uint32 index = 0; @@ -1130,7 +1128,7 @@ void WorldSession::ProcessQueryCallbacks() } } -void WorldSession::InitWarden(BigNumber* k, std::string os) +void WorldSession::InitWarden(BigNumber* k, std::string const& os) { if (os == "Win") { diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index fb555b42ea0..464b7ee215c 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -204,7 +204,7 @@ class CharacterCreateInfo friend class Player; protected: - CharacterCreateInfo(std::string name, uint8 race, uint8 cclass, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId, + CharacterCreateInfo(std::string const& name, uint8 race, uint8 cclass, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId, WorldPacket& data) : Name(name), Race(race), Class(cclass), Gender(gender), Skin(skin), Face(face), HairStyle(hairStyle), HairColor(hairColor), FacialHair(facialHair), OutfitId(outfitId), Data(data), CharCount(0) {} @@ -251,8 +251,8 @@ class WorldSession void SendPacket(WorldPacket const* packet, bool forced = false); void SendNotification(const char *format, ...) ATTR_PRINTF(2, 3); void SendNotification(uint32 string_id, ...); - void SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName); - void SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res, uint32 val = 0); + void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName *declinedName); + void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0); void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3); void SendSetPhaseShift(std::set<uint32> const& phaseIds, std::set<uint32> const& terrainswaps); void SendQueryTimeResponse(); @@ -263,14 +263,16 @@ class WorldSession AccountTypes GetSecurity() const { return _security; } uint32 GetAccountId() const { return _accountId; } Player* GetPlayer() const { return _player; } - std::string GetPlayerName(bool simple = true) const; + std::string const& GetPlayerName() const; + std::string GetPlayerInfo() const; + uint32 GetGuidLow() const; void SetSecurity(AccountTypes security) { _security = security; } std::string const& GetRemoteAddress() { return m_Address; } void SetPlayer(Player* player); uint8 Expansion() const { return m_expansion; } - void InitWarden(BigNumber* k, std::string os); + void InitWarden(BigNumber* k, std::string const& os); /// Session in auth.queue currently void SetInQueue(bool state) { m_inQueue = state; } @@ -303,7 +305,7 @@ class WorldSession void SendNameQueryOpcode(uint64 guid); void SendTrainerList(uint64 guid); - void SendTrainerList(uint64 guid, const std::string& strTitle); + void SendTrainerList(uint64 guid, std::string const& strTitle); void SendListInventory(uint64 guid); void SendShowBank(uint64 guid); void SendTabardVendorActivate(uint64 guid); @@ -332,7 +334,7 @@ class WorldSession // Account Data AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; } - void SetAccountData(AccountDataType type, time_t tm, std::string data); + void SetAccountData(AccountDataType type, time_t tm, std::string const& data); void SendAccountDataTimes(uint32 mask); void LoadGlobalAccountData(); void LoadAccountData(PreparedQueryResult result, uint32 mask); @@ -370,7 +372,7 @@ class WorldSession void SendDiscoverNewTaxiNode(uint32 nodeid); // Guild/Arena Team - void SendArenaTeamCommandResult(uint32 team_action, const std::string& team, const std::string& player, uint32 error_id); + void SendArenaTeamCommandResult(uint32 team_action, std::string const& team, std::string const& player, uint32 error_id); void SendNotInArenaTeamPacket(uint8 type); void SendPetitionShowList(uint64 guid); @@ -494,7 +496,7 @@ class WorldSession void HandleEmoteOpcode(WorldPacket& recvPacket); void HandleContactListOpcode(WorldPacket& recvPacket); void HandleAddFriendOpcode(WorldPacket& recvPacket); - void HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string friendNote); + void HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string const& friendNote); void HandleDelFriendOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcodeCallBack(PreparedQueryResult result); @@ -729,8 +731,8 @@ class WorldSession bool processChatmessageFurtherAfterSecurityChecks(std::string&, uint32); void HandleMessagechatOpcode(WorldPacket& recvPacket); void HandleAddonMessagechatOpcode(WorldPacket& recvPacket); - void SendPlayerNotFoundNotice(std::string name); - void SendPlayerAmbiguousNotice(std::string name); + void SendPlayerNotFoundNotice(std::string const& name); + void SendPlayerAmbiguousNotice(std::string const& name); void SendWrongFactionNotice(); void SendChatRestrictedNotice(ChatRestrictionType restriction); void HandleTextEmoteOpcode(WorldPacket& recvPacket); @@ -792,7 +794,7 @@ class WorldSession void HandleSetActionBarToggles(WorldPacket& recvData); void HandleCharRenameOpcode(WorldPacket& recvData); - void HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string newName); + void HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string const& newName); void HandleSetPlayerDeclinedNames(WorldPacket& recvData); void HandleTotemDestroyed(WorldPacket& recvData); @@ -847,6 +849,7 @@ class WorldSession void HandleLfgTeleportOpcode(WorldPacket& recvData); void HandleLfrJoinOpcode(WorldPacket& recvData); void HandleLfrLeaveOpcode(WorldPacket& recvData); + void HandleLfgGetStatus(WorldPacket& recvData); void SendLfgUpdatePlayer(const LfgUpdateData& updateData); void SendLfgUpdateParty(const LfgUpdateData& updateData); diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 4cf144dd7a2..38c6ed6276e 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -486,7 +486,7 @@ int WorldSocket::handle_input_header (void) sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::handle_input_header(): client (account: %u, char [GUID: %u, name: %s]) sent malformed packet (size: %d, cmd: %d)", m_Session ? m_Session->GetAccountId() : 0, _player ? _player->GetGUIDLow() : 0, - _player ? _player->GetName() : "<none>", + _player ? _player->GetName().c_str() : "<none>", header.size, header.cmd); errno = EINVAL; @@ -689,7 +689,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) case CMSG_AUTH_SESSION: if (m_Session) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", m_Session->GetPlayerName(false).c_str()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", m_Session->GetPlayerInfo().c_str()); return -1; } @@ -734,7 +734,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) OpcodeHandler const* handler = opcodeTable[opcode]; if (!handler || handler->Status == STATUS_UNHANDLED) { - sLog->outError(LOG_FILTER_OPCODES, "No defined handler for opcode %s sent by %s", GetOpcodeNameForLogging(new_pct->GetOpcode()).c_str(), m_Session->GetPlayerName(false).c_str()); + sLog->outError(LOG_FILTER_OPCODES, "No defined handler for opcode %s sent by %s", GetOpcodeNameForLogging(new_pct->GetOpcode()).c_str(), m_Session->GetPlayerInfo().c_str()); return 0; } @@ -1071,7 +1071,7 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket) if (m_Session && AccountMgr::IsPlayerAccount(m_Session->GetSecurity())) { sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::HandlePing: %s kicked for over-speed pings (address: %s)", - m_Session->GetPlayerName(false).c_str(), GetRemoteAddress().c_str()); + m_Session->GetPlayerInfo().c_str(), GetRemoteAddress().c_str()); return -1; } diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 55dd4219bcc..190c2fcdb8c 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -575,8 +575,8 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) { //TODO: There is a crash caused by shadowfiend load addon sLog->outFatal(LOG_FILTER_SPELLS_AURAS, "Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).", GetSpellInfo()->Id, - GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), - itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); + GetOwner()->GetName().c_str(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), + itr->first->GetName().c_str(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); ASSERT(false); } itr->first->_CreateAuraApplication(this, itr->second); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 8ed95ae9530..1a565dacad9 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4281,14 +4281,16 @@ void Spell::SendResurrectRequest(Player* target) { // get ressurector name for creature resurrections, otherwise packet will be not accepted // for player resurrections the name is looked up by guid - char const* resurrectorName = m_caster->GetTypeId() == TYPEID_PLAYER ? "" : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()); + std::string const sentName(m_caster->GetTypeId() == TYPEID_PLAYER + ? "" + : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex())); - WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+strlen(resurrectorName)+1+1+1+4)); - data << uint64(m_caster->GetGUID()); // resurrector guid - data << uint32(strlen(resurrectorName) + 1); + WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+sentName.size()+1+1+1+4)); + data << uint64(m_caster->GetGUID()); + data << uint32(sentName.size() + 1); - data << resurrectorName; - data << uint8(0); // use timer according to client symbols + data << sentName; + data << uint8(0); // null terminator data << uint8(m_caster->GetTypeId() == TYPEID_PLAYER ? 0 : 1); // "you'll be afflicted with resurrection sickness" // override delay sent with SMSG_CORPSE_RECLAIM_DELAY, set instant resurrection for spells with this attribute diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 16cf6549c41..81f1bbe7198 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1843,7 +1843,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) if (!gameObjTarget->isSpawned() && !player->isGameMaster()) { sLog->outError(LOG_FILTER_SPELLS_AURAS, "Possible hacking attempt: Player %s [guid: %u] tried to loot a gameobject [entry: %u id: %u] which is on respawn time without being in GM mode!", - player->GetName(), player->GetGUIDLow(), gameObjTarget->GetEntry(), gameObjTarget->GetGUIDLow()); + player->GetName().c_str(), player->GetGUIDLow(), gameObjTarget->GetEntry(), gameObjTarget->GetGUIDLow()); return; } // special case, already has GossipHello inside so return and avoid calling twice @@ -2637,9 +2637,9 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (item_owner != p_caster && !AccountMgr::IsPlayerAccount(p_caster->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName(), item_owner->GetSession()->GetAccountId()); + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2702,9 +2702,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (item_owner != p_caster && !AccountMgr::IsPlayerAccount(p_caster->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName(), item_owner->GetSession()->GetAccountId()); + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2784,9 +2784,9 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (item_owner != p_caster && !AccountMgr::IsPlayerAccount(p_caster->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName(), item_owner->GetSession()->GetAccountId()); + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -3645,7 +3645,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) const char *gender = "his"; if (m_caster->getGender() > 0) gender = "her"; - sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName(), gender, gender, urand(1, 10), urand(1, 10)); + sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName().c_str(), gender, gender, urand(1, 10), urand(1, 10)); m_caster->MonsterTextEmote(buf, 0); break; } @@ -3656,7 +3656,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) const char *gender = "his"; if (m_caster->getGender() > 0) gender = "her"; - sprintf(buf, "%s causually tosses %s [Worn Troll Dice]. One %u and one %u.", m_caster->GetName(), gender, urand(1, 6), urand(1, 6)); + sprintf(buf, "%s causually tosses %s [Worn Troll Dice]. One %u and one %u.", m_caster->GetName().c_str(), gender, urand(1, 6), urand(1, 6)); m_caster->MonsterTextEmote(buf, 0); break; } @@ -4266,7 +4266,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) Player* target = (Player*)m_caster; sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell Effect: Stuck"); - sLog->outInfo(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", target->GetName(), target->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), target->GetPositionY(), target->GetPositionZ()); + sLog->outInfo(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", target->GetName().c_str(), target->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), target->GetPositionY(), target->GetPositionZ()); if (target->isInFlight()) return; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index b1a2097a8f9..26dda4d2327 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -72,6 +72,8 @@ class _SpellScript { public: EffectHook(uint8 _effIndex); + virtual ~EffectHook() { } + uint8 GetAffectedEffectsMask(SpellInfo const* spellEntry); bool IsEffectAffected(SpellInfo const* spellEntry, uint8 effIndex); virtual bool CheckEffect(SpellInfo const* spellEntry, uint8 effIndex) = 0; @@ -83,7 +85,7 @@ class _SpellScript class EffectNameCheck { public: - EffectNameCheck(uint16 _effName) {effName = _effName;}; + EffectNameCheck(uint16 _effName) { effName = _effName; } bool Check(SpellInfo const* spellEntry, uint8 effIndex); std::string ToString(); private: @@ -118,7 +120,7 @@ class _SpellScript virtual bool Load() { return true; } // Function called when script is destroyed // use for: deallocating memory allocated by script - virtual void Unload() {} + virtual void Unload() { } }; // SpellScript interface - enum used for runtime checks of script function calls diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 7818527b34b..5c2639175d2 100755 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -34,14 +34,14 @@ class CreatureTextBuilder size_t operator()(WorldPacket* data, LocaleConstant locale) const { - std::string text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); - char const* localizedName = _source->GetNameForLocaleIdx(locale); + std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); + std::string const& localizedName = _source->GetNameForLocaleIdx(locale); *data << uint8(_msgType); *data << uint32(_language); *data << uint64(_source->GetGUID()); *data << uint32(1); // 2.1.0 - *data << uint32(strlen(localizedName)+1); + *data << uint32(localizedName.size() + 1); *data << localizedName; size_t whisperGUIDpos = data->wpos(); *data << uint64(_targetGUID); // Unit Target @@ -178,7 +178,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp CreatureTextMap::const_iterator sList = mTextMap.find(source->GetEntry()); if (sList == mTextMap.end()) { - sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find Text for Creature(%s) Entry %u in 'creature_text' table. Ignoring.", source->GetName(), source->GetEntry()); + sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find Text for Creature(%s) Entry %u in 'creature_text' table. Ignoring.", source->GetName().c_str(), source->GetEntry()); return 0; } @@ -186,7 +186,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp CreatureTextHolder::const_iterator itr = textHolder.find(textGroup); if (itr == textHolder.end()) { - sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find TextGroup %u for Creature(%s) GuidLow %u Entry %u. Ignoring.", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry()); + sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find TextGroup %u for Creature(%s) GuidLow %u Entry %u. Ignoring.", uint32(textGroup), source->GetName().c_str(), source->GetGUIDLow(), source->GetEntry()); return 0; } @@ -383,7 +383,7 @@ void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id) if (std::find(repeats.begin(), repeats.end(), id) == repeats.end()) repeats.push_back(id); else - sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); + sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName().c_str(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); } CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index 63837e39452..7e6768b96b2 100755 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -94,8 +94,8 @@ public: uint32 GetId() const { return _id; } Player* GetPlayer() const { return ObjectAccessor::FindPlayer(_playerGuid); } - std::string GetPlayerName() const { return _playerName; } - std::string GetMessage() const { return _message; } + std::string const& GetPlayerName() const { return _playerName; } + std::string const& GetMessage() const { return _message; } Player* GetAssignedPlayer() const { return ObjectAccessor::FindPlayer(_assignedTo); } uint64 GetAssignedToGUID() const { return _assignedTo; } std::string GetAssignedToName() const @@ -120,16 +120,16 @@ public: _escalatedStatus = TICKET_ASSIGNED; } void SetClosedBy(const int64& value) { _closedBy = value; } - void SetMessage(const std::string& message) + void SetMessage(std::string const& message) { _message = message; _lastModifiedTime = uint64(time(NULL)); } - void SetComment(const std::string& comment) { _comment = comment; } + void SetComment(std::string const& comment) { _comment = comment; } void SetViewed() { _viewed = true; } void SetUnassigned(); - void AppendResponse(const std::string& response) { _response += response; } + void AppendResponse(std::string const& response) { _response += response; } bool LoadFromDB(Field* fields); void SaveToDB(SQLTransaction& trans) const; @@ -143,7 +143,7 @@ public: std::string FormatMessageString(ChatHandler& handler, const char* szClosedName, const char* szAssignedToName, const char* szUnassignedName, const char* szDeletedName) const; void SetChatLog(std::list<uint32> time, std::string const& log); - std::string GetChatLog() const { return _chatLog; } + std::string const& GetChatLog() const { return _chatLog; } private: uint32 _id; diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 86cc42fba42..f5cd88df58d 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -119,7 +119,7 @@ std::string gettablename(std::string &str) return str.substr(s, e-s); } -bool changenth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false) +bool changenth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false) { std::string::size_type s, e; if (!findnth(str, n, s, e)) @@ -144,7 +144,7 @@ std::string getnth(std::string &str, int n) return str.substr(s, e-s); } -bool changetoknth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false) +bool changetoknth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false) { std::string::size_type s = 0, e = 0; if (!findtoknth(str, n, s, e)) @@ -200,7 +200,7 @@ std::string CreateDumpString(char const* tableName, QueryResult result) { if (!tableName || !result) return ""; std::ostringstream ss; - ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; + ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; Field* fields = result->Fetch(); for (uint32 i = 0; i < result->GetFieldCount(); ++i) { @@ -400,7 +400,7 @@ void fixNULLfields(std::string &line) } } -DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid) +DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid) { uint32 charcount = AccountMgr::GetCharactersCount(account); if (charcount >= 10) diff --git a/src/server/game/Tools/PlayerDump.h b/src/server/game/Tools/PlayerDump.h index a387c05f9b5..90a3328055e 100755 --- a/src/server/game/Tools/PlayerDump.h +++ b/src/server/game/Tools/PlayerDump.h @@ -74,7 +74,7 @@ class PlayerDumpWriter : public PlayerDump PlayerDumpWriter() {} bool GetDump(uint32 guid, std::string& dump); - DumpReturn WriteDump(const std::string& file, uint32 guid); + DumpReturn WriteDump(std::string const& file, uint32 guid); private: typedef std::set<uint32> GUIDs; @@ -92,8 +92,7 @@ class PlayerDumpReader : public PlayerDump public: PlayerDumpReader() {} - DumpReturn LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid); + DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid); }; #endif - diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index d651fbd4ce1..ce64dbd1a94 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -106,7 +106,7 @@ void Warden::Update() if (_clientResponseTimer > maxClientResponseDelay * IN_MILLISECONDS) { sLog->outWarn(LOG_FILTER_WARDEN, "%s (latency: %u, IP: %s) exceeded Warden module response delay for more than %s - disconnecting client", - _session->GetPlayerName(false).c_str(), _session->GetLatency(), _session->GetRemoteAddress().c_str(), secsToTimeString(maxClientResponseDelay, true).c_str()); + _session->GetPlayerInfo().c_str(), _session->GetLatency(), _session->GetRemoteAddress().c_str(), secsToTimeString(maxClientResponseDelay, true).c_str()); _session->KickPlayer(); } else diff --git a/src/server/game/Warden/WardenMac.cpp b/src/server/game/Warden/WardenMac.cpp index 9c90662105a..e08d24ecbcd 100644 --- a/src/server/game/Warden/WardenMac.cpp +++ b/src/server/game/Warden/WardenMac.cpp @@ -152,7 +152,7 @@ void WardenMac::HandleHashResult(ByteBuffer &buff) // Verify key if (memcmp(buff.contents() + 1, sha1.GetDigest(), 20) != 0) { - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp index 20f09ec5bda..3d5f27f6a31 100644 --- a/src/server/game/Warden/WardenWin.cpp +++ b/src/server/game/Warden/WardenWin.cpp @@ -156,7 +156,7 @@ void WardenWin::HandleHashResult(ByteBuffer &buff) // Verify key if (memcmp(buff.contents() + 1, Module.ClientKeySeedHash, 20) != 0) { - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } @@ -341,7 +341,7 @@ void WardenWin::HandleData(ByteBuffer &buff) if (!IsValidCheckSum(Checksum, buff.contents() + buff.rpos(), Length)) { buff.rpos(buff.wpos()); - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed checksum. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed checksum. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } @@ -352,7 +352,7 @@ void WardenWin::HandleData(ByteBuffer &buff) // TODO: test it. if (result == 0x00) { - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed timing check. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed timing check. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } @@ -494,7 +494,7 @@ void WardenWin::HandleData(ByteBuffer &buff) if (checkFailed > 0) { WardenCheck* check = sWardenCheckMgr->GetWardenDataById(checkFailed); - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed Warden check %u. Action: %s", _session->GetPlayerName(false).c_str(), checkFailed, Penalty(check).c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed Warden check %u. Action: %s", _session->GetPlayerInfo().c_str(), checkFailed, Penalty(check).c_str()); } // Set hold off timer, minimum timer should at least be 1 second diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 796a7eccb59..054ca15fd25 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2292,7 +2292,7 @@ void World::KickAllLess(AccountTypes sec) } /// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban -BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author) +BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, std::string const& duration, std::string const& reason, std::string const& author) { uint32 duration_secs = TimeStringToSecs(duration); PreparedQueryResult resultAccounts = PreparedQueryResult(NULL); //used for kicking @@ -2370,7 +2370,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura } /// Remove a ban from an account or IP address -bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) +bool World::RemoveBanAccount(BanMode mode, std::string const& nameOrIP) { PreparedStatement* stmt = NULL; if (mode == BAN_IP) @@ -2399,9 +2399,9 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) } /// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban -BanReturn World::BanCharacter(std::string name, std::string duration, std::string reason, std::string author) +BanReturn World::BanCharacter(std::string const& name, std::string const& duration, std::string const& reason, std::string const& author) { - Player* pBanned = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pBanned = sObjectAccessor->FindPlayerByName(name); uint32 guid = 0; uint32 duration_secs = TimeStringToSecs(duration); @@ -2440,9 +2440,9 @@ BanReturn World::BanCharacter(std::string name, std::string duration, std::strin } /// Remove a ban from a character -bool World::RemoveBanCharacter(std::string name) +bool World::RemoveBanCharacter(std::string const& name) { - Player* pBanned = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pBanned = sObjectAccessor->FindPlayerByName(name); uint32 guid = 0; /// Pick a player to ban if not online diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index a6d3a6f8dc6..cc97742e25d 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -620,19 +620,19 @@ class World void SetAllowMovement(bool allow) { m_allowMovement = allow; } /// Set a new Message of the Day - void SetMotd(const std::string& motd); + void SetMotd(std::string const& motd); /// Get the current Message of the Day const char* GetMotd() const; /// Set the string for new characters (first login) - void SetNewCharString(std::string str) { m_newCharString = str; } + void SetNewCharString(std::string const& str) { m_newCharString = str; } /// Get the string for new characters (first login) - const std::string& GetNewCharString() const { return m_newCharString; } + std::string const& GetNewCharString() const { return m_newCharString; } LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; } /// Get the path where data (dbc, maps) are stored on disk - std::string GetDataPath() const { return m_dataPath; } + std::string const& GetDataPath() const { return m_dataPath; } /// When server started? time_t const& GetStartTime() const { return m_startTime; } @@ -735,10 +735,10 @@ class World void KickAll(); void KickAllLess(AccountTypes sec); - BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); - bool RemoveBanAccount(BanMode mode, std::string nameOrIP); - BanReturn BanCharacter(std::string name, std::string duration, std::string reason, std::string author); - bool RemoveBanCharacter(std::string name); + BanReturn BanAccount(BanMode mode, std::string const& nameOrIP, std::string const& duration, std::string const& reason, std::string const& author); + bool RemoveBanAccount(BanMode mode, std::string const& nameOrIP); + BanReturn BanCharacter(std::string const& name, std::string const& duration, std::string const& reason, std::string const& author); + bool RemoveBanCharacter(std::string const& name); // for max speed access static float GetMaxVisibleDistanceOnContinents() { return m_MaxVisibleDistanceOnContinents; } diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 3dfb5b39c24..b85a30dc5f9 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -44,6 +44,7 @@ if(SCRIPTS) include(Kalimdor/CMakeLists.txt) include(Outland/CMakeLists.txt) include(Northrend/CMakeLists.txt) + include(Events/CMakeLists.txt) endif() message(STATUS "SCRIPT PREPARATION COMPLETE") diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 1024a3acf15..15a724e69d1 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -111,9 +111,9 @@ public: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); if (handler->GetSession()) { - sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password." - , handler->GetSession()->GetAccountId(),handler->GetSession()->GetRemoteAddress().c_str() - , handler->GetSession()->GetPlayer()->GetName(), handler->GetSession()->GetPlayer()->GetGUIDLow()); + sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password.", + handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), + handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); } break; case AOR_NAME_TOO_LONG: diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index d6c4ef54d15..d0bd7503216 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -265,7 +265,7 @@ public: return false; LocaleConstant loc = handler->GetSessionDbcLocale(); - char const* targetName = target->GetName(); + char const* targetName = target->GetName().c_str(); char const* knownStr = handler->GetTrinityString(LANG_KNOWN); // Search in CharTitles.dbc @@ -681,7 +681,7 @@ public: uint64 characterGuid; uint32 accountId; - Player* player = sObjectAccessor->FindPlayerByName(characterName.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(characterName); if (player) { characterGuid = player->GetGUID(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 6c5abfe60e6..2f5049c9da6 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -418,7 +418,7 @@ public: sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending opcode %u", data.GetOpcode()); data.hexlike(); player->GetSession()->SendPacket(&data, true); - handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); + handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName().c_str()); return true; } @@ -497,7 +497,9 @@ public: if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName() : "offline") : "no loot recipient"); + handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", + target->GetName().c_str(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), + target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); return true; } @@ -797,17 +799,17 @@ public: if (!target || target->isTotem() || target->isPet()) return false; - std::list<HostileReference*>& threatList = target->getThreatManager().getThreatList(); - std::list<HostileReference*>::iterator itr; + ThreatContainer::StorageType const &threatList = target->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator itr; uint32 count = 0; - handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); for (itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = (*itr)->getTarget(); if (!unit) continue; ++count; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat()); } handler->SendSysMessage("End of threat list."); return true; @@ -820,13 +822,13 @@ public: target = handler->GetSession()->GetPlayer(); HostileReference* ref = target->getHostileRefManager().getFirst(); uint32 count = 0; - handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); while (ref) { if (Unit* unit = ref->getSource()->getOwner()) { ++count; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUIDLow(), ref->getThreat()); } ref = ref->next(); } @@ -1061,7 +1063,7 @@ public: static bool HandleDebugLoSCommand(ChatHandler* handler, char const* /*args*/) { if (Unit* unit = handler->getSelectedUnit()) - handler->PSendSysMessage("Unit %s (GuidLow: %u) is %sin LoS", unit->GetName(), unit->GetGUIDLow(), handler->GetSession()->GetPlayer()->IsWithinLOSInMap(unit) ? "" : "not "); + handler->PSendSysMessage("Unit %s (GuidLow: %u) is %sin LoS", unit->GetName().c_str(), unit->GetGUIDLow(), handler->GetSession()->GetPlayer()->IsWithinLOSInMap(unit) ? "" : "not "); return true; } diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 0230ebcd1e7..087a72764dc 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -130,16 +130,17 @@ public: handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage("========================"); } - char const* name = itr->second->GetName(); + std::string const& name = itr->second->GetName(); + uint8 size = name.size(); uint8 security = itrSec; - uint8 max = ((16 - strlen(name)) / 2); + uint8 max = ((16 - size) / 2); uint8 max2 = max; - if ((max + max2 + strlen(name)) == 16) + if ((max + max2 + size) == 16) max2 = max - 1; if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name, security); + handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security); else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security); } } if (footer) diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 45ecc4e4721..5f1ed59176f 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -28,9 +28,9 @@ void GetPlayerInfo(ChatHandler* handler, Player* player) uint64 guid = player->GetGUID(); LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid); - char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); - handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName(), - state, uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(), + std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); + handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(), + state.c_str(), uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(), sLFGMgr->GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str()); } @@ -85,9 +85,9 @@ public: } uint64 guid = grp->GetGUID(); - char const * const state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); + std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(), - state, sLFGMgr->GetDungeon(guid)); + state.c_str(), sLFGMgr->GetDungeon(guid)); for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) GetPlayerInfo(handler, itr->getSource()); @@ -114,9 +114,9 @@ public: return true; } - static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* /*args*/) + static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* args) { - handler->SendSysMessage(sLFGMgr->DumpQueueInfo().c_str()); + handler->SendSysMessage(sLFGMgr->DumpQueueInfo(*args).c_str()); return true; } diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 3a2ef366ace..6e592e47fb8 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -970,7 +970,7 @@ public: Player* target = handler->getSelectedPlayer(); // title name have single string arg for player name - char const* targetName = target ? target->GetName() : "NAME"; + char const* targetName = target ? target->GetName().c_str() : "NAME"; std::string namePart = args; std::wstring wNamePart; diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index d61abf34e2f..de2fcf26943 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -71,7 +71,7 @@ public: Player* player = handler->GetSession()->GetPlayer(); Channel* channcel = NULL; - if (ChannelMgr* cMgr = channelMgr(player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(player->GetTeam())) channcel = cMgr->GetChannel(channelStr, player); if (strcmp(argStr, "on") == 0) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 7c7adafdfeb..d69e7e1cc6b 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1922,9 +1922,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); else - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); break; } case FOLLOW_MOTION_TYPE: @@ -1938,9 +1938,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); else - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); break; } case HOME_MOTION_TYPE: @@ -2533,7 +2533,7 @@ public: { name = TargetName; normalizePlayerName(name); - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); } if (!player) @@ -2592,7 +2592,7 @@ public: { name = targetName; normalizePlayerName(name); - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); } else // If no name was entered - use target { diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 30713728cf6..1fa84985445 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -47,19 +47,19 @@ public: { "weapon", SEC_ADMINISTRATOR, false, &HandleNpcAddWeaponCommand, "", NULL }, //} { "", SEC_GAMEMASTER, false, &HandleNpcAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcDeleteCommandTable[] = { { "item", SEC_GAMEMASTER, false, &HandleNpcDeleteVendorItemCommand, "", NULL }, { "", SEC_GAMEMASTER, false, &HandleNpcDeleteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcFollowCommandTable[] = { { "stop", SEC_GAMEMASTER, false, &HandleNpcUnFollowCommand, "", NULL }, { "", SEC_GAMEMASTER, false, &HandleNpcFollowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcSetCommandTable[] = { @@ -79,7 +79,7 @@ public: { "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL }, { "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL }, //} - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcCommandTable[] = { @@ -95,18 +95,18 @@ public: { "delete", SEC_GAMEMASTER, false, NULL, "", npcDeleteCommandTable }, { "follow", SEC_GAMEMASTER, false, NULL, "", npcFollowCommandTable }, { "set", SEC_GAMEMASTER, false, NULL, "", npcSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; return commandTable; } //add spawn of creature - static bool HandleNpcAddCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -231,7 +231,7 @@ public: } //add move for creature - static bool HandleNpcAddMoveCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddMoveCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -295,7 +295,7 @@ public: return true; } - static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, char const* /*args*/) { if (sWorld->getAllowMovement()) { @@ -310,7 +310,7 @@ public: return true; } - static bool HandleNpcSetEntryCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetEntryCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -335,7 +335,7 @@ public: } //change level of creature or pet - static bool HandleNpcSetLevelCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetLevelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -376,7 +376,7 @@ public: return true; } - static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcDeleteCommand(ChatHandler* handler, char const* args) { Creature* unit = NULL; @@ -415,7 +415,7 @@ public: } //del item from vendor list - static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, const char* args) + static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -453,7 +453,7 @@ public: } //set faction of creature - static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -500,7 +500,7 @@ public: } //set npcflag of creature - static bool HandleNpcSetFlagCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetFlagCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -531,7 +531,7 @@ public: } //set data of creature for testing scripting - static bool HandleNpcSetDataCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetDataCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -559,12 +559,12 @@ public: creature->AI()->SetData(data_1, data_2); std::string AIorScript = creature->GetAIName() != "" ? "AI type: " + creature->GetAIName() : (creature->GetScriptName() != "" ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set"); - handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript.c_str()); + handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str()); return true; } //npc follow handling - static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcFollowCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creature = handler->getSelectedCreature(); @@ -579,11 +579,11 @@ public: // Follow player - Using pet's default dist and angle creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); - handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str()); return true; } - static bool HandleNpcInfoCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcInfoCommand(ChatHandler* handler, char const* /*args*/) { Creature* target = handler->getSelectedCreature(); @@ -629,7 +629,7 @@ public: } //move selected creature - static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args) + static bool HandleNpcMoveCommand(ChatHandler* handler, char const* args) { uint32 lowguid = 0; @@ -717,7 +717,7 @@ public: } //play npc emote - static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, char const* args) { uint32 emote = atoi((char*)args); @@ -746,7 +746,7 @@ public: } //set model of creature - static bool HandleNpcSetModelCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetModelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -782,7 +782,7 @@ public: * additional parameter: NODEL - so no waypoints are deleted, if you * change the movement type */ - static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -918,7 +918,7 @@ public: //npc phasemask handling //change phasemask of creature or pet - static bool HandleNpcSetPhaseCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetPhaseCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -948,7 +948,7 @@ public: } //set spawn dist of creature - static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -994,7 +994,7 @@ public: } //spawn time handling - static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1034,7 +1034,7 @@ public: return true; } - static bool HandleNpcSayCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSayCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1062,7 +1062,7 @@ public: } //show text emote by creature in chat - static bool HandleNpcTextEmoteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcTextEmoteCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1082,7 +1082,7 @@ public: } //npc unfollow handling - static bool HandleNpcUnFollowCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcUnFollowCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creature = handler->getSelectedCreature(); @@ -1097,7 +1097,7 @@ public: if (/*creature->GetMotionMaster()->empty() ||*/ creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } @@ -1106,7 +1106,7 @@ public: if (mgen->GetTarget() != player) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } @@ -1114,12 +1114,12 @@ public: // reset movement creature->GetMotionMaster()->MovementExpired(true); - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str()); return true; } // make npc whisper to player - static bool HandleNpcWhisperCommand(ChatHandler* handler, const char* args) + static bool HandleNpcWhisperCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1146,7 +1146,7 @@ public: return true; } - static bool HandleNpcYellCommand(ChatHandler* handler, const char* args) + static bool HandleNpcYellCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1168,7 +1168,7 @@ public: } // add creature, temp only - static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1188,7 +1188,7 @@ public: } //npc tame handling - static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcTameCommand(ChatHandler* handler, char const* /*args*/) { Creature* creatureTarget = handler->getSelectedCreature(); if (!creatureTarget || creatureTarget->isPet()) @@ -1254,7 +1254,7 @@ public: return true; } - static bool HandleNpcAddFormationCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddFormationCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1306,7 +1306,7 @@ public: return true; } - static bool HandleNpcSetLinkCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetLinkCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1341,7 +1341,7 @@ public: } //TODO: NpcCommands that need to be fixed : - static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, char const* /*args*/) { /*if (!*args) return false; @@ -1409,7 +1409,7 @@ public: return true; } - static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, char const* /*args*/) { /* Temp. disabled if (!*args) @@ -1456,7 +1456,7 @@ public: return true; } - static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, char const* /*args*/) { /* Temp. disabled diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index baaa5d2bd43..c99931a90fb 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -156,7 +156,7 @@ public: sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : -1); sTicketMgr->UpdateLastChange(); - std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName() : "Console", NULL, NULL, NULL); + std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); // Inform player, who submitted this ticket, that it is closed @@ -206,7 +206,7 @@ public: sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), NULL, NULL); - msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName() : "Console", comment); + msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName().c_str() : "Console", comment); handler->SendGlobalGMSysMessage(msg.c_str()); return true; @@ -258,7 +258,7 @@ public: return true; } - std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console"); + std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->RemoveTicket(ticket->GetId()); @@ -389,7 +389,7 @@ public: sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), - handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console", NULL); + handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; @@ -427,7 +427,7 @@ public: // Detect target's GUID uint64 guid = 0; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) guid = player->GetGUID(); else guid = sObjectMgr->GetPlayerGUIDByName(name); diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index cb52844c626..046841128e8 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -36,7 +36,7 @@ public: static ChatCommand titlesSetCommandTable[] = { { "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand titlesCommandTable[] = { @@ -44,17 +44,17 @@ public: { "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL }, { "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL }, { "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; return commandTable; } - static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesCurrentCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -99,7 +99,7 @@ public: return true; } - static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesAddCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -136,9 +136,8 @@ public: std::string tNameLink = handler->GetNameLink(target); - char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr, 80, titleInfo->name, targetName); + snprintf(titleNameStr, 80, titleInfo->name, target->GetName().c_str()); target->SetTitle(titleInfo); handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); @@ -146,7 +145,7 @@ public: return true; } - static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesRemoveCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -185,9 +184,8 @@ public: std::string tNameLink = handler->GetNameLink(target); - char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr, 80, titleInfo->name, targetName); + snprintf(titleNameStr, 80, titleInfo->name, target->GetName().c_str()); handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); @@ -201,7 +199,7 @@ public: } //Edit Player KnownTitles - static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesSetMaskCommand(ChatHandler* handler, char const* args) { if (!*args) return false; diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 25c3f2e41e3..9beb3bb10fe 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -240,8 +240,8 @@ public: //Affliction_Timer if (Affliction_Timer <= diff) { - std::list<HostileReference*> threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { if ((*i) && (*i)->getSource()) { diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp index bf27cad44ef..2c7e1b9c48a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp @@ -187,13 +187,11 @@ public: if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1)) DoCast(target, SPELL_HATEFUL_BOLT); - } else HatefulBoltTimer -= diff; DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_curator() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp index 8921867be21..5f974a890bf 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp @@ -132,9 +132,7 @@ public: DoMeleeAttackIfReady(); } - }; - }; void AddSC_boss_maiden_of_virtue() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index ea9cfe5c3c1..7eeced1d970 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -111,7 +111,6 @@ public: DoScriptText(SAY_DISARMED, me); } }; - }; class boss_midnight : public CreatureScript @@ -232,7 +231,6 @@ public: CAST_AI(boss_attumen::boss_attumenAI, pAttumen->AI())->Midnight = value; } }; - }; void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) @@ -284,9 +282,9 @@ void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) if (ChargeTimer <= diff) { Unit* target = NULL; - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); std::vector<Unit*> target_list; - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) { target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (target && !target->IsWithinDist(me, ATTACK_DISTANCE, false)) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 533a1aac2f0..99f2cb51c85 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -307,7 +307,6 @@ public: DoMeleeAttackIfReady(); } }; - }; struct boss_moroes_guestAI : public ScriptedAI @@ -452,7 +451,6 @@ public: } else ShadowWordPain_Timer -= diff; } }; - }; class boss_baron_rafe_dreuger : public CreatureScript @@ -510,7 +508,6 @@ public: } else HammerOfJustice_Timer -= diff; } }; - }; class boss_lady_catriona_von_indi : public CreatureScript @@ -581,7 +578,6 @@ public: } else DispelMagic_Timer -= diff; } }; - }; class boss_lady_keira_berrybuck : public CreatureScript @@ -656,7 +652,6 @@ public: } else Cleanse_Timer -= diff; } }; - }; class boss_lord_robin_daris : public CreatureScript @@ -713,7 +708,6 @@ public: } else WhirlWind_Timer -= diff; } }; - }; class boss_lord_crispin_ference : public CreatureScript @@ -778,7 +772,6 @@ public: } else ShieldWall_Timer -= diff; } }; - }; void AddSC_boss_moroes() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 60e1a5ebc4c..c6587c3cd8a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -333,7 +333,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_netherspite() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index e2420749a4c..690822203b5 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -413,7 +413,6 @@ public: } } }; - }; void AddSC_boss_nightbane() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index f4195620dda..d1c4790d705 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -169,7 +169,6 @@ public: void Cleanup(); }; - }; class boss_malchezaar : public CreatureScript @@ -314,14 +313,14 @@ public: if (!info) return; - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); std::vector<Unit*> targets; if (t_list.empty()) return; //begin + 1, so we don't target the one with the highest threat - std::list<HostileReference*>::const_iterator itr = t_list.begin(); + ThreatContainer::StorageType::const_iterator itr = t_list.begin(); std::advance(itr, 1); for (; itr != t_list.end(); ++itr) //store the threat list in a different container if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) @@ -483,14 +482,12 @@ public: { DoCast(me->getVictim(), SPELL_SUNDER_ARMOR); SunderArmorTimer = urand(10000, 18000); - } else SunderArmorTimer -= diff; if (Cleave_Timer <= diff) { DoCast(me->getVictim(), SPELL_CLEAVE); Cleave_Timer = urand(6000, 12000); - } else Cleave_Timer -= diff; } else @@ -602,15 +599,14 @@ public: positions.push_back(point); } }; - }; void netherspite_infernal::netherspite_infernalAI::Cleanup() { - Unit* pMalchezaar = Unit::GetUnit(*me, malchezaar); + Creature *pMalchezaar = Unit::GetCreature(*me, malchezaar); if (pMalchezaar && pMalchezaar->isAlive()) - CAST_AI(boss_malchezaar::boss_malchezaarAI, CAST_CRE(pMalchezaar)->AI())->Cleanup(me, point); + CAST_AI(boss_malchezaar::boss_malchezaarAI, pMalchezaar->AI())->Cleanup(me, point); } void AddSC_boss_malchezaar() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 7dd4e731a18..25fafdfcd0d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -187,13 +187,13 @@ public: void FlameWreathEffect() { std::vector<Unit*> targets; - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); if (t_list.empty()) return; //store the threat list in a different container - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); //only on alive players @@ -508,7 +508,6 @@ public: } } }; - }; class mob_aran_elemental : public CreatureScript @@ -546,7 +545,6 @@ public: } else CastTimer -= diff; } }; - }; void AddSC_boss_shade_of_aran() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp index 44cd7e0faea..688a678060f 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp @@ -127,7 +127,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_demon_chain : public CreatureScript @@ -165,7 +164,6 @@ public: } } }; - }; class mob_fiendish_portal : public CreatureScript @@ -200,7 +198,6 @@ public: summons.DespawnAll(); } }; - }; #define SPELL_FIREBOLT 30050 // Blasts a target for 181-209 Fire damage. @@ -245,7 +242,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_terestian_illhoof : public CreatureScript @@ -422,7 +418,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_terestian_illhoof() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 30d33dc65cf..a4f4f603206 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -216,7 +216,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_tito : public CreatureScript @@ -271,7 +270,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void boss_dorothee::boss_dorotheeAI::SummonTito() @@ -398,7 +396,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_tinhead : public CreatureScript @@ -508,7 +505,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_roar : public CreatureScript @@ -617,7 +613,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_crone : public CreatureScript @@ -699,7 +694,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_cyclone : public CreatureScript @@ -743,7 +737,6 @@ public: } else MoveTimer -= diff; } }; - }; /**************************************/ @@ -792,7 +785,6 @@ public: return true; } - }; class boss_bigbadwolf : public CreatureScript @@ -915,10 +907,8 @@ public: DoCast(me->getVictim(), SPELL_WIDE_SWIPE); SwipeTimer = urand(25000, 30000); } else SwipeTimer -= diff; - } }; - }; /**********************************************/ @@ -977,7 +967,7 @@ void PretendToDie(Creature* creature) creature->GetMotionMaster()->MovementExpired(false); creature->GetMotionMaster()->MoveIdle(); creature->SetStandState(UNIT_STAND_STATE_DEAD); -}; +} void Resurrect(Creature* target) { @@ -992,7 +982,7 @@ void Resurrect(Creature* target) } else target->GetMotionMaster()->Initialize(); -}; +} class boss_julianne : public CreatureScript { @@ -1114,7 +1104,6 @@ public: void UpdateAI(const uint32 diff); }; - }; class boss_romulo : public CreatureScript @@ -1321,7 +1310,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void boss_julianne::boss_julianneAI::UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp index 05d6ecf1478..2ecd98cbc4c 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp @@ -288,7 +288,7 @@ public: return 0; } - void Load(const char* chrIn) + void Load(char const* chrIn) { if (!chrIn) { @@ -308,7 +308,6 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } }; - }; void AddSC_instance_karazhan() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index b84fc15d664..3bdfeab30da 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -321,7 +321,6 @@ public: WipeTimer = 15000; } else WipeTimer -= diff; } - } } }; @@ -344,17 +343,17 @@ public: case GOSSIP_ACTION_INFO_DEF+3: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_OZ; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_OZ", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_OZ", player->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+4: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_HOOD; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_HOOD", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_HOOD", player->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+5: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_RAJ; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_RAJ", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_RAJ", player->GetGUID()); break; } @@ -397,7 +396,6 @@ public: { return new npc_barnesAI(creature); } - }; /*### @@ -438,7 +436,6 @@ public: player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); return true; } - }; /*### @@ -538,7 +535,7 @@ public: uint32 NextStep(uint32 Step) { - Unit* arca = Unit::GetUnit(*me, ArcanagosGUID); + Creature* arca = Unit::GetCreature(*me, ArcanagosGUID); Map* map = me->GetMap(); switch (Step) { @@ -548,21 +545,21 @@ public: return 10000; case 2: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL, 0); return 20000; case 3: me->MonsterYell(SAY_DIALOG_MEDIVH_3, LANG_UNIVERSAL, 0); return 10000; case 4: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL, 0); return 20000; case 5: me->MonsterYell(SAY_DIALOG_MEDIVH_5, LANG_UNIVERSAL, 0); return 20000; case 6: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL, 0); return 10000; case 7: FireArcanagosTimer = 500; @@ -580,7 +577,7 @@ public: return 1000; case 11: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL, 0); return 5000; case 12: arca->GetMotionMaster()->MovePoint(0, -11010.82f, -1761.18f, 156.47f); @@ -613,12 +610,10 @@ public: return 5000; default : return 9999999; } - } void UpdateAI(const uint32 diff) { - if (YellTimer <= diff) { if (EventStarted) @@ -645,7 +640,6 @@ public: } } }; - }; void AddSC_karazhan() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h index e1817034189..c8a1aa55c7e 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h @@ -64,4 +64,3 @@ enum OperaEvents #define ERROR_INST_DATA(a) sLog->outError(LOG_FILTER_TSCR, "Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); #endif - diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index d1b0e076d9c..7fbd329ab87 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -189,20 +189,20 @@ public: ScriptedAI::MoveInLineOfSight(who); } - void SetThreatList(Creature* SummonedUnit) + void SetThreatList(Creature* summonedUnit) { - if (!SummonedUnit) + if (!summonedUnit) return; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->isAlive()) { float threat = me->getThreatManager().getThreat(unit); - SummonedUnit->AddThreat(unit, threat); + summonedUnit->AddThreat(unit, threat); } } } @@ -212,9 +212,9 @@ public: float x = KaelLocations[0][0]; float y = KaelLocations[0][1]; me->SetPosition(x, y, LOCATION_Z, 0.0f); - //me->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -225,8 +225,9 @@ public: void CastGravityLapseKnockUp() { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -237,8 +238,9 @@ public: void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -256,8 +258,9 @@ public: void RemoveGravityLapse() { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -304,7 +307,6 @@ public: if (PhoenixTimer <= diff) { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1); uint8 random = urand(1, 2); @@ -408,7 +410,6 @@ public: Orb->AddThreat(target, 1000000.0f); Orb->AI()->AttackStart(target); } - } DoCast(me, SPELL_GRAVITY_LAPSE_CHANNEL); @@ -429,7 +430,6 @@ public: } } }; - }; class mob_felkael_flamestrike : public CreatureScript @@ -471,7 +471,6 @@ public: } else FlameStrikeTimer -= diff; } }; - }; class mob_felkael_phoenix : public CreatureScript @@ -520,7 +519,6 @@ public: { damage = 0; return; - } //Don't really die in all phases of Kael'Thas if (instance && instance->GetData(DATA_KAELTHAS_EVENT) == 0) @@ -542,9 +540,7 @@ public: me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); me->SetStandState(UNIT_STAND_STATE_DEAD); - } - } void JustDied(Unit* /*killer*/) @@ -554,7 +550,6 @@ public: void UpdateAI(const uint32 diff) { - //If we are fake death, we cast revbirth and after that we kill the phoenix to spawn the egg. if (FakeDeath) { @@ -566,7 +561,6 @@ public: if (Rebirth) { - if (Death_Timer <= diff) { me->SummonCreature(CREATURE_PHOENIX_EGG, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); @@ -574,7 +568,6 @@ public: Rebirth = false; } else Death_Timer -= diff; } - } if (!UpdateVictim()) @@ -591,7 +584,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_felkael_phoenix_egg : public CreatureScript @@ -625,10 +617,8 @@ public: me->SummonCreature(CREATURE_PHOENIX, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); me->Kill(me); } else HatchTimer -= diff; - } }; - }; class mob_arcane_sphere : public CreatureScript @@ -685,7 +675,6 @@ public: } else ChangeTargetTimer -= diff; } }; - }; void AddSC_boss_felblood_kaelthas() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 7ce9b08845f..2af417381a5 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -331,7 +331,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eHealingPotion @@ -574,7 +573,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eWarlockSpells @@ -671,7 +669,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eKickDown @@ -728,7 +725,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eMageSpells @@ -835,8 +831,8 @@ public: if (Blink_Timer <= diff) { bool InMeleeRange = false; - std::list<HostileReference*>& t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) { @@ -859,7 +855,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eWarriorSpells @@ -922,8 +917,8 @@ public: if (Intercept_Stun_Timer <= diff) { bool InMeleeRange = false; - std::list<HostileReference*>& t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) { @@ -979,7 +974,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eHunterSpells @@ -1103,7 +1097,6 @@ public: } } }; - }; enum Spells @@ -1203,7 +1196,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eEngineerSpells @@ -1298,7 +1290,6 @@ public: DoMeleeAttackIfReady(); } }; - }; /* diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index 82ad3ee2630..430bbb79bde 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -105,20 +105,20 @@ public: for (std::list<uint64>::const_iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) { //Unit* unit = Unit::GetUnit(*me, FelCrystals[i]); - Unit* unit = Unit::GetUnit(*me, *itr); - if (unit) + if (Creature *creature = Unit::GetCreature(*me, *itr)) { - if (!unit->isAlive()) - CAST_CRE(unit)->Respawn(); // Let the core handle setting death state, etc. + if (!creature->isAlive()) + creature->Respawn(); // Let the core handle setting death state, etc. // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here. - unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } } instance->HandleGameObject(instance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true); // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here) - // Small door opened after event are expected to be closed by default + // Small door opened after event are expected to be closed by default + // Set Inst data for encounter instance->SetData(DATA_SELIN_EVENT, NOT_STARTED); } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); @@ -291,7 +291,6 @@ public: DrainCrystalTimer = urand(20000, 25000); } else DrainCrystalTimer -= diff; } - }else { if (IsDraining) @@ -319,7 +318,6 @@ public: DoMeleeAttackIfReady(); // No need to check if we are draining crystal here, as the spell has a stun. } }; - }; class mob_fel_crystal : public CreatureScript @@ -365,7 +363,6 @@ public: } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); } }; - }; void AddSC_boss_selin_fireheart() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp index b5cf443c5a5..34682683ee3 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp @@ -192,7 +192,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_pure_energy : public CreatureScript @@ -224,7 +223,6 @@ public: void MoveInLineOfSight(Unit* /*who*/) {} void AttackStart(Unit* /*who*/) {} }; - }; void AddSC_boss_vexallus() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index cd2874f7253..da8b24c3985 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -262,7 +262,6 @@ public: return 0; } }; - }; void AddSC_instance_magisters_terrace() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp index 69e0e5bff40..64b6c8d75b2 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp @@ -140,14 +140,14 @@ public: if (lList.isEmpty()) return; - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); for (Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i) { if (Player* player = i->getSource()) { - if (pSpell && pSpell->Effects[0].MiscValue) - player->KilledMonsterCredit(pSpell->Effects[0].MiscValue, 0); + if (spell && spell->Effects[0].MiscValue) + player->KilledMonsterCredit(spell->Effects[0].MiscValue, 0); } } } @@ -170,7 +170,6 @@ public: } } }; - }; void AddSC_magisters_terrace() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h index 78aa14b9102..660e58d325a 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h @@ -20,7 +20,6 @@ #define DEF_MAGISTERS_TERRACE_H #define ERROR_INST_DATA "TSCR Error: Instance Data not set properly for Magister's Terrace instance (map 585). Encounters will be buggy." -#endif enum Data { @@ -47,3 +46,5 @@ enum Data DATA_ESCAPE_ORB = 16 }; + +#endif diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 8cf964808d3..34c1c9b2c83 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -46,7 +46,7 @@ uint32 RandomLaugh[] = {11965, 11975, 11976}; enum Entry { HH_MOUNTED = 23682, - HH_DISMOUNTED = 23800, // unhorsed?? wtf type of engrish was that? + HH_DISMOUNTED = 23800, HEAD = 23775, PULSING_PUMPKIN = 23694, PUMPKIN_FIEND = 23545, @@ -127,7 +127,7 @@ static Locations Spawn[]= {1765.28f, 1347.46f, 17.55f} //spawn point for smoke }; -static const char* Text[]= +static char const* Text[]= { "Horseman rise...", "Your time is nigh...", @@ -592,8 +592,8 @@ public: caster->GetMotionMaster()->Clear(false); caster->GetMotionMaster()->MoveFollow(me, 6, float(urand(0, 5))); //DoResetThreat();//not sure if need - std::list<HostileReference*>::const_iterator itr; - for (itr = caster->getThreatManager().getThreatList().begin(); itr != caster->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = caster->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive() && unit != caster) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp index 59244585ecf..dbbbb7fb0dd 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp @@ -153,12 +153,7 @@ public: uint32 Start_Timer; void Reset() {} - - void WaypointReached(uint32 /*waypointId*/) - { - - } - + void WaypointReached(uint32 /*waypointId*/) {} void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index e40a48d0251..c763cb69dec 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -344,7 +344,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_brutallus() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp index e7b0e86285e..34548ec9116 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp @@ -121,13 +121,12 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); - if (Temp) + if (Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_ALYTHESS))) { - if (Temp->isDead()) - CAST_CRE(Temp)->Respawn(); - else if (Temp->getVictim()) - me->getThreatManager().addThreat(Temp->getVictim(), 0.0f); + if (temp->isDead()) + temp->Respawn(); + else if (temp->getVictim()) + me->getThreatManager().addThreat(temp->getVictim(), 0.0f); } } @@ -153,9 +152,9 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); - if (Temp && Temp->isAlive() && !(Temp->getVictim())) - CAST_CRE(Temp)->AI()->AttackStart(who); + Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_ALYTHESS)); + if (temp && temp->isAlive() && !temp->getVictim()) + temp->AI()->AttackStart(who); } if (instance) @@ -341,7 +340,6 @@ public: } } }; - }; class boss_alythess : public CreatureScript @@ -383,13 +381,12 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); - if (Temp) + if (Creature *temp = Unit::GetCreature((*me), instance->GetData64(DATA_SACROLASH))) { - if (Temp->isDead()) - CAST_CRE(Temp)->Respawn(); - else if (Temp->getVictim()) - me->getThreatManager().addThreat(Temp->getVictim(), 0.0f); + if (temp->isDead()) + temp->Respawn(); + else if (temp->getVictim()) + me->getThreatManager().addThreat(temp->getVictim(), 0.0f); } } @@ -416,9 +413,9 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); - if (Temp && Temp->isAlive() && !(Temp->getVictim())) - CAST_CRE(Temp)->AI()->AttackStart(who); + Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_SACROLASH)); + if (temp && temp->isAlive() && !temp->getVictim()) + temp->AI()->AttackStart(who); } if (instance) @@ -480,7 +477,6 @@ public: { switch (spell->Id) { - case SPELL_BLAZE: target->CastSpell(target, SPELL_BLAZE_SUMMON, true); case SPELL_CONFLAGRATION: @@ -670,7 +666,6 @@ public: } else EnrageTimer -= diff; } }; - }; class mob_shadow_image : public CreatureScript @@ -705,7 +700,6 @@ public: { switch (spell->Id) { - case SPELL_SHADOW_FURY: case SPELL_DARK_STRIKE: if (!target->HasAura(SPELL_DARK_FLAME)) @@ -752,7 +746,6 @@ public: } else DarkstrikeTimer -= diff; } }; - }; void AddSC_boss_eredar_twins() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 7267c4e1bdb..bc841d76714 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -512,7 +512,6 @@ public: } } }; - }; class mob_felmyst_vapor : public CreatureScript @@ -545,7 +544,6 @@ public: AttackStart(target); } }; - }; class mob_felmyst_trail : public CreatureScript @@ -573,7 +571,6 @@ public: void MoveInLineOfSight(Unit* /*who*/) {} void UpdateAI(const uint32 /*diff*/) {} }; - }; void AddSC_boss_felmyst() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 57e69238816..3e503a547d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -304,11 +304,20 @@ public: if (SpectralBlastTimer <= diff) { - std::list<HostileReference*> &m_threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); std::list<Unit*> targetList; - for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) - if ((*itr)->getTarget() && (*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->GetGUID() != me->getVictim()->GetGUID() && !(*itr)->getTarget()->HasAura(AURA_SPECTRAL_EXHAUSTION) && (*itr)->getTarget()->GetPositionZ() > me->GetPositionZ()-5) - targetList.push_back((*itr)->getTarget()); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + { + Unit* target = (*itr)->getTarget(); + if (target + && target->GetTypeId() == TYPEID_PLAYER + && target->GetGUID() != me->getVictim()->GetGUID() + && target->GetPositionZ() > me->GetPositionZ() - 5 + && !target->HasAura(AURA_SPECTRAL_EXHAUSTION)) + { + targetList.push_back(target); + } + } if (targetList.empty()) { SpectralBlastTimer = 1000; @@ -431,7 +440,6 @@ public: } } }; - }; class boss_kalec : public CreatureScript @@ -533,7 +541,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class kalecgos_teleporter : public GameObjectScript @@ -561,7 +568,6 @@ public: player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); return true; } - }; class boss_sathrovarr : public CreatureScript @@ -761,15 +767,12 @@ public: if (ResetThreat <= diff) { - for (std::list<HostileReference*>::const_iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - { - if (unit->GetPositionZ() > me->GetPositionZ()+5) - { + if (unit->GetPositionZ() > me->GetPositionZ() + 5) me->getThreatManager().modifyThreatPercent(unit, -100); - } - } } ResetThreat = 1000; } else ResetThreat -= diff; @@ -799,7 +802,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_kalecgos() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 9085bf239a6..8dabe2b842d 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -367,7 +367,6 @@ public: } } }; - }; class go_orb_of_the_blue_flight : public GameObjectScript @@ -391,7 +390,6 @@ public: } return true; } - }; //AI for Kil'jaeden Event Controller @@ -492,7 +490,6 @@ public: } } }; - }; //AI for Kil'jaeden @@ -900,7 +897,6 @@ public: } } }; - }; //AI for Hand of the Deceiver @@ -987,8 +983,8 @@ public: { if (Creature* pPortal = DoSpawnCreature(CREATURE_FELFIRE_PORTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000)) { - std::list<HostileReference*>::iterator itr; - for (itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit) @@ -1001,7 +997,6 @@ public: DoMeleeAttackIfReady(); } }; - }; //AI for Felfire Portal @@ -1046,7 +1041,6 @@ public: } else uiSpawnFiendTimer -= diff; } }; - }; //AI for Felfire Fiend @@ -1104,7 +1098,6 @@ public: } } }; - }; //AI for Armageddon target @@ -1159,7 +1152,6 @@ public: } else uiTimer -=diff; } }; - }; //AI for Shield Orbs @@ -1247,7 +1239,6 @@ public: bPointReached = true; } }; - }; //AI for Sinister Reflection @@ -1310,7 +1301,8 @@ public: } } - switch (victimClass) { + switch (victimClass) + { case CLASS_DRUID: if (uiTimer[1] <= diff) { @@ -1411,13 +1403,12 @@ public: } DoMeleeAttackIfReady(); break; - } - sLog->outDebug(LOG_FILTER_TSCR, "Sinister-Timer"); - for (uint8 i = 0; i < 3; ++i) - uiTimer[i] -= diff; } + sLog->outDebug(LOG_FILTER_TSCR, "Sinister-Timer"); + for (uint8 i = 0; i < 3; ++i) + uiTimer[i] -= diff; + } }; - }; void AddSC_boss_kiljaeden() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index c00ab84b567..9fd0a5eb5d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -199,7 +199,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_muru : public CreatureScript @@ -364,7 +363,6 @@ public: } } }; - }; class npc_muru_portal : public CreatureScript @@ -448,7 +446,6 @@ public: } else SummonTimer -= diff; } }; - }; class npc_dark_fiend : public CreatureScript @@ -500,7 +497,6 @@ public: } else { - if (me->IsWithinDist(me->getVictim(), 5)) { DoCastAOE(SPELL_DARKFIEND_AOE, false); @@ -511,7 +507,6 @@ public: } else WaitTimer -= diff; } }; - }; class npc_void_sentinel : public CreatureScript @@ -567,7 +562,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_blackhole : public CreatureScript @@ -646,7 +640,6 @@ public: else DespawnTimer -= diff; } }; - }; void AddSC_boss_muru() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index 6324c5adf16..bea73837304 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -134,8 +134,9 @@ public: return player; } } + else + sLog->outDebug(LOG_FILTER_TSCR, "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); - sLog->outDebug(LOG_FILTER_TSCR, "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); return NULL; } @@ -281,7 +282,7 @@ public: return stream.str(); } - void Load(const char* in) + void Load(char const* in) { if (!in) { @@ -299,7 +300,6 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } }; - }; void AddSC_instance_sunwell_plateau() diff --git a/src/server/scripts/Events/CMakeLists.txt b/src/server/scripts/Events/CMakeLists.txt new file mode 100644 index 00000000000..d8be052d645 --- /dev/null +++ b/src/server/scripts/Events/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set(scripts_STAT_SRCS + ${scripts_STAT_SRCS} + Events/childrens_week.cpp + Events/event.cpp +) + +message(" -> Prepared: Events") diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp new file mode 100644 index 00000000000..c4d3650868d --- /dev/null +++ b/src/server/scripts/Events/childrens_week.cpp @@ -0,0 +1,1048 @@ +/* +* Copyright (C) 2008-2012 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/>. +*/ + +#include "ScriptMgr.h" +#include "ScriptedCreature.h" + +enum Orphans +{ + ORPHAN_ORACLE = 33533, + ORPHAN_WOLVAR = 33532, + ORPHAN_BLOOD_ELF = 22817, + ORPHAN_DRAENEI = 22818, + ORPHAN_HUMAN = 14305, + ORPHAN_ORCISH = 14444, +}; + +enum Texts +{ + TEXT_ORACLE_ORPHAN_1 = 1, + TEXT_ORACLE_ORPHAN_2 = 2, + TEXT_ORACLE_ORPHAN_3 = 3, + TEXT_ORACLE_ORPHAN_4 = 4, + TEXT_ORACLE_ORPHAN_5 = 5, + TEXT_ORACLE_ORPHAN_6 = 6, + TEXT_ORACLE_ORPHAN_7 = 7, + TEXT_ORACLE_ORPHAN_8 = 8, + TEXT_ORACLE_ORPHAN_9 = 9, + TEXT_ORACLE_ORPHAN_10 = 10, + TEXT_ORACLE_ORPHAN_11 = 11, + TEXT_ORACLE_ORPHAN_12 = 12, + TEXT_ORACLE_ORPHAN_13 = 13, + TEXT_ORACLE_ORPHAN_14 = 14, + + TEXT_WOLVAR_ORPHAN_1 = 1, + TEXT_WOLVAR_ORPHAN_2 = 2, + TEXT_WOLVAR_ORPHAN_3 = 3, + TEXT_WOLVAR_ORPHAN_4 = 4, + TEXT_WOLVAR_ORPHAN_5 = 5, + // 6 - 9 used in Nesingwary script + TEXT_WOLVAR_ORPHAN_10 = 10, + TEXT_WOLVAR_ORPHAN_11 = 11, + TEXT_WOLVAR_ORPHAN_12 = 12, + TEXT_WOLVAR_ORPHAN_13 = 13, + + TEXT_WINTERFIN_PLAYMATE_1 = 1, + TEXT_WINTERFIN_PLAYMATE_2 = 2, + + TEXT_SNOWFALL_GLADE_PLAYMATE_1 = 1, + TEXT_SNOWFALL_GLADE_PLAYMATE_2 = 2, + + TEXT_SOO_ROO_1 = 1, + TEXT_ELDER_KEKEK_1 = 1, + + TEXT_ALEXSTRASZA_2 = 2, + TEXT_KRASUS_8 = 8, +}; + +enum Quests +{ + QUEST_PLAYMATE_WOLVAR = 13951, + QUEST_PLAYMATE_ORACLE = 13950, + QUEST_THE_BIGGEST_TREE_EVER = 13929, + QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE = 13933, + QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR = 13934, + QUEST_MEETING_A_GREAT_ONE = 13956, + QUEST_THE_MIGHTY_HEMET_NESINGWARY = 13957, + QUEST_DOWN_AT_THE_DOCKS = 910, + QUEST_GATEWAY_TO_THE_FRONTIER = 911, + QUEST_BOUGHT_OF_ETERNALS = 1479, + QUEST_SPOOKY_LIGHTHOUSE = 1687, + QUEST_STONEWROUGHT_DAM = 1558, + QUEST_DARK_PORTAL_H = 10951, + QUEST_DARK_PORTAL_A = 10952, + QUEST_LORDAERON_THRONE_ROOM = 1800, + QUEST_AUCHINDOUN_AND_THE_RING = 10950, + QUEST_TIME_TO_VISIT_THE_CAVERNS_H = 10963, + QUEST_TIME_TO_VISIT_THE_CAVERNS_A = 10962, + QUEST_THE_SEAT_OF_THE_NARUU = 10956, + QUEST_CALL_ON_THE_FARSEER = 10968, + QUEST_JHEEL_IS_AT_AERIS_LANDING = 10954, + QUEST_HCHUU_AND_THE_MUSHROOM_PEOPLE = 10945, + QUEST_VISIT_THE_THRONE_OF_ELEMENTS = 10953, + QUEST_NOW_WHEN_I_GROW_UP = 11975, + QUEST_HOME_OF_THE_BEAR_MEN = 13930, + QUEST_THE_DRAGON_QUEEN_ORACLE = 13954, + QUEST_THE_DRAGON_QUEEN_WOLVAR = 13955, +}; + +enum Areatriggers +{ + AT_DOWN_AT_THE_DOCKS = 3551, + AT_GATEWAY_TO_THE_FRONTIER = 3549, + AT_LORDAERON_THRONE_ROOM = 3547, + AT_BOUGHT_OF_ETERNALS = 3546, + AT_SPOOKY_LIGHTHOUSE = 3552, + AT_STONEWROUGHT_DAM = 3548, + AT_DARK_PORTAL = 4356, + + NPC_CAVERNS_OF_TIME_CW_TRIGGER = 22872, + NPC_EXODAR_01_CW_TRIGGER = 22851, + NPC_EXODAR_02_CW_TRIGGER = 22905, + NPC_AERIS_LANDING_CW_TRIGGER = 22838, + NPC_AUCHINDOUN_CW_TRIGGER = 22831, + NPC_SPOREGGAR_CW_TRIGGER = 22829, + NPC_THRONE_OF_ELEMENTS_CW_TRIGGER = 22839, + NPC_SILVERMOON_01_CW_TRIGGER = 22866, + NPC_KRASUS = 27990, +}; + +enum Misc +{ + SPELL_SNOWBALL = 21343, + SPELL_ORPHAN_OUT = 58818, + + DISPLAY_INVISIBLE = 11686, +}; + +uint64 getOrphanGUID(Player* player, uint32 orphan) +{ + if (Aura* orphanOut = player->GetAura(SPELL_ORPHAN_OUT)) + if (orphanOut->GetCaster() && orphanOut->GetCaster()->GetEntry() == orphan) + return orphanOut->GetCaster()->GetGUID(); + + return 0; +} + +/*###### +## npc_winterfin_playmate +######*/ +class npc_winterfin_playmate : public CreatureScript +{ + public: + npc_winterfin_playmate() : CreatureScript("npc_winterfin_playmate") {} + + struct npc_winterfin_playmateAI : public ScriptedAI + { + npc_winterfin_playmateAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_PLAYMATE_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch(phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_1); + timer = 3000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_WINTERFIN_PLAYMATE_1); + me->HandleEmoteCommand(EMOTE_STATE_DANCE); + timer = 3000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_2); + timer = 3000; + break; + case 4: + Talk(TEXT_WINTERFIN_PLAYMATE_2); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_3); + me->HandleEmoteCommand(EMOTE_STATE_NONE); + player->GroupEventHappens(QUEST_PLAYMATE_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_winterfin_playmateAI(creature); + } +}; + +/*###### +## npc_snowfall_glade_playmate +######*/ +class npc_snowfall_glade_playmate : public CreatureScript +{ + public: + npc_snowfall_glade_playmate() : CreatureScript("npc_snowfall_glade_playmate") {} + + struct npc_snowfall_glade_playmateAI : public ScriptedAI + { + npc_snowfall_glade_playmateAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_PLAYMATE_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_1); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_SNOWFALL_GLADE_PLAYMATE_1); + DoCast(orphan, SPELL_SNOWBALL); + timer = 5000; + break; + case 3: + Talk(TEXT_SNOWFALL_GLADE_PLAYMATE_2); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_2); + orphan->AI()->DoCast(me, SPELL_SNOWBALL); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_3); + player->GroupEventHappens(QUEST_PLAYMATE_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + }; + + CreatureAI* GetAI(Creature* pCreature) const + { + return new npc_snowfall_glade_playmateAI(pCreature); + } +}; + +/*###### +## npc_the_biggest_tree +######*/ +class npc_the_biggest_tree : public CreatureScript +{ + public: + npc_the_biggest_tree() : CreatureScript("npc_the_biggest_tree") {} + + struct npc_the_biggest_treeAI : public ScriptedAI + { + npc_the_biggest_treeAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void Reset() + { + timer = 1000; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BIGGEST_TREE_EVER) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + timer = 2000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_4); + timer = 5000; + break; + case 3: + player->GroupEventHappens(QUEST_THE_BIGGEST_TREE_EVER, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + uint8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_the_biggest_treeAI(creature); + } +}; + +/*###### +## npc_high_oracle_soo_roo +######*/ +class npc_high_oracle_soo_roo : public CreatureScript +{ + public: + npc_high_oracle_soo_roo() : CreatureScript("npc_high_oracle_soo_roo") {} + + struct npc_high_oracle_soo_rooAI : public ScriptedAI + { + npc_high_oracle_soo_rooAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_5); + timer = 3000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_SOO_ROO_1); + timer = 6000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_6); + player->GroupEventHappens(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_high_oracle_soo_rooAI(creature); + } +}; + +/*###### +## npc_elder_kekek +######*/ +class npc_elder_kekek : public CreatureScript +{ + public: + npc_elder_kekek() : CreatureScript("npc_elder_kekek") {} + + struct npc_elder_kekekAI : public ScriptedAI + { + npc_elder_kekekAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!player || !orphan) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_4); + timer = 3000; + break; + case 2: + Talk(TEXT_ELDER_KEKEK_1); + timer = 6000; + break; + case 3: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_5); + player->GroupEventHappens(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_elder_kekekAI(creature); + } +}; + +/*###### +## npc_the_etymidian +## TODO: A red crystal as a gift for the great one should be spawned during the event. +######*/ +class npc_the_etymidian : public CreatureScript +{ + public: + npc_the_etymidian() : CreatureScript("npc_the_etymidian") {} + + struct npc_the_etymidianAI : public ScriptedAI + { + npc_the_etymidianAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_7); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_8); + timer = 5000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_9); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_10); + timer = 5000; + break; + case 5: + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + player->GroupEventHappens(QUEST_MEETING_A_GREAT_ONE, me); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint32 GOtimer; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_the_etymidianAI(creature); + } +}; + +/*###### +## npc_cw_alexstrasza_trigger +######*/ +class npc_alexstraza_the_lifebinder : public CreatureScript +{ + public: + npc_alexstraza_the_lifebinder() : CreatureScript("npc_alexstraza_the_lifebinder") {} + + struct npc_alexstraza_the_lifebinderAI : public ScriptedAI + { + npc_alexstraza_the_lifebinderAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void SetData(uint32 type, uint32 data) + { + // Existing SmartAI + if (type == 0) + { + switch (data) + { + case 1: + me->SetOrientation(1.6049f); + break; + case 2: + me->SetOrientation(me->GetHomePosition().GetOrientation()); + break; + } + } + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + { + if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + playerGUID = player->GetGUID(); + } + else if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) + phase = 7; + playerGUID = player->GetGUID(); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_11); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_12); + timer = 5000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_13); + timer = 5000; + break; + case 4: + Talk(TEXT_ALEXSTRASZA_2); + me->SetStandState(UNIT_STAND_STATE_KNEEL); + me->SetFacingToObject(orphan); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_14); + timer = 5000; + break; + case 6: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->SetOrientation(me->GetHomePosition().GetOrientation()); + player->GroupEventHappens(QUEST_THE_DRAGON_QUEEN_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + case 7: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_11); + timer = 5000; + break; + case 8: + if(Creature* krasus = me->FindNearestCreature(NPC_KRASUS, 10.0f)) + { + orphan->SetFacingToObject(krasus); + krasus->AI()->Talk(TEXT_KRASUS_8); + } + timer = 5000; + break; + case 9: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_12); + timer = 5000; + break; + case 10: + orphan->SetFacingToObject(me); + Talk(TEXT_ALEXSTRASZA_2); + timer = 5000; + break; + case 11: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_13); + timer = 5000; + break; + case 12: + player->GroupEventHappens(QUEST_THE_DRAGON_QUEEN_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + int8 phase; + uint32 timer; + uint64 playerGUID; + uint64 orphanGUID; + uint64 alexstraszaGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_alexstraza_the_lifebinderAI(creature); + } +}; + +/*###### +## at_bring_your_orphan_to +######*/ + +class at_bring_your_orphan_to : public AreaTriggerScript +{ + public: + at_bring_your_orphan_to() : AreaTriggerScript("at_bring_your_orphan_to") { } + + bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) + { + if (player->isDead() || !player->HasAura(SPELL_ORPHAN_OUT)) + return false; + + uint32 questId = 0; + uint32 orphanId = 0; + + switch (trigger->id) + { + case AT_DOWN_AT_THE_DOCKS: + questId = QUEST_DOWN_AT_THE_DOCKS; + orphanId = ORPHAN_ORCISH; + break; + case AT_GATEWAY_TO_THE_FRONTIER: + questId = QUEST_GATEWAY_TO_THE_FRONTIER; + orphanId = ORPHAN_ORCISH; + break; + case AT_LORDAERON_THRONE_ROOM: + questId = QUEST_LORDAERON_THRONE_ROOM; + orphanId = ORPHAN_ORCISH; + break; + case AT_BOUGHT_OF_ETERNALS: + questId = QUEST_BOUGHT_OF_ETERNALS; + orphanId = ORPHAN_HUMAN; + break; + case AT_SPOOKY_LIGHTHOUSE: + questId = QUEST_SPOOKY_LIGHTHOUSE; + orphanId = ORPHAN_HUMAN; + break; + case AT_STONEWROUGHT_DAM: + questId = QUEST_STONEWROUGHT_DAM; + orphanId = ORPHAN_HUMAN; + break; + case AT_DARK_PORTAL: + questId = player->GetTeam() == ALLIANCE ? QUEST_DARK_PORTAL_A : QUEST_DARK_PORTAL_H; + orphanId = player->GetTeam() == ALLIANCE ? ORPHAN_DRAENEI : ORPHAN_BLOOD_ELF; + break; + } + + if (questId && orphanId && getOrphanGUID(player, orphanId) && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(questId); + + return true; + } +}; + +/*###### +## npc_cw_area_trigger +######*/ +class npc_cw_area_trigger : public CreatureScript +{ + public: + npc_cw_area_trigger() : CreatureScript("npc_cw_area_trigger") {} + + struct npc_cw_area_triggerAI : public ScriptedAI + { + npc_cw_area_triggerAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void MoveInLineOfSight(Unit* who) + { + if (who && me->GetDistance2d(who) < 20.0f) + if (Player* player = who->ToPlayer()) + if (player->HasAura(SPELL_ORPHAN_OUT)) + { + uint32 questId = 0; + uint32 orphanId = 0; + switch (me->GetEntry()) + { + case NPC_CAVERNS_OF_TIME_CW_TRIGGER: + questId = player->GetTeam() == ALLIANCE ? QUEST_TIME_TO_VISIT_THE_CAVERNS_A : QUEST_TIME_TO_VISIT_THE_CAVERNS_H; + orphanId = player->GetTeam() == ALLIANCE ? ORPHAN_DRAENEI : ORPHAN_BLOOD_ELF; + break; + case NPC_EXODAR_01_CW_TRIGGER: + questId = QUEST_THE_SEAT_OF_THE_NARUU; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_EXODAR_02_CW_TRIGGER: + questId = QUEST_CALL_ON_THE_FARSEER; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_AERIS_LANDING_CW_TRIGGER: + questId = QUEST_JHEEL_IS_AT_AERIS_LANDING; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_AUCHINDOUN_CW_TRIGGER: + questId = QUEST_AUCHINDOUN_AND_THE_RING; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_SPOREGGAR_CW_TRIGGER: + questId = QUEST_HCHUU_AND_THE_MUSHROOM_PEOPLE; + orphanId = ORPHAN_BLOOD_ELF; + break; + case NPC_THRONE_OF_ELEMENTS_CW_TRIGGER: + questId = QUEST_VISIT_THE_THRONE_OF_ELEMENTS; + orphanId = ORPHAN_BLOOD_ELF; + break; + case NPC_SILVERMOON_01_CW_TRIGGER: + if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_INCOMPLETE && getOrphanGUID(player, ORPHAN_BLOOD_ELF)) + { + player->AreaExploredOrEventHappens(QUEST_NOW_WHEN_I_GROW_UP); + if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_COMPLETE) + if (Creature* samuro = me->FindNearestCreature(25151, 20.0f)) + { + uint32 emote = 0; + switch(urand(1,5)) + { + case 1: + emote = EMOTE_ONESHOT_WAVE; + break; + case 2: + emote = EMOTE_ONESHOT_ROAR; + break; + case 3: + emote = EMOTE_ONESHOT_FLEX; + break; + case 4: + emote = EMOTE_ONESHOT_SALUTE; + break; + case 5: + emote = EMOTE_ONESHOT_DANCE; + break; + } + samuro->HandleEmoteCommand(emote); + } + } + break; + } + if (questId && orphanId && getOrphanGUID(player, orphanId) && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(questId); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_cw_area_triggerAI(creature); + } +}; + +/*###### +## npc_grizzlemaw_cw_trigger +######*/ +class npc_grizzlemaw_cw_trigger : public CreatureScript +{ + public: + npc_grizzlemaw_cw_trigger() : CreatureScript("npc_grizzlemaw_cw_trigger") {} + + struct npc_grizzlemaw_cw_triggerAI : public ScriptedAI + { + npc_grizzlemaw_cw_triggerAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void MoveInLineOfSight(Unit* who) + { + if (who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_HOME_OF_THE_BEAR_MEN) == QUEST_STATUS_INCOMPLETE) + if (Creature* orphan = Creature::GetCreature(*me, getOrphanGUID(player, ORPHAN_WOLVAR))) + { + player->AreaExploredOrEventHappens(QUEST_HOME_OF_THE_BEAR_MEN); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_10); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_grizzlemaw_cw_triggerAI(creature); + } +}; + +void AddSC_event_childrens_week() +{ + new npc_elder_kekek(); + new npc_high_oracle_soo_roo(); + new npc_winterfin_playmate(); + new npc_snowfall_glade_playmate(); + new npc_the_etymidian(); + new npc_the_biggest_tree(); + new at_bring_your_orphan_to(); + new npc_grizzlemaw_cw_trigger(); + new npc_cw_area_trigger(); + new npc_alexstraza_the_lifebinder(); +} diff --git a/src/server/scripts/Events/event.cpp b/src/server/scripts/Events/event.cpp new file mode 100644 index 00000000000..22334f8d365 --- /dev/null +++ b/src/server/scripts/Events/event.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2008-2012 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/>. + */ + +#include "ScriptPCH.h" + +void AddSC_event_childrens_week(); + +void AddSC_event_scripts() +{ + AddSC_event_childrens_week(); +} diff --git a/src/server/scripts/Examples/example_gossip_codebox.cpp b/src/server/scripts/Examples/example_gossip_codebox.cpp index a5627c68ff6..d6936c8fb9e 100644 --- a/src/server/scripts/Examples/example_gossip_codebox.cpp +++ b/src/server/scripts/Examples/example_gossip_codebox.cpp @@ -72,7 +72,7 @@ class example_gossip_codebox : public CreatureScript return true; } - bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) + bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code) { player->PlayerTalkClass->ClearMenus(); if (sender == GOSSIP_SENDER_MAIN) @@ -80,7 +80,7 @@ class example_gossip_codebox : public CreatureScript switch (action) { case GOSSIP_ACTION_INFO_DEF+1: - if (std::strcmp(code, player->GetName()) != 0) + if (player->GetName() != code) { DoScriptText(SAY_WRONG, creature); creature->CastSpell(player, SPELL_POLYMORPH, true); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index ee988accbac..1c91d78cd29 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -129,7 +129,6 @@ public: } else CheckTimer -= diff; } }; - }; /* This script is merely a placeholder for the Doomfire that triggers Doomfire spell. It will @@ -220,7 +219,6 @@ public: } else ChangeTargetTimer -= diff; } }; - }; /* Finally, Archimonde's script. His script isn't extremely complex, most are simply spells on timers. @@ -315,8 +313,8 @@ public: { Talk(SAY_SLAY); - if (victim && (victim->GetTypeId() == TYPEID_PLAYER)) - GainSoulCharge(CAST_PLR(victim)); + if (victim && victim->GetTypeId() == TYPEID_PLAYER) + GainSoulCharge(victim->ToPlayer()); } void GainSoulCharge(Player* victim) @@ -360,13 +358,13 @@ public: if (victim && me->IsWithinDistInMap(victim, me->GetAttackDistance(victim))) return false; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return false; std::list<Unit*> targets; - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive()) @@ -637,13 +635,8 @@ public: DoMeleeAttackIfReady(); } - - void WaypointReached(uint32 /*waypointId*/) - { - - } + void WaypointReached(uint32 /*waypointId*/) { } }; - }; void AddSC_boss_archimonde() diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 9aa2ccbee9d..411e55275b9 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -368,7 +368,7 @@ class boss_halion : public CreatureScript { events.SetPhase(PHASE_TWO); Talk(SAY_PHASE_TWO); - + me->CastStop(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_TWILIGHT_PHASING); @@ -1740,7 +1740,7 @@ void AddSC_boss_halion() { new boss_halion(); new boss_twilight_halion(); - + new npc_halion_controller(); new npc_meteor_strike_initial(); new npc_meteor_strike(); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 10b40b490c4..c88377da3f3 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -59,7 +59,8 @@ enum Yells SAY_REQUEST_AID = -1533103, //start of phase 3 SAY_ANSWER_REQUEST = -1533104 //lich king answer }; -enum Event + +enum Events { EVENT_NONE, EVENT_BOLT, @@ -607,13 +608,17 @@ public: case EVENT_DETONATE: { std::vector<Unit*> unitList; - std::list<HostileReference*> *threatList = &me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = threatList->begin(); itr != threatList->end(); ++itr) + ThreatContainer::StorageType const &threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { - if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER - && (*itr)->getTarget()->getPowerType() == POWER_MANA - && (*itr)->getTarget()->GetPower(POWER_MANA)) - unitList.push_back((*itr)->getTarget()); + Unit * const target = (*itr)->getTarget(); + + if (target->GetTypeId() == TYPEID_PLAYER + && target->getPowerType() == POWER_MANA + && target->GetPower(POWER_MANA)) + { + unitList.push_back(target); + } } if (!unitList.empty()) @@ -654,7 +659,6 @@ public: { return new boss_kelthuzadAI (creature); } - }; class at_kelthuzad_center : public AreaTriggerScript diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 9f5eb8d879a..28f73ed14b0 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -305,8 +305,8 @@ public: summons.DespawnAll(); // players that used Hover Disk are no in the aggro list me->SetInCombatWithZone(); - std::list<HostileReference*> &m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) { @@ -683,8 +683,8 @@ class spell_malygos_vortex_visual : public SpellScriptLoader { if (Unit* caster = GetCaster()) { - std::list<HostileReference*> &m_threatlist = caster->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + ThreatContainer::StorageType const& m_threatlist = caster->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) { diff --git a/src/server/scripts/Northrend/sholazar_basin.cpp b/src/server/scripts/Northrend/sholazar_basin.cpp index 56ef25c5753..14319d26cf5 100644 --- a/src/server/scripts/Northrend/sholazar_basin.cpp +++ b/src/server/scripts/Northrend/sholazar_basin.cpp @@ -470,11 +470,27 @@ public: enum utils { - NPC_HEMET = 27986, - NPC_HADRIUS = 28047, - NPC_TAMARA = 28568, - SPELL_OFFER = 51962, - QUEST_ENTRY = 12645, + NPC_HEMET = 27986, + NPC_HADRIUS = 28047, + NPC_TAMARA = 28568, + SPELL_OFFER = 51962, + QUEST_ENTRY = 12645, +}; + +enum NesingwaryChildrensWeek +{ + SPELL_ORPHAN_OUT = 58818, + + QUEST_THE_MIGHTY_HEMET_NESINGWARY = 13957, + + ORPHAN_WOLVAR = 33532, + + TEXT_WOLVAR_ORPHAN_6 = 6, + TEXT_WOLVAR_ORPHAN_7 = 7, + TEXT_WOLVAR_ORPHAN_8 = 8, + TEXT_WOLVAR_ORPHAN_9 = 9, + + TEXT_NESINGWARY_1 = 1, }; class npc_jungle_punch_target : public CreatureScript @@ -486,17 +502,86 @@ public: { npc_jungle_punch_targetAI(Creature* creature) : ScriptedAI(creature) {} - uint16 sayTimer; - uint8 sayStep; - void Reset() { sayTimer = 3500; sayStep = 0; + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_MIGHTY_HEMET_NESINGWARY) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (Aura* orphanOut = player->GetAura(SPELL_ORPHAN_OUT)) + if (orphanOut->GetCaster() && orphanOut->GetCaster()->GetEntry() == ORPHAN_WOLVAR) + { + orphanGUID = orphanOut->GetCaster()->GetGUID(); + phase = 1; + } + } + } + + void proceedCwEvent(const uint32 diff) + { + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if(!orphan || !player) + { + Reset(); + return; + } + + switch(phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_6); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_7); + timer = 5000; + break; + case 3: + Talk(TEXT_NESINGWARY_1); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_8); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_9); + timer = 5000; + break; + case 6: + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + player->GroupEventHappens(QUEST_THE_MIGHTY_HEMET_NESINGWARY, me); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; } void UpdateAI(const uint32 uiDiff) { + if (phase) + proceedCwEvent(uiDiff); + if (!sayStep) return; @@ -588,6 +673,14 @@ public: break; } } + + private: + uint16 sayTimer; + uint8 sayStep; + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; }; CreatureAI* GetAI(Creature* creature) const diff --git a/src/server/scripts/Northrend/wintergrasp.cpp b/src/server/scripts/Northrend/wintergrasp.cpp index 2aed813550d..d4a3f83ab70 100644 --- a/src/server/scripts/Northrend/wintergrasp.cpp +++ b/src/server/scripts/Northrend/wintergrasp.cpp @@ -559,7 +559,8 @@ public: { if (Battlefield* wg = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG)) if (Player* target = GetExplTargetUnit()->ToPlayer()) - if (target->GetTeamId() != wg->GetDefenderTeam() || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER)) + // check if we are in Wintergrasp at all, SotA uses same teleport spells + if ((target->GetZoneId() == 4197) && target->GetTeamId() != wg->GetDefenderTeam() || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER)) return SPELL_FAILED_BAD_TARGETS; return SPELL_CAST_OK; } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp index 9572125a4bd..fdf6533a64b 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp @@ -296,9 +296,12 @@ void OPvPCapturePointTF::ChangeState() uint32 alliance_towers = ((OutdoorPvPTF*)m_PvP)->GetAllianceTowersControlled(); if (alliance_towers < TF_TOWER_NUM) ((OutdoorPvPTF*)m_PvP)->SetAllianceTowersControlled(++alliance_towers); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_TF_CAPTURE_A)); + for (PlayerSet::iterator itr = m_activePlayers[0].begin(); itr != m_activePlayers[0].end(); ++itr) - (*itr)->AreaExploredOrEventHappens(TF_ALLY_QUEST); + if (Player* player = ObjectAccessor::FindPlayer(*itr)) + player->AreaExploredOrEventHappens(TF_ALLY_QUEST); break; } case OBJECTIVESTATE_HORDE: @@ -308,9 +311,12 @@ void OPvPCapturePointTF::ChangeState() uint32 horde_towers = ((OutdoorPvPTF*)m_PvP)->GetHordeTowersControlled(); if (horde_towers < TF_TOWER_NUM) ((OutdoorPvPTF*)m_PvP)->SetHordeTowersControlled(++horde_towers); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_TF_CAPTURE_H)); + for (PlayerSet::iterator itr = m_activePlayers[1].begin(); itr != m_activePlayers[1].end(); ++itr) - (*itr)->AreaExploredOrEventHappens(TF_HORDE_QUEST); + if (Player* player = ObjectAccessor::FindPlayer(*itr)) + player->AreaExploredOrEventHappens(TF_HORDE_QUEST); break; } case OBJECTIVESTATE_NEUTRAL: diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp index 4f8fc917424..0f3bcce6493 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp @@ -80,8 +80,8 @@ public: void SonicBoomEffect() { - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (target && target->GetTypeId() == TYPEID_PLAYER) @@ -165,8 +165,8 @@ public: // Thundering Storm if (ThunderingStorm_Timer <= diff) { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (target->isAlive() && !me->IsWithinDist(target, 35, false)) DoCast(target, SPELL_THUNDERING_STORM, true); @@ -188,8 +188,8 @@ public: return; if (!me->IsWithinMeleeRange(me->getVictim())) { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (target->isAlive() && me->IsWithinMeleeRange(target)) { @@ -201,7 +201,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_murmur() diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 6fd6f61c061..f812b1b35cd 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -46,9 +46,9 @@ EndScriptData */ #define SOUND_AKAMA_LEAVE 11390 // Self explanatory -const char* SAY_KILL1 = "Who shall be next to taste my blades?!"; +char const* SAY_KILL1 = "Who shall be next to taste my blades?!"; #define SOUND_KILL1 11473 -const char* SAY_KILL2 = "This is too easy!"; +char const* SAY_KILL2 = "This is too easy!"; #define SOUND_KILL2 11472 // I think I'll fly now and let my subordinates take you on @@ -254,7 +254,6 @@ struct Yells }; static const Yells Conversation[22] = - { {11463, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.", ILLIDAN_STORMRAGE, 8000, 0, true}, {0, "", ILLIDAN_STORMRAGE, 5000, 396, true}, @@ -464,7 +463,6 @@ public: DoMeleeAttackIfReady(); } }; - }; /************************************** Illidan's AI* **************************************/ @@ -614,7 +612,8 @@ public: void DeleteFromThreatList(uint64 TargetGUID) { - for (std::list<HostileReference*>::const_iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if ((*itr)->getUnitGuid() == TargetGUID) { @@ -1151,7 +1150,6 @@ public: } } }; - }; /********************************** End of Illidan AI* *****************************************/ @@ -1378,7 +1376,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_akama_illidan : public CreatureScript @@ -1491,9 +1488,9 @@ public: void KillAllElites() { - std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &threatList = me->getThreatManager().getThreatList(); std::vector<Unit*> eliteList; - for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->GetEntry() == ILLIDARI_ELITE) @@ -1649,7 +1646,8 @@ public: void HandleChannelSequence() { - Unit* Channel = NULL, *Spirit[2] = { NULL, NULL }; + Unit* Channel = NULL; + Unit* Spirit[2] = { NULL, NULL }; if (ChannelCount <= 5) { Channel = Unit::GetUnit(*me, ChannelGUID); @@ -1840,7 +1838,6 @@ public: { return new npc_akama_illidanAI(creature); } - }; void boss_illidan_stormrage::boss_illidan_stormrageAI::Reset() @@ -2000,7 +1997,6 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() Akama->SetPosition(x, y, z, 0.0f); Akama->MonsterMoveWithSpeed(x, y, z, 0); // Illidan must not die until Akama arrives. Akama->GetMotionMaster()->MoveChase(me); - } } break; @@ -2194,7 +2190,6 @@ public: me->SetDisplayId(21431);// appear when hit by Illidan's glaive } }; - }; class mob_parasitic_shadowfiend : public CreatureScript diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index ec9e4e116bf..5ab9dcab667 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -128,7 +128,6 @@ public: void JustDied(Unit* /*killer*/); }; - }; class boss_reliquary_of_souls : public CreatureScript @@ -233,9 +232,8 @@ public: if (!target) return; - std::list<HostileReference*>& m_threatlist = target->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = target->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit) @@ -376,7 +374,6 @@ public: } else Timer -= diff; } }; - }; void npc_enslaved_soul::npc_enslaved_soulAI::JustDied(Unit* /*killer*/) @@ -453,12 +450,12 @@ public: void CastFixate() { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return; // No point continuing if empty threatlist. std::list<Unit*> targets; - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive() && (unit->GetTypeId() == TYPEID_PLAYER)) // Only alive players @@ -511,7 +508,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_essence_of_desire : public CreatureScript @@ -615,7 +611,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_essence_of_anger : public CreatureScript @@ -716,7 +711,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_reliquary_of_souls() diff --git a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp index e34a229eea5..77d1c86951b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp @@ -78,7 +78,6 @@ public: me->CastSpell(me, SPELL_MOLTEN_FLAME, true); } }; - }; class boss_supremus : public CreatureScript @@ -183,9 +182,9 @@ public: uint32 health = 0; Unit* target = NULL; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i!= m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && me->IsWithinMeleeRange(unit)) @@ -258,7 +257,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_volcano : public CreatureScript @@ -303,9 +301,7 @@ public: } else wait -= diff; } - }; - }; void AddSC_boss_supremus() diff --git a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp index 524992b3c44..9a200d07d2b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp @@ -169,12 +169,12 @@ public: void CheckPlayers() { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return; // No threat list. Don't continue. - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); std::list<Unit*> targets; - for (; itr != m_threatlist.end(); ++itr) + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive()) @@ -207,7 +207,6 @@ public: } else CheckTeronTimer -= diff; } }; - }; class boss_teron_gorefiend : public CreatureScript @@ -317,20 +316,20 @@ public: return coord; } - void SetThreatList(Creature* Blossom) + void SetThreatList(Creature* blossom) { - if (!Blossom) + if (!blossom) return; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->isAlive()) { float threat = DoGetThreat(unit); - Blossom->AddThreat(unit, threat); + blossom->AddThreat(unit, threat); } } } @@ -344,26 +343,26 @@ public: /** WHAT IS FULLY NECESSARY FOR GOREFIEND TO BE 100% COMPLETE *****/ /************************************************************************/ - Unit* Ghost = NULL; + Unit* ghost = NULL; if (GhostGUID) - Ghost = Unit::GetUnit(*me, GhostGUID); - if (Ghost && Ghost->isAlive() && Ghost->HasAura(SPELL_SHADOW_OF_DEATH)) + ghost = Unit::GetUnit(*me, GhostGUID); + if (ghost && ghost->isAlive() && ghost->HasAura(SPELL_SHADOW_OF_DEATH)) { /*float x, y, z; - Ghost->GetPosition(x, y, z); + ghost->GetPosition(x, y, z); Creature* control = me->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000); if (control) { - CAST_PLR(Ghost)->Possess(control); - Ghost->DealDamage(Ghost, Ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, + CAST_PLR(ghost)->Possess(control); + ghost->DealDamage(ghost, ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); }*/ for (uint8 i = 0; i < 4; ++i) { Creature* Construct = NULL; - float X = CalculateRandomLocation(Ghost->GetPositionX(), 10); - float Y = CalculateRandomLocation(Ghost->GetPositionY(), 10); - Construct = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, Ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + float X = CalculateRandomLocation(ghost->GetPositionX(), 10); + float Y = CalculateRandomLocation(ghost->GetPositionY(), 10); + Construct = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); if (Construct) { Construct->CastSpell(Construct, SPELL_PASSIVE_SHADOWFORM, true); @@ -511,7 +510,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_teron_gorefiend() diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 81e03a19c1f..9b739a1a6ac 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -171,7 +171,6 @@ public: DoMeleeAttackIfReady(); } }; - }; //Original Leotheras the Blind AI @@ -263,7 +262,6 @@ public: Creature* binder = me->SummonCreature(MOB_SPELLBINDER, nx, ny, z, o, TEMPSUMMON_DEAD_DESPAWN, 0); if (binder) SpellBinderGUID[i] = binder->GetGUID(); - } } void MoveInLineOfSight(Unit* who) @@ -525,9 +523,9 @@ public: //Summon Inner Demon if (InnerDemons_Timer <= diff) { - std::list<HostileReference*>& ThreatList = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const & ThreatList = me->getThreatManager().getThreatList(); std::vector<Unit*> TargetList; - for (std::list<HostileReference*>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) { Unit* tempTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->getVictim()->GetGUID() && TargetList.size()<5) @@ -602,7 +600,6 @@ public: } } }; - }; //Leotheras the Blind Demon Form AI @@ -812,7 +809,6 @@ public: void JustDied(Unit* /*killer*/) {} }; - }; void AddSC_boss_leotheras_the_blind() diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index cb9f9cbc15c..2008a1bc640 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -176,7 +176,7 @@ struct advisorbase_ai : public ScriptedAI //reset encounter if (instance && (instance->GetData(DATA_KAELTHASEVENT) == 1 || instance->GetData(DATA_KAELTHASEVENT) == 3)) - if (Creature* Kaelthas = Unit::GetCreature((*me), instance->GetData64(DATA_KAELTHAS))) + if (Creature* Kaelthas = Unit::GetCreature(*me, instance->GetData64(DATA_KAELTHAS))) Kaelthas->AI()->EnterEvadeMode(); } @@ -344,7 +344,7 @@ class boss_kaelthas : public CreatureScript { for (uint8 i = 0; i < MAX_ADVISORS; ++i) { - if (Creature* creature = Unit::GetCreature((*me), m_auiAdvisorGuid[i])) + if (Creature* creature = Unit::GetCreature(*me, m_auiAdvisorGuid[i])) { creature->Respawn(); creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -379,7 +379,6 @@ class boss_kaelthas : public CreatureScript if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) AttackStart(target); - } else { @@ -499,7 +498,7 @@ class boss_kaelthas : public CreatureScript case 1: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[0])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[0])); if (Advisor) { @@ -517,7 +516,7 @@ class boss_kaelthas : public CreatureScript //Subphase 2 - Start case 2: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[0])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[0])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -533,7 +532,7 @@ class boss_kaelthas : public CreatureScript case 3: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[1])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[1])); if (Advisor) { @@ -551,7 +550,7 @@ class boss_kaelthas : public CreatureScript //Subphase 3 - Start case 4: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[1])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[1])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -567,7 +566,7 @@ class boss_kaelthas : public CreatureScript case 5: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[2])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[2])); if (Advisor) { @@ -585,7 +584,7 @@ class boss_kaelthas : public CreatureScript //Subphase 4 - Start case 6: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[2])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[2])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -601,7 +600,7 @@ class boss_kaelthas : public CreatureScript case 7: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[3])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[3])); if (Advisor) { @@ -620,7 +619,7 @@ class boss_kaelthas : public CreatureScript //End of phase 1 case 8: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[3])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[3])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -691,7 +690,7 @@ class boss_kaelthas : public CreatureScript Creature* Advisor; for (uint8 i = 0; i < MAX_ADVISORS; ++i) { - Advisor = Unit::GetCreature((*me), m_auiAdvisorGuid[i]); + Advisor = Unit::GetCreature(*me, m_auiAdvisorGuid[i]); if (!Advisor) sLog->outError(LOG_FILTER_TSCR, "SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); @@ -787,7 +786,7 @@ class boss_kaelthas : public CreatureScript if (me->getThreatManager().getThreatList().size() >= 2) for (uint32 i = 0; i < 3; ++i) { - sLog->outDebug(LOG_FILTER_TSCR, "SD2: Kael'Thas mind control not supported."); + sLog->outDebug(LOG_FILTER_TSCR, "Kael'Thas mind control not supported."); //DoCast(unit, SPELL_MIND_CONTROL); } @@ -879,11 +878,12 @@ class boss_kaelthas : public CreatureScript //Phase 5 if (Phase == 6) { - //GravityLapse_Timer if (GravityLapse_Timer <= diff) { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + switch (GravityLapse_Phase) { case 0: @@ -894,7 +894,7 @@ class boss_kaelthas : public CreatureScript me->MonsterMoveWithSpeed(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); // 1) Kael'thas will portal the whole raid right into his body - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -915,7 +915,7 @@ class boss_kaelthas : public CreatureScript DoScriptText(RAND(SAY_GRAVITYLAPSE1, SAY_GRAVITYLAPSE2), me); // 2) At that point he will put a Gravity Lapse debuff on everyone - for (i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -947,7 +947,7 @@ class boss_kaelthas : public CreatureScript case 3: //Remove flight - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -1285,8 +1285,8 @@ class boss_grand_astromancer_capernian : public CreatureScript { bool InMeleeRange = false; Unit* target = NULL; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); i!= m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i!= threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); //if in melee range diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index c47e155accb..d456f2a1f56 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -353,7 +353,7 @@ class spell_rog_deadly_poison : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]); if (!spellInfo) { - sLog->outError(LOG_FILTER_SPELLS_AURAS, "Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName(), player->GetGUIDLow(), enchant->spellid[s]); + sLog->outError(LOG_FILTER_SPELLS_AURAS, "Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName().c_str(), player->GetGUIDLow(), enchant->spellid[s]); continue; } diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index f302009a4f3..67aeda314bf 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -235,21 +235,19 @@ enum eWaygate QUEST_THE_MAKERS_OVERLOOK = 12613, QUEST_THE_MAKERS_PERCH = 12559, + QUEST_MEETING_A_GREAT_ONE = 13956, }; class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript { public: - AreaTrigger_at_sholazar_waygate() - : AreaTriggerScript("at_sholazar_waygate") - { - } + AreaTrigger_at_sholazar_waygate() : AreaTriggerScript("at_sholazar_waygate") {} bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) { - if (player->GetQuestStatus(QUEST_THE_MAKERS_OVERLOOK) == QUEST_STATUS_REWARDED && !player->isDead() && - player->GetQuestStatus(QUEST_THE_MAKERS_PERCH) == QUEST_STATUS_REWARDED) + if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE || + (player->GetQuestStatus(QUEST_THE_MAKERS_OVERLOOK) == QUEST_STATUS_REWARDED && player->GetQuestStatus(QUEST_THE_MAKERS_PERCH) == QUEST_STATUS_REWARDED))) { switch (trigger->id) { @@ -303,76 +301,6 @@ class AreaTrigger_at_nats_landing : public AreaTriggerScript }; /*###### -## at_bring_your_orphan_to -######*/ - -enum BringYourOrphanTo -{ - QUEST_DOWN_AT_THE_DOCKS = 910, - QUEST_GATEWAY_TO_THE_FRONTIER = 911, - QUEST_LORDAERON_THRONE_ROOM = 1800, - QUEST_BOUGHT_OF_ETERNALS = 1479, - QUEST_SPOOKY_LIGHTHOUSE = 1687, - QUEST_STONEWROUGHT_DAM = 1558, - QUEST_DARK_PORTAL_H = 10951, - QUEST_DARK_PORTAL_A = 10952, - - AT_DOWN_AT_THE_DOCKS = 3551, - AT_GATEWAY_TO_THE_FRONTIER = 3549, - AT_LORDAERON_THRONE_ROOM = 3547, - AT_BOUGHT_OF_ETERNALS = 3546, - AT_SPOOKY_LIGHTHOUSE = 3552, - AT_STONEWROUGHT_DAM = 3548, - AT_DARK_PORTAL = 4356, - - AURA_ORPHAN_OUT = 58818, -}; - -class AreaTrigger_at_bring_your_orphan_to : public AreaTriggerScript -{ - public: - AreaTrigger_at_bring_your_orphan_to() : AreaTriggerScript("at_bring_your_orphan_to") { } - - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) - { - uint32 questId = 0; - - if (player->isDead() || !player->HasAura(AURA_ORPHAN_OUT)) - return false; - - switch (trigger->id) - { - case AT_DOWN_AT_THE_DOCKS: - questId = QUEST_DOWN_AT_THE_DOCKS; - break; - case AT_GATEWAY_TO_THE_FRONTIER: - questId = QUEST_GATEWAY_TO_THE_FRONTIER; - break; - case AT_LORDAERON_THRONE_ROOM: - questId = QUEST_LORDAERON_THRONE_ROOM; - break; - case AT_BOUGHT_OF_ETERNALS: - questId = QUEST_BOUGHT_OF_ETERNALS; - break; - case AT_SPOOKY_LIGHTHOUSE: - questId = QUEST_SPOOKY_LIGHTHOUSE; - break; - case AT_STONEWROUGHT_DAM: - questId = QUEST_STONEWROUGHT_DAM; - break; - case AT_DARK_PORTAL: - questId = player->GetTeam() == ALLIANCE ? QUEST_DARK_PORTAL_A : QUEST_DARK_PORTAL_H; - break; - } - - if (questId && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(questId); - - return true; - } -}; - -/*###### ## at_brewfest ######*/ @@ -505,7 +433,6 @@ void AddSC_areatrigger_scripts() new AreaTrigger_at_last_rites(); new AreaTrigger_at_sholazar_waygate(); new AreaTrigger_at_nats_landing(); - new AreaTrigger_at_bring_your_orphan_to(); new AreaTrigger_at_brewfest(); new AreaTrigger_at_area_52_entrance(); } diff --git a/src/server/scripts/World/chat_log.cpp b/src/server/scripts/World/chat_log.cpp index fb540c177bc..236436b229b 100755 --- a/src/server/scripts/World/chat_log.cpp +++ b/src/server/scripts/World/chat_log.cpp @@ -32,25 +32,25 @@ public: case CHAT_MSG_ADDON: if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s sends: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_SAY: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[SAY] Player %s says (language %u): %s", - player->GetName(), lang, msg.c_str()); + player->GetName().c_str(), lang, msg.c_str()); break; case CHAT_MSG_EMOTE: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[TEXTEMOTE] Player %s emotes: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_YELL: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[YELL] Player %s yells (language %u): %s", - player->GetName(), lang, msg.c_str()); + player->GetName().c_str(), lang, msg.c_str()); break; } } @@ -59,10 +59,10 @@ public: { if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_WHISPER)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[WHISPER] Player %s tells %s: %s", - player->GetName(), receiver ? receiver->GetName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells %s: %s", - player->GetName(), receiver ? receiver->GetName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str()); } void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) @@ -74,52 +74,52 @@ public: case CHAT_MSG_PARTY: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[PARTY] Player %s tells group with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells group with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); break; case CHAT_MSG_PARTY_LEADER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[PARTY] Leader %s tells group: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_RAID: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_RAID)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[RAID] Player %s tells raid with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells raid with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); break; case CHAT_MSG_RAID_LEADER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[RAID] Leader player %s tells raid: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_RAID_WARNING: if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[RAID] Leader player %s warns raid with: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_BATTLEGROUND: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[BATTLEGROUND] Player %s tells battleground with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells battleground with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); break; case CHAT_MSG_BATTLEGROUND_LEADER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[BATTLEGROUND] Leader player %s tells battleground: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; } } @@ -131,16 +131,16 @@ public: case CHAT_MSG_GUILD: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[GUILD] Player %s tells guild %s: %s", - player->GetName(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s sends to guild %s: %s", - player->GetName(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); break; case CHAT_MSG_OFFICER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[OFFICER] Player %s tells guild %s officers: %s", - player->GetName(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); break; } } @@ -155,10 +155,10 @@ public: if (sWorld->getBoolConfig(CONFIG_CHATLOG_SYSCHAN) && isSystem) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[SYSCHAN] Player %s tells channel %s: %s", - player->GetName(), channel->GetName().c_str(), msg.c_str()); + player->GetName().c_str(), channel->GetName().c_str(), msg.c_str()); else if (sWorld->getBoolConfig(CONFIG_CHATLOG_CHANNEL)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[CHANNEL] Player %s tells channel %s: %s", - player->GetName(), channel ? channel->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), channel ? channel->GetName().c_str() : "<unknown>", msg.c_str()); } }; diff --git a/src/server/shared/Logging/Appender.cpp b/src/server/shared/Logging/Appender.cpp index 348ec4b3c7c..0bfcc8abbd2 100644 --- a/src/server/shared/Logging/Appender.cpp +++ b/src/server/shared/Logging/Appender.cpp @@ -217,6 +217,8 @@ char const* Appender::getLogFilterTypeString(LogFilterType type) return "SERVER LOADING"; case LOG_FILTER_OPCODES: return "OPCODE"; + case LOG_FILTER_SOAP: + return "SOAP"; default: break; } diff --git a/src/server/shared/Logging/Appender.h b/src/server/shared/Logging/Appender.h index 2d6145b14af..89d0016ce2b 100644 --- a/src/server/shared/Logging/Appender.h +++ b/src/server/shared/Logging/Appender.h @@ -66,10 +66,11 @@ enum LogFilterType LOG_FILTER_PLAYER_DUMP = 38, LOG_FILTER_BATTLEFIELD = 39, LOG_FILTER_SERVER_LOADING = 40, - LOG_FILTER_OPCODES = 41 + LOG_FILTER_OPCODES = 41, + LOG_FILTER_SOAP = 42 }; -const uint8 MaxLogFilter = uint8(LOG_FILTER_OPCODES) + 1; +const uint8 MaxLogFilter = 43; // Values assigned have their equivalent in enum ACE_Log_Priority enum LogLevel diff --git a/src/server/worldserver/TCSoap/TCSoap.cpp b/src/server/worldserver/TCSoap/TCSoap.cpp index 3ce4d4f59cb..40b35df9aee 100755 --- a/src/server/worldserver/TCSoap/TCSoap.cpp +++ b/src/server/worldserver/TCSoap/TCSoap.cpp @@ -32,18 +32,18 @@ void TCSoapRunnable::run() soap.send_timeout = 5; if (!soap_valid_socket(soap_bind(&soap, m_host.c_str(), m_port, 100))) { - sLog->outError(LOG_FILTER_WORLDSERVER, "TCSoap: couldn't bind to %s:%d", m_host.c_str(), m_port); + sLog->outError(LOG_FILTER_SOAP, "Couldn't bind to %s:%d", m_host.c_str(), m_port); exit(-1); } - sLog->outInfo(LOG_FILTER_WORLDSERVER, "TCSoap: bound to http://%s:%d", m_host.c_str(), m_port); + sLog->outInfo(LOG_FILTER_SOAP, "Bound to http://%s:%d", m_host.c_str(), m_port); while (!World::IsStopped()) { if (!soap_valid_socket(soap_accept(&soap))) continue; // ran into an accept timeout - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); + sLog->outDebug(LOG_FILTER_SOAP, "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); struct soap* thread_soap = soap_copy(&soap);// make a safe copy ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*)); @@ -78,33 +78,33 @@ int ns1__executeCommand(soap* soap, char* command, char** result) // security check if (!soap->userid || !soap->passwd) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: Client didn't provide login information"); + sLog->outDebug(LOG_FILTER_SOAP, "Client didn't provide login information"); return 401; } uint32 accountId = AccountMgr::GetId(soap->userid); if (!accountId) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: Client used invalid username '%s'", soap->userid); + sLog->outDebug(LOG_FILTER_SOAP, "Client used invalid username '%s'", soap->userid); return 401; } if (!AccountMgr::CheckPassword(accountId, soap->passwd)) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: invalid password for account '%s'", soap->userid); + sLog->outDebug(LOG_FILTER_SOAP, "Invalid password for account '%s'", soap->userid); return 401; } if (AccountMgr::GetSecurity(accountId) < SEC_ADMINISTRATOR) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: %s's gmlevel is too low", soap->userid); + sLog->outDebug(LOG_FILTER_SOAP, "%s's gmlevel is too low", soap->userid); return 403; } if (!command || !*command) return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string"); - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: got command '%s'", command); + sLog->outDebug(LOG_FILTER_SOAP, "Got command '%s'", command); SOAPCommand connection; // commands are executed in the world thread. We have to wait for them to be completed @@ -119,7 +119,7 @@ int ns1__executeCommand(soap* soap, char* command, char** result) int acc = connection.pendingCommands.acquire(); if (acc) { - sLog->outError(LOG_FILTER_WORLDSERVER, "TCSoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno); + sLog->outError(LOG_FILTER_SOAP, "Error while acquiring lock, acc = %i, errno = %u", acc, errno); } // alright, command finished diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index f8cb61d659d..d8f7932470a 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -2771,6 +2771,8 @@ Appenders=Console Server GM DBErrors Char RA Warden Chat # 39 - Battlefield # 40 - Server Loading # 41 - Opcodes (just id and name sent / received) +# 42 - SOAP +# # LogLevel # 0 - (Disabled) # 1 - (Trace) |