diff options
Diffstat (limited to 'src')
108 files changed, 1245 insertions, 767 deletions
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 14e7571dd42..b41ba41bcff 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -603,7 +603,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() // PvPstats PrepareStatement(CHAR_SEL_PVPSTATS_MAXID, "SELECT MAX(id) FROM pvpstats_battlegrounds", CONNECTION_SYNCH); PrepareStatement(CHAR_INS_PVPSTATS_BATTLEGROUND, "INSERT INTO pvpstats_battlegrounds (id, winner_faction, bracket_id, type, date) VALUES (?, ?, ?, ?, NOW())", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_PVPSTATS_PLAYER, "INSERT INTO pvpstats_players (battleground_id, character_guid, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_PVPSTATS_PLAYER, "INSERT INTO pvpstats_players (battleground_id, character_guid, winner, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PVPSTATS_FACTIONS_OVERALL, "SELECT winner_faction, COUNT(*) AS count FROM pvpstats_battlegrounds WHERE DATEDIFF(NOW(), date) < 7 GROUP BY winner_faction ORDER BY winner_faction ASC", CONNECTION_SYNCH); // QuestTracker diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 5aa6ea8ea7a..f0d9d34db69 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -29,7 +29,15 @@ void UnitAI::AttackStart(Unit* victim) { if (victim && me->Attack(victim, true)) + { + // Clear distracted state on attacking + if (me->HasUnitState(UNIT_STATE_DISTRACTED)) + { + me->ClearUnitState(UNIT_STATE_DISTRACTED); + me->GetMotionMaster()->Clear(); + } me->GetMotionMaster()->MoveChase(victim); + } } void UnitAI::AttackStartCaster(Unit* victim, float dist) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 8e2a82dbfd3..7b145268d22 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -470,6 +470,7 @@ void BossAI::_Reset() if (!me->IsAlive()) return; + me->SetCombatPulseDelay(0); me->ResetLootMode(); events.Reset(); summons.DespawnAll(); @@ -500,6 +501,7 @@ void BossAI::_EnterCombat() instance->SetBossState(_bossId, IN_PROGRESS); } + me->SetCombatPulseDelay(5); me->setActive(true); DoZoneInCombat(); ScheduleTasks(); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 46122697094..46cf934356d 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -453,45 +453,15 @@ void SmartAI::MoveInLineOfSight(Unit* who) GetScript()->OnMoveInLineOfSight(who); - if (me->HasReactState(REACT_PASSIVE) || AssistPlayerInCombat(who)) + if (AssistPlayerInCombat(who)) return; - if (!CanAIAttack(who)) - return; - - if (!me->CanStartAttack(who, false)) - return; - - if (me->IsHostileTo(who)) - { - float fAttackRadius = me->GetAttackDistance(who); - if (me->IsWithinDistInMap(who, fAttackRadius) && me->IsWithinLOSInMap(who)) - { - if (!me->GetVictim()) - { - // Clear distracted state on combat - if (me->HasUnitState(UNIT_STATE_DISTRACTED)) - { - me->ClearUnitState(UNIT_STATE_DISTRACTED); - me->GetMotionMaster()->Clear(); - } - - AttackStart(who); - } - else/* if (me->GetMap()->IsDungeon())*/ - { - who->SetInCombatWith(me); - me->AddThreat(who, 0.0f); - } - } - } + CreatureAI::MoveInLineOfSight(who); } bool SmartAI::CanAIAttack(const Unit* /*who*/) const { - if (me->GetReactState() == REACT_PASSIVE) - return false; - return true; + return !(me->HasReactState(REACT_PASSIVE)); } bool SmartAI::AssistPlayerInCombat(Unit* who) diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index cb338cd3584..96aa1f735fc 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -175,7 +175,7 @@ class SmartScript return 0; } - GameObject* FindGameObjectNear(WorldObject* searchObject, uint32 guid) const + GameObject* FindGameObjectNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); if (bounds.first == bounds.second) @@ -184,7 +184,7 @@ class SmartScript return bounds.first->second; } - Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const + Creature* FindCreatureNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid); if (bounds.first == bounds.second) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 1809e306a45..768def2ff4d 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -300,7 +300,7 @@ void AuctionHouseMgr::LoadAuctionItems() { Field* fields = result->Fetch(); - uint32 item_guid = fields[11].GetUInt32(); + ObjectGuid::LowType item_guid = fields[11].GetUInt32(); uint32 itemEntry = fields[12].GetUInt32(); ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry); @@ -372,7 +372,7 @@ void AuctionHouseMgr::AddAItem(Item* it) mAitems[it->GetGUID().GetCounter()] = it; } -bool AuctionHouseMgr::RemoveAItem(uint32 id, bool deleteItem) +bool AuctionHouseMgr::RemoveAItem(ObjectGuid::LowType id, bool deleteItem) { ItemMap::iterator i = mAitems.find(id); if (i == mAitems.end()) @@ -738,7 +738,7 @@ std::string AuctionEntry::BuildAuctionMailSubject(MailAuctionAnswers response) c return strm.str(); } -std::string AuctionEntry::BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut) +std::string AuctionEntry::BuildAuctionMailBody(ObjectGuid::LowType lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut) { std::ostringstream strm; strm.width(16); diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index f05d8583329..45cdba361f3 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -72,15 +72,15 @@ struct AuctionEntry { uint32 Id; uint8 houseId; - uint32 itemGUIDLow; + ObjectGuid::LowType itemGUIDLow; uint32 itemEntry; uint32 itemCount; - uint32 owner; + ObjectGuid::LowType owner; uint32 startbid; //maybe useless uint32 bid; uint32 buyout; time_t expire_time; - uint32 bidder; + ObjectGuid::LowType bidder; uint32 deposit; //deposit can be calculated only when creating auction AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc @@ -93,7 +93,7 @@ struct AuctionEntry void SaveToDB(SQLTransaction& trans) const; bool LoadFromDB(Field* fields); std::string BuildAuctionMailSubject(MailAuctionAnswers response) const; - static std::string BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); + static std::string BuildAuctionMailBody(ObjectGuid::LowType lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); }; @@ -150,13 +150,13 @@ class AuctionHouseMgr return &instance; } - typedef std::unordered_map<uint32, Item*> ItemMap; + typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap; AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId); AuctionHouseObject* GetAuctionsMapByHouseId(uint8 auctionHouseId); AuctionHouseObject* GetBidsMap(uint32 factionTemplateId); - Item* GetAItem(uint32 id) + Item* GetAItem(ObjectGuid::LowType id) { ItemMap::const_iterator itr = mAitems.find(id); if (itr != mAitems.end()) @@ -183,7 +183,7 @@ class AuctionHouseMgr void LoadAuctions(); void AddAItem(Item* it); - bool RemoveAItem(uint32 id, bool deleteItem = false); + bool RemoveAItem(ObjectGuid::LowType id, bool deleteItem = false); void Update(); diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index c860d36e712..bb3ecb60838 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -193,7 +193,7 @@ class Battlefield : public ZoneScript virtual ~Battlefield(); /// typedef of map witch store capturepoint and the associate gameobject entry - typedef std::map<uint32 /*lowguid */, BfCapturePoint*> BfCapturePointMap; + typedef std::map<ObjectGuid::LowType /*lowguid */, BfCapturePoint*> BfCapturePointMap; /// Call this to init the Battlefield virtual bool SetupBattlefield() { return true; } @@ -400,7 +400,7 @@ class Battlefield : public ZoneScript // CapturePoint system void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointEntry()] = cp; } - BfCapturePoint* GetCapturePoint(uint32 lowguid) const + BfCapturePoint* GetCapturePoint(ObjectGuid::LowType lowguid) const { Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid); if (itr != m_capturePoints.end()) diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index e75c07d8946..7806e0b343b 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -63,7 +63,7 @@ bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& te EmblemColor = emblemColor; BorderStyle = borderStyle; BorderColor = borderColor; - uint32 captainLowGuid = captainGuid.GetCounter(); + ObjectGuid::LowType captainLowGuid = captainGuid.GetCounter(); // Save arena team to db PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index ad8a7b9e729..0e44925cd57 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -784,19 +784,20 @@ void Battleground::EndBattleground(uint32 winner) stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_PLAYER); BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID().GetCounter()); - stmt->setUInt32(0, battlegroundId); - stmt->setUInt32(1, player->GetGUID().GetCounter()); - stmt->setUInt32(2, score->second->GetKillingBlows()); - stmt->setUInt32(3, score->second->GetDeaths()); - stmt->setUInt32(4, score->second->GetHonorableKills()); - stmt->setUInt32(5, score->second->GetBonusHonor()); - stmt->setUInt32(6, score->second->GetDamageDone()); - stmt->setUInt32(7, score->second->GetHealingDone()); - stmt->setUInt32(8, score->second->GetAttr1()); - stmt->setUInt32(9, score->second->GetAttr2()); - stmt->setUInt32(10, score->second->GetAttr3()); - stmt->setUInt32(11, score->second->GetAttr4()); - stmt->setUInt32(12, score->second->GetAttr5()); + stmt->setUInt32(0, battlegroundId); + stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->setBool (2, team == winner); + stmt->setUInt32(3, score->second->GetKillingBlows()); + stmt->setUInt32(4, score->second->GetDeaths()); + stmt->setUInt32(5, score->second->GetHonorableKills()); + stmt->setUInt32(6, score->second->GetBonusHonor()); + stmt->setUInt32(7, score->second->GetDamageDone()); + stmt->setUInt32(8, score->second->GetHealingDone()); + stmt->setUInt32(9, score->second->GetAttr1()); + stmt->setUInt32(10, score->second->GetAttr2()); + stmt->setUInt32(11, score->second->GetAttr3()); + stmt->setUInt32(12, score->second->GetAttr4()); + stmt->setUInt32(13, score->second->GetAttr5()); CharacterDatabase.Execute(stmt); } @@ -1165,48 +1166,58 @@ void Battleground::RemoveFromBGFreeSlotQueue() // returns the number how many players can join battleground to MaxPlayersPerTeam uint32 Battleground::GetFreeSlotsForTeam(uint32 Team) const { - // if BG is starting ... invite anyone - if (GetStatus() == STATUS_WAIT_JOIN) + // if BG is starting and CONFIG_BATTLEGROUND_INVITATION_TYPE == BG_QUEUE_INVITATION_TYPE_NO_BALANCE, invite anyone + if (GetStatus() == STATUS_WAIT_JOIN && sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_NO_BALANCE) return (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0; - // if BG is already started .. do not allow to join too much players of one faction - uint32 otherTeam; - uint32 otherIn; + + // if BG is already started or CONFIG_BATTLEGROUND_INVITATION_TYPE != BG_QUEUE_INVITATION_TYPE_NO_BALANCE, do not allow to join too much players of one faction + uint32 otherTeamInvitedCount; + uint32 thisTeamInvitedCount; + uint32 otherTeamPlayersCount; + uint32 thisTeamPlayersCount; + if (Team == ALLIANCE) { - otherTeam = GetInvitedCount(HORDE); - otherIn = GetPlayersCountByTeam(HORDE); + thisTeamInvitedCount = GetInvitedCount(ALLIANCE); + otherTeamInvitedCount = GetInvitedCount(HORDE); + thisTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE); + otherTeamPlayersCount = GetPlayersCountByTeam(HORDE); } else { - otherTeam = GetInvitedCount(ALLIANCE); - otherIn = GetPlayersCountByTeam(ALLIANCE); + thisTeamInvitedCount = GetInvitedCount(HORDE); + otherTeamInvitedCount = GetInvitedCount(ALLIANCE); + thisTeamPlayersCount = GetPlayersCountByTeam(HORDE); + otherTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE); } - if (GetStatus() == STATUS_IN_PROGRESS) + if (GetStatus() == STATUS_IN_PROGRESS || GetStatus() == STATUS_WAIT_JOIN) { // difference based on ppl invited (not necessarily entered battle) // default: allow 0 uint32 diff = 0; - // allow join one person if the sides are equal (to fill up bg to minplayersperteam) - if (otherTeam == GetInvitedCount(Team)) + + // allow join one person if the sides are equal (to fill up bg to minPlayerPerTeam) + if (otherTeamInvitedCount == thisTeamInvitedCount) diff = 1; // allow join more ppl if the other side has more players - else if (otherTeam > GetInvitedCount(Team)) - diff = otherTeam - GetInvitedCount(Team); + else if (otherTeamInvitedCount > thisTeamInvitedCount) + diff = otherTeamInvitedCount - thisTeamInvitedCount; // difference based on max players per team (don't allow inviting more) - uint32 diff2 = (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0; + uint32 diff2 = (thisTeamInvitedCount < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - thisTeamInvitedCount : 0; + // difference based on players who already entered // default: allow 0 uint32 diff3 = 0; - // allow join one person if the sides are equal (to fill up bg minplayersperteam) - if (otherIn == GetPlayersCountByTeam(Team)) + // allow join one person if the sides are equal (to fill up bg minPlayerPerTeam) + if (otherTeamPlayersCount == thisTeamPlayersCount) diff3 = 1; // allow join more ppl if the other side has more players - else if (otherIn > GetPlayersCountByTeam(Team)) - diff3 = otherIn - GetPlayersCountByTeam(Team); + else if (otherTeamPlayersCount > thisTeamPlayersCount) + diff3 = otherTeamPlayersCount - thisTeamPlayersCount; // or other side has less than minPlayersPerTeam - else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam()) - diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1; + else if (thisTeamInvitedCount <= GetMinPlayersPerTeam()) + diff3 = GetMinPlayersPerTeam() - thisTeamInvitedCount + 1; // return the minimum of the 3 differences diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 73c0f1c22a5..162122ab4db 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -497,24 +497,51 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId { int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE); int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE); + uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size(); + uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size(); + + // try to get even teams + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_EVEN) + { + // check if the teams are even + if (hordeFree == 1 && aliFree == 1) + { + // if we are here, the teams have the same amount of players + // then we have to allow to join the same amount of players + int32 hordeExtra = hordeCount - aliCount; + int32 aliExtra = aliCount - hordeCount; + + hordeExtra = std::max(hordeExtra, 0); + aliExtra = std::max(aliExtra, 0); + + if (aliCount != hordeCount) + { + aliFree -= aliExtra; + hordeFree -= hordeExtra; + + aliFree = std::max(aliFree, 0); + hordeFree = std::max(hordeFree, 0); + } + } + } //iterator for iterating through bg queue GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin(); //count of groups in queue - used to stop cycles - uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size(); + //index to queue which group is current uint32 aliIndex = 0; for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++) ++Ali_itr; //the same thing for horde GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin(); - uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size(); + uint32 hordeIndex = 0; for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++) ++Horde_itr; //if ofc like BG queue invitation is set in config, then we are happy - if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == 0) + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_NO_BALANCE) return; /* @@ -649,7 +676,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, Battleground uint32 j = TEAM_ALLIANCE; if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount()) j = TEAM_HORDE; - if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != 0 + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != BG_QUEUE_INVITATION_TYPE_NO_BALANCE && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers) { //we will try to invite more groups to team with less players indexed by j diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 7e8debfd24d..1509a60e15d 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -64,6 +64,13 @@ enum BattlegroundQueueGroupTypes }; #define BG_QUEUE_GROUP_TYPES_COUNT 4 +enum BattlegroundQueueInvitationType +{ + BG_QUEUE_INVITATION_TYPE_NO_BALANCE = 0, // no balance: N+M vs N players + BG_QUEUE_INVITATION_TYPE_BALANCED = 1, // teams balanced: N+1 vs N players + BG_QUEUE_INVITATION_TYPE_EVEN = 2 // teams even: N vs N players +}; + class Battleground; class BattlegroundQueue { diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index fd63dd04bf6..368ebecba84 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -66,7 +66,7 @@ void CalendarMgr::LoadFromDB() uint32 eventTime = fields[6].GetUInt32(); uint32 flags = fields[7].GetUInt32(); uint32 timezoneTime = fields[8].GetUInt32(); - uint32 guildId = 0; + ObjectGuid::LowType guildId = 0; if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) guildId = Player::GetGuildIdFromDB(creatorGUID); @@ -270,7 +270,7 @@ void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); } -void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId) +void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, ObjectGuid::LowType guildId) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) @@ -573,7 +573,7 @@ void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calend Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid); uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid); - uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); + ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); data << inviteeGuid.WriteAsPacked(); data << uint8(inviteeLevel); diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index 1027bd817f0..9969c00e3af 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -203,7 +203,7 @@ struct CalendarEvent _description = calendarEvent.GetDescription(); } - CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId, + CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, ObjectGuid::LowType guildId, CalendarEventType type, int32 dungeonId, time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) : _eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId), _eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title), @@ -220,8 +220,8 @@ struct CalendarEvent void SetCreatorGUID(ObjectGuid guid) { _creatorGUID = guid; } ObjectGuid GetCreatorGUID() const { return _creatorGUID; } - void SetGuildId(uint32 guildId) { _guildId = guildId; } - uint32 GetGuildId() const { return _guildId; } + void SetGuildId(ObjectGuid::LowType guildId) { _guildId = guildId; } + ObjectGuid::LowType GetGuildId() const { return _guildId; } void SetTitle(const std::string& title) { _title = title; } std::string GetTitle() const { return _title; } @@ -253,7 +253,7 @@ struct CalendarEvent private: uint64 _eventId; ObjectGuid _creatorGUID; - uint32 _guildId; + ObjectGuid::LowType _guildId; CalendarEventType _type; int32 _dungeonId; time_t _eventTime; @@ -316,7 +316,7 @@ class CalendarMgr void UpdateInvite(CalendarInvite* invite, SQLTransaction& trans); void RemoveAllPlayerEventsAndInvites(ObjectGuid guid); - void RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId); + void RemovePlayerGuildEventsAndSignups(ObjectGuid guid, ObjectGuid::LowType guildId); void SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType); void SendCalendarEventInvite(CalendarInvite const& invite); diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 2f003a58a69..da3055ebaaf 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -910,7 +910,7 @@ GameObject* ChatHandler::GetNearbyGameObject() return obj; } -GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry) +GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry) { if (!m_session) return NULL; @@ -1060,7 +1060,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text) } case SPELL_LINK_CREATURE: { - uint32 lowguid = atoul(idS); + ObjectGuid::LowType lowguid = atoul(idS); if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid)) return ObjectGuid(HighGuid::Unit, data->id, lowguid); @@ -1069,7 +1069,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text) } case SPELL_LINK_GAMEOBJECT: { - uint32 lowguid = atoul(idS); + ObjectGuid::LowType lowguid = atoul(idS); if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid)) return ObjectGuid(HighGuid::GameObject, data->id, lowguid); diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 72d80aba7e6..57192f948d5 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -135,7 +135,7 @@ class ChatHandler std::string GetNameLink(Player* chr) const; GameObject* GetNearbyGameObject(); - GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry); + GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry); bool HasSentErrorMessage() const { return sentErrorMessage; } void SetSentErrorMessage(bool val){ sentErrorMessage = val; } static bool LoadCommandTable() { return load_command_table; } diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 360cfdf1ae3..ca808ad15a8 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -59,14 +59,14 @@ void Corpse::RemoveFromWorld() WorldObject::RemoveFromWorld(); } -bool Corpse::Create(uint32 guidlow, Map* map) +bool Corpse::Create(ObjectGuid::LowType guidlow, Map* map) { SetMap(map); Object::_Create(guidlow, 0, HighGuid::Corpse); return true; } -bool Corpse::Create(uint32 guidlow, Player* owner) +bool Corpse::Create(ObjectGuid::LowType guidlow, Player* owner) { ASSERT(owner); @@ -149,13 +149,13 @@ void Corpse::DeleteFromDB(ObjectGuid const& ownerGuid, SQLTransaction& trans) CharacterDatabase.ExecuteOrAppend(trans, stmt); } -bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) +bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ? - uint32 ownerGuid = fields[16].GetUInt32(); + ObjectGuid::LowType ownerGuid = fields[16].GetUInt32(); float posX = fields[0].GetFloat(); float posY = fields[1].GetFloat(); float posZ = fields[2].GetFloat(); diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index eeb22a064ba..be2cb435ac9 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -55,11 +55,11 @@ class Corpse : public WorldObject, public GridObject<Corpse> void AddToWorld() override; void RemoveFromWorld() override; - bool Create(uint32 guidlow, Map* map); - bool Create(uint32 guidlow, Player* owner); + bool Create(ObjectGuid::LowType guidlow, Map* map); + bool Create(ObjectGuid::LowType guidlow, Player* owner); void SaveToDB(); - bool LoadCorpseFromDB(uint32 guid, Field* fields); + bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields); void DeleteBonesFromWorld(); void DeleteFromDB(SQLTransaction& trans); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 7fe3628f893..6a994d61852 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -138,7 +138,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(), m_lootRecipientGroup(0), _skinner(), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0), -m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE), +m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(NULL), m_creatureData(NULL), m_waypointID(0), m_path_id(0), m_formation(NULL) @@ -226,7 +226,7 @@ void Creature::SearchFormation() if (IsSummon()) return; - uint32 lowguid = GetSpawnId(); + ObjectGuid::LowType lowguid = GetSpawnId(); if (!lowguid) return; @@ -539,10 +539,44 @@ void Creature::Update(uint32 diff) LastCharmerGUID.Clear(); } + // if periodic combat pulse is enabled and we are both in combat and in a dungeon, do this now + if (m_combatPulseDelay > 0 && IsInCombat() && GetMap()->IsDungeon()) + { + if (diff > m_combatPulseTime) + m_combatPulseTime = 0; + else + m_combatPulseTime -= diff; + + if (m_combatPulseTime == 0) + { + Map::PlayerList const &players = GetMap()->GetPlayers(); + if (!players.isEmpty()) + for (Map::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it) + { + if (Player* player = it->GetSource()) + { + if (player->IsGameMaster()) + continue; + + if (player->IsAlive() && this->IsHostileTo(player)) + { + if (CanHaveThreatList()) + AddThreat(player, 0.0f); + this->SetInCombatWith(player); + player->SetInCombatWith(this); + } + } + } + + m_combatPulseTime = m_combatPulseDelay * IN_MILLISECONDS; + } + } + if (!IsInEvadeMode() && IsAIEnabled) { // do not allow the AI to be changed during update m_AI_locked = true; + i_AI->UpdateAI(diff); m_AI_locked = false; } @@ -741,7 +775,7 @@ void Creature::Motion_Initialize() GetMotionMaster()->Initialize(); } -bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) +bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) { ASSERT(map); SetMap(map); @@ -1164,7 +1198,7 @@ float Creature::GetSpellDamageMod(int32 Rank) const } } -bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) +bool Creature::CreateFromProto(ObjectGuid::LowType guidlow, uint32 entry, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) { SetZoneScript(); if (GetZoneScript() && data) @@ -1205,7 +1239,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* return true; } -bool Creature::LoadCreatureFromDB(uint32 spawnId, Map* map, bool addToMap) +bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap) { CreatureData const* data = sObjectMgr->GetCreatureData(spawnId); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 3e381063772..7744e30f122 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -317,7 +317,8 @@ struct CreatureAddon std::vector<uint32> auras; }; -typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonContainer; +typedef std::unordered_map<ObjectGuid::LowType, CreatureAddon> CreatureAddonContainer; +typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonTemplateContainer; // Vendors struct VendorItem @@ -430,12 +431,12 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void DisappearAndDie(); - bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0); + bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0); bool LoadCreaturesAddon(bool reload = false); void SelectLevel(); void LoadEquipment(int8 id = 1, bool force = false); - uint32 GetSpawnId() const { return m_spawnId; } + ObjectGuid::LowType GetSpawnId() const { return m_spawnId; } void Update(uint32 time) override; // overwrited Unit::Update void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr, float* dist =nullptr) const; @@ -529,8 +530,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void setDeathState(DeathState s) override; // override virtual Unit::setDeathState - bool LoadFromDB(uint32 spawnId, Map* map) { return LoadCreatureFromDB(spawnId, map, false); } - bool LoadCreatureFromDB(uint32 spawnId, Map* map, bool addToMap = true); + bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map) { return LoadCreatureFromDB(spawnId, map, false); } + bool LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true); void SaveToDB(); // overriden in Pet virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); @@ -601,8 +602,16 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject float GetRespawnRadius() const { return m_respawnradius; } void SetRespawnRadius(float dist) { m_respawnradius = dist; } + uint32 GetCombatPulseDelay() const { return m_combatPulseDelay; } + void SetCombatPulseDelay(uint32 delay) // (secs) interval at which the creature pulses the entire zone into combat (only works in dungeons) + { + m_combatPulseDelay = delay; + if (m_combatPulseTime == 0 || m_combatPulseTime > delay) + m_combatPulseTime = delay; + } + uint32 m_groupLootTimer; // (msecs)timer used for group loot - uint32 lootingGroupLowGUID; // used to find group which is looting corpse + ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting corpse void SendZoneUnderAttackMessage(Player* attacker); @@ -667,7 +676,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void ClearTextRepeatGroup(uint8 textGroup); protected: - bool CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* data = nullptr, uint32 vehId = 0); + bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 entry, CreatureData const* data = nullptr, uint32 vehId = 0); bool InitEntry(uint32 entry, CreatureData const* data = nullptr); // vendor items @@ -686,13 +695,15 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance float m_respawnradius; + uint32 m_combatPulseTime; // (msecs) remaining time for next zone-in-combat pulse + uint32 m_combatPulseDelay; // (secs) how often the creature puts the entire zone in combat (only works in dungeons) ReactStates m_reactState; // for AI, not charmInfo void RegenerateMana(); void RegenerateHealth(); void Regenerate(Powers power); MovementGeneratorType m_defaultMovementType; - uint32 m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid + ObjectGuid::LowType m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid uint8 m_equipmentId; int8 m_originalEquipmentId; // can be -1 diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index f29e896f050..2d353fa154e 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -30,27 +30,27 @@ FormationMgr::~FormationMgr() delete itr->second; } -void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member) +void FormationMgr::AddCreatureToGroup(uint32 leaderGuid, Creature* creature) { - Map* map = member->FindMap(); + Map* map = creature->FindMap(); if (!map) return; - CreatureGroupHolderType::iterator itr = map->CreatureGroupHolder.find(groupId); + CreatureGroupHolderType::iterator itr = map->CreatureGroupHolder.find(leaderGuid); //Add member to an existing group if (itr != map->CreatureGroupHolder.end()) { - TC_LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", groupId, member->GetGUID().GetCounter(), member->GetInstanceId()); - itr->second->AddMember(member); + TC_LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", leaderGuid, creature->GetGUID().GetCounter(), creature->GetInstanceId()); + itr->second->AddMember(creature); } //Create new group else { - TC_LOG_DEBUG("entities.unit", "Group not found: %u. Creating new group.", groupId); - CreatureGroup* group = new CreatureGroup(groupId); - map->CreatureGroupHolder[groupId] = group; - group->AddMember(member); + TC_LOG_DEBUG("entities.unit", "Group not found: %u. Creating new group.", leaderGuid); + CreatureGroup* group = new CreatureGroup(leaderGuid); + map->CreatureGroupHolder[leaderGuid] = group; + group->AddMember(creature); } } diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index 714a0a35caf..3d92f9e18cf 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -79,7 +79,7 @@ void DynamicObject::RemoveFromWorld() } } -bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type) +bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type) { SetMap(caster->GetMap()); Relocate(pos); diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index f850573ec5a..44c771c77c4 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -41,7 +41,7 @@ class DynamicObject : public WorldObject, public GridObject<DynamicObject>, publ void AddToWorld() override; void RemoveFromWorld() override; - bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); + bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); void Update(uint32 p_time) override; void Remove(); void SetDuration(int32 newDuration); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 42ed4674a53..c1ec2294c3d 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -167,7 +167,7 @@ void GameObject::RemoveFromWorld() } } -bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit) +bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit) { ASSERT(map); SetMap(map); @@ -815,7 +815,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) WorldDatabase.CommitTransaction(trans); } -bool GameObject::LoadGameObjectFromDB(uint32 spawnId, Map* map, bool addToMap) +bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap) { GameObjectData const* data = sObjectMgr->GetGOData(spawnId); @@ -1152,7 +1152,7 @@ void GameObject::SetGoArtKit(uint8 kit) data->artKit = kit; } -void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid) +void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid) { const GameObjectData* data = NULL; if (go) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index b91f1b6eeee..a744efbe1e3 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -652,7 +652,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void RemoveFromWorld() override; void CleanupsBeforeDelete(bool finalCleanup = true) override; - bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0); + bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0); void Update(uint32 p_time) override; GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectData const* GetGOData() const { return m_goData; } @@ -662,7 +662,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool IsDynTransport() const; bool IsDestructibleBuilding() const; - uint32 GetSpawnId() const { return m_spawnId; } + ObjectGuid::LowType GetSpawnId() const { return m_spawnId; } void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f); @@ -671,8 +671,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); - bool LoadFromDB(uint32 spawnId, Map* map) { return LoadGameObjectFromDB(spawnId, map, false); } - bool LoadGameObjectFromDB(uint32 spawnId, Map* map, bool addToMap = true); + bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map) { return LoadGameObjectFromDB(spawnId, map, false); } + bool LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true); void DeleteFromDB(); void SetOwnerGUID(ObjectGuid owner) @@ -733,7 +733,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void SetGoArtKit(uint8 artkit); uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); } void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); } - static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0); + static void SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid = 0); void SetPhaseMask(uint32 newPhaseMask, bool update) override; void EnableCollision(bool enable); @@ -751,10 +751,10 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; } void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; } - void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } - bool IsInSkillupList(uint32 PlayerGuidLow) const + void AddToSkillupList(ObjectGuid::LowType PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } + bool IsInSkillupList(ObjectGuid::LowType PlayerGuidLow) const { - for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i) + for (std::list<ObjectGuid::LowType>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i) if (*i == PlayerGuidLow) return true; @@ -778,7 +778,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool IsLootAllowedFor(Player const* player) const; bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; } uint32 m_groupLootTimer; // (msecs)timer used for group loot - uint32 lootingGroupLowGUID; // used to find group which is looting + ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting bool hasQuest(uint32 quest_id) const override; bool hasInvolvedQuest(uint32 quest_id) const override; @@ -861,7 +861,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool m_spawnedByDefault; time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction). // For traps this: spell casting cooldown, for doors/buttons: reset time. - std::list<uint32> m_SkillupList; + std::list<ObjectGuid::LowType> m_SkillupList; ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) GuidSet m_unique_users; @@ -870,7 +870,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map typedef std::map<uint32, ObjectGuid> ChairSlotAndUser; ChairSlotAndUser ChairListSlots; - uint32 m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid + ObjectGuid::LowType m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid GameObjectTemplate const* m_goInfo; GameObjectData const* m_goData; GameObjectValue m_goValue; diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp index 69a77dd9213..1d2fd9b2804 100644 --- a/src/server/game/Entities/Item/Container/Bag.cpp +++ b/src/server/game/Entities/Item/Container/Bag.cpp @@ -69,7 +69,7 @@ void Bag::RemoveFromWorld() Item::RemoveFromWorld(); } -bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) +bool Bag::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) { ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid); @@ -109,7 +109,7 @@ void Bag::SaveToDB(SQLTransaction& trans) Item::SaveToDB(trans); } -bool Bag::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) +bool Bag::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) { if (!Item::LoadFromDB(guid, owner_guid, fields, entry)) return false; diff --git a/src/server/game/Entities/Item/Container/Bag.h b/src/server/game/Entities/Item/Container/Bag.h index 11bff67855d..ead059030b6 100644 --- a/src/server/game/Entities/Item/Container/Bag.h +++ b/src/server/game/Entities/Item/Container/Bag.h @@ -35,7 +35,7 @@ class Bag : public Item void AddToWorld() override; void RemoveFromWorld() override; - bool Create(uint32 guidlow, uint32 itemid, Player const* owner) override; + bool Create(ObjectGuid::LowType guidlow, ObjectGuid::LowType itemid, Player const* owner) override; void Clear(); void StoreItem(uint8 slot, Item* pItem, bool update); @@ -54,7 +54,7 @@ class Bag : public Item // overwrite virtual Item::SaveToDB void SaveToDB(SQLTransaction& trans) override; // overwrite virtual Item::LoadFromDB - bool LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override; + bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override; // overwrite virtual Item::DeleteFromDB void DeleteFromDB(SQLTransaction& trans) override; diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index f5eb9972af5..9a6af376e6d 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -255,7 +255,7 @@ Item::Item() m_paidExtendedCost = 0; } -bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) +bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) { Object::_Create(guidlow, 0, HighGuid::Item); @@ -317,7 +317,7 @@ void Item::SaveToDB(SQLTransaction& trans) if (!isInTransaction) trans = CharacterDatabase.BeginTransaction(); - uint32 guid = GetGUID().GetCounter(); + ObjectGuid::LowType guid = GetGUID().GetCounter(); switch (uState) { case ITEM_NEW: @@ -398,7 +398,7 @@ void Item::SaveToDB(SQLTransaction& trans) CharacterDatabase.CommitTransaction(trans); } -bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) +bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) { // 0 1 2 3 4 5 6 7 8 9 10 //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid); @@ -480,7 +480,7 @@ bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 } /*static*/ -void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid) +void Item::DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt->setUInt32(0, itemGuid); @@ -497,7 +497,7 @@ void Item::DeleteFromDB(SQLTransaction& trans) } /*static*/ -void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid) +void Item::DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); stmt->setUInt32(0, itemGuid); @@ -1254,7 +1254,7 @@ void Item::ItemContainerSaveLootToDB() if (loot.isLooted()) // no money and no loot return; - uint32 container_id = GetGUID().GetCounter(); + ObjectGuid::LowType container_id = GetGUID().GetCounter(); SQLTransaction trans = CharacterDatabase.BeginTransaction(); loot.containerID = container_id; // Save this for when a LootItem is removed @@ -1322,7 +1322,7 @@ bool Item::ItemContainerLoadLootFromDB() // Default. If there are no records for this item then it will be rolled for in Player::SendLoot() m_lootGenerated = false; - uint32 container_id = GetGUID().GetCounter(); + ObjectGuid::LowType container_id = GetGUID().GetCounter(); // Save this for later use loot.containerID = container_id; @@ -1398,7 +1398,7 @@ bool Item::ItemContainerLoadLootFromDB() void Item::ItemContainerDeleteLootItemsFromDB() { // Deletes items associated with an openable item from the DB - uint32 containerId = GetGUID().GetCounter(); + ObjectGuid::LowType containerId = GetGUID().GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS); stmt->setUInt32(0, containerId); SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -1409,7 +1409,7 @@ void Item::ItemContainerDeleteLootItemsFromDB() void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID) { // Deletes a single item associated with an openable item from the DB - uint32 containerId = GetGUID().GetCounter(); + ObjectGuid::LowType containerId = GetGUID().GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM); stmt->setUInt32(0, containerId); stmt->setUInt32(1, itemID); @@ -1421,7 +1421,7 @@ void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID) void Item::ItemContainerDeleteLootMoneyFromDB() { // Deletes the money loot associated with an openable item from the DB - uint32 containerId = GetGUID().GetCounter(); + ObjectGuid::LowType containerId = GetGUID().GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); stmt->setUInt32(0, containerId); SQLTransaction trans = CharacterDatabase.BeginTransaction(); diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index ad74906b4c9..a268334b212 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -211,7 +211,7 @@ class Item : public Object Item(); - virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner); + virtual bool Create(ObjectGuid::LowType guidlow, ObjectGuid::LowType itemid, Player const* owner); ItemTemplate const* GetTemplate() const; @@ -225,10 +225,10 @@ class Item : public Object bool IsBindedNotWith(Player const* player) const; bool IsBoundByEnchant() const; virtual void SaveToDB(SQLTransaction& trans); - virtual bool LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry); - static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid); + virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry); + static void DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); virtual void DeleteFromDB(SQLTransaction& trans); - static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid); + static void DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); // Lootable items and their contents void ItemContainerSaveLootToDB(); @@ -331,7 +331,7 @@ class Item : public Object // Item Refund system void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = NULL); - void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; } + void SetRefundRecipient(ObjectGuid::LowType pGuidLow) { m_refundRecipient = pGuidLow; } void SetPaidMoney(uint32 money) { m_paidMoney = money; } void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; } @@ -362,7 +362,7 @@ class Item : public Object int16 uQueuePos; bool mb_in_trade; // true if item is currently in trade-window time_t m_lastPlayedTimeUpdate; - uint32 m_refundRecipient; + ObjectGuid::LowType m_refundRecipient; uint32 m_paidMoney; uint32 m_paidExtendedCost; AllowedLooterSet allowedGUIDs; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 21a65440a55..e4d9e61bca3 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -103,7 +103,7 @@ void Object::_InitValues() m_objectUpdated = false; } -void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) +void Object::_Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh) { if (!m_uint32Values) _InitValues(); @@ -1066,7 +1066,7 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/) transport->RemovePassenger(this); } -void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask) +void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask) { Object::_Create(guidlow, 0, guidhigh); m_phaseMask = phaseMask; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 43d1ecdeabd..c9e3d069218 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -204,7 +204,7 @@ class Object Object(); void _InitValues(); - void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh); + void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh); std::string _ConcatFields(uint16 startIndex, uint16 size) const; void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count); @@ -431,7 +431,7 @@ class WorldObject : public Object, public WorldLocation virtual void Update (uint32 /*time_diff*/) { } - void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask); + void _Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask); virtual void RemoveFromWorld() override; void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const; diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index 705cc3eac3e..697ee3835f6 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -154,14 +154,14 @@ class ObjectGuid : LowType(_guid & UI64LIT(0x00000000FFFFFFFF)); } - static uint32 GetMaxCounter(HighGuid high) + static LowType GetMaxCounter(HighGuid high) { return HasEntry(high) - ? uint32(0x00FFFFFF) - : uint32(0xFFFFFFFF); + ? LowType(0x00FFFFFF) + : LowType(0xFFFFFFFF); } - uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); } + ObjectGuid::LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); } bool IsEmpty() const { return _guid == 0; } bool IsCreature() const { return GetHigh() == HighGuid::Unit; } @@ -283,13 +283,13 @@ class ObjectGuidGeneratorBase public: ObjectGuidGeneratorBase(ObjectGuid::LowType start = 1) : _nextGuid(start) { } - virtual void Set(uint32 val) { _nextGuid = val; } + virtual void Set(ObjectGuid::LowType val) { _nextGuid = val; } virtual ObjectGuid::LowType Generate() = 0; ObjectGuid::LowType GetNextAfterMaxUsed() const { return _nextGuid; } protected: static void HandleCounterOverflow(HighGuid high); - uint64 _nextGuid; + ObjectGuid::LowType _nextGuid; }; template<HighGuid high> diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 57fc56af89c..0121194e327 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -98,7 +98,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c { m_loading = true; - uint32 ownerid = owner->GetGUID().GetCounter(); + ObjectGuid::LowType ownerid = owner->GetGUID().GetCounter(); PreparedStatement* stmt; PreparedQueryResult result; @@ -174,7 +174,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c } Map* map = owner->GetMap(); - uint32 guid = map->GenerateLowGuid<HighGuid::Pet>(); + ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>(); if (!Create(guid, map, owner->GetPhaseMask(), petEntry, petId)) return false; @@ -415,7 +415,7 @@ void Pet::SavePetToDB(PetSaveMode mode) // current/stable/not_in_slot if (mode >= PET_SAVE_AS_CURRENT) { - uint32 ownerLowGUID = GetOwnerGUID().GetCounter(); + ObjectGuid::LowType ownerLowGUID = GetOwnerGUID().GetCounter(); std::string name = m_name; CharacterDatabase.EscapeString(name); trans = CharacterDatabase.BeginTransaction(); @@ -485,7 +485,7 @@ void Pet::SavePetToDB(PetSaveMode mode) } } -void Pet::DeleteFromDB(uint32 guidlow) +void Pet::DeleteFromDB(ObjectGuid::LowType guidlow) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -807,7 +807,7 @@ bool Pet::CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner) bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask) { TC_LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed"); - uint32 guid=map->GenerateLowGuid<HighGuid::Pet>(); + ObjectGuid::LowType guid=map->GenerateLowGuid<HighGuid::Pet>(); uint32 petId = sObjectMgr->GeneratePetNumber(); if (!Create(guid, map, phaseMask, cinfo->Entry, petId)) return false; @@ -1835,7 +1835,7 @@ bool Pet::IsPermanentPetFor(Player* owner) const } } -bool Pet::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 petId) +bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 petId) { ASSERT(map); SetMap(map); diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index e47bf220195..85c1f83d4a7 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -55,7 +55,7 @@ class Pet : public Guardian bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER - bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); + bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner); bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask); @@ -63,7 +63,7 @@ class Pet : public Guardian bool IsLoading() const override { return m_loading;} void SavePetToDB(PetSaveMode mode); void Remove(PetSaveMode mode, bool returnreagent = false); - static void DeleteFromDB(uint32 guidlow); + static void DeleteFromDB(ObjectGuid::LowType guidlow); void setDeathState(DeathState s) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 7d817a18bc6..9737940dc14 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -504,7 +504,7 @@ inline void KillRewarder::_InitXP(Player* player) // * otherwise, not in PvP; // * not if killer is on vehicle. if (_isBattleGround || (!_isPvP && !_killer->GetVehicle())) - _xp = Trinity::XP::Gain(player, _victim); + _xp = Trinity::XP::Gain(player, _victim, _isBattleGround); } inline void KillRewarder::_RewardHonor(Player* player) @@ -957,7 +957,7 @@ void Player::CleanupsBeforeDelete(bool finalCleanup) itr->second.save->RemovePlayer(this); } -bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) +bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo) { //FIXME: outfitId not used in player creating /// @todo need more checks against packet modifications @@ -1961,7 +1961,7 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint8 plrRace = fields[2].GetUInt8(); uint8 plrClass = fields[3].GetUInt8(); uint8 gender = fields[4].GetUInt8(); @@ -3416,7 +3416,7 @@ void Player::RemoveMail(uint32 id) } } -void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, uint32 item_guid, uint32 item_count) +void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count) { WorldPacket data(SMSG_SEND_MAIL_RESULT, (4+4+4+(mailError == MAIL_ERR_EQUIP_ERROR?4:(mailAction == MAIL_ITEM_TAKEN?4+4:0)))); data << (uint32) mailId; @@ -4523,7 +4523,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe updateRealmChars = false; // Convert guid to low GUID for CharacterNameData, but also other methods on success - uint32 guid = playerguid.GetCounter(); + ObjectGuid::LowType guid = playerguid.GetCounter(); uint32 charDelete_method = sWorld->getIntConfig(CONFIG_CHARDELETE_METHOD); if (deleteFinally) @@ -4539,7 +4539,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe charDelete_method = CHAR_DELETE_REMOVE; } - if (uint32 guildId = GetGuildIdFromDB(playerguid)) + if (ObjectGuid::LowType guildId = GetGuildIdFromDB(playerguid)) if (Guild* guild = sGuildMgr->GetGuildById(guildId)) guild->DeleteMember(playerguid, false, false, true); @@ -4617,7 +4617,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe do { Field* itemFields = resultItems->Fetch(); - uint32 item_guidlow = itemFields[11].GetUInt32(); + ObjectGuid::LowType item_guidlow = itemFields[11].GetUInt32(); uint32 item_template = itemFields[12].GetUInt32(); ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template); @@ -4664,7 +4664,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe { do { - uint32 petguidlow = (*resultPets)[0].GetUInt32(); + ObjectGuid::LowType petguidlow = (*resultPets)[0].GetUInt32(); Pet::DeleteFromDB(petguidlow); } while (resultPets->NextRow()); } @@ -7232,7 +7232,7 @@ void Player::ModifyArenaPoints(int32 value, SQLTransaction trans) } } -uint32 Player::GetGuildIdFromDB(ObjectGuid guid) +ObjectGuid::LowType Player::GetGuildIdFromDB(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); stmt->setUInt32(0, guid.GetCounter()); @@ -7286,7 +7286,7 @@ uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, uint8 type) uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { - uint32 guidLow = guid.GetCounter(); + ObjectGuid::LowType guidLow = guid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_ZONE); stmt->setUInt32(0, guidLow); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -16890,7 +16890,7 @@ bool Player::HasPvPForcingQuest() const /*** LOAD SYSTEM ***/ /*********************************************************/ -void Player::Initialize(uint32 guid) +void Player::Initialize(ObjectGuid::LowType guid) { Object::_Create(guid, 0, HighGuid::Player); } @@ -17213,7 +17213,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) InitPrimaryProfessions(); // to max set before any spell loaded // init saved position, and fix it later if problematic - uint32 transLowGUID = fields[30].GetUInt32(); + ObjectGuid::LowType transLowGUID = fields[30].GetUInt32(); Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat()); uint32 mapId = fields[15].GetUInt16(); uint32 instanceId = fields[58].GetUInt32(); @@ -17965,8 +17965,8 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { uint32 zoneId = GetZoneId(); - std::map<uint32, Bag*> bagMap; // fast guid lookup for bags - std::map<uint32, Item*> invalidBagMap; // fast guid lookup for bags + std::map<ObjectGuid::LowType, Bag*> bagMap; // fast guid lookup for bags + std::map<ObjectGuid::LowType, Item*> invalidBagMap; // fast guid lookup for bags std::list<Item*> problematicItems; SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -17977,7 +17977,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) Field* fields = result->Fetch(); if (Item* item = _LoadItem(trans, zoneId, timeDiff, fields)) { - uint32 bagGuid = fields[11].GetUInt32(); + ObjectGuid::LowType bagGuid = fields[11].GetUInt32(); uint8 slot = fields[12].GetUInt8(); uint8 err = EQUIP_ERR_OK; @@ -18025,7 +18025,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { item->SetSlot(NULL_SLOT); // Item is in the bag, find the bag - std::map<uint32, Bag*>::iterator itr = bagMap.find(bagGuid); + std::map<ObjectGuid::LowType, Bag*>::iterator itr = bagMap.find(bagGuid); if (itr != bagMap.end()) { ItemPosCountVec dest; @@ -18035,7 +18035,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) } else if (invalidBagMap.find(bagGuid) != invalidBagMap.end()) { - std::map<uint32, Item*>::iterator invalidBagItr = invalidBagMap.find(bagGuid); + std::map<ObjectGuid::LowType, Item*>::iterator invalidBagItr = invalidBagMap.find(bagGuid); if (std::find(problematicItems.begin(), problematicItems.end(), invalidBagItr->second) != problematicItems.end()) err = EQUIP_ERR_INT_BAG_ERROR; } @@ -18087,7 +18087,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields) { Item* item = NULL; - uint32 itemGuid = fields[13].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[13].GetUInt32(); uint32 itemEntry = fields[14].GetUInt32(); if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry)) { @@ -18225,7 +18225,7 @@ void Player::_LoadMailedItems(Mail* mail) { Field* fields = result->Fetch(); - uint32 itemGuid = fields[11].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[11].GetUInt32(); uint32 itemTemplate = fields[12].GetUInt32(); mail->AddItem(itemGuid, itemTemplate); @@ -19152,7 +19152,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setFloat(index++, finiteAlways(GetTransOffsetY())); stmt->setFloat(index++, finiteAlways(GetTransOffsetZ())); stmt->setFloat(index++, finiteAlways(GetTransOffsetO())); - uint32 transLowGUID = 0; + ObjectGuid::LowType transLowGUID = 0; if (GetTransport()) transLowGUID = GetTransport()->GetGUID().GetCounter(); stmt->setUInt32(index++, transLowGUID); @@ -19272,7 +19272,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setFloat(index++, finiteAlways(GetTransOffsetY())); stmt->setFloat(index++, finiteAlways(GetTransOffsetZ())); stmt->setFloat(index++, finiteAlways(GetTransOffsetO())); - uint32 transLowGUID = 0; + ObjectGuid::LowType transLowGUID = 0; if (GetTransport()) transLowGUID = GetTransport()->GetGUID().GetCounter(); stmt->setUInt32(index++, transLowGUID); @@ -19568,7 +19568,7 @@ void Player::_SaveInventory(SQLTransaction& trans) if (m_itemUpdateQueue.empty()) return; - uint32 lowGuid = GetGUID().GetCounter(); + ObjectGuid::LowType lowGuid = GetGUID().GetCounter(); for (size_t i = 0; i < m_itemUpdateQueue.size(); ++i) { Item* item = m_itemUpdateQueue[i]; @@ -19576,14 +19576,14 @@ void Player::_SaveInventory(SQLTransaction& trans) continue; Bag* container = item->GetContainer(); - uint32 bag_guid = container ? container->GetGUID().GetCounter() : 0; + ObjectGuid::LowType bag_guid = container ? container->GetGUID().GetCounter() : 0; if (item->GetState() != ITEM_REMOVED) { Item* test = GetItemByPos(item->GetBagSlot(), item->GetSlot()); if (test == NULL) { - uint32 bagTestGUID = 0; + ObjectGuid::LowType bagTestGUID = 0; if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot())) bagTestGUID = test2->GetGUID().GetCounter(); TC_LOG_ERROR("entities.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->GetGUID().GetCounter(), (int32)item->GetState()); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index e62673855b9..17176786085 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1117,7 +1117,7 @@ class Player : public Unit, public GridObject<Player> void SetSummonPoint(uint32 mapid, float x, float y, float z); void SummonIfPossible(bool agree); - bool Create(uint32 guidlow, CharacterCreateInfo* createInfo); + bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo); void Update(uint32 time) override; @@ -1483,7 +1483,7 @@ class Player : public Unit, public GridObject<Player> bool LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder); bool IsLoading() const override; - void Initialize(uint32 guid); + void Initialize(ObjectGuid::LowType guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); static float GetFloatValueFromArray(Tokenizer const& data, uint16 index); static uint32 GetZoneIdFromDB(ObjectGuid guid); @@ -1549,7 +1549,7 @@ class Player : public Unit, public GridObject<Player> void ClearComboPoints(); void SendComboPoints(); - void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0); + void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0); void SendNewMail(); void UpdateNextMailTimeAndUnreads(); void AddNewMailDeliverTime(time_t deliver_time); @@ -1715,7 +1715,7 @@ class Player : public Unit, public GridObject<Player> void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } Guild* GetGuild(); - static uint32 GetGuildIdFromDB(ObjectGuid guid); + static ObjectGuid::LowType GetGuildIdFromDB(ObjectGuid guid); static uint8 GetRankFromDB(ObjectGuid guid); int GetGuildIdInvited() const { return m_GuildIdInvited; } static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type); diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index e7989c405a8..b65584a4357 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -40,7 +40,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) return counter; } -bool PlayerSocial::AddToSocialList(uint32 friendGuid, bool ignore) +bool PlayerSocial::AddToSocialList(ObjectGuid::LowType friendGuid, bool ignore) { // check client limits if (ignore) @@ -88,7 +88,7 @@ bool PlayerSocial::AddToSocialList(uint32 friendGuid, bool ignore) return true; } -void PlayerSocial::RemoveFromSocialList(uint32 friendGuid, bool ignore) +void PlayerSocial::RemoveFromSocialList(ObjectGuid::LowType friendGuid, bool ignore) { PlayerSocialMap::iterator itr = m_playerSocialMap.find(friendGuid); if (itr == m_playerSocialMap.end()) // not exist @@ -122,7 +122,7 @@ void PlayerSocial::RemoveFromSocialList(uint32 friendGuid, bool ignore) } } -void PlayerSocial::SetFriendNote(uint32 friendGuid, std::string note) +void PlayerSocial::SetFriendNote(ObjectGuid::LowType friendGuid, std::string note) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid); if (itr == m_playerSocialMap.end()) // not exist @@ -175,7 +175,7 @@ void PlayerSocial::SendSocialList(Player* player) TC_LOG_DEBUG("network", "WORLD: Sent SMSG_CONTACT_LIST"); } -bool PlayerSocial::HasFriend(uint32 friendGuid) +bool PlayerSocial::HasFriend(ObjectGuid::LowType friendGuid) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid); if (itr != m_playerSocialMap.end()) @@ -183,7 +183,7 @@ bool PlayerSocial::HasFriend(uint32 friendGuid) return false; } -bool PlayerSocial::HasIgnore(uint32 ignore_guid) +bool PlayerSocial::HasIgnore(ObjectGuid::LowType ignore_guid) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(ignore_guid); if (itr != m_playerSocialMap.end()) @@ -195,7 +195,7 @@ SocialMgr::SocialMgr() { } SocialMgr::~SocialMgr() { } -void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo) +void SocialMgr::GetFriendInfo(Player* player, ObjectGuid::LowType friendGUID, FriendInfo &friendInfo) { if (!player) return; @@ -239,14 +239,14 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri } } -void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data) +void SocialMgr::MakeFriendStatusPacket(FriendsResult result, ObjectGuid::LowType guid, WorldPacket* data) { data->Initialize(SMSG_FRIEND_STATUS, 9); *data << uint8(result); *data << uint64(guid); } -void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friendGuid, bool broadcast) +void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid::LowType friendGuid, bool broadcast) { FriendInfo fi; @@ -310,7 +310,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) } } -PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) +PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid::LowType guid) { PlayerSocial *social = &m_socialMap[guid]; social->SetPlayerGUID(guid); @@ -318,7 +318,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) if (!result) return social; - uint32 friendGuid = 0; + ObjectGuid::LowType friendGuid = 0; uint8 flags = 0; std::string note = ""; diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 5bf336a9abe..887b5de58df 100644 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -21,6 +21,7 @@ #include "DatabaseEnv.h" #include "Common.h" +#include "ObjectGuid.h" class SocialMgr; class PlayerSocial; @@ -60,8 +61,8 @@ struct FriendInfo { } }; -typedef std::map<uint32, FriendInfo> PlayerSocialMap; -typedef std::map<uint32, PlayerSocial> SocialMap; +typedef std::map<ObjectGuid::LowType, FriendInfo> PlayerSocialMap; +typedef std::map<ObjectGuid::LowType, PlayerSocial> SocialMap; /// Results of friend related commands enum FriendsResult @@ -104,20 +105,20 @@ class PlayerSocial public: PlayerSocial(); // adding/removing - bool AddToSocialList(uint32 friend_guid, bool ignore); - void RemoveFromSocialList(uint32 friend_guid, bool ignore); - void SetFriendNote(uint32 friendGuid, std::string note); + bool AddToSocialList(ObjectGuid::LowType friendGuid, bool ignore); + void RemoveFromSocialList(ObjectGuid::LowType friend_guid, bool ignore); + void SetFriendNote(ObjectGuid::LowType friendGuid, std::string note); // Packet send's void SendSocialList(Player* player); // Misc - bool HasFriend(uint32 friend_guid); - bool HasIgnore(uint32 ignore_guid); - uint32 GetPlayerGUID() const { return m_playerGUID; } - void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; } + bool HasFriend(ObjectGuid::LowType friend_guid); + bool HasIgnore(ObjectGuid::LowType ignore_guid); + ObjectGuid::LowType GetPlayerGUID() const { return m_playerGUID; } + void SetPlayerGUID(ObjectGuid::LowType guid) { m_playerGUID = guid; } uint32 GetNumberOfSocialsWithFlag(SocialFlag flag); private: PlayerSocialMap m_playerSocialMap; - uint32 m_playerGUID; + ObjectGuid::LowType m_playerGUID; }; class SocialMgr @@ -134,15 +135,15 @@ class SocialMgr } // Misc - void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); } + void RemovePlayerSocial(ObjectGuid::LowType guid) { m_socialMap.erase(guid); } - void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo); + void GetFriendInfo(Player* player, ObjectGuid::LowType friendGUID, FriendInfo &friendInfo); // Packet management - void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data); - void SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast); + void MakeFriendStatusPacket(FriendsResult result, ObjectGuid::LowType friend_guid, WorldPacket* data); + void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid::LowType friend_guid, bool broadcast); void BroadcastToFriendListers(Player* player, WorldPacket* packet); // Loading - PlayerSocial *LoadFromDB(PreparedQueryResult result, uint32 guid); + PlayerSocial *LoadFromDB(PreparedQueryResult result, ObjectGuid::LowType guid); private: SocialMap m_socialMap; }; diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 144805b88b5..99459dce81e 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -43,7 +43,7 @@ Transport::~Transport() UnloadStaticPassengers(); } -bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress) +bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress) { Relocate(x, y, z, ang); @@ -281,7 +281,7 @@ void Transport::RemovePassenger(WorldObject* passenger) } } -Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data) +Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data) { Map* map = GetMap(); Creature* creature = new Creature(); @@ -328,7 +328,7 @@ Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data) return creature; } -GameObject* Transport::CreateGOPassenger(uint32 guid, GameObjectData const* data) +GameObject* Transport::CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data) { Map* map = GetMap(); GameObject* go = new GameObject(); diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index c56ceb1696d..3a2d0e4a7bd 100644 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -27,7 +27,7 @@ struct CreatureData; class Transport : public GameObject, public TransportBase { - friend Transport* TransportMgr::CreateTransport(uint32, uint32, Map*); + friend Transport* TransportMgr::CreateTransport(uint32, ObjectGuid::LowType, Map*); Transport(); public: @@ -35,7 +35,7 @@ class Transport : public GameObject, public TransportBase ~Transport(); - bool Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress); + bool Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress); void CleanupsBeforeDelete(bool finalCleanup = true) override; void Update(uint32 diff) override; @@ -47,8 +47,8 @@ class Transport : public GameObject, public TransportBase void RemovePassenger(WorldObject* passenger); PassengerSet const& GetPassengers() const { return _passengers; } - Creature* CreateNPCPassenger(uint32 guid, CreatureData const* data); - GameObject* CreateGOPassenger(uint32 guid, GameObjectData const* data); + Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data); + GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data); /** * @fn bool Transport::SummonPassenger(uint64, Position const&, TempSummonType, SummonPropertiesEntry const*, uint32, Unit*, uint32, uint32) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f085bab165a..9ced65b56c7 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3908,20 +3908,27 @@ void Unit::RemoveAurasWithAttribute(uint32 flags) void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) { // single target auras from other casters - for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) + // Iterate m_ownedAuras - aura is marked as single target in Unit::AddAura (and pushed to m_ownedAuras). + // m_appliedAuras will NOT contain the aura before first Unit::Update after adding it to m_ownedAuras. + // Quickly removing such an aura will lead to it not being unregistered from caster's single cast auras container + // leading to assertion failures if the aura was cast on a player that can + // (and is changing map at the point where this function is called). + // Such situation occurs when player is logging in inside an instance and fails the entry check for any reason. + // The aura that was loaded from db (indirectly, via linked casts) gets removed before it has a chance + // to register in m_appliedAuras + for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();) { - AuraApplication const* aurApp = iter->second; - Aura const* aura = aurApp->GetBase(); + Aura const* aura = iter->second; - if (aura->GetCasterGUID() != GetGUID() && aura->GetSpellInfo()->IsSingleTarget()) + if (aura->GetCasterGUID() != GetGUID() && aura->IsSingleTarget()) { if (!newPhase) - RemoveAura(iter); + RemoveOwnedAura(iter); else { Unit* caster = aura->GetCaster(); if (!caster || !caster->InSamePhase(newPhase)) - RemoveAura(iter); + RemoveOwnedAura(iter); else ++iter; } diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 8f2d0491a91..9e5e7ff9990 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -371,7 +371,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); int16 event_id = fields[1].GetInt8(); int32 internal_event_id = mGameEvent.size() + event_id - 1; @@ -417,7 +417,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); int16 event_id = fields[1].GetInt8(); int32 internal_event_id = mGameEvent.size() + event_id - 1; @@ -463,7 +463,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); uint16 event_id = fields[2].GetUInt8(); @@ -712,7 +712,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint16 event_id = fields[1].GetUInt8(); uint32 npcflag = fields[2].GetUInt32(); @@ -798,7 +798,7 @@ void GameEventMgr::LoadFromDB() NPCVendorList& vendors = mGameEventVendors[event_id]; NPCVendorEntry newEntry; - uint32 guid = fields[1].GetUInt32(); + ObjectGuid::LowType guid = fields[1].GetUInt32(); newEntry.item = fields[2].GetUInt32(); newEntry.maxcount = fields[3].GetUInt32(); newEntry.incrtime = fields[4].GetUInt32(); @@ -917,7 +917,7 @@ void GameEventMgr::LoadFromDB() uint32 GameEventMgr::GetNPCFlag(Creature* cr) { uint32 mask = 0; - uint32 guid = cr->GetSpawnId(); + ObjectGuid::LowType guid = cr->GetSpawnId(); for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { @@ -1400,7 +1400,7 @@ bool GameEventMgr::hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 e } return false; } -bool GameEventMgr::hasCreatureActiveEventExcept(uint32 creature_id, uint16 event_id) +bool GameEventMgr::hasCreatureActiveEventExcept(ObjectGuid::LowType creature_id, uint16 event_id) { for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { @@ -1416,7 +1416,7 @@ bool GameEventMgr::hasCreatureActiveEventExcept(uint32 creature_id, uint16 event } return false; } -bool GameEventMgr::hasGameObjectActiveEventExcept(uint32 go_id, uint16 event_id) +bool GameEventMgr::hasGameObjectActiveEventExcept(ObjectGuid::LowType go_id, uint16 event_id) { for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index eb29e463a4d..57f30eb4015 100644 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -20,6 +20,7 @@ #define TRINITY_GAMEEVENT_MGR_H #include "Common.h" +#include "ObjectGuid.h" #include "SharedDefines.h" #include "Define.h" @@ -144,14 +145,14 @@ class GameEventMgr void SaveWorldEventStateToDB(uint16 event_id); bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); - bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id); - bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id); + bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id); + bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id); - typedef std::list<uint32> GuidList; + typedef std::list<ObjectGuid::LowType> GuidList; typedef std::list<uint32> IdList; typedef std::vector<GuidList> GameEventGuidMap; typedef std::vector<IdList> GameEventIdMap; - typedef std::pair<uint32, ModelEquip> ModelEquipPair; + typedef std::pair<ObjectGuid::LowType, ModelEquip> ModelEquipPair; typedef std::list<ModelEquipPair> ModelEquipList; typedef std::vector<ModelEquipList> GameEventModelEquipMap; typedef std::pair<uint32, uint32> QuestRelation; @@ -160,7 +161,7 @@ class GameEventMgr typedef std::list<NPCVendorEntry> NPCVendorList; typedef std::vector<NPCVendorList> GameEventNPCVendorMap; typedef std::map<uint32 /*quest id*/, GameEventQuestToEventConditionNum> QuestIdToEventConditionMap; - typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; + typedef std::pair<ObjectGuid::LowType /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; typedef std::list<GuidNPCFlagPair> NPCFlagList; typedef std::vector<NPCFlagList> GameEventNPCFlagMap; typedef std::vector<uint32> GameEventBitmask; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b5d8d08a6a4..db352ec80dd 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -961,7 +961,7 @@ void ObjectMgr::LoadCreatureAddons() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); CreatureData const* creData = GetCreatureData(guid); if (!creData) @@ -1084,7 +1084,7 @@ GameObjectAddon const* ObjectMgr::GetGameObjectAddon(ObjectGuid::LowType lowguid return NULL; } -CreatureAddon const* ObjectMgr::GetCreatureAddon(uint32 lowguid) +CreatureAddon const* ObjectMgr::GetCreatureAddon(ObjectGuid::LowType lowguid) { CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid); if (itr != _creatureAddonStore.end()) @@ -1338,8 +1338,8 @@ void ObjectMgr::LoadLinkedRespawn() { Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); - uint32 linkedGuidLow = fields[1].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType linkedGuidLow = fields[1].GetUInt32(); uint8 linkType = fields[2].GetUInt8(); ObjectGuid guid, linkedGuid; @@ -1504,7 +1504,7 @@ void ObjectMgr::LoadLinkedRespawn() TC_LOG_INFO("server.loading", ">> Loaded " UI64FMTD " linked respawns in %u ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime)); } -bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow) +bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid::LowType linkedGuidLow) { if (!guidLow) return false; @@ -1672,7 +1672,7 @@ void ObjectMgr::LoadCreatures() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); CreatureTemplate const* cInfo = GetCreatureTemplate(entry); @@ -1803,7 +1803,7 @@ void ObjectMgr::LoadCreatures() TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " creatures in %u ms", _creatureDataStore.size(), GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) +void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -1817,7 +1817,7 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) } } -void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) +void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -1831,7 +1831,7 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) } } -uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3) +ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3) { GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry); if (!goinfo) @@ -1841,7 +1841,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float if (!map) return 0; - uint32 guid = GenerateGameObjectSpawnId(); + ObjectGuid::LowType guid = GenerateGameObjectSpawnId(); GameObjectData& data = NewGOData(guid); data.id = entry; @@ -1883,7 +1883,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float } -uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay /*= 0*/) +ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay /*= 0*/) { CreatureTemplate const* cInfo = GetCreatureTemplate(entry); if (!cInfo) @@ -1895,7 +1895,7 @@ uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, if (!map) return 0; - uint32 guid = GenerateCreatureSpawnId(); + ObjectGuid::LowType guid = GenerateCreatureSpawnId(); CreatureData& data = NewOrExistCreatureData(guid); data.id = entry; data.mapid = mapId; @@ -1966,7 +1966,7 @@ void ObjectMgr::LoadGameobjects() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry); @@ -2094,7 +2094,7 @@ void ObjectMgr::LoadGameobjects() TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " gameobjects in %u ms", _gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) +void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2108,7 +2108,7 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) } } -void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) +void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2122,7 +2122,7 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data } } -Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const +Player* ObjectMgr::GetPlayerByLowGUID(ObjectGuid::LowType lowguid) const { ObjectGuid guid(HighGuid::Player, lowguid); return ObjectAccessor::FindPlayer(guid); @@ -7338,7 +7338,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() TC_LOG_INFO("server.loading", ">> Loaded %u spellclick definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::DeleteCreatureData(uint32 guid) +void ObjectMgr::DeleteCreatureData(ObjectGuid::LowType guid) { // remove mapid*cellid -> guid_set map CreatureData const* data = GetCreatureData(guid); @@ -7348,7 +7348,7 @@ void ObjectMgr::DeleteCreatureData(uint32 guid) _creatureDataStore.erase(guid); } -void ObjectMgr::DeleteGOData(uint32 guid) +void ObjectMgr::DeleteGOData(ObjectGuid::LowType guid) { // remove mapid*cellid -> guid_set map GameObjectData const* data = GetGOData(guid); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 462370001dd..cdd974fa013 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -258,7 +258,7 @@ struct ScriptInfo struct // SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (9) { - uint32 GOGuid; // datalong + ObjectGuid::LowType GOGuid; // datalong uint32 DespawnDelay; // datalong2 } RespawnGameobject; @@ -277,7 +277,7 @@ struct ScriptInfo struct // SCRIPT_COMMAND_CLOSE_DOOR (12) // SCRIPT_COMMAND_OPEN_DOOR (11) { - uint32 GOGuid; // datalong + ObjectGuid::LowType GOGuid; // datalong uint32 ResetDelay; // datalong2 } ToggleDoor; @@ -463,8 +463,8 @@ struct TrinityString }; typedef std::map<ObjectGuid, ObjectGuid> LinkedRespawnContainer; -typedef std::unordered_map<uint32, CreatureData> CreatureDataContainer; -typedef std::unordered_map<uint32, GameObjectData> GameObjectDataContainer; +typedef std::unordered_map<ObjectGuid::LowType, CreatureData> CreatureDataContainer; +typedef std::unordered_map<ObjectGuid::LowType, GameObjectData> GameObjectDataContainer; typedef std::map<TempSummonGroupKey, std::vector<TempSummonData> > TempSummonDataContainer; typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer; typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleContainer; @@ -706,7 +706,7 @@ class ObjectMgr typedef std::map<uint32, uint32> CharacterConversionMap; - Player* GetPlayerByLowGUID(uint32 lowguid) const; + Player* GetPlayerByLowGUID(ObjectGuid::LowType lowguid) const; GameObjectTemplate const* GetGameObjectTemplate(uint32 entry); GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; } @@ -722,7 +722,7 @@ class ObjectMgr static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = NULL); static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = NULL); EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id); - CreatureAddon const* GetCreatureAddon(uint32 lowguid); + CreatureAddon const* GetCreatureAddon(ObjectGuid::LowType lowguid); GameObjectAddon const* GetGameObjectAddon(ObjectGuid::LowType lowguid); CreatureAddon const* GetCreatureTemplateAddon(uint32 entry); ItemTemplate const* GetItemTemplate(uint32 entry); @@ -984,7 +984,7 @@ class ObjectMgr void LoadTempSummons(); void LoadCreatures(); void LoadLinkedRespawn(); - bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid); + bool SetCreatureLinkedRespawn(ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid); void LoadCreatureAddons(); void LoadGameObjectAddons(); void LoadCreatureModelInfo(); @@ -1127,14 +1127,14 @@ class ObjectMgr return NULL; } - CreatureData const* GetCreatureData(uint32 guid) const + CreatureData const* GetCreatureData(ObjectGuid::LowType guid) const { CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid); if (itr == _creatureDataStore.end()) return NULL; return &itr->second; } - CreatureData& NewOrExistCreatureData(uint32 guid) { return _creatureDataStore[guid]; } - void DeleteCreatureData(uint32 guid); + CreatureData& NewOrExistCreatureData(ObjectGuid::LowType guid) { return _creatureDataStore[guid]; } + void DeleteCreatureData(ObjectGuid::LowType guid); ObjectGuid GetLinkedRespawnGuid(ObjectGuid guid) const { LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid); @@ -1196,14 +1196,14 @@ class ObjectMgr return &itr->second; } - GameObjectData const* GetGOData(uint32 guid) const + GameObjectData const* GetGOData(ObjectGuid::LowType guid) const { GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(guid); if (itr == _gameObjectDataStore.end()) return NULL; return &itr->second; } - GameObjectData& NewGOData(uint32 guid) { return _gameObjectDataStore[guid]; } - void DeleteGOData(uint32 guid); + GameObjectData& NewGOData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; } + void DeleteGOData(ObjectGuid::LowType guid); TrinityString const* GetTrinityString(uint32 entry) const { @@ -1218,12 +1218,12 @@ class ObjectMgr void SetDBCLocaleIndex(LocaleConstant locale) { DBCLocaleIndex = locale; } // grid objects - void AddCreatureToGrid(uint32 guid, CreatureData const* data); - void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); - void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); - void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); - uint32 AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); - uint32 AddCreatureData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); + void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data); + void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data); + void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data); + void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data); + ObjectGuid::LowType AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); + ObjectGuid::LowType AddCreatureData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); // reserved names void LoadReservedPlayersNames(); @@ -1439,7 +1439,7 @@ class ObjectMgr CreatureTemplateContainer _creatureTemplateStore; CreatureModelContainer _creatureModelStore; CreatureAddonContainer _creatureAddonStore; - CreatureAddonContainer _creatureTemplateAddonStore; + CreatureAddonTemplateContainer _creatureTemplateAddonStore; GameObjectAddonContainer _gameObjectAddonStore; GameObjectQuestItemMap _gameObjectQuestItemStore; CreatureQuestItemMap _creatureQuestItemStore; diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index de0ab490e9c..efbbf1abf72 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -118,7 +118,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { T* obj = new T; - uint32 guid = *i_guid; + ObjectGuid::LowType guid = *i_guid; //TC_LOG_INFO("misc", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid); if (!obj->LoadFromDB(guid, map)) { diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index cc9ef29a8e8..5f500156f58 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -91,7 +91,7 @@ Group::~Group() bool Group::Create(Player* leader) { ObjectGuid leaderGuid = leader->GetGUID(); - uint32 lowguid = sGroupMgr->GenerateGroupId(); + ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId(); m_guid = ObjectGuid(HighGuid::Group, lowguid); m_leaderGuid = leaderGuid; @@ -198,7 +198,7 @@ void Group::LoadGroupFromDB(Field* fields) sLFGMgr->_LoadFromDB(fields, GetGUID()); } -void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles) +void Group::LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles) { MemberSlot member; member.guid = ObjectGuid(HighGuid::Player, guidLow); @@ -2224,7 +2224,7 @@ ObjectGuid Group::GetGUID() const return m_guid; } -uint32 Group::GetLowGUID() const +ObjectGuid::LowType Group::GetLowGUID() const { return m_guid.GetCounter(); } diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 732afce9517..b814ab08026 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -186,7 +186,7 @@ class Group // group manipulation methods bool Create(Player* leader); void LoadGroupFromDB(Field* field); - void LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles); + void LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles); bool AddInvite(Player* player); void RemoveInvite(Player* player); void RemoveAllInvites(); @@ -211,7 +211,7 @@ class Group bool IsCreated() const; ObjectGuid GetLeaderGUID() const; ObjectGuid GetGUID() const; - uint32 GetLowGUID() const; + ObjectGuid::LowType GetLowGUID() const; const char * GetLeaderName() const; LootMethod GetLootMethod() const; ObjectGuid GetLooterGuid() const; diff --git a/src/server/game/Groups/GroupMgr.cpp b/src/server/game/Groups/GroupMgr.cpp index ab80a208765..b8c8157b6d9 100644 --- a/src/server/game/Groups/GroupMgr.cpp +++ b/src/server/game/Groups/GroupMgr.cpp @@ -82,7 +82,7 @@ Group* GroupMgr::GetGroupByDbStoreId(uint32 storageId) const return NULL; } -uint32 GroupMgr::GenerateGroupId() +ObjectGuid::LowType GroupMgr::GenerateGroupId() { if (NextGroupId >= 0xFFFFFFFE) { @@ -92,7 +92,7 @@ uint32 GroupMgr::GenerateGroupId() return NextGroupId++; } -Group* GroupMgr::GetGroupByGUID(uint32 groupId) const +Group* GroupMgr::GetGroupByGUID(ObjectGuid::LowType groupId) const { GroupContainer::const_iterator itr = GroupStore.find(groupId); if (itr != GroupStore.end()) diff --git a/src/server/game/Groups/GroupMgr.h b/src/server/game/Groups/GroupMgr.h index 737c1771c14..ec02de16bc2 100644 --- a/src/server/game/Groups/GroupMgr.h +++ b/src/server/game/Groups/GroupMgr.h @@ -33,10 +33,10 @@ public: return &instance; } - typedef std::map<uint32, Group*> GroupContainer; + typedef std::map<ObjectGuid::LowType, Group*> GroupContainer; typedef std::vector<Group*> GroupDbContainer; - Group* GetGroupByGUID(uint32 guid) const; + Group* GetGroupByGUID(ObjectGuid::LowType guid) const; uint32 GenerateNewGroupDbStoreId(); void RegisterGroupDbStoreId(uint32 storageId, Group* group); @@ -46,13 +46,13 @@ public: void SetGroupDbStoreSize(uint32 newSize) { GroupDbStore.resize(newSize); } void LoadGroups(); - uint32 GenerateGroupId(); + ObjectGuid::LowType GenerateGroupId(); void AddGroup(Group* group); void RemoveGroup(Group* group); protected: - uint32 NextGroupId; + ObjectGuid::LowType NextGroupId; uint32 NextGroupDbStoreId; GroupContainer GroupStore; GroupDbContainer GroupDbStore; diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index fab22b30f47..d2fcad512bb 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -395,7 +395,7 @@ void Guild::BankTab::LoadFromDB(Field* fields) bool Guild::BankTab::LoadItemFromDB(Field* fields) { uint8 slotId = fields[13].GetUInt8(); - uint32 itemGuid = fields[14].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[14].GetUInt32(); uint32 itemEntry = fields[15].GetUInt32(); if (slotId >= GUILD_BANK_MAX_SLOTS) { @@ -784,7 +784,7 @@ void EmblemInfo::WritePacket(WorldPacket& data) const data << uint32(m_backgroundColor); } -void EmblemInfo::SaveToDB(uint32 guildId) const +void EmblemInfo::SaveToDB(ObjectGuid::LowType guildId) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_EMBLEM_INFO); stmt->setUInt32(0, m_style); @@ -1972,7 +1972,7 @@ void Guild::LoadRankFromDB(Field* fields) bool Guild::LoadMemberFromDB(Field* fields) { - uint32 lowguid = fields[1].GetUInt32(); + ObjectGuid::LowType lowguid = fields[1].GetUInt32(); Member *member = new Member(m_id, ObjectGuid(HighGuid::Player, lowguid), fields[2].GetUInt8()); if (!member->LoadFromDB(fields)) { @@ -2019,7 +2019,7 @@ bool Guild::LoadBankEventLogFromDB(Field* fields) LogHolder* pLog = m_bankEventLog[tabId]; if (pLog->CanInsert()) { - uint32 guid = fields[2].GetUInt32(); + ObjectGuid::LowType guid = fields[2].GetUInt32(); GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].GetUInt8()); if (BankEventLogEntry::IsMoneyEvent(eventType)) { @@ -2222,7 +2222,7 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId) // This will be prevent attempt to join many guilds and corrupt guild data integrity Player::RemovePetitionsAndSigns(guid, GUILD_CHARTER_TYPE); - uint32 lowguid = guid.GetCounter(); + ObjectGuid::LowType lowguid = guid.GetCounter(); // If rank was not passed, assign lowest possible rank if (rankId == GUILD_RANK_NONE) @@ -2284,7 +2284,7 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId) void Guild::DeleteMember(ObjectGuid guid, bool isDisbanding, bool isKicked, bool canDeleteGuild) { - uint32 lowguid = guid.GetCounter(); + ObjectGuid::LowType lowguid = guid.GetCounter(); Player* player = ObjectAccessor::FindConnectedPlayer(guid); // Guild master can be deleted when loading guild and guid doesn't exist in characters table @@ -2635,7 +2635,7 @@ inline bool Guild::_MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 righ } // Add new event log record -inline void Guild::_LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +inline void Guild::_LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); m_eventLog->AddEvent(trans, new EventLogEntry(m_id, m_eventLog->GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank)); @@ -2645,7 +2645,7 @@ inline void Guild::_LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, u } // Add new bank event log record -void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 lowguid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType lowguid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) { if (tabId > GUILD_BANK_MAX_TABS) return; diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index b0ea9e1f4e5..ca5ea95ee2c 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -229,7 +229,7 @@ public: EmblemInfo() : m_style(0), m_color(0), m_borderStyle(0), m_borderColor(0), m_backgroundColor(0) { } void LoadFromDB(Field* fields); - void SaveToDB(uint32 guildId) const; + void SaveToDB(ObjectGuid::LowType guildId) const; void ReadPacket(WorldPacket& recv); void WritePacket(WorldPacket& data) const; @@ -286,7 +286,7 @@ private: class Member { public: - Member(uint32 guildId, ObjectGuid guid, uint8 rankId) : + Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId) : m_guildId(guildId), m_guid(guid), m_zoneId(0), @@ -345,7 +345,7 @@ private: inline Player* FindConnectedPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); } private: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; // Fields from characters table ObjectGuid m_guid; std::string m_name; @@ -367,8 +367,8 @@ private: class LogEntry { public: - LogEntry(uint32 guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(NULL)) { } - LogEntry(uint32 guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } + LogEntry(ObjectGuid::LowType guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(NULL)) { } + LogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } virtual ~LogEntry() { } uint32 GetGUID() const { return m_guid; } @@ -378,7 +378,7 @@ private: virtual void WritePacket(WorldPacket& data) const = 0; protected: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; uint32 m_guid; uint64 m_timestamp; }; @@ -387,10 +387,10 @@ private: class EventLogEntry : public LogEntry { public: - EventLogEntry(uint32 guildId, uint32 guid, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) : + EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) : LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { } - EventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) : + EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) : LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { } ~EventLogEntry() { } @@ -400,8 +400,8 @@ private: private: GuildEventLogTypes m_eventType; - uint32 m_playerGuid1; - uint32 m_playerGuid2; + ObjectGuid::LowType m_playerGuid1; + ObjectGuid::LowType m_playerGuid2; uint8 m_newRank; }; @@ -417,11 +417,11 @@ private: eventType == GUILD_BANK_LOG_REPAIR_MONEY; } - BankEventLogEntry(uint32 guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : + BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid), m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { } - BankEventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : + BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid), m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { } @@ -433,7 +433,7 @@ private: private: GuildBankEventLogTypes m_eventType; uint8 m_bankTabId; - uint32 m_playerGuid; + ObjectGuid::LowType m_playerGuid; uint32 m_itemOrMoney; uint16 m_itemStackCount; uint8 m_destTabId; @@ -470,8 +470,8 @@ private: { public: RankInfo(): m_guildId(0), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } - RankInfo(uint32 guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } - RankInfo(uint32 guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) : + RankInfo(ObjectGuid::LowType guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } + RankInfo(ObjectGuid::LowType guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) : m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights), m_bankMoneyPerDay(rankId != GR_GUILDMASTER ? money : GUILD_WITHDRAW_MONEY_UNLIMITED) { } @@ -505,7 +505,7 @@ private: void CreateMissingTabsIfNeeded(uint8 ranks, SQLTransaction& trans, bool logOnCreate = false); private: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; uint8 m_rankId; std::string m_name; @@ -517,7 +517,7 @@ private: class BankTab { public: - BankTab(uint32 guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId) + BankTab(ObjectGuid::LowType guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId) { memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); } @@ -542,7 +542,7 @@ private: bool SetItem(SQLTransaction& trans, uint8 slotId, Item* pItem); private: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; uint8 m_tabId; Item* m_items[GUILD_BANK_MAX_SLOTS]; @@ -653,7 +653,7 @@ public: void Disband(); // Getters - uint32 GetId() const { return m_id; } + ObjectGuid::LowType GetId() const { return m_id; } ObjectGuid GetLeaderGUID() const { return m_leaderGuid; } std::string const& GetName() const { return m_name; } std::string const& GetMOTD() const { return m_motd; } @@ -745,7 +745,7 @@ public: void ResetTimes(); protected: - uint32 m_id; + ObjectGuid::LowType m_id; std::string m_name; ObjectGuid m_leaderGuid; std::string m_motd; @@ -803,7 +803,7 @@ private: return NULL; } - inline void _DeleteMemberFromDB(uint32 lowguid) const + inline void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER); stmt->setUInt32(0, lowguid); @@ -838,8 +838,8 @@ private: void _UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId); bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const; - void _LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2 = 0, uint8 newRank = 0); - void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); + void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2 = 0, uint8 newRank = 0); + void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); Item* _GetItem(uint8 tabId, uint8 slotId) const; void _RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId); diff --git a/src/server/game/Guilds/GuildMgr.cpp b/src/server/game/Guilds/GuildMgr.cpp index 2603a60ee0e..6a75761ded0 100644 --- a/src/server/game/Guilds/GuildMgr.cpp +++ b/src/server/game/Guilds/GuildMgr.cpp @@ -32,12 +32,12 @@ void GuildMgr::AddGuild(Guild* guild) GuildStore[guild->GetId()] = guild; } -void GuildMgr::RemoveGuild(uint32 guildId) +void GuildMgr::RemoveGuild(ObjectGuid::LowType guildId) { GuildStore.erase(guildId); } -uint32 GuildMgr::GenerateGuildId() +ObjectGuid::LowType GuildMgr::GenerateGuildId() { if (NextGuildId >= 0xFFFFFFFE) { @@ -48,7 +48,7 @@ uint32 GuildMgr::GenerateGuildId() } // Guild collection -Guild* GuildMgr::GetGuildById(uint32 guildId) const +Guild* GuildMgr::GetGuildById(ObjectGuid::LowType guildId) const { GuildContainer::const_iterator itr = GuildStore.find(guildId); if (itr != GuildStore.end()) @@ -71,7 +71,7 @@ Guild* GuildMgr::GetGuildByName(const std::string& guildName) const return NULL; } -std::string GuildMgr::GetGuildNameById(uint32 guildId) const +std::string GuildMgr::GetGuildNameById(ObjectGuid::LowType guildId) const { if (Guild* guild = GetGuildById(guildId)) return guild->GetName(); diff --git a/src/server/game/Guilds/GuildMgr.h b/src/server/game/Guilds/GuildMgr.h index 2a73d53a740..1450769c578 100644 --- a/src/server/game/Guilds/GuildMgr.h +++ b/src/server/game/Guilds/GuildMgr.h @@ -34,21 +34,21 @@ public: } Guild* GetGuildByLeader(ObjectGuid guid) const; - Guild* GetGuildById(uint32 guildId) const; + Guild* GetGuildById(ObjectGuid::LowType guildId) const; Guild* GetGuildByName(std::string const& guildName) const; - std::string GetGuildNameById(uint32 guildId) const; + std::string GetGuildNameById(ObjectGuid::LowType guildId) const; void LoadGuilds(); void AddGuild(Guild* guild); - void RemoveGuild(uint32 guildId); + void RemoveGuild(ObjectGuid::LowType guildId); - uint32 GenerateGuildId(); - void SetNextGuildId(uint32 Id) { NextGuildId = Id; } + ObjectGuid::LowType GenerateGuildId(); + void SetNextGuildId(ObjectGuid::LowType Id) { NextGuildId = Id; } void ResetTimes(); protected: - typedef std::unordered_map<uint32, Guild*> GuildContainer; - uint32 NextGuildId; + typedef std::unordered_map<ObjectGuid::LowType, Guild*> GuildContainer; + ObjectGuid::LowType NextGuildId; GuildContainer GuildStore; }; diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 0293901c9e3..8ecf86680ca 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -265,6 +265,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (!auctioneerData) { TC_LOG_ERROR("misc", "Data for auctioneer not found (%s)", auctioneer.ToString().c_str()); + SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR); + delete AH; return; } @@ -272,6 +274,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (!auctioneerInfo) { TC_LOG_ERROR("misc", "Non existing auctioneer (%s)", auctioneer.ToString().c_str()); + SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR); + delete AH; return; } diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index ba22ab6aa07..29761ead707 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -65,7 +65,7 @@ bool LoginQueryHolder::Initialize() SetSize(MAX_PLAYER_LOGIN_QUERY); bool res = true; - uint32 lowGuid = m_guid.GetCounter(); + ObjectGuid::LowType lowGuid = m_guid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER); stmt->setUInt32(0, lowGuid); @@ -1134,7 +1134,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); std::string oldName = fields[1].GetString(); // Update name and at_login flag in the db @@ -1593,7 +1593,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) >> factionChangeInfo.Face >> factionChangeInfo.Race; - uint32 lowGuid = factionChangeInfo.Guid.GetCounter(); + ObjectGuid::LowType lowGuid = factionChangeInfo.Guid.GetCounter(); // get the players old (at this moment current) race CharacterNameData const* nameData = sWorld->GetCharacterNameData(factionChangeInfo.Guid); diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index c7a3f419d62..952659dcea5 100644 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -243,7 +243,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) ObjectGuid petitionguid; recvData >> petitionguid; // petition guid - uint32 petitionGuidLow = petitionguid.GetCounter(); + ObjectGuid::LowType petitionGuidLow = petitionguid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE); @@ -284,7 +284,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) for (uint8 i = 1; i <= signs; ++i) { Field* fields2 = result->Fetch(); - uint32 lowGuid = fields2[0].GetUInt32(); + ObjectGuid::LowType lowGuid = fields2[0].GetUInt32(); data << ObjectGuid(HighGuid::Player, 0, lowGuid); // Player GUID data << uint32(0); // there 0 ... @@ -298,7 +298,7 @@ void WorldSession::HandlePetitionQueryOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_QUERY"); // ok - uint32 guildguid; + ObjectGuid::LowType guildguid; ObjectGuid petitionguid; recvData >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid) recvData >> petitionguid; // petition guid @@ -470,7 +470,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData) uint64 signs = fields[1].GetUInt64(); uint8 type = fields[2].GetUInt8(); - uint32 playerGuid = _player->GetGUID().GetCounter(); + ObjectGuid::LowType playerGuid = _player->GetGUID().GetCounter(); if (ownerGuid == _player->GetGUID()) return; @@ -735,7 +735,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) TC_LOG_DEBUG("network", "Petition %s turned in by %u", petitionGuid.ToString().c_str(), _player->GetGUID().GetCounter()); // Get petition data from db - uint32 ownerguidlo; + ObjectGuid::LowType ownerguidlo; uint32 type; std::string name; diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 5d44f3ec696..a8cf42ea49e 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -652,3 +652,25 @@ void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 credi } } } + +std::string InstanceScript::GetBossStateName(uint8 state) +{ + // See enum EncounterState in InstanceScript.h + switch (state) + { + case NOT_STARTED: + return "NOT_STARTED"; + case IN_PROGRESS: + return "IN_PROGRESS"; + case FAIL: + return "FAIL"; + case DONE: + return "DONE"; + case SPECIAL: + return "SPECIAL"; + case TO_BE_DECIDED: + return "TO_BE_DECIDED"; + default: + return "INVALID"; + } +} diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index e832d7cdffe..93dafea0413 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -220,6 +220,7 @@ class InstanceScript : public ZoneScript virtual bool SetBossState(uint32 id, EncounterState state); EncounterState GetBossState(uint32 id) const { return id < bosses.size() ? bosses[id].state : TO_BE_DECIDED; } + static std::string GetBossStateName(uint8 state); BossBoundaryMap const* GetBossBoundary(uint32 id) const { return id < bosses.size() ? &bosses[id].boundary : NULL; } // Achievement criteria additional requirements check diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 22ebe6c679e..be1b395b082 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -481,7 +481,7 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting) { - uint32 plguid = player->GetGUID().GetCounter(); + ObjectGuid::LowType plguid = player->GetGUID().GetCounter(); QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid); if (qmapitr == PlayerQuestItems.end()) diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 7d7580fd49f..35687aee66c 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -146,7 +146,7 @@ struct LootStoreItem // Checks correctness of values }; -typedef std::set<uint32> AllowedLooterSet; +typedef std::set<ObjectGuid::LowType> AllowedLooterSet; struct LootItem { diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index fd9392fb62f..78cd4d3692c 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -72,7 +72,7 @@ MailSender::MailSender(Player* sender) MailReceiver::MailReceiver(Player* receiver) : m_receiver(receiver), m_receiver_lowguid(receiver->GetGUID().GetCounter()) { } -MailReceiver::MailReceiver(Player* receiver, uint32 receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid) +MailReceiver::MailReceiver(Player* receiver, ObjectGuid::LowType receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid) { ASSERT(!receiver || receiver->GetGUID().GetCounter() == receiver_lowguid); } @@ -127,7 +127,7 @@ void MailDraft::deleteIncludedItems(SQLTransaction& trans, bool inDB /*= false*/ m_items.clear(); } -void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans) +void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, SQLTransaction& trans) { ObjectGuid receiverGuid(HighGuid::Player, receiver_guid); Player* receiver = ObjectAccessor::FindConnectedPlayer(receiverGuid); diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index f4f155c5926..f044996bd0a 100644 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -20,6 +20,7 @@ #define TRINITY_MAIL_H #include "Common.h" +#include "ObjectGuid.h" #include <map> struct AuctionEntry; @@ -81,7 +82,7 @@ enum MailShowFlags class MailSender { public: // Constructors - MailSender(MailMessageType messageType, uint32 sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT) + MailSender(MailMessageType messageType, ObjectGuid::LowType sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT) : m_messageType(messageType), m_senderId(sender_guidlow_or_entry), m_stationery(stationery) { } @@ -91,31 +92,31 @@ class MailSender MailSender(Player* sender); public: // Accessors MailMessageType GetMailMessageType() const { return m_messageType; } - uint32 GetSenderId() const { return m_senderId; } + ObjectGuid::LowType GetSenderId() const { return m_senderId; } MailStationery GetStationery() const { return m_stationery; } private: MailMessageType m_messageType; - uint32 m_senderId; // player low guid or other object entry + ObjectGuid::LowType m_senderId; // player low guid or other object entry MailStationery m_stationery; }; class MailReceiver { public: // Constructors - explicit MailReceiver(uint32 receiver_lowguid) : m_receiver(NULL), m_receiver_lowguid(receiver_lowguid) { } + explicit MailReceiver(ObjectGuid::LowType receiver_lowguid) : m_receiver(NULL), m_receiver_lowguid(receiver_lowguid) { } MailReceiver(Player* receiver); - MailReceiver(Player* receiver, uint32 receiver_lowguid); + MailReceiver(Player* receiver, ObjectGuid::LowType receiver_lowguid); public: // Accessors Player* GetPlayer() const { return m_receiver; } - uint32 GetPlayerGUIDLow() const { return m_receiver_lowguid; } + ObjectGuid::LowType GetPlayerGUIDLow() const { return m_receiver_lowguid; } private: Player* m_receiver; - uint32 m_receiver_lowguid; + ObjectGuid::LowType m_receiver_lowguid; }; class MailDraft { - typedef std::map<uint32, Item*> MailItemMap; + typedef std::map<ObjectGuid::LowType, Item*> MailItemMap; public: // Constructors explicit MailDraft(uint16 mailTemplateId, bool need_items = true) @@ -136,7 +137,7 @@ class MailDraft MailDraft& AddCOD(uint32 COD) { m_COD = COD; return *this; } public: // finishers - void SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans); + void SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, SQLTransaction& trans); void SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked = MAIL_CHECK_MASK_NONE, uint32 deliver_delay = 0); private: @@ -156,7 +157,7 @@ class MailDraft struct MailItemInfo { - uint32 item_guid; + ObjectGuid::LowType item_guid; uint32 item_template; }; typedef std::vector<MailItemInfo> MailItemInfoVec; @@ -167,12 +168,12 @@ struct Mail uint8 messageType; uint8 stationery; uint16 mailTemplateId; - uint32 sender; - uint32 receiver; + ObjectGuid::LowType sender; + ObjectGuid::LowType receiver; std::string subject; std::string body; std::vector<MailItemInfo> items; - std::vector<uint32> removedItems; + std::vector<ObjectGuid::LowType> removedItems; time_t expire_time; time_t deliver_time; uint32 money; @@ -180,7 +181,7 @@ struct Mail uint32 checked; MailState state; - void AddItem(uint32 itemGuidLow, uint32 item_template) + void AddItem(ObjectGuid::LowType itemGuidLow, uint32 item_template) { MailItemInfo mii; mii.item_guid = itemGuidLow; @@ -188,7 +189,7 @@ struct Mail items.push_back(mii); } - bool RemoveItem(uint32 item_guid) + bool RemoveItem(ObjectGuid::LowType item_guid) { for (MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 2af77ffdec3..7ab83d51c7c 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3396,7 +3396,7 @@ void Map::UpdateIteratorBack(Player* player) m_mapRefIter = m_mapRefIter->nocheck_prev(); } -void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime) +void Map::SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime) { if (!respawnTime) { @@ -3415,7 +3415,7 @@ void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime) CharacterDatabase.Execute(stmt); } -void Map::RemoveCreatureRespawnTime(uint32 dbGuid) +void Map::RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid) { _creatureRespawnTimes.erase(dbGuid); @@ -3426,7 +3426,7 @@ void Map::RemoveCreatureRespawnTime(uint32 dbGuid) CharacterDatabase.Execute(stmt); } -void Map::SaveGORespawnTime(uint32 dbGuid, time_t respawnTime) +void Map::SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime) { if (!respawnTime) { @@ -3445,7 +3445,7 @@ void Map::SaveGORespawnTime(uint32 dbGuid, time_t respawnTime) CharacterDatabase.Execute(stmt); } -void Map::RemoveGORespawnTime(uint32 dbGuid) +void Map::RemoveGORespawnTime(ObjectGuid::LowType dbGuid) { _goRespawnTimes.erase(dbGuid); @@ -3466,7 +3466,7 @@ void Map::LoadRespawnTimes() do { Field* fields = result->Fetch(); - uint32 loguid = fields[0].GetUInt32(); + ObjectGuid::LowType loguid = fields[0].GetUInt32(); uint32 respawnTime = fields[1].GetUInt32(); _creatureRespawnTimes[loguid] = time_t(respawnTime); @@ -3481,7 +3481,7 @@ void Map::LoadRespawnTimes() do { Field* fields = result->Fetch(); - uint32 loguid = fields[0].GetUInt32(); + ObjectGuid::LowType loguid = fields[0].GetUInt32(); uint32 respawnTime = fields[1].GetUInt32(); _goRespawnTimes[loguid] = time_t(respawnTime); @@ -3542,7 +3542,7 @@ void Map::LoadCorpseData() { Field* fields = result->Fetch(); CorpseType type = CorpseType(fields[13].GetUInt8()); - uint32 guid = fields[16].GetUInt32(); + ObjectGuid::LowType guid = fields[16].GetUInt32(); if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES) { TC_LOG_ERROR("misc", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type); diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 2ba5e10c82c..184f1f9a426 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -499,28 +499,28 @@ class Map : public GridRefManager<NGridType> RESPAWN TIMES */ time_t GetLinkedRespawnTime(ObjectGuid guid) const; - time_t GetCreatureRespawnTime(uint32 dbGuid) const + time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const { - std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid); + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid); if (itr != _creatureRespawnTimes.end()) return itr->second; return time_t(0); } - time_t GetGORespawnTime(uint32 dbGuid) const + time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const { - std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid); + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid); if (itr != _goRespawnTimes.end()) return itr->second; return time_t(0); } - void SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime); - void RemoveCreatureRespawnTime(uint32 dbGuid); - void SaveGORespawnTime(uint32 dbGuid, time_t respawnTime); - void RemoveGORespawnTime(uint32 dbGuid); + void SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime); + void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid); + void SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime); + void RemoveGORespawnTime(ObjectGuid::LowType dbGuid); void LoadRespawnTimes(); void DeleteRespawnTimes(); @@ -659,7 +659,7 @@ class Map : public GridRefManager<NGridType> Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const; - GameObject* _FindGameObject(WorldObject* pWorldObject, uint32 guid) const; + GameObject* _FindGameObject(WorldObject* pWorldObject, ObjectGuid::LowType guid) const; time_t i_gridExpiry; @@ -711,8 +711,8 @@ class Map : public GridRefManager<NGridType> m_activeNonPlayers.erase(obj); } - std::unordered_map<uint32 /*dbGUID*/, time_t> _creatureRespawnTimes; - std::unordered_map<uint32 /*dbGUID*/, time_t> _goRespawnTimes; + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t> _creatureRespawnTimes; + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t> _goRespawnTimes; ZoneDynamicInfoMap _zoneDynamicInfo; uint32 _defaultLight; diff --git a/src/server/game/Maps/TransportMgr.cpp b/src/server/game/Maps/TransportMgr.cpp index cac6e3b91ea..84eba74c6dc 100644 --- a/src/server/game/Maps/TransportMgr.cpp +++ b/src/server/game/Maps/TransportMgr.cpp @@ -348,7 +348,7 @@ void TransportMgr::AddPathNodeToTransport(uint32 transportEntry, uint32 timeSeg, animNode.Path[timeSeg] = node; } -Transport* TransportMgr::CreateTransport(uint32 entry, uint32 guid /*= 0*/, Map* map /*= NULL*/) +Transport* TransportMgr::CreateTransport(uint32 entry, ObjectGuid::LowType guid /*= 0*/, Map* map /*= NULL*/) { // instance case, execute GetGameObjectEntry hook if (map) @@ -425,7 +425,7 @@ void TransportMgr::SpawnContinentTransports() do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); if (TransportTemplate const* tInfo = GetTransportTemplate(entry)) diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h index c273ea7fb15..d100f60c604 100644 --- a/src/server/game/Maps/TransportMgr.h +++ b/src/server/game/Maps/TransportMgr.h @@ -21,6 +21,7 @@ #include <G3D/Quat.h> #include "Spline.h" #include "DBCStores.h" +#include "ObjectGuid.h" struct KeyFrame; struct GameObjectTemplate; @@ -111,7 +112,7 @@ class TransportMgr void LoadTransportTemplates(); // Creates a transport using given GameObject template entry - Transport* CreateTransport(uint32 entry, uint32 guid = 0, Map* map = NULL); + Transport* CreateTransport(uint32 entry, ObjectGuid::LowType guid = 0, Map* map = NULL); // Spawns all continent transports, used at core startup void SpawnContinentTransports(); diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index ba39723b19d..aa9a738b5dc 100644 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -158,7 +158,7 @@ namespace Trinity return baseGain; } - inline uint32 Gain(Player* player, Unit* u) + inline uint32 Gain(Player* player, Unit* u, bool isBattleGround = false) { Creature* creature = u->ToCreature(); uint32 gain = 0; @@ -184,7 +184,7 @@ namespace Trinity xpMod *= creature->GetCreatureTemplate()->ModExperience; } - xpMod *= sWorld->getRate(RATE_XP_KILL); + xpMod *= isBattleGround ? sWorld->getRate(RATE_XP_BG_KILL) : sWorld->getRate(RATE_XP_KILL); gain = uint32(gain * xpMod); } diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index d914ef01108..9046d9e6991 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -85,7 +85,7 @@ void OPvPCapturePoint::SendChangePhase() SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } -void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry) +void OPvPCapturePoint::AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry) { if (!entry) { @@ -99,7 +99,7 @@ void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry) m_ObjectTypes[m_Objects[type]] = type; } -void OPvPCapturePoint::AddCre(uint32 type, uint32 guid, uint32 entry) +void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry) { if (!entry) { @@ -115,7 +115,7 @@ void OPvPCapturePoint::AddCre(uint32 type, uint32 guid, uint32 entry) bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) { - if (uint32 guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) + if (ObjectGuid::LowType guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) { AddGO(type, guid, entry); return true; @@ -126,7 +126,7 @@ bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, TeamId /*teamId = TEAM_NEUTRAL*/, uint32 spawntimedelay /*= 0*/) { - if (uint32 guid = sObjectMgr->AddCreatureData(entry, map, x, y, z, o, spawntimedelay)) + if (ObjectGuid::LowType guid = sObjectMgr->AddCreatureData(entry, map, x, y, z, o, spawntimedelay)) { AddCre(type, guid, entry); return true; diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index d075da19ebc..b35147a8502 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -128,12 +128,12 @@ class OPvPCapturePoint virtual void DeleteSpawns(); - uint32 m_capturePointSpawnId; + ObjectGuid::LowType m_capturePointSpawnId; GameObject* m_capturePoint; - void AddGO(uint32 type, uint32 guid, uint32 entry = 0); - void AddCre(uint32 type, uint32 guid, uint32 entry = 0); + void AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0); + void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0); bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); @@ -178,10 +178,10 @@ class OPvPCapturePoint // map to store the various gameobjects and creatures spawned by the objective // type, guid - std::map<uint32, uint32> m_Objects; - std::map<uint32, uint32> m_Creatures; - std::map<uint32, uint32> m_ObjectTypes; - std::map<uint32, uint32> m_CreatureTypes; + std::map<uint32, ObjectGuid::LowType> m_Objects; + std::map<uint32, ObjectGuid::LowType> m_Creatures; + std::map<ObjectGuid::LowType, uint32> m_ObjectTypes; + std::map<ObjectGuid::LowType, uint32> m_CreatureTypes; }; // base class for specific outdoor pvp handlers @@ -200,7 +200,7 @@ class OutdoorPvP : public ZoneScript // deletes all gos/creatures spawned by the pvp void DeleteSpawns(); - typedef std::map<uint32/*spawnId*/, OPvPCapturePoint*> OPvPCapturePointMap; + typedef std::map<ObjectGuid::LowType/*spawnId*/, OPvPCapturePoint*> OPvPCapturePointMap; typedef std::pair<ObjectGuid::LowType, GameObject*> GoScriptPair; typedef std::pair<ObjectGuid::LowType, Creature*> CreatureScriptPair; @@ -292,7 +292,7 @@ class OutdoorPvP : public ZoneScript m_capturePoints[cp->m_capturePointSpawnId] = cp; } - OPvPCapturePoint * GetCapturePoint(uint32 guid) const + OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType guid) const { OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(guid); if (itr != m_capturePoints.end()) diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index 8f3d4a758f3..1e7826f280b 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -184,7 +184,7 @@ PoolObject* PoolGroup<T>::RollOne(ActivePoolData& spawns, uint32 triggerFrom) // If no guid is passed, the pool is just removed (event end case) // If guid is filled, cache will be used and no removal will occur, it just fill the cache template<class T> -void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid) +void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid) { for (size_t i=0; i < EqualChanced.size(); ++i) { @@ -215,7 +215,7 @@ void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid) // Method that is actualy doing the removal job on one creature template<> -void PoolGroup<Creature>::Despawn1Object(uint32 guid) +void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid) { if (CreatureData const* data = sObjectMgr->GetCreatureData(guid)) { @@ -237,7 +237,7 @@ void PoolGroup<Creature>::Despawn1Object(uint32 guid) // Same on one gameobject template<> -void PoolGroup<GameObject>::Despawn1Object(uint32 guid) +void PoolGroup<GameObject>::Despawn1Object(ObjectGuid::LowType guid) { if (GameObjectData const* data = sObjectMgr->GetGOData(guid)) { @@ -621,7 +621,7 @@ void PoolMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 pool_id = fields[1].GetUInt32(); float chance = fields[2].GetFloat(); @@ -677,7 +677,7 @@ void PoolMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 pool_id = fields[1].GetUInt32(); float chance = fields[2].GetFloat(); diff --git a/src/server/game/Pools/PoolMgr.h b/src/server/game/Pools/PoolMgr.h index 4ffcbe1faac..e165f9bd397 100644 --- a/src/server/game/Pools/PoolMgr.h +++ b/src/server/game/Pools/PoolMgr.h @@ -31,16 +31,16 @@ struct PoolTemplateData struct PoolObject { - uint32 guid; + ObjectGuid::LowType guid; float chance; - PoolObject(uint32 _guid, float _chance) : guid(_guid), chance(std::fabs(_chance)) { } + PoolObject(ObjectGuid::LowType _guid, float _chance) : guid(_guid), chance(std::fabs(_chance)) { } }; class Pool // for Pool of Pool case { }; -typedef std::set<uint32> ActivePoolObjects; +typedef std::set<ObjectGuid::LowType> ActivePoolObjects; typedef std::map<uint32, uint32> ActivePoolPools; class ActivePoolData @@ -77,8 +77,8 @@ class PoolGroup void AddEntry(PoolObject& poolitem, uint32 maxentries); bool CheckPool() const; PoolObject* RollOne(ActivePoolData& spawns, uint32 triggerFrom); - void DespawnObject(ActivePoolData& spawns, uint32 guid=0); - void Despawn1Object(uint32 guid); + void DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid=0); + void Despawn1Object(ObjectGuid::LowType guid); void SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom); void Spawn1Object(PoolObject* obj); diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index a369750b0c6..63006bc6ed6 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -220,7 +220,7 @@ inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const { bool bOpen = false; - uint32 guid = scriptInfo->ToggleDoor.GOGuid; + ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid; int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay)); switch (scriptInfo->command) { @@ -266,7 +266,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script } } -inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const +inline GameObject* Map::_FindGameObject(WorldObject* searchObject, ObjectGuid::LowType guid) const { auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); if (bounds.first == bounds.second) diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 0ece05f1d93..db5e09c5d2a 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1392,12 +1392,12 @@ void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool FOREACH_SCRIPT(GuildScript)->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId); } -void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) { FOREACH_SCRIPT(GuildScript)->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank); } -void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) { FOREACH_SCRIPT(GuildScript)->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId); } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index a226f1b7ed2..7e1751244fd 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -839,9 +839,9 @@ class GuildScript : public ScriptObject virtual void OnItemMove(Guild* /*guild*/, Player* /*player*/, Item* /*pItem*/, bool /*isSrcBank*/, uint8 /*srcContainer*/, uint8 /*srcSlotId*/, bool /*isDestBank*/, uint8 /*destContainer*/, uint8 /*destSlotId*/) { } - virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, uint32 /*playerGuid1*/, uint32 /*playerGuid2*/, uint8 /*newRank*/) { } + virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, ObjectGuid::LowType /*playerGuid1*/, ObjectGuid::LowType /*playerGuid2*/, uint8 /*newRank*/) { } - virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, uint32 /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } + virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, ObjectGuid::LowType /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } }; class GroupScript : public ScriptObject @@ -1111,8 +1111,8 @@ class ScriptMgr void OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &amount); void OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); - void OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); - void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); + void OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank); + void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); public: /* GroupScript */ diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 45a816eda9b..b4bb7541be8 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -180,7 +180,7 @@ std::string WorldSession::GetPlayerInfo() const } /// Get player guid if available. Use for logging purposes only -uint32 WorldSession::GetGUIDLow() const +ObjectGuid::LowType WorldSession::GetGUIDLow() const { return GetPlayer() ? GetPlayer()->GetGUID().GetCounter() : 0; } diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index e597cbff27b..6b1279e3e0c 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -287,7 +287,7 @@ class WorldSession std::string const& GetPlayerName() const; std::string GetPlayerInfo() const; - uint32 GetGUIDLow() const; + ObjectGuid::LowType GetGUIDLow() const; void SetSecurity(AccountTypes security) { _security = security; } std::string const& GetRemoteAddress() const { return m_Address; } void SetPlayer(Player* player); @@ -1026,7 +1026,7 @@ class WorldSession // characters who failed on Player::BuildEnumData shouldn't login GuidSet _legitCharacters; - uint32 m_GUIDLow; // set logined or recently logout player (while m_playerRecentlyLogout set) + ObjectGuid::LowType m_GUIDLow; // set logined or recently logout player (while m_playerRecentlyLogout set) Player* _player; std::shared_ptr<WorldSocket> m_Socket; std::string m_Address; // Current Remote Address diff --git a/src/server/game/Skills/SkillExtraItems.cpp b/src/server/game/Skills/SkillExtraItems.cpp index 8df9ce86f9a..2c9a2a7bcfd 100644 --- a/src/server/game/Skills/SkillExtraItems.cpp +++ b/src/server/game/Skills/SkillExtraItems.cpp @@ -20,11 +20,98 @@ #include "DatabaseEnv.h" #include "Log.h" #include "Player.h" +#include "ObjectMgr.h" #include <map> // some type definitions // no use putting them in the header file, they're only used in this .cpp +// struct to store information about perfection procs +// one entry per spell +struct SkillPerfectItemEntry +{ + // the spell id of the spell required - it's named "specialization" to conform with SkillExtraItemEntry + uint32 requiredSpecialization; + // perfection proc chance + float perfectCreateChance; + // itemid of the resulting perfect item + uint32 perfectItemType; + + SkillPerfectItemEntry() + : requiredSpecialization(0), perfectCreateChance(0.0f), perfectItemType(0) { } + SkillPerfectItemEntry(uint32 rS, float pCC, uint32 pIT) + : requiredSpecialization(rS), perfectCreateChance(pCC), perfectItemType(pIT) { } +}; + +// map to store perfection info. key = spellId of the creation spell, value is the perfectitementry as specified above +typedef std::map<uint32, SkillPerfectItemEntry> SkillPerfectItemMap; + +SkillPerfectItemMap SkillPerfectItemStore; + +// loads the perfection proc info from DB +void LoadSkillPerfectItemTable() +{ + uint32 oldMSTime = getMSTime(); + + SkillPerfectItemStore.clear(); // reload capability + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, perfectCreateChance, perfectItemType FROM skill_perfect_item_template"); + + if (!result) + { + TC_LOG_ERROR("server.loading", ">> Loaded 0 spell perfection definitions. DB table `skill_perfect_item_template` is empty."); + return; + } + + uint32 count = 0; + + do /* fetch data and run sanity checks */ + { + Field* fields = result->Fetch(); + + uint32 spellId = fields[0].GetUInt32(); + + if (!sSpellMgr->GetSpellInfo(spellId)) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has non-existent spell id in `skill_perfect_item_template`!", spellId); + continue; + } + + uint32 requiredSpecialization = fields[1].GetUInt32(); + if (!sSpellMgr->GetSpellInfo(requiredSpecialization)) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has non-existent required specialization spell id %u in `skill_perfect_item_template`!", spellId, requiredSpecialization); + continue; + } + + float perfectCreateChance = fields[2].GetFloat(); + if (perfectCreateChance <= 0.0f) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has impossibly low proc chance in `skill_perfect_item_template`!", spellId); + continue; + } + + uint32 perfectItemType = fields[3].GetUInt32(); + if (!sObjectMgr->GetItemTemplate(perfectItemType)) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u references non-existent perfect item id %u in `skill_perfect_item_template`!", spellId, perfectItemType); + continue; + } + + SkillPerfectItemEntry& skillPerfectItemEntry = SkillPerfectItemStore[spellId]; + + skillPerfectItemEntry.requiredSpecialization = requiredSpecialization; + skillPerfectItemEntry.perfectCreateChance = perfectCreateChance; + skillPerfectItemEntry.perfectItemType = perfectItemType; + + ++count; + } + while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u spell perfection definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + // struct to store information about extra item creation // one entry for every spell that is able to create an extra item struct SkillExtraItemEntry @@ -112,6 +199,30 @@ void LoadSkillExtraItemTable() TC_LOG_INFO("server.loading", ">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateChance, uint32 &perfectItemType) +{ + SkillPerfectItemMap::const_iterator ret = SkillPerfectItemStore.find(spellId); + // no entry in DB means no perfection proc possible + if (ret == SkillPerfectItemStore.end()) + return false; + + SkillPerfectItemEntry const* thisEntry = &ret->second; + // lack of entry means no perfection proc possible + if (!thisEntry) + return false; + + // if you don't have the spell needed, then no procs for you + if (!player->HasSpell(thisEntry->requiredSpecialization)) + return false; + + // set values as appropriate + perfectCreateChance = thisEntry->perfectCreateChance; + perfectItemType = thisEntry->perfectItemType; + + // and tell the caller to start rolling the dice + return true; +} + bool CanCreateExtraItems(Player* player, uint32 spellId, float &additionalChance, uint8 &additionalMax) { // get the info for the specified spell diff --git a/src/server/game/Skills/SkillExtraItems.h b/src/server/game/Skills/SkillExtraItems.h index 0cdfff74ed2..118c49ed00f 100644 --- a/src/server/game/Skills/SkillExtraItems.h +++ b/src/server/game/Skills/SkillExtraItems.h @@ -23,6 +23,10 @@ // predef classes used in functions class Player; +// returns true and sets the appropriate info if the player can create a perfect item with the given spellId +bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateChance, uint32 &perfectItemType); +// load perfection proc info from DB +void LoadSkillPerfectItemTable(); // returns true and sets the appropriate info if the player can create extra items with the given spellId bool CanCreateExtraItems(Player* player, uint32 spellId, float &additionalChance, uint8 &additionalMax); // function to load the extra item creation info from DB diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 10dfbd511df..e587a59858a 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1571,6 +1571,22 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) if (num_to_add > pProto->GetMaxStackSize()) num_to_add = pProto->GetMaxStackSize(); + /* == gem perfection handling == */ + + // the chance of getting a perfect result + float perfectCreateChance = 0.0f; + // the resulting perfect item if successful + uint32 perfectItemType = itemtype; + // get perfection capability and chance + if (CanCreatePerfectItem(player, m_spellInfo->Id, perfectCreateChance, perfectItemType)) + if (roll_chance_f(perfectCreateChance)) // if the roll succeeds... + newitemid = perfectItemType; // the perfect item replaces the regular one + + /* == gem perfection handling over == */ + + + /* == profession specialization handling == */ + // init items_count to 1, since 1 item will be created regardless of specialization int items_count=1; // the chance to create additional items @@ -1579,15 +1595,16 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) uint8 additionalMaxNum=0; // get the chance and maximum number for creating extra items if (CanCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum)) - { // roll with this chance till we roll not to create or we create the max num while (roll_chance_f(additionalCreateChance) && items_count <= additionalMaxNum) ++items_count; - } // really will be created more items num_to_add *= items_count; + /* == profession specialization handling over == */ + + // can the player store the new item? ItemPosCountVec dest; uint32 no_space = 0; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index f27f9220aaa..55d0ad0b4dc 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3105,11 +3105,13 @@ void SpellMgr::LoadSpellInfoCorrections() case 28796: // Poison Bolt Volly - Faerlina spellInfo->MaxAffectedTargets = 5; break; + case 54835: // Curse of the Plaguebringer - Noth (H) + spellInfo->MaxAffectedTargets = 8; + break; case 40827: // Sinful Beam case 40859: // Sinister Beam case 40860: // Vile Beam case 40861: // Wicked Beam - case 54835: // Curse of the Plaguebringer - Noth (H) case 54098: // Poison Bolt Volly - Faerlina (H) spellInfo->MaxAffectedTargets = 10; break; diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 8710100d9b3..1657b6cd028 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -158,38 +158,38 @@ bool changetoknth(std::string &str, int n, char const* with, bool insert = false return true; } -uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32> &guidMap, uint32 hiGuid) +ObjectGuid::LowType registerNewGuid(ObjectGuid::LowType oldGuid, std::map<ObjectGuid::LowType, ObjectGuid::LowType> &guidMap, ObjectGuid::LowType hiGuid) { - std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid); + std::map<ObjectGuid::LowType, ObjectGuid::LowType>::const_iterator itr = guidMap.find(oldGuid); if (itr != guidMap.end()) return itr->second; - uint32 newguid = hiGuid + guidMap.size(); + ObjectGuid::LowType newguid = hiGuid + guidMap.size(); guidMap[oldGuid] = newguid; return newguid; } -bool changeGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint32 hiGuid, bool nonzero = false) +bool changeGuid(std::string &str, int n, std::map<ObjectGuid::LowType, ObjectGuid::LowType> &guidMap, ObjectGuid::LowType hiGuid, bool nonzero = false) { char chritem[20]; - uint32 oldGuid = atoi(getnth(str, n).c_str()); + ObjectGuid::LowType oldGuid = atoi(getnth(str, n).c_str()); if (nonzero && oldGuid == 0) return true; // not an error - uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); + ObjectGuid::LowType newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); snprintf(chritem, 20, "%u", newGuid); return changenth(str, n, chritem, false, nonzero); } -bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint32 hiGuid, bool nonzero = false) +bool changetokGuid(std::string &str, int n, std::map<ObjectGuid::LowType, ObjectGuid::LowType> &guidMap, ObjectGuid::LowType hiGuid, bool nonzero = false) { char chritem[20]; - uint32 oldGuid = atoi(gettoknth(str, n).c_str()); + ObjectGuid::LowType oldGuid = atoi(gettoknth(str, n).c_str()); if (nonzero && oldGuid == 0) return true; // not an error - uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); + ObjectGuid::LowType newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); snprintf(chritem, 20, "%u", newGuid); return changetoknth(str, n, chritem, false, nonzero); @@ -216,7 +216,7 @@ std::string CreateDumpString(char const* tableName, QueryResult result) return ss.str(); } -std::string PlayerDumpWriter::GenerateWhereStr(char const* field, uint32 guid) +std::string PlayerDumpWriter::GenerateWhereStr(char const* field, ObjectGuid::LowType guid) { std::ostringstream wherestr; wherestr << field << " = '" << guid << '\''; @@ -245,25 +245,25 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g return wherestr.str(); } -void StoreGUID(QueryResult result, uint32 field, std::set<uint32>& guids) +void StoreGUID(QueryResult result, uint32 field, std::set<ObjectGuid::LowType>& guids) { Field* fields = result->Fetch(); - uint32 guid = fields[field].GetUInt32(); + ObjectGuid::LowType guid = fields[field].GetUInt32(); if (guid) guids.insert(guid); } -void StoreGUID(QueryResult result, uint32 data, uint32 field, std::set<uint32>& guids) +void StoreGUID(QueryResult result, uint32 data, uint32 field, std::set<ObjectGuid::LowType>& guids) { Field* fields = result->Fetch(); std::string dataStr = fields[data].GetString(); - uint32 guid = atoi(gettoknth(dataStr, field).c_str()); + ObjectGuid::LowType guid = atoi(gettoknth(dataStr, field).c_str()); if (guid) guids.insert(guid); } // Writing - High-level functions -bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type) +bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, char const*tableFrom, char const*tableTo, DumpTableType type) { GUIDs const* guids = NULL; char const* fieldname = NULL; @@ -340,7 +340,7 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl return true; } -bool PlayerDumpWriter::GetDump(uint32 guid, std::string &dump) +bool PlayerDumpWriter::GetDump(ObjectGuid::LowType guid, std::string &dump) { dump = "IMPORTANT NOTE: THIS DUMPFILE IS MADE FOR USE WITH THE 'PDUMP' COMMAND ONLY - EITHER THROUGH INGAME CHAT OR ON CONSOLE!\n"; dump += "IMPORTANT NOTE: DO NOT apply it directly - it will irreversibly DAMAGE and CORRUPT your database! You have been warned!\n\n"; @@ -355,7 +355,7 @@ bool PlayerDumpWriter::GetDump(uint32 guid, std::string &dump) return true; } -DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid) +DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, ObjectGuid::LowType guid) { if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_PATHS)) if (strstr(file.c_str(), "\\") || strstr(file.c_str(), "/")) @@ -394,7 +394,7 @@ void fixNULLfields(std::string &line) } } -DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid) +DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, ObjectGuid::LowType 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 5a26c10b7d8..d0c5b90fec5 100644 --- a/src/server/game/Tools/PlayerDump.h +++ b/src/server/game/Tools/PlayerDump.h @@ -22,6 +22,7 @@ #include <string> #include <map> #include <set> +#include "ObjectGuid.h" enum DumpTableType { @@ -72,14 +73,14 @@ class PlayerDumpWriter : public PlayerDump public: PlayerDumpWriter() { } - bool GetDump(uint32 guid, std::string& dump); - DumpReturn WriteDump(std::string const& file, uint32 guid); + bool GetDump(ObjectGuid::LowType guid, std::string& dump); + DumpReturn WriteDump(std::string const& file, ObjectGuid::LowType guid); private: - typedef std::set<uint32> GUIDs; + typedef std::set<ObjectGuid::LowType> GUIDs; - bool DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type); + bool DumpTable(std::string& dump, ObjectGuid::LowType guid, char const*tableFrom, char const*tableTo, DumpTableType type); std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr); - std::string GenerateWhereStr(char const* field, uint32 guid); + std::string GenerateWhereStr(char const* field, ObjectGuid::LowType guid); GUIDs pets; GUIDs mails; @@ -91,7 +92,7 @@ class PlayerDumpReader : public PlayerDump public: PlayerDumpReader() { } - DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid); + DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, ObjectGuid::LowType guid); }; #endif diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 56c4cdf0acf..8a84176ade1 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -456,6 +456,7 @@ void World::LoadConfigSettings(bool reload) rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT] = sConfigMgr->GetFloatDefault("Rate.Drop.Item.ReferencedAmount", 1.0f); rate_values[RATE_DROP_MONEY] = sConfigMgr->GetFloatDefault("Rate.Drop.Money", 1.0f); rate_values[RATE_XP_KILL] = sConfigMgr->GetFloatDefault("Rate.XP.Kill", 1.0f); + rate_values[RATE_XP_BG_KILL] = sConfigMgr->GetFloatDefault("Rate.XP.BattlegroundKill", 1.0f); rate_values[RATE_XP_QUEST] = sConfigMgr->GetFloatDefault("Rate.XP.Quest", 1.0f); rate_values[RATE_XP_EXPLORE] = sConfigMgr->GetFloatDefault("Rate.XP.Explore", 1.0f); rate_values[RATE_REPAIRCOST] = sConfigMgr->GetFloatDefault("Rate.RepairCost", 1.0f); @@ -1644,6 +1645,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); + TC_LOG_INFO("server.loading", "Loading Skill Perfection Data Table..."); + LoadSkillPerfectItemTable(); + TC_LOG_INFO("server.loading", "Loading Skill Fishing base level requirements..."); sObjectMgr->LoadFishingBaseSkillLevel(); @@ -2505,7 +2509,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string const& nameOrIP) BanReturn World::BanCharacter(std::string const& name, std::string const& duration, std::string const& reason, std::string const& author) { Player* pBanned = ObjectAccessor::FindConnectedPlayerByName(name); - uint32 guid = 0; + ObjectGuid::LowType guid = 0; uint32 duration_secs = TimeStringToSecs(duration); @@ -2546,7 +2550,7 @@ BanReturn World::BanCharacter(std::string const& name, std::string const& durati bool World::RemoveBanCharacter(std::string const& name) { Player* pBanned = ObjectAccessor::FindConnectedPlayerByName(name); - uint32 guid = 0; + ObjectGuid::LowType guid = 0; /// Pick a player to ban if not online if (!pBanned) diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 5efa3ce3f46..7c7af77d19d 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -374,6 +374,7 @@ enum Rates RATE_DROP_ITEM_REFERENCED_AMOUNT, RATE_DROP_MONEY, RATE_XP_KILL, + RATE_XP_BG_KILL, RATE_XP_QUEST, RATE_XP_EXPLORE, RATE_REPAIRCOST, diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index fc246898186..ed7b31198db 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -300,7 +300,7 @@ public: return false; Player* target = ObjectAccessor::FindPlayerByName(args); - uint32 targetGuid = 0; + ObjectGuid::LowType targetGuid = 0; std::string name(args); if (!target) diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 405f6fde624..8714838879f 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -909,7 +909,7 @@ public: guidStr = strtok(NULL, " "); } - uint32 guid = 0; + ObjectGuid::LowType guid = 0; if (guidStr) { diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 422104fedd5..901043980c5 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -971,7 +971,7 @@ public: if (!e || !f) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); uint32 index = (uint32)atoi(f); Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid(HighGuid::Item, 0, guid)); @@ -1001,7 +1001,7 @@ public: if (!e || !f || !g) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); uint32 index = (uint32)atoi(f); uint32 value = (uint32)atoi(g); @@ -1027,7 +1027,7 @@ public: if (!e) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid(HighGuid::Item, guid)); diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 0a45506c736..9710a7e634c 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -81,7 +81,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -150,7 +150,7 @@ public: Map* map = player->GetMap(); GameObject* object = new GameObject; - uint32 guidLow = map->GenerateLowGuid<HighGuid::GameObject>(); + ObjectGuid::LowType guidLow = map->GenerateLowGuid<HighGuid::GameObject>(); if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) { @@ -292,7 +292,8 @@ public: bool found = false; float x, y, z, o; - uint32 guidLow, id, phase; + ObjectGuid::LowType guidLow; + uint32 id, phase; uint16 mapId; uint32 poolId; @@ -352,7 +353,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -400,7 +401,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -459,7 +460,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -533,7 +534,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -587,7 +588,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); @@ -656,7 +657,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index a735e296f59..c2b9076017a 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -158,7 +158,7 @@ public: if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) return false; - uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); + ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); if (!guildId) return false; @@ -184,7 +184,7 @@ public: if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name)) return false; - uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); + ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); if (!guildId) return false; diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index c960d3f3753..aa7310e3c65 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -254,7 +254,8 @@ public: } map->ToInstanceMap()->GetInstanceScript()->SetBossState(encounterId, (EncounterState)state); - handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state); + std::string stateName = InstanceScript::GetBossStateName(state); + handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName); return true; } @@ -318,7 +319,8 @@ public: } uint8 state = map->ToInstanceMap()->GetInstanceScript()->GetBossState(encounterId); - handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state); + std::string stateName = InstanceScript::GetBossStateName(state); + handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName); return true; } }; diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index fb051832d7b..0de62f805de 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -109,7 +109,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); float z = fields[3].GetFloat(); @@ -235,8 +235,8 @@ public: do { Field* fields = result->Fetch(); - uint32 itemGuid = fields[0].GetUInt32(); - uint32 itemSender = fields[1].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[0].GetUInt32(); + ObjectGuid::LowType itemSender = fields[1].GetUInt32(); uint32 itemReceiver = fields[2].GetUInt32(); uint32 itemSenderAccountId = fields[3].GetUInt32(); std::string itemSenderName = fields[4].GetString(); @@ -398,7 +398,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); float z = fields[3].GetFloat(); @@ -534,7 +534,7 @@ public: { do { - uint32 item_guid = (*result2)[0].GetUInt32(); + ObjectGuid::LowType item_guid = (*result2)[0].GetUInt32(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_ITEMS); stmt->setUInt32(0, item_guid); PreparedQueryResult result3 = CharacterDatabase.Query(stmt); diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 56aa6d0bf92..cb2d467f8d7 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -1410,7 +1410,7 @@ public: do { Field* characterFields = result2->Fetch(); - uint32 guid = characterFields[0].GetUInt32(); + ObjectGuid::LowType guid = characterFields[0].GetUInt32(); std::string name = characterFields[1].GetString(); handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid); diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 21a55b1558a..725fdd4c27d 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1470,7 +1470,7 @@ public: // Account data print variables std::string userName = handler->GetTrinityString(LANG_ERROR); uint32 accId = 0; - uint32 lowguid = targetGuid.GetCounter(); + ObjectGuid::LowType lowguid = targetGuid.GetCounter(); std::string eMail = handler->GetTrinityString(LANG_ERROR); std::string regMail = handler->GetTrinityString(LANG_ERROR); uint32 security = 0; @@ -1659,7 +1659,7 @@ public: { Field* fields = result4->Fetch(); xp = fields[0].GetUInt32(); // Used for "current xp" output and "%u XP Left" calculation - uint32 gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all + ObjectGuid::LowType gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all xptotal = sObjectMgr->GetXPForLevel(level); if (gguid != 0) @@ -2487,7 +2487,7 @@ public: // If player found: delete his freeze aura Field* fields = result->Fetch(); - uint32 lowGuid = fields[0].GetUInt32(); + ObjectGuid::LowType lowGuid = fields[0].GetUInt32(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); stmt->setUInt32(0, lowGuid); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index dcf75d0c5db..8e7a1387a32 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -260,7 +260,7 @@ public: if (Transport* trans = chr->GetTransport()) { - uint32 guid = map->GenerateLowGuid<HighGuid::Unit>(); + ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Unit>(); CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid); data.id = id; data.phaseMask = chr->GetPhaseMaskForSpawn(); @@ -286,7 +286,7 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - uint32 db_guid = creature->GetSpawnId(); + ObjectGuid::LowType db_guid = creature->GetSpawnId(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells() // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior @@ -368,7 +368,7 @@ public: char* guidStr = strtok((char*)args, " "); char* waitStr = strtok((char*)NULL, " "); - uint32 lowGuid = atoi((char*)guidStr); + ObjectGuid::LowType lowGuid = atoi((char*)guidStr); // attempt check creature existence by DB data CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid); @@ -489,7 +489,7 @@ public: if (!cId) return false; - uint32 lowguid = atoi(cId); + ObjectGuid::LowType lowguid = atoi(cId); if (!lowguid) return false; @@ -764,7 +764,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); @@ -790,7 +790,7 @@ public: //move selected creature static bool HandleNpcMoveCommand(ChatHandler* handler, char const* args) { - uint32 lowguid = 0; + ObjectGuid::LowType lowguid = 0; Creature* creature = handler->getSelectedCreature(); @@ -939,7 +939,7 @@ public: if (!guid_str) return false; - uint32 lowguid = 0; + ObjectGuid::LowType lowguid = 0; Creature* creature = NULL; if (dontdel_str) @@ -1101,7 +1101,7 @@ public: mtype = RANDOM_MOTION_TYPE; Creature* creature = handler->getSelectedCreature(); - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; if (creature) guidLow = creature->GetSpawnId(); @@ -1150,7 +1150,7 @@ public: } Creature* creature = handler->getSelectedCreature(); - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; if (creature) guidLow = creature->GetSpawnId(); @@ -1414,7 +1414,7 @@ public: if (!*args) return false; - uint32 leaderGUID = (uint32) atoi((char*)args); + ObjectGuid::LowType leaderGUID = (uint32) atoi((char*)args); Creature* creature = handler->getSelectedCreature(); if (!creature || !creature->GetSpawnId()) @@ -1424,7 +1424,7 @@ public: return false; } - uint32 lowguid = creature->GetSpawnId(); + ObjectGuid::LowType lowguid = creature->GetSpawnId(); if (creature->GetFormation()) { handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId()); @@ -1466,7 +1466,7 @@ public: if (!*args) return false; - uint32 linkguid = (uint32) atoi((char*)args); + ObjectGuid::LowType linkguid = (uint32) atoi((char*)args); Creature* creature = handler->getSelectedCreature(); diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index f4b442de92a..2863d2d4ede 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -749,12 +749,21 @@ public: return true; } - static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleReloadSkillPerfectItemTemplateCommand(ChatHandler* handler, const char* /*args*/) + { // latched onto HandleReloadSkillExtraItemTemplateCommand as it's part of that table group (and i don't want to chance all the command IDs) + TC_LOG_INFO("misc", "Re-Loading Skill Perfection Data Table..."); + LoadSkillPerfectItemTable(); + handler->SendGlobalGMSysMessage("DB table `skill_perfect_item_template` (perfect item procs when crafting) reloaded."); + return true; + } + + static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* args) { TC_LOG_INFO("misc", "Re-Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); handler->SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); - return true; + + return HandleReloadSkillPerfectItemTemplateCommand(handler, args); } static bool HandleReloadSkillFishingBaseLevelCommand(ChatHandler* handler, const char* /*args*/) diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 00b8bec51c8..9db1e5d68d8 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -150,7 +150,7 @@ public: path_number = strtok((char*)args, " "); uint32 pathid = 0; - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; Creature* target = handler->getSelectedCreature(); // Did player provide a path_id? @@ -1037,7 +1037,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, guid)); if (!creature) { diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 9747d31952b..f2d7f23bdc7 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -93,11 +93,6 @@ class npc_unworthy_initiate : public CreatureScript public: npc_unworthy_initiate() : CreatureScript("npc_unworthy_initiate") { } - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_unworthy_initiateAI(creature); - } - struct npc_unworthy_initiateAI : public ScriptedAI { npc_unworthy_initiateAI(Creature* creature) : ScriptedAI(creature) @@ -156,7 +151,7 @@ public: me->CastSpell(me, SPELL_DK_INITIATE_VISUAL, true); if (Player* starter = ObjectAccessor::GetPlayer(*me, playerGUID)) - sCreatureTextMgr->SendChat(me, SAY_EVENT_ATTACK, NULL, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, starter); + Talk(SAY_EVENT_ATTACK, starter); phase = PHASE_TO_ATTACK; } @@ -286,6 +281,11 @@ public: } } }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_unworthy_initiateAI(creature); + } }; class npc_unworthy_initiate_anchor : public CreatureScript @@ -457,6 +457,7 @@ enum Spells_DKI //SPELL_DUEL_TRIGGERED = 52990, SPELL_DUEL_VICTORY = 52994, SPELL_DUEL_FLAG = 52991, + SPELL_GROVEL = 7267, }; enum Says_VBM @@ -494,8 +495,6 @@ public: creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_15); - sCreatureTextMgr->SendChat(creature, SAY_DUEL, NULL, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); - player->CastSpell(creature, SPELL_DUEL, false); player->CastSpell(player, SPELL_DUEL_FLAG, true); } @@ -518,11 +517,6 @@ public: return true; } - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_death_knight_initiateAI(creature); - } - struct npc_death_knight_initiateAI : public CombatAI { npc_death_knight_initiateAI(Creature* creature) : CombatAI(creature) @@ -557,6 +551,7 @@ public: if (!m_bIsDuelInProgress && pSpell->Id == SPELL_DUEL) { m_uiDuelerGUID = pCaster->GetGUID(); + Talk(SAY_DUEL, pCaster); m_bIsDuelInProgress = true; } } @@ -577,7 +572,7 @@ public: pDoneBy->AttackStop(); me->CastSpell(pDoneBy, SPELL_DUEL_VICTORY, true); lose = true; - me->CastSpell(me, 7267, true); + me->CastSpell(me, SPELL_GROVEL, true); me->RestoreFaction(); } } @@ -607,13 +602,13 @@ public: { if (lose) { - if (!me->HasAura(7267)) + if (!me->HasAura(SPELL_GROVEL)) EnterEvadeMode(); return; } else if (me->GetVictim() && me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER && me->EnsureVictim()->HealthBelowPct(10)) { - me->EnsureVictim()->CastSpell(me->GetVictim(), 7267, true); // beg + me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_GROVEL, true); // beg me->EnsureVictim()->RemoveGameObject(SPELL_DUEL_FLAG, true); EnterEvadeMode(); return; @@ -626,6 +621,10 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_death_knight_initiateAI(creature); + } }; /*###### diff --git a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp index c4ab8f76487..0ae870b27ee 100644 --- a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp @@ -808,7 +808,7 @@ public: private: int8 _phase; uint32 _moveTimer; - uint32 _eventStarterGuidLow; + ObjectGuid::LowType _eventStarterGuidLow; GuidList _explosivesGuids; EventMap _events; }; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp index 3d7c128c8dd..5248c48029c 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp @@ -21,36 +21,42 @@ #include "naxxramas.h" #include "Player.h" -enum Heigan +enum Spells { - SPELL_DECREPIT_FEVER = 29998, // 25-man: 55011 - SPELL_SPELL_DISRUPTION = 29310, - SPELL_PLAGUE_CLOUD = 29350, - - SAY_AGGRO = 0, - SAY_SLAY = 1, - SAY_TAUNT = 2, - SAY_DEATH = 3 + SPELL_DECREPIT_FEVER = 29998, // 25-man: 55011 + SPELL_SPELL_DISRUPTION = 29310, + SPELL_PLAGUE_CLOUD = 29350, + SPELL_TELEPORT_SELF = 30211, +}; + +enum Yells +{ + SAY_AGGRO = 0, + SAY_SLAY = 1, + SAY_TAUNT = 2, + SAY_DEATH = 3, + + EMOTE_DANCE = 4, + EMOTE_DANCE_END = 5, }; enum Events { - EVENT_NONE, - EVENT_DISRUPT, + EVENT_DISRUPT = 1, EVENT_FEVER, EVENT_ERUPT, - EVENT_PHASE, + EVENT_DANCE, + EVENT_DANCE_END }; enum Phases { PHASE_FIGHT = 1, - PHASE_DANCE, + PHASE_DANCE }; enum Misc { - ACTION_SAFETY_DANCE_FAIL = 1, DATA_SAFETY_DANCE = 19962139 }; @@ -66,39 +72,25 @@ public: struct boss_heiganAI : public BossAI { - boss_heiganAI(Creature* creature) : BossAI(creature, BOSS_HEIGAN) + boss_heiganAI(Creature* creature) : BossAI(creature, BOSS_HEIGAN), eruptSection(0), eruptDirection(false), safetyDance(false) { } + + void Reset() override { - eruptSection = 0; - eruptDirection = false; - safetyDance = false; - phase = PHASE_FIGHT; + me->SetReactState(REACT_AGGRESSIVE); + _Reset(); } - uint32 eruptSection; - bool eruptDirection; - bool safetyDance; - Phases phase; - void KilledUnit(Unit* who) override { - if (!(rand32() % 5)) - Talk(SAY_SLAY); + Talk(SAY_SLAY); + if (who->GetTypeId() == TYPEID_PLAYER) safetyDance = false; } - void SetData(uint32 id, uint32 data) override - { - if (id == DATA_SAFETY_DANCE) - safetyDance = data ? true : false; - } - uint32 GetData(uint32 type) const override { - if (type == DATA_SAFETY_DANCE) - return safetyDance ? 1 : 0; - - return 0; + return (type == DATA_SAFETY_DANCE && safetyDance) ? 1u : 0u; } void JustDied(Unit* /*killer*/) override @@ -111,35 +103,14 @@ public: { _EnterCombat(); Talk(SAY_AGGRO); - EnterPhase(PHASE_FIGHT); - safetyDance = true; - } - - void EnterPhase(Phases newPhase) - { - phase = newPhase; - events.Reset(); + eruptSection = 3; - if (phase == PHASE_FIGHT) - { - events.ScheduleEvent(EVENT_DISRUPT, urand(10000, 25000)); - events.ScheduleEvent(EVENT_FEVER, urand(15000, 20000)); - events.ScheduleEvent(EVENT_PHASE, 90000); - events.ScheduleEvent(EVENT_ERUPT, 15000); - me->GetMotionMaster()->MoveChase(me->GetVictim()); - } - else - { - float x, y, z, o; - me->GetHomePosition(x, y, z, o); - me->NearTeleportTo(x, y, z, o - (float(M_PI) / 2)); - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveIdle(); - me->SetTarget(ObjectGuid::Empty); - DoCastAOE(SPELL_PLAGUE_CLOUD); - events.ScheduleEvent(EVENT_PHASE, 45000); - events.ScheduleEvent(EVENT_ERUPT, 8000); - } + events.ScheduleEvent(EVENT_DISRUPT, urand(15 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_FEVER, urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_DANCE, 90 * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_ERUPT, 15 * IN_MILLISECONDS, 0, PHASE_FIGHT); + + safetyDance = true; } void UpdateAI(uint32 diff) override @@ -155,15 +126,36 @@ public: { case EVENT_DISRUPT: DoCastAOE(SPELL_SPELL_DISRUPTION); - events.ScheduleEvent(EVENT_DISRUPT, urand(5000, 10000)); + events.ScheduleEvent(EVENT_DISRUPT, 11 * IN_MILLISECONDS); break; case EVENT_FEVER: DoCastAOE(SPELL_DECREPIT_FEVER); - events.ScheduleEvent(EVENT_FEVER, urand(20000, 25000)); + events.ScheduleEvent(EVENT_FEVER, urand(20 * IN_MILLISECONDS, 25 * IN_MILLISECONDS)); + break; + case EVENT_DANCE: + events.SetPhase(PHASE_DANCE); + Talk(SAY_TAUNT); + Talk(EMOTE_DANCE); + eruptSection = 3; + me->SetReactState(REACT_PASSIVE); + me->AttackStop(); + me->StopMoving(); + DoCast(SPELL_TELEPORT_SELF); + DoCastAOE(SPELL_PLAGUE_CLOUD); + events.ScheduleEvent(EVENT_DANCE_END, 45 * IN_MILLISECONDS, 0, PHASE_DANCE); + events.ScheduleEvent(EVENT_ERUPT, 10 * IN_MILLISECONDS); break; - case EVENT_PHASE: - /// @todo Add missing texts for both phase switches - EnterPhase(phase == PHASE_FIGHT ? PHASE_DANCE : PHASE_FIGHT); + case EVENT_DANCE_END: + events.SetPhase(PHASE_FIGHT); + Talk(EMOTE_DANCE_END); + eruptSection = 3; + events.ScheduleEvent(EVENT_DISRUPT, urand(10, 25) * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_FEVER, urand(15, 20) * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_DANCE, 90 * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_ERUPT, 15 * IN_MILLISECONDS, 0, PHASE_FIGHT); + me->CastStop(); + me->SetReactState(REACT_AGGRESSIVE); + DoZoneInCombat(); break; case EVENT_ERUPT: instance->SetData(DATA_HEIGAN_ERUPT, eruptSection); @@ -176,13 +168,22 @@ public: eruptDirection ? ++eruptSection : --eruptSection; - events.ScheduleEvent(EVENT_ERUPT, phase == PHASE_FIGHT ? 10000 : 3000); + if (events.IsInPhase(PHASE_DANCE)) + events.ScheduleEvent(EVENT_ERUPT, 3 * IN_MILLISECONDS, 0, PHASE_DANCE); + else + events.ScheduleEvent(EVENT_ERUPT, 10 * IN_MILLISECONDS, 0, PHASE_FIGHT); break; } } DoMeleeAttackIfReady(); } + + private: + uint32 eruptSection; + bool eruptDirection; + + bool safetyDance; // is achievement still possible? (= no player deaths yet) }; }; @@ -205,7 +206,7 @@ class spell_heigan_eruption : public SpellScriptLoader if (GetHitDamage() >= int32(GetHitPlayer()->GetHealth())) if (InstanceScript* instance = caster->GetInstanceScript()) if (Creature* Heigan = ObjectAccessor::GetCreature(*caster, instance->GetGuidData(DATA_HEIGAN))) - Heigan->AI()->SetData(DATA_SAFETY_DANCE, 0); + Heigan->AI()->KilledUnit(GetHitPlayer()); } void Register() override @@ -223,9 +224,7 @@ class spell_heigan_eruption : public SpellScriptLoader class achievement_safety_dance : public AchievementCriteriaScript { public: - achievement_safety_dance() : AchievementCriteriaScript("achievement_safety_dance") - { - } + achievement_safety_dance() : AchievementCriteriaScript("achievement_safety_dance") { } bool OnCheck(Player* /*player*/, Unit* target) override { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp index 33fb43b6bbc..494c173f5fc 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp @@ -27,7 +27,10 @@ enum Spells SPELL_WARN_NECROTIC_AURA = 59481, SPELL_SUMMON_SPORE = 29234, SPELL_DEATHBLOOM = 29865, - SPELL_INEVITABLE_DOOM = 29204 + SPELL_INEVITABLE_DOOM = 29204, + SPELL_FUNGAL_CREEP = 29232, + + SPELL_DEATHBLOOM_FINAL_DAMAGE = 55594, }; enum Texts @@ -72,29 +75,35 @@ class boss_loatheb : public CreatureScript void Reset() override { _Reset(); + instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_FUNGAL_CREEP); Initialize(); } void EnterCombat(Unit* /*who*/) override { _EnterCombat(); - events.ScheduleEvent(EVENT_NECROTIC_AURA, 17000); - events.ScheduleEvent(EVENT_DEATHBLOOM, 5000); - events.ScheduleEvent(EVENT_SPORE, IsHeroic() ? 18000 : 36000); - events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 120000); + events.ScheduleEvent(EVENT_NECROTIC_AURA, 17 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_DEATHBLOOM, 5 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SPORE, RAID_MODE(36,18) * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 2 * MINUTE * IN_MILLISECONDS); } - void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override + void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override { _sporeLoserData = false; + summon->CastSpell(summon,SPELL_FUNGAL_CREEP,true); } - uint32 GetData(uint32 id) const override + void SummonedCreatureDespawn(Creature* summon) override { - if (id != DATA_ACHIEVEMENT_SPORE_LOSER) - return 0; + summons.Despawn(summon); + if (summon->IsAlive()) + summon->CastSpell(summon,SPELL_FUNGAL_CREEP,true); + } - return uint32(_sporeLoserData); + uint32 GetData(uint32 id) const override + { + return (_sporeLoserData && id == DATA_ACHIEVEMENT_SPORE_LOSER) ? 1u : 0u; } void UpdateAI(uint32 diff) override @@ -111,21 +120,29 @@ class boss_loatheb : public CreatureScript case EVENT_NECROTIC_AURA: DoCastAOE(SPELL_NECROTIC_AURA); DoCast(me, SPELL_WARN_NECROTIC_AURA); - events.ScheduleEvent(EVENT_NECROTIC_AURA, 20000); - events.ScheduleEvent(EVENT_NECROTIC_AURA_FADING, 14000); + events.ScheduleEvent(EVENT_NECROTIC_AURA, 20 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_NECROTIC_AURA_FADING, 14 * IN_MILLISECONDS); break; case EVENT_DEATHBLOOM: DoCastAOE(SPELL_DEATHBLOOM); - events.ScheduleEvent(EVENT_DEATHBLOOM, 30000); + events.ScheduleEvent(EVENT_DEATHBLOOM, 30 * IN_MILLISECONDS); break; case EVENT_INEVITABLE_DOOM: _doomCounter++; DoCastAOE(SPELL_INEVITABLE_DOOM); - events.ScheduleEvent(EVENT_INEVITABLE_DOOM, std::max(120000 - _doomCounter * 15000, 15000)); // needs to be confirmed + if (_doomCounter > 6) + { + if (_doomCounter & 1) // odd + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 14 * IN_MILLISECONDS); + else + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 17 * IN_MILLISECONDS); + } + else + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 30 * IN_MILLISECONDS); break; case EVENT_SPORE: DoCast(me, SPELL_SUMMON_SPORE, false); - events.ScheduleEvent(EVENT_SPORE, IsHeroic() ? 18000 : 36000); + events.ScheduleEvent(EVENT_SPORE, RAID_MODE(36,18) * IN_MILLISECONDS); break; case EVENT_NECROTIC_AURA_FADING: Talk(SAY_NECROTIC_AURA_FADING); @@ -203,9 +220,46 @@ class spell_loatheb_necrotic_aura_warning : public SpellScriptLoader } }; +class spell_loatheb_deathbloom : public SpellScriptLoader +{ + public: + spell_loatheb_deathbloom() : SpellScriptLoader("spell_loatheb_deathbloom") { } + + class spell_loatheb_deathbloom_AuraScript : public AuraScript + { + PrepareAuraScript(spell_loatheb_deathbloom_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_DEATHBLOOM_FINAL_DAMAGE)) + return false; + return true; + } + + void AfterRemove(AuraEffect const* eff, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + return; + + GetTarget()->CastSpell(nullptr, SPELL_DEATHBLOOM_FINAL_DAMAGE, true, nullptr, eff, GetCasterGUID()); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_loatheb_deathbloom_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_loatheb_deathbloom_AuraScript(); + } +}; + void AddSC_boss_loatheb() { new boss_loatheb(); new achievement_spore_loser(); new spell_loatheb_necrotic_aura_warning(); + new spell_loatheb_deathbloom(); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp index f5e5b287571..810d446111a 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp @@ -19,51 +19,58 @@ #include "ScriptedCreature.h" #include "naxxramas.h" -enum Noth +enum Phases { - SAY_AGGRO = 0, - SAY_SUMMON = 1, - SAY_SLAY = 2, - SAY_DEATH = 3, - - SOUND_DEATH = 8848, - - SPELL_CURSE_PLAGUEBRINGER = 29213, // 25-man: 54835 - SPELL_CRIPPLE = 29212, // 25-man: 54814 - SPELL_TELEPORT = 29216, - - NPC_WARRIOR = 16984, - NPC_CHAMPION = 16983, - NPC_GUARDIAN = 16981 + PHASE_NONE, + PHASE_GROUND, + PHASE_BALCONY }; -#define SPELL_BLINK RAND(29208, 29209, 29210, 29211) +enum Events +{ + EVENT_CURSE = 1, // curse of the plaguebringer + EVENT_BLINK, // blink (25m only) + EVENT_WARRIOR, // summon warriors during ground phase + EVENT_BALCONY, // become untargetable and begin balcony phase + EVENT_BALCONY_TELEPORT, // actually teleport to balcony, this is slightly delayed + EVENT_WAVE, // spawn wave during balcony phase + EVENT_GROUND, // end balcony phase and teleport to ground + EVENT_GROUND_ATTACKABLE // become attackable and aggressive again at start of ground phase, once again slightly delayed to prevent motionmaster weirdness +}; -// Teleport position of Noth on his balcony -Position const Teleport = { 2631.370f, -3529.680f, 274.040f, 6.277f }; +enum Talk +{ + SAY_AGGRO = 0, + SAY_SUMMON = 1, + SAY_SLAY = 2, + SAY_DEATH = 3, -#define MAX_SUMMON_POS 5 + EMOTE_SUMMON = 4, // ground phase + EMOTE_SUMMON_WAVE = 5, // balcony phase + EMOTE_TELEPORT_1 = 6, // ground to balcony + EMOTE_TELEPORT_2 = 7 // balcony to ground +}; -Position const SummonPos[MAX_SUMMON_POS] = +enum Spells { - { 2728.12f, -3544.43f, 261.91f, 6.04f }, - { 2729.05f, -3544.47f, 261.91f, 5.58f }, - { 2728.24f, -3465.08f, 264.20f, 3.56f }, - { 2704.11f, -3456.81f, 265.53f, 4.51f }, - { 2663.56f, -3464.43f, 262.66f, 5.20f } + SPELL_CURSE = 29213, // 25-man: 54835 + SPELL_CRIPPLE = 29212, // 25-man: 54814 + + SPELL_TELEPORT = 29216, // ground to balcony + SPELL_TELEPORT_BACK = 29231 // balcony to ground }; -enum Events +enum Adds { - EVENT_NONE, - EVENT_BERSERK, - EVENT_CURSE, - EVENT_BLINK, - EVENT_WARRIOR, - EVENT_BALCONY, - EVENT_WAVE, - EVENT_GROUND + N_WARRIOR_SPELLS = 3, + N_CHAMPION_SPELLS = 6, + N_GUARDIAN_SPELLS = 3 }; +const uint32 SummonWarriorSpells[N_WARRIOR_SPELLS] = { 29247, 29248, 29249 }; +const uint32 SummonChampionSpells[N_CHAMPION_SPELLS] = { 29238, 29255, 29257, 29258, 29262, 29267 }; +const uint32 SummonGuardianSpells[N_GUARDIAN_SPELLS] = { 29239, 29256, 29268 }; + +#define SPELL_BLINK RAND(29208, 29209, 29210, 29211) class boss_noth : public CreatureScript { @@ -72,16 +79,38 @@ public: struct boss_nothAI : public BossAI { - boss_nothAI(Creature* creature) : BossAI(creature, BOSS_NOTH) + boss_nothAI(Creature* creature) : BossAI(creature, BOSS_NOTH), balconyCount(0), justBlinked(false) { - balconyCount = 0; - waveCount = 0; + std::copy(SummonWarriorSpells, SummonWarriorSpells + N_WARRIOR_SPELLS, _SummonWarriorSpells); + std::copy(SummonChampionSpells, SummonChampionSpells + N_CHAMPION_SPELLS, _SummonChampionSpells); + std::copy(SummonGuardianSpells, SummonGuardianSpells + N_GUARDIAN_SPELLS, _SummonGuardianSpells); + + events.SetPhase(PHASE_NONE); + } + + void EnterEvadeMode() override + { + Reset(); // teleport back first + _EnterEvadeMode(); } void Reset() override { - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + if (!me->IsAlive()) + return; + + // in case we reset during balcony phase + if (events.IsInPhase(PHASE_BALCONY)) + { + DoCastAOE(SPELL_TELEPORT_BACK); + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); + } + + balconyCount = 0; + events.SetPhase(PHASE_NONE); + justBlinked = false; + _Reset(); } @@ -89,31 +118,44 @@ public: { _EnterCombat(); Talk(SAY_AGGRO); - balconyCount = 0; EnterPhaseGround(); } void EnterPhaseGround() { - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + events.SetPhase(PHASE_GROUND); + DoZoneInCombat(); if (me->getThreatManager().isThreatListEmpty()) - EnterEvadeMode(); + Reset(); else { - events.ScheduleEvent(EVENT_BALCONY, 110000); - events.ScheduleEvent(EVENT_CURSE, 10000 + rand32() % 15000); - events.ScheduleEvent(EVENT_WARRIOR, 30000); + uint8 secondsGround; + switch (balconyCount) + { + case 0: + secondsGround = 90; + break; + case 1: + secondsGround = 110; + break; + case 2: + default: + secondsGround = 180; + } + events.ScheduleEvent(EVENT_GROUND_ATTACKABLE, 2 * IN_MILLISECONDS, 0, PHASE_GROUND); + events.ScheduleEvent(EVENT_BALCONY, secondsGround * IN_MILLISECONDS, 0, PHASE_GROUND); + events.ScheduleEvent(EVENT_CURSE, urand(10,25) * IN_MILLISECONDS, 0, PHASE_GROUND); + events.ScheduleEvent(EVENT_WARRIOR, urand(20,30) * IN_MILLISECONDS, 0, PHASE_GROUND); if (GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL) - events.ScheduleEvent(EVENT_BLINK, urand(20000, 40000)); + events.ScheduleEvent(EVENT_BLINK, urand(20,30) * IN_MILLISECONDS, 0, PHASE_GROUND); } } - void KilledUnit(Unit* /*victim*/) override + void KilledUnit(Unit* victim) override { - if (!(rand32() % 5)) + if(victim->GetTypeId() == TYPEID_PLAYER) Talk(SAY_SLAY); } @@ -121,7 +163,7 @@ public: { summons.Summon(summon); summon->setActive(true); - summon->AI()->DoZoneInCombat(); + summon->AI()->DoZoneInCombat(nullptr, 250.0f); // specify range to cover entire room - default 50yd is not enough } void JustDied(Unit* /*killer*/) override @@ -130,10 +172,35 @@ public: Talk(SAY_DEATH); } - void SummonUndead(uint32 entry, uint32 num) + void DamageTaken(Unit* /*who*/, uint32& damage) // prevent noth from somehow dying in the balcony phase { - for (uint32 i = 0; i < num; ++i) - me->SummonCreature(entry, SummonPos[rand32() % MAX_SUMMON_POS], TEMPSUMMON_CORPSE_DESPAWN, 60000); + if (!events.IsInPhase(PHASE_BALCONY)) + return; + if (damage < me->GetHealth()) + return; + + me->SetHealth(1u); + damage = 0u; + } + + void HandleSummon(uint32* spellsList, const uint8 nSpells, uint8 num) + { // this ensures we do not spawn two mobs using the same spell (<=> in the same position) if we can help it + while (num) + for (uint8 it = 0; it < nSpells && num; ++it) + { + num--; + uint8 selected = urand(it, nSpells - 1); + DoCastAOE(spellsList[selected]); + if (selected != it) // shuffle the selected into the part of the array that is no longer being searched + std::swap(spellsList[selected], spellsList[it]); + } + } + + void CastSummon(uint8 nWarrior, uint8 nChampion, uint8 nGuardian) + { + HandleSummon(_SummonWarriorSpells, N_WARRIOR_SPELLS, nWarrior); + HandleSummon(_SummonChampionSpells, N_CHAMPION_SPELLS, nChampion); + HandleSummon(_SummonGuardianSpells, N_GUARDIAN_SPELLS, nGuardian); } void UpdateAI(uint32 diff) override @@ -151,72 +218,115 @@ public: switch (eventId) { case EVENT_CURSE: - DoCastAOE(SPELL_CURSE_PLAGUEBRINGER); - events.ScheduleEvent(EVENT_CURSE, urand(50000, 60000)); - return; + { + DoCastAOE(SPELL_CURSE); + events.ScheduleEvent(EVENT_CURSE, urand(50, 70) * IN_MILLISECONDS, 0, PHASE_GROUND); + break; + } case EVENT_WARRIOR: Talk(SAY_SUMMON); - SummonUndead(NPC_WARRIOR, RAID_MODE(2, 3)); - events.ScheduleEvent(EVENT_WARRIOR, 30000); - return; + Talk(EMOTE_SUMMON); + + CastSummon(RAID_MODE(2, 3), 0, 0); + + events.ScheduleEvent(EVENT_WARRIOR, 40 * IN_MILLISECONDS, 0, PHASE_GROUND); + break; case EVENT_BLINK: DoCastAOE(SPELL_CRIPPLE, true); DoCastAOE(SPELL_BLINK); DoResetThreat(); - events.ScheduleEvent(EVENT_BLINK, 40000); - return; + justBlinked = true; + + events.ScheduleEvent(EVENT_BLINK, 40000, 0, PHASE_GROUND); + break; case EVENT_BALCONY: + events.SetPhase(PHASE_BALCONY); me->SetReactState(REACT_PASSIVE); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); me->AttackStop(); + me->StopMoving(); me->RemoveAllAuras(); - me->NearTeleportTo(Teleport.GetPositionX(), Teleport.GetPositionY(), Teleport.GetPositionZ(), Teleport.GetOrientation()); - events.Reset(); - events.ScheduleEvent(EVENT_WAVE, urand(2000, 5000)); - waveCount = 0; - return; + + events.ScheduleEvent(EVENT_BALCONY_TELEPORT, 3 * IN_MILLISECONDS, 0, PHASE_BALCONY); + events.ScheduleEvent(EVENT_WAVE, urand(5 * IN_MILLISECONDS, 8 * IN_MILLISECONDS), 0, PHASE_BALCONY); + + uint8 secondsBalcony; + switch (balconyCount) + { + case 0: + secondsBalcony = 70; + break; + case 1: + secondsBalcony = 97; + break; + case 2: + default: + secondsBalcony = 120; + break; + } + events.ScheduleEvent(EVENT_GROUND, secondsBalcony * IN_MILLISECONDS, 0, PHASE_BALCONY); + break; + case EVENT_BALCONY_TELEPORT: + Talk(EMOTE_TELEPORT_1); + DoCastAOE(SPELL_TELEPORT); + break; case EVENT_WAVE: - Talk(SAY_SUMMON); + Talk(EMOTE_SUMMON_WAVE); switch (balconyCount) { case 0: - SummonUndead(NPC_CHAMPION, RAID_MODE(2, 4)); + CastSummon(0, RAID_MODE(2, 4), 0); break; case 1: - SummonUndead(NPC_CHAMPION, RAID_MODE(1, 2)); - SummonUndead(NPC_GUARDIAN, RAID_MODE(1, 2)); + CastSummon(0, RAID_MODE(1, 2), RAID_MODE(1, 2)); break; case 2: - SummonUndead(NPC_GUARDIAN, RAID_MODE(2, 4)); + CastSummon(0, 0, RAID_MODE(2, 4)); break; default: - SummonUndead(NPC_CHAMPION, RAID_MODE(5, 10)); - SummonUndead(NPC_GUARDIAN, RAID_MODE(5, 10)); + CastSummon(0, RAID_MODE(5, 10), RAID_MODE(5, 10)); break; } - ++waveCount; - events.ScheduleEvent(waveCount < 2 ? EVENT_WAVE : EVENT_GROUND, urand(30000, 45000)); - return; + events.ScheduleEvent(EVENT_WAVE, urand(30, 45) * IN_MILLISECONDS, 0, PHASE_BALCONY); + break; case EVENT_GROUND: - { ++balconyCount; - float x, y, z, o; - me->GetHomePosition(x, y, z, o); - me->NearTeleportTo(x, y, z, o); - events.ScheduleEvent(EVENT_BALCONY, 110000); + + DoCastAOE(SPELL_TELEPORT_BACK); + Talk(EMOTE_TELEPORT_2); + EnterPhaseGround(); - return; - } + break; + case EVENT_GROUND_ATTACKABLE: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + break; } } - if (me->HasReactState(REACT_AGGRESSIVE)) - DoMeleeAttackIfReady(); + if (events.IsInPhase(PHASE_GROUND)) + { + /* workaround for movechase breaking after blinking + without this noth would just stand there unless his current target moves */ + if (justBlinked && me->GetVictim() && !me->IsWithinMeleeRange(me->EnsureVictim())) + { + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveChase(me->EnsureVictim()); + justBlinked = false; + } + else + DoMeleeAttackIfReady(); + } } private: - uint32 waveCount; uint32 balconyCount; + + bool justBlinked; + + uint32 _SummonWarriorSpells[N_WARRIOR_SPELLS]; + uint32 _SummonChampionSpells[N_CHAMPION_SPELLS]; + uint32 _SummonGuardianSpells[N_GUARDIAN_SPELLS]; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index 3a431ab3ac0..692e6d8b589 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -78,12 +78,13 @@ ObjectData const objectData[] = { 0, 0, } }; -float const HeiganPos[2] = { 2796.0f, -3707.0f }; +// from P2 teleport spell stored target +float const HeiganPos[2] = { 2793.86f, -3707.38f }; float const HeiganEruptionSlope[3] = { - (-3685.0f - HeiganPos[1]) / (2724.0f - HeiganPos[0]), - (-3647.0f - HeiganPos[1]) / (2749.0f - HeiganPos[0]), - (-3637.0f - HeiganPos[1]) / (2771.0f - HeiganPos[0]) + (-3703.303223f - HeiganPos[1]) / (2777.494141f - HeiganPos[0]), // between right center and far right + (-3696.948242f - HeiganPos[1]) / (2785.624268f - HeiganPos[0]), // between left and right halves + (-3691.880615f - HeiganPos[1]) / (2790.280029f - HeiganPos[0]) // between far left and left center }; // 0 H x @@ -246,7 +247,6 @@ class instance_naxxramas : public InstanceMapScript if (go->GetGOInfo()->displayId == 6785 || go->GetGOInfo()->displayId == 1287) { uint32 section = GetEruptionSection(go->GetPositionX(), go->GetPositionY()); - HeiganEruptionGUID[section].erase(go->GetGUID()); return; } @@ -552,7 +552,7 @@ class instance_naxxramas : public InstanceMapScript // This Function is called in CheckAchievementCriteriaMeet and CheckAchievementCriteriaMeet is called before SetBossState(bossId, DONE), // so to check if all bosses are done the checker must exclude 1 boss, the last done, if there is at most 1 encouter in progress when is // called this function then all bosses are done. The one boss that check is the boss that calls this function, so it is dead. - bool AreAllEncoutersDone() + bool AreAllEncountersDone() { uint32 numBossAlive = 0; for (uint32 i = 0; i < EncounterCount; ++i) @@ -589,7 +589,7 @@ class instance_naxxramas : public InstanceMapScript case 13239: // Loatheb case 13240: // Thaddius case 7617: // Kel'Thuzad - if (AreAllEncoutersDone() && !playerDied) + if (AreAllEncountersDone() && !playerDied) return true; return false; } diff --git a/src/server/scripts/Northrend/isle_of_conquest.cpp b/src/server/scripts/Northrend/isle_of_conquest.cpp index 79a20da9702..fccdc8098b6 100644 --- a/src/server/scripts/Northrend/isle_of_conquest.cpp +++ b/src/server/scripts/Northrend/isle_of_conquest.cpp @@ -206,7 +206,7 @@ class spell_ioc_parachute_ic : public SpellScriptLoader class StartLaunchEvent : public BasicEvent { public: - StartLaunchEvent(float x, float y, float z, uint32 lowGuid) : _x(x), _y(y), _z(z), _lowGuid(lowGuid) + StartLaunchEvent(float x, float y, float z, ObjectGuid::LowType lowGuid) : _x(x), _y(y), _z(z), _lowGuid(lowGuid) { } @@ -227,7 +227,7 @@ class StartLaunchEvent : public BasicEvent private: float _x, _y, _z; - uint32 _lowGuid; + ObjectGuid::LowType _lowGuid; }; class spell_ioc_launch : public SpellScriptLoader diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 0ab7c2fcb54..ca8c9a9ef93 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3424,7 +3424,7 @@ class spell_gen_turkey_marker : public SpellScriptLoader void Register() override { - AfterEffectApply += AuraEffectApplyFn(spell_gen_turkey_marker_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectApply += AuraEffectApplyFn(spell_gen_turkey_marker_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_turkey_marker_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } diff --git a/src/server/scripts/World/action_ip_logger.cpp b/src/server/scripts/World/action_ip_logger.cpp index 4a60a80ee5a..f0ffbe1c7f3 100644 --- a/src/server/scripts/World/action_ip_logger.cpp +++ b/src/server/scripts/World/action_ip_logger.cpp @@ -96,7 +96,7 @@ class AccountActionIpLogger : public AccountScript // We declare all the required variables uint32 playerGuid = accountId; - uint32 characterGuid = 0; + ObjectGuid::LowType characterGuid = 0; std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. // With this switch, we change systemNote so that we have a more accurate phrasing of what type it is. @@ -201,7 +201,7 @@ class CharacterActionIpLogger : public PlayerScript // We declare all the required variables uint32 playerGuid = player->GetSession()->GetAccountId(); - uint32 characterGuid = player->GetGUID().GetCounter(); + ObjectGuid::LowType characterGuid = player->GetGUID().GetCounter(); const std::string currentIp = player->GetSession()->GetRemoteAddress(); std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it... @@ -269,7 +269,7 @@ public: // Else, this script isn't loaded in the first place: We require no config check. // We declare all the required variables - uint32 characterGuid = guid.GetCounter(); // We have no access to any member function of Player* or WorldSession*. So use old-fashioned way. + ObjectGuid::LowType characterGuid = guid.GetCounter(); // We have no access to any member function of Player* or WorldSession*. So use old-fashioned way. // Query playerGuid/accountId, as we only have characterGuid std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index 44411b20aaf..9c05e4e2c08 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -179,6 +179,52 @@ enum ProfessionSpells }; /*### +# specialization trainers +###*/ +enum SpecializationTrainers +{ + /* Alchemy */ + N_TRAINER_TRANSMUTE = 22427, // Zarevhi + N_TRAINER_ELIXIR = 19052, // Lorokeem + N_TRAINER_POTION = 17909, // Lauranna Thar'well + + /* Blacksmithing */ + N_TRAINER_SMITHOMNI1 = 11145, // Myolor Sunderfury + N_TRAINER_SMITHOMNI2 = 11176, // Krathok Moltenfist + N_TRAINER_WEAPON1 = 11146, // Ironus Coldsteel + N_TRAINER_WEAPON2 = 11178, // Borgosh Corebender + N_TRAINER_ARMOR1 = 5164, // Grumnus Steelshaper + N_TRAINER_ARMOR2 = 11177, // Okothos Ironrager + N_TRAINER_HAMMER = 11191, // Lilith the Lithe + N_TRAINER_AXE = 11192, // Kilram + N_TRAINER_SWORD = 11193, // Seril Scourgebane + + /* Leatherworking */ + N_TRAINER_DRAGON1 = 7866, // Peter Galen + N_TRAINER_DRAGON2 = 7867, // Thorkaf Dragoneye + N_TRAINER_ELEMENTAL1 = 7868, // Sarah Tanner + N_TRAINER_ELEMENTAL2 = 7869, // Brumn Winterhoof + N_TRAINER_TRIBAL1 = 7870, // Caryssia Moonhunter + N_TRAINER_TRIBAL2 = 7871, // Se'Jib + + /* Tailoring */ + N_TRAINER_SPELLFIRE = 22213, // Gidge Spellweaver + N_TRAINER_MOONCLOTH = 22208, // Nasmara Moonsong + N_TRAINER_SHADOWEAVE = 22212, // Andrion Darkspinner +}; + +/*### +# specialization quests +###*/ +enum SpecializationQuests +{ + /* Alchemy */ + Q_MASTER_TRANSMUTE = 10899, + Q_MASTER_ELIXIR = 10902, + Q_MASTER_POTION = 10897, +}; + +/*### # formulas to calculate unlearning cost ###*/ @@ -395,23 +441,23 @@ public: if (player->HasSkill(SKILL_ALCHEMY) && player->GetBaseSkillValue(SKILL_ALCHEMY) >= 350 && player->getLevel() > 67) { - if (player->GetQuestRewardStatus(10899) || player->GetQuestRewardStatus(10902) || player->GetQuestRewardStatus(10897)) + if (player->GetQuestRewardStatus(Q_MASTER_TRANSMUTE) || player->GetQuestRewardStatus(Q_MASTER_ELIXIR) || player->GetQuestRewardStatus(Q_MASTER_POTION)) { switch (creature->GetEntry()) { - case 22427: //Zarevhi + case N_TRAINER_TRANSMUTE: //Zarevhi if (!HasAlchemySpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); if (player->HasSpell(S_TRANSMUTE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); break; - case 19052: //Lorokeem + case N_TRAINER_ELIXIR: //Lorokeem if (!HasAlchemySpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); if (player->HasSpell(S_ELIXIR)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); break; - case 17909: //Lauranna Thar'well + case N_TRAINER_POTION: //Lauranna Thar'well if (!HasAlchemySpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_POTION, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); if (player->HasSpell(S_POTION)) @@ -464,17 +510,17 @@ public: { switch (creature->GetEntry()) { - case 22427: + case N_TRAINER_TRANSMUTE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 19052: + case N_TRAINER_ELIXIR: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 17909: + case N_TRAINER_POTION: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_POTION, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -489,17 +535,17 @@ public: { switch (creature->GetEntry()) { - case 22427: //Zarevhi + case N_TRAINER_TRANSMUTE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 19052: //Lorokeem + case N_TRAINER_ELIXIR: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 17909: //Lauranna Thar'well + case N_TRAINER_POTION: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_POTION, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -564,20 +610,20 @@ public: { switch (creatureId) { - case 11145: //Myolor Sunderfury - case 11176: //Krathok Moltenfist + case N_TRAINER_SMITHOMNI1: + case N_TRAINER_SMITHOMNI2: if (!player->HasSpell(S_ARMOR) && !player->HasSpell(S_WEAPON) && player->GetReputationRank(REP_ARMOR) >= REP_FRIENDLY) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ARMOR_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); if (!player->HasSpell(S_WEAPON) && !player->HasSpell(S_ARMOR) && player->GetReputationRank(REP_WEAPON) >= REP_FRIENDLY) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WEAPON_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); break; - case 11146: //Ironus Coldsteel - case 11178: //Borgosh Corebender + case N_TRAINER_WEAPON1: + case N_TRAINER_WEAPON2: if (player->HasSpell(S_WEAPON)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WEAPON_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); break; - case 5164: //Grumnus Steelshaper - case 11177: //Okothos Ironrager + case N_TRAINER_ARMOR1: + case N_TRAINER_ARMOR2: if (player->HasSpell(S_ARMOR)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ARMOR_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); break; @@ -588,19 +634,19 @@ public: { switch (creatureId) { - case 11191: //Lilith the Lithe + case N_TRAINER_HAMMER: if (!HasWeaponSub(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 5); if (player->HasSpell(S_HAMMER)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 8); break; - case 11192: //Kilram + case N_TRAINER_AXE: if (!HasWeaponSub(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_AXE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 6); if (player->HasSpell(S_AXE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 9); break; - case 11193: //Seril Scourgebane + case N_TRAINER_SWORD: if (!HasWeaponSub(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 7); if (player->HasSpell(S_SWORD)) @@ -685,17 +731,17 @@ public: { switch (creature->GetEntry()) { - case 11191: + case N_TRAINER_HAMMER: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_CHECK, action); //unknown textID (TALK_HAMMER_LEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11192: + case N_TRAINER_AXE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_AXE, GOSSIP_SENDER_CHECK, action); //unknown textID (TALK_AXE_LEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11193: + case N_TRAINER_SWORD: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_CHECK, action); //unknown textID (TALK_SWORD_LEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -710,26 +756,26 @@ public: { switch (creature->GetEntry()) { - case 11146: //Ironus Coldsteel - case 11178: //Borgosh Corebender - case 5164: //Grumnus Steelshaper - case 11177: //Okothos Ironrager + case N_TRAINER_WEAPON1: + case N_TRAINER_WEAPON2: + case N_TRAINER_ARMOR1: + case N_TRAINER_ARMOR2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SMITH_SPEC, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ARMORORWEAPON, DoLowUnlearnCost(player), false); //unknown textID (TALK_UNLEARN_AXEORWEAPON) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11191: + case N_TRAINER_HAMMER: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player), false); //unknown textID (TALK_HAMMER_UNLEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11192: + case N_TRAINER_AXE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player), false); //unknown textID (TALK_AXE_UNLEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11193: + case N_TRAINER_SWORD: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SWORD, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player), false); //unknown textID (TALK_SWORD_UNLEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -901,18 +947,18 @@ public: { switch (creature->GetEntry()) { - case 7866: //Peter Galen - case 7867: //Thorkaf Dragoneye + case N_TRAINER_DRAGON1: + case N_TRAINER_DRAGON2: if (player->HasSpell(S_DRAGON)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 1); break; - case 7868: //Sarah Tanner - case 7869: //Brumn Winterhoof + case N_TRAINER_ELEMENTAL1: + case N_TRAINER_ELEMENTAL2: if (player->HasSpell(S_ELEMENTAL)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 2); break; - case 7870: //Caryssia Moonhunter - case 7871: //Se'Jib + case N_TRAINER_TRIBAL1: + case N_TRAINER_TRIBAL2: if (player->HasSpell(S_TRIBAL)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); break; @@ -952,20 +998,20 @@ public: { switch (creature->GetEntry()) { - case 7866: //Peter Galen - case 7867: //Thorkaf Dragoneye + case N_TRAINER_DRAGON1: + case N_TRAINER_DRAGON2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 7868: //Sarah Tanner - case 7869: //Brumn Winterhoof + case N_TRAINER_ELEMENTAL1: + case N_TRAINER_ELEMENTAL2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 7870: //Caryssia Moonhunter - case 7871: //Se'Jib + case N_TRAINER_TRIBAL1: + case N_TRAINER_TRIBAL2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -1027,19 +1073,19 @@ public: { switch (creature->GetEntry()) { - case 22213: //Gidge Spellweaver + case N_TRAINER_SPELLFIRE: if (!HasTailorSpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); if (player->HasSpell(S_SPELLFIRE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); break; - case 22208: //Nasmara Moonsong + case N_TRAINER_MOONCLOTH: if (!HasTailorSpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); if (player->HasSpell(S_MOONCLOTH)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); break; - case 22212: //Andrion Darkspinner + case N_TRAINER_SHADOWEAVE: if (!HasTailorSpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); if (player->HasSpell(S_SHADOWEAVE)) @@ -1092,17 +1138,17 @@ public: { switch (creature->GetEntry()) { - case 22213: + case N_TRAINER_SPELLFIRE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22208: + case N_TRAINER_MOONCLOTH: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22212: + case N_TRAINER_SHADOWEAVE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -1117,17 +1163,17 @@ public: { switch (creature->GetEntry()) { - case 22213: //Gidge Spellweaver + case N_TRAINER_SPELLFIRE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22208: //Nasmara Moonsong + case N_TRAINER_MOONCLOTH: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22212: //Andrion Darkspinner + case N_TRAINER_SHADOWEAVE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index a885c23ab82..221fea12399 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -1855,7 +1855,7 @@ Rate.Drop.Item.ReferencedAmount = 1 # Rate.XP.Quest # Rate.XP.Explore # Description: Experience rates. -# Default: 1 - (Rate.XP.Kill) +# Default: 1 - (Rate.XP.Kill, affects only kills outside of Battlegrounds) # 1 - (Rate.XP.Quest) # 1 - (Rate.XP.Explore) @@ -1864,6 +1864,14 @@ Rate.XP.Quest = 1 Rate.XP.Explore = 1 # +# Rate.XP.BattlegroundKill +# Description: Experience rate for honorable kills in battlegrounds, +# it works when Battleground.GiveXPForKills = 1 +# Default: 1 + +Rate.XP.BattlegroundKill = 1 + +# # Rate.Quest.Money.Reward # Rate.Quest.Money.Max.Level.Reward # Description: Multiplier for money quest rewards. Can not be below 0. @@ -2197,6 +2205,7 @@ Battleground.StoreStatistics.Enable = 0 # Don't bother with balance) # 1 - (Experimental, Don't allow to invite much more players # of one faction) +# 2 - (Experimental, Try to have even teams) Battleground.InvitationType = 0 @@ -2220,7 +2229,8 @@ BattleGround.PremadeGroupWaitForMatch = 1800000 # # Battleground.GiveXPForKills -# Description: Give experience for honorable kills in battlegrounds. +# Description: Give experience for honorable kills in battlegrounds, +# the rate can be changed in the Rate.XP.BattlegroundKill setting. # Default: 0 - (Disabled) # 1 - (Enabled) |