mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-03 11:03:47 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#include "WorldSession.h"
|
||||
|
||||
ArenaTeam::ArenaTeam()
|
||||
: TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
|
||||
: TeamId(0), Type(0), TeamName(), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
|
||||
BorderStyle(0), BorderColor(0)
|
||||
{
|
||||
Stats.WeekGames = 0;
|
||||
@@ -32,10 +32,10 @@ ArenaTeam::~ArenaTeam()
|
||||
{
|
||||
}
|
||||
|
||||
bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
|
||||
bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
|
||||
{
|
||||
// Check if captain is present
|
||||
if (!ObjectAccessor::FindPlayerInOrOutOfWorld(captainGuid))
|
||||
if (!ObjectAccessor::FindConnectedPlayer(captainGuid))
|
||||
return false;
|
||||
|
||||
// Check if arena team name is already taken
|
||||
@@ -54,13 +54,12 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamNa
|
||||
EmblemColor = emblemColor;
|
||||
BorderStyle = borderStyle;
|
||||
BorderColor = borderColor;
|
||||
uint32 captainLowGuid = GUID_LOPART(captainGuid);
|
||||
|
||||
// Save arena team to db
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->setString(1, TeamName);
|
||||
stmt->setUInt32(2, captainLowGuid);
|
||||
stmt->setUInt32(2, captainGuid.GetCounter());
|
||||
stmt->setUInt8(3, Type);
|
||||
stmt->setUInt16(4, Stats.Rating);
|
||||
stmt->setUInt32(5, BackgroundColor);
|
||||
@@ -75,7 +74,7 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamNa
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArenaTeam::AddMember(uint64 playerGuid)
|
||||
bool ArenaTeam::AddMember(ObjectGuid playerGuid)
|
||||
{
|
||||
std::string playerName;
|
||||
uint8 playerClass;
|
||||
@@ -85,7 +84,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
|
||||
return false;
|
||||
|
||||
// xinef: Get player name and class from player storage or global data storage
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(playerGuid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(playerGuid);
|
||||
if (player)
|
||||
{
|
||||
playerClass = player->getClass();
|
||||
@@ -93,7 +92,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(playerGuid));
|
||||
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(playerGuid.GetCounter());
|
||||
if (!playerData)
|
||||
return false;
|
||||
|
||||
@@ -105,9 +104,9 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
|
||||
return false;
|
||||
|
||||
// Check if player is already in a similar arena team
|
||||
if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromStorage(GUID_LOPART(playerGuid), GetSlot()) != 0)
|
||||
if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromStorage(playerGuid.GetCounter(), GetSlot()) != 0)
|
||||
{
|
||||
LOG_ERROR("server", "Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType());
|
||||
LOG_ERROR("server", "Arena: Player %s (%s) already has an arena team of type %u", playerName.c_str(), playerGuid.ToString().c_str(), GetType());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,7 +121,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
|
||||
// xinef: zomg! sync query
|
||||
// Try to get player's match maker rating from db and fall back to config setting if not found
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING);
|
||||
stmt->setUInt32(0, GUID_LOPART(playerGuid));
|
||||
stmt->setUInt32(0, playerGuid.GetCounter());
|
||||
stmt->setUInt8(1, GetSlot());
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
@@ -158,12 +157,12 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
|
||||
newMember.MaxMMR = maxMMR;
|
||||
|
||||
Members.push_back(newMember);
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(playerGuid), GetSlot(), GetId());
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(playerGuid.GetCounter(), GetSlot(), GetId());
|
||||
|
||||
// Save player's arena team membership to db
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->setUInt32(1, GUID_LOPART(playerGuid));
|
||||
stmt->setUInt32(1, playerGuid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Inform player if online
|
||||
@@ -189,7 +188,7 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult result)
|
||||
|
||||
TeamId = fields[0].GetUInt32();
|
||||
TeamName = fields[1].GetString();
|
||||
CaptainGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
CaptainGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
|
||||
Type = fields[3].GetUInt8();
|
||||
BackgroundColor = fields[4].GetUInt32();
|
||||
EmblemStyle = fields[5].GetUInt8();
|
||||
@@ -228,7 +227,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
|
||||
break;
|
||||
|
||||
ArenaTeamMember newMember;
|
||||
newMember.Guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
newMember.Guid = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32());
|
||||
newMember.WeekGames = fields[2].GetUInt16();
|
||||
newMember.WeekWins = fields[3].GetUInt16();
|
||||
newMember.SeasonGames = fields[4].GetUInt16();
|
||||
@@ -242,7 +241,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
|
||||
// Delete member if character information is missing
|
||||
if (fields[6].GetString().empty())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, GUID_LOPART(newMember.Guid));
|
||||
LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably player %s doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.ToString().c_str());
|
||||
this->DelMember(newMember.Guid, true);
|
||||
continue;
|
||||
}
|
||||
@@ -253,7 +252,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
|
||||
|
||||
// Put the player in the team
|
||||
Members.push_back(newMember);
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(newMember.Guid), GetSlot(), GetId());
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(newMember.Guid.GetCounter(), GetSlot(), GetId());
|
||||
} while (result->NextRow());
|
||||
|
||||
if (Empty() || !captainPresentInTeam)
|
||||
@@ -281,10 +280,10 @@ bool ArenaTeam::SetName(std::string const& name)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ArenaTeam::SetCaptain(uint64 guid)
|
||||
void ArenaTeam::SetCaptain(ObjectGuid guid)
|
||||
{
|
||||
// Disable remove/promote buttons
|
||||
Player* oldCaptain = ObjectAccessor::FindPlayerInOrOutOfWorld(GetCaptain());
|
||||
Player* oldCaptain = ObjectAccessor::FindConnectedPlayer(GetCaptain());
|
||||
if (oldCaptain)
|
||||
oldCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
|
||||
|
||||
@@ -293,33 +292,33 @@ void ArenaTeam::SetCaptain(uint64 guid)
|
||||
|
||||
// Update database
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_CAPTAIN);
|
||||
stmt->setUInt32(0, GUID_LOPART(guid));
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, GetId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Enable remove/promote buttons
|
||||
if (Player* newCaptain = ObjectAccessor::FindPlayerInOrOutOfWorld(guid))
|
||||
if (Player* newCaptain = ObjectAccessor::FindConnectedPlayer(guid))
|
||||
{
|
||||
newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0);
|
||||
/*if (oldCaptain)
|
||||
{
|
||||
LOG_DEBUG("bg.battleground", "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].",
|
||||
oldCaptain->GetName().c_str(), oldCaptain->GetGUIDLow(), newCaptain->GetName().c_str(),
|
||||
newCaptain->GetGUIDLow(), GetId(), GetType());
|
||||
LOG_DEBUG("bg.battleground", "Player: %s [%s] promoted player: %s [%s] to leader of arena team [Id: %u] [Type: %u].",
|
||||
oldCaptain->GetName().c_str(), oldCaptain->GetGUID().ToString().c_str(), newCaptain->GetName().c_str(),
|
||||
newCaptain->GetGUID().ToString().c_str(), GetId(), GetType());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
|
||||
void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
Group* group = (player && player->GetGroup()) ? player->GetGroup() : nullptr;
|
||||
|
||||
// Remove member from team
|
||||
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
{
|
||||
// Remove queues of members
|
||||
if (Player* playerMember = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid))
|
||||
if (Player* playerMember = ObjectAccessor::FindConnectedPlayer(itr->Guid))
|
||||
{
|
||||
if (group && playerMember->GetGroup() && group->GetGUID() == playerMember->GetGroup()->GetGUID())
|
||||
{
|
||||
@@ -345,7 +344,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
|
||||
if (itr->Guid == guid)
|
||||
{
|
||||
Members.erase(itr);
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(guid), GetSlot(), 0);
|
||||
sWorld->UpdateGlobalPlayerArenaTeam(guid.GetCounter(), GetSlot(), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -364,7 +363,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBER);
|
||||
stmt->setUInt32(0, GetId());
|
||||
stmt->setUInt32(1, GUID_LOPART(guid));
|
||||
stmt->setUInt32(1, guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
@@ -378,7 +377,7 @@ void ArenaTeam::Disband(WorldSession* session)
|
||||
// Broadcast update
|
||||
if (session)
|
||||
{
|
||||
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), "");
|
||||
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, ObjectGuid::Empty, 2, session->GetPlayerName(), GetName(), "");
|
||||
}
|
||||
|
||||
// Update database
|
||||
@@ -436,12 +435,12 @@ void ArenaTeam::Roster(WorldSession* session)
|
||||
|
||||
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
{
|
||||
player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid);
|
||||
player = ObjectAccessor::FindConnectedPlayer(itr->Guid);
|
||||
|
||||
data << uint64(itr->Guid); // guid
|
||||
data << uint8((player ? 1 : 0)); // online flag
|
||||
data << itr->Guid; // guid
|
||||
data << uint8((player ? 1 : 0)); // online flag
|
||||
tempName = "";
|
||||
sObjectMgr->GetPlayerNameByGUID(itr->Guid, tempName);
|
||||
sObjectMgr->GetPlayerNameByGUID(itr->Guid.GetCounter(), tempName);
|
||||
data << tempName; // member name
|
||||
data << uint32((itr->Guid == GetCaptain() ? 0 : 1));// captain flag 0 captain 1 member
|
||||
data << uint8((player ? player->getLevel() : 0)); // unknown, level?
|
||||
@@ -499,18 +498,18 @@ void ArenaTeam::NotifyStatsChanged()
|
||||
// This is called after a rated match ended
|
||||
// Updates arena team stats for every member of the team (not only the ones who participated!)
|
||||
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid))
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid))
|
||||
SendStats(player->GetSession());
|
||||
}
|
||||
|
||||
void ArenaTeam::Inspect(WorldSession* session, uint64 guid)
|
||||
void ArenaTeam::Inspect(WorldSession* session, ObjectGuid guid)
|
||||
{
|
||||
ArenaTeamMember* member = GetMember(guid);
|
||||
if (!member || GetSlot() >= MAX_ARENA_SLOT)
|
||||
return;
|
||||
|
||||
WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8 + 1 + 4 * 6);
|
||||
data << uint64(guid); // player guid
|
||||
data << guid; // player guid
|
||||
data << uint8(GetSlot()); // slot (0...2)
|
||||
data << uint32(GetId()); // arena team id
|
||||
data << uint32(Stats.Rating); // rating
|
||||
@@ -556,11 +555,11 @@ void ArenaTeamMember::ModifyMatchmakerRating(int32 mod, uint32 /*slot*/)
|
||||
void ArenaTeam::BroadcastPacket(WorldPacket* packet)
|
||||
{
|
||||
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid))
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid))
|
||||
player->GetSession()->SendPacket(packet);
|
||||
}
|
||||
|
||||
void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3)
|
||||
void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3)
|
||||
{
|
||||
WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1 + 1 + 1);
|
||||
data << uint8(event);
|
||||
@@ -584,7 +583,7 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCoun
|
||||
}
|
||||
|
||||
if (guid)
|
||||
data << uint64(guid);
|
||||
data << guid;
|
||||
|
||||
BroadcastPacket(&data);
|
||||
|
||||
@@ -602,7 +601,7 @@ void ArenaTeam::MassInviteToEvent(WorldSession* session)
|
||||
{
|
||||
if (itr->Guid != session->GetPlayer()->GetGUID())
|
||||
{
|
||||
data.appendPackGUID(itr->Guid);
|
||||
data << itr->Guid.WriteAsPacked();
|
||||
data << uint8(0); // unk
|
||||
}
|
||||
}
|
||||
@@ -635,7 +634,7 @@ uint8 ArenaTeam::GetSlotByType(uint32 type)
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
bool ArenaTeam::IsMember(uint64 guid) const
|
||||
bool ArenaTeam::IsMember(ObjectGuid guid) const
|
||||
{
|
||||
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
if (itr->Guid == guid)
|
||||
@@ -684,7 +683,7 @@ uint32 ArenaTeam::GetAverageMMR(Group* group) const
|
||||
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
{
|
||||
// Skip if player is not online
|
||||
if (!ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid))
|
||||
if (!ObjectAccessor::FindConnectedPlayer(itr->Guid))
|
||||
continue;
|
||||
|
||||
// Skip if player is not member of group
|
||||
@@ -778,7 +777,7 @@ void ArenaTeam::FinishGame(int32 mod, const Map* bgMap)
|
||||
|
||||
// Check if rating related achivements are met
|
||||
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
if (Player* member = ObjectAccessor::FindPlayerInOrOutOfWorld(itr->Guid))
|
||||
if (Player* member = ObjectAccessor::FindConnectedPlayer(itr->Guid))
|
||||
if (member->FindMap() == bgMap)
|
||||
member->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, Stats.Rating, Type);
|
||||
}
|
||||
@@ -892,7 +891,7 @@ void ArenaTeam::MemberWon(Player* player, uint32 againstMatchmakerRating, int32
|
||||
}
|
||||
}
|
||||
|
||||
void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints)
|
||||
void ArenaTeam::UpdateArenaPointsHelper(std::map<ObjectGuid, uint32>& playerPoints)
|
||||
{
|
||||
// Called after a match has ended and the stats are already modified
|
||||
// Helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons)
|
||||
@@ -910,15 +909,15 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints)
|
||||
if (itr->WeekGames >= requiredGames)
|
||||
pointsToAdd = GetPoints(itr->PersonalRating);
|
||||
|
||||
std::map<uint32, uint32>::iterator plr_itr = playerPoints.find(GUID_LOPART(itr->Guid));
|
||||
std::map<ObjectGuid, uint32>::iterator plr_itr = playerPoints.find(itr->Guid);
|
||||
if (plr_itr != playerPoints.end())
|
||||
{
|
||||
// Check if there is already more points
|
||||
if (plr_itr->second < pointsToAdd)
|
||||
playerPoints[GUID_LOPART(itr->Guid)] = pointsToAdd;
|
||||
playerPoints[itr->Guid] = pointsToAdd;
|
||||
}
|
||||
else
|
||||
playerPoints[GUID_LOPART(itr->Guid)] = pointsToAdd;
|
||||
playerPoints[itr->Guid] = pointsToAdd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -951,11 +950,11 @@ void ArenaTeam::SaveToDB()
|
||||
stmt->setUInt16(3, itr->SeasonGames);
|
||||
stmt->setUInt16(4, itr->SeasonWins);
|
||||
stmt->setUInt32(5, GetId());
|
||||
stmt->setUInt32(6, GUID_LOPART(itr->Guid));
|
||||
stmt->setUInt32(6, itr->Guid.GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHARACTER_ARENA_STATS);
|
||||
stmt->setUInt32(0, GUID_LOPART(itr->Guid));
|
||||
stmt->setUInt32(0, itr->Guid.GetCounter());
|
||||
stmt->setUInt8(1, GetSlot());
|
||||
stmt->setUInt16(2, itr->MatchMakerRating);
|
||||
stmt->setUInt16(3, itr->MaxMMR);
|
||||
@@ -994,7 +993,7 @@ ArenaTeamMember* ArenaTeam::GetMember(const std::string& name)
|
||||
return GetMember(sObjectMgr->GetPlayerGUIDByName(name));
|
||||
}
|
||||
|
||||
ArenaTeamMember* ArenaTeam::GetMember(uint64 guid)
|
||||
ArenaTeamMember* ArenaTeam::GetMember(ObjectGuid guid)
|
||||
{
|
||||
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
if (itr->Guid == guid)
|
||||
|
||||
@@ -95,7 +95,7 @@ enum ArenaSlot
|
||||
|
||||
struct ArenaTeamMember
|
||||
{
|
||||
uint64 Guid;
|
||||
ObjectGuid Guid;
|
||||
std::string Name;
|
||||
uint8 Class;
|
||||
uint16 WeekGames;
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
ArenaTeam();
|
||||
~ArenaTeam();
|
||||
|
||||
bool Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
|
||||
bool Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
|
||||
void Disband(WorldSession* session);
|
||||
void Disband();
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
[[nodiscard]] uint8 GetSlot() const { return GetSlotByType(GetType()); }
|
||||
static uint8 GetSlotByType(uint32 type);
|
||||
static uint8 GetReqPlayersForType(uint32 type);
|
||||
[[nodiscard]] uint64 GetCaptain() const { return CaptainGuid; }
|
||||
[[nodiscard]] ObjectGuid GetCaptain() const { return CaptainGuid; }
|
||||
[[nodiscard]] std::string const& GetName() const { return TeamName; }
|
||||
[[nodiscard]] const ArenaTeamStats& GetStats() const { return Stats; }
|
||||
void SetArenaTeamStats(ArenaTeamStats& stats) { Stats = stats; }
|
||||
@@ -147,22 +147,22 @@ public:
|
||||
[[nodiscard]] uint32 GetRating() const { return Stats.Rating; }
|
||||
uint32 GetAverageMMR(Group* group) const;
|
||||
|
||||
void SetCaptain(uint64 guid);
|
||||
void SetCaptain(ObjectGuid guid);
|
||||
bool SetName(std::string const& name);
|
||||
bool AddMember(uint64 playerGuid);
|
||||
bool AddMember(ObjectGuid playerGuid);
|
||||
|
||||
// Shouldn't be uint64 ed, because than can reference guid from members on Disband
|
||||
// Shouldn't be ObjectGuid, because than can reference guid from members on Disband
|
||||
// and this method removes given record from list. So invalid reference can happen.
|
||||
void DelMember(uint64 guid, bool cleanDb);
|
||||
void DelMember(ObjectGuid guid, bool cleanDb);
|
||||
|
||||
[[nodiscard]] size_t GetMembersSize() const { return Members.size(); }
|
||||
[[nodiscard]] bool Empty() const { return Members.empty(); }
|
||||
MemberList::iterator m_membersBegin() { return Members.begin(); }
|
||||
MemberList::iterator m_membersEnd() { return Members.end(); }
|
||||
MemberList& GetMembers() { return Members; }
|
||||
[[nodiscard]] bool IsMember(uint64 guid) const;
|
||||
[[nodiscard]] bool IsMember(ObjectGuid guid) const;
|
||||
|
||||
ArenaTeamMember* GetMember(uint64 guid);
|
||||
ArenaTeamMember* GetMember(ObjectGuid guid);
|
||||
ArenaTeamMember* GetMember(std::string const& name);
|
||||
|
||||
[[nodiscard]] bool IsFighting() const;
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
void SaveToDB();
|
||||
|
||||
void BroadcastPacket(WorldPacket* packet);
|
||||
void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3);
|
||||
void BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3);
|
||||
void NotifyStatsChanged();
|
||||
|
||||
void MassInviteToEvent(WorldSession* session);
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
void Roster(WorldSession* session);
|
||||
void Query(WorldSession* session);
|
||||
void SendStats(WorldSession* session);
|
||||
void Inspect(WorldSession* session, uint64 guid);
|
||||
void Inspect(WorldSession* session, ObjectGuid guid);
|
||||
|
||||
uint32 GetPoints(uint32 MemberRating);
|
||||
int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change, const Map* bgMap);
|
||||
void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
|
||||
|
||||
void UpdateArenaPointsHelper(std::map<uint32, uint32>& PlayerPoints);
|
||||
void UpdateArenaPointsHelper(std::map<ObjectGuid, uint32>& PlayerPoints);
|
||||
|
||||
void FinishWeek();
|
||||
void FinishGame(int32 mod, const Map* bgMap);
|
||||
@@ -207,7 +207,7 @@ protected:
|
||||
uint32 TeamId;
|
||||
uint8 Type;
|
||||
std::string TeamName;
|
||||
uint64 CaptainGuid;
|
||||
ObjectGuid CaptainGuid;
|
||||
|
||||
uint32 BackgroundColor; // ARGB format
|
||||
uint8 EmblemStyle; // icon id
|
||||
|
||||
@@ -82,7 +82,7 @@ ArenaTeam* ArenaTeamMgr::GetArenaTeamByName(std::string const& arenaTeamName, co
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid) const
|
||||
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(ObjectGuid guid) const
|
||||
{
|
||||
for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid, const uint32 type) const
|
||||
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(ObjectGuid guid, const uint32 type) const
|
||||
{
|
||||
for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ void ArenaTeamMgr::DistributeArenaPoints()
|
||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START);
|
||||
|
||||
// Temporary structure for storing maximum points to add values for all players
|
||||
std::map<uint32, uint32> PlayerPoints;
|
||||
std::map<ObjectGuid, uint32> PlayerPoints;
|
||||
|
||||
// At first update all points for all team members
|
||||
for (ArenaTeamContainer::iterator teamItr = GetArenaTeamMapBegin(); teamItr != GetArenaTeamMapEnd(); ++teamItr)
|
||||
@@ -206,16 +206,16 @@ void ArenaTeamMgr::DistributeArenaPoints()
|
||||
PreparedStatement* stmt;
|
||||
|
||||
// Cycle that gives points to all players
|
||||
for (std::map<uint32, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr)
|
||||
for (std::map<ObjectGuid, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr)
|
||||
{
|
||||
// Add points to player if online
|
||||
if (Player* player = HashMapHolder<Player>::Find(playerItr->first))
|
||||
if (Player* player = ObjectAccessor::FindPlayer(playerItr->first))
|
||||
player->ModifyArenaPoints(playerItr->second, &trans);
|
||||
else // Update database
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ARENA_POINTS);
|
||||
stmt->setUInt32(0, playerItr->second);
|
||||
stmt->setUInt32(1, playerItr->first);
|
||||
stmt->setUInt32(1, playerItr->first.GetCounter());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public:
|
||||
|
||||
ArenaTeam* GetArenaTeamById(uint32 arenaTeamId) const;
|
||||
ArenaTeam* GetArenaTeamByName(std::string const& arenaTeamName) const;
|
||||
ArenaTeam* GetArenaTeamByCaptain(uint64 guid) const;
|
||||
ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid) const;
|
||||
ArenaTeam* GetArenaTeamByName(std::string const& arenaTeamName, const uint32 type) const;
|
||||
ArenaTeam* GetArenaTeamByCaptain(uint64 guid, const uint32 type) const;
|
||||
ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid, const uint32 type) const;
|
||||
|
||||
void LoadArenaTeams();
|
||||
void AddArenaTeam(ArenaTeam* arenaTeam);
|
||||
|
||||
@@ -328,12 +328,12 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
|
||||
{
|
||||
if (GetReviveQueueSize())
|
||||
{
|
||||
for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
|
||||
for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
|
||||
{
|
||||
Creature* sh = nullptr;
|
||||
for (std::vector<uint64>::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
|
||||
for (ObjectGuid const guid : itr->second)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(*itr2);
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -348,9 +348,10 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
|
||||
|
||||
// Resurrection visual
|
||||
player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
|
||||
m_ResurrectQueue.push_back(*itr2);
|
||||
m_ResurrectQueue.push_back(guid);
|
||||
}
|
||||
(itr->second).clear();
|
||||
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
m_ReviveQueue.clear();
|
||||
@@ -362,15 +363,15 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
|
||||
}
|
||||
else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC
|
||||
{
|
||||
for (std::vector<uint64>::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
|
||||
for (ObjectGuid const guid : m_ResurrectQueue)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(*itr);
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (!player)
|
||||
continue;
|
||||
player->ResurrectPlayer(1.0f);
|
||||
player->CastSpell(player, 6962, true);
|
||||
player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
|
||||
sObjectAccessor->ConvertCorpseForPlayer(*itr);
|
||||
player->SpawnCorpseBones(false);
|
||||
}
|
||||
m_ResurrectQueue.clear();
|
||||
}
|
||||
@@ -557,7 +558,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
|
||||
if (GetStatus() == STATUS_IN_PROGRESS)
|
||||
{
|
||||
for (ToBeTeleportedMap::const_iterator itr = m_ToBeTeleported.begin(); itr != m_ToBeTeleported.end(); ++itr)
|
||||
if (Player* p = ObjectAccessor::GetObjectInOrOutOfWorld(itr->first, (Player*)nullptr))
|
||||
if (Player* p = ObjectAccessor::FindConnectedPlayer(itr->first))
|
||||
if (Player* t = ObjectAccessor::FindPlayer(itr->second))
|
||||
{
|
||||
if (!t->FindMap() || t->FindMap() != GetBgMap())
|
||||
@@ -566,7 +567,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
|
||||
p->SetSummonPoint(t->GetMapId(), t->GetPositionX(), t->GetPositionY(), t->GetPositionZ(), 15, true);
|
||||
|
||||
WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4);
|
||||
data << uint64(t->GetGUID());
|
||||
data << t->GetGUID();
|
||||
data << uint32(t->GetZoneId());
|
||||
data << uint32(15 * IN_MILLISECONDS);
|
||||
p->GetSession()->SendPacket(&data);
|
||||
@@ -1019,7 +1020,7 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
||||
BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID());
|
||||
|
||||
stmt->setUInt32(0, battlegroundId);
|
||||
stmt->setUInt32(1, player->GetGUIDLow());
|
||||
stmt->setUInt32(1, player->GetGUID().GetCounter());
|
||||
stmt->setBool(2, bgTeamId == winnerTeamId);
|
||||
stmt->setUInt32(3, score->second->GetKillingBlows());
|
||||
stmt->setUInt32(4, score->second->GetDeaths());
|
||||
@@ -1205,7 +1206,7 @@ void Battleground::AddPlayer(Player* player)
|
||||
|
||||
// score struct must be created in inherited class
|
||||
|
||||
uint64 guid = player->GetGUID();
|
||||
ObjectGuid guid = player->GetGUID();
|
||||
TeamId teamId = player->GetBgTeamId();
|
||||
|
||||
// Add to list/maps
|
||||
@@ -1282,7 +1283,7 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, TeamId teamId)
|
||||
return;
|
||||
}
|
||||
|
||||
uint64 playerGuid = player->GetGUID();
|
||||
ObjectGuid playerGuid = player->GetGUID();
|
||||
Group* group = GetBgRaid(teamId);
|
||||
if (!group) // first player joined
|
||||
{
|
||||
@@ -1380,7 +1381,7 @@ void Battleground::ReadyMarkerClicked(Player* p)
|
||||
{
|
||||
if (!isArena() || GetStatus() >= STATUS_IN_PROGRESS || GetStartDelayTime() <= BG_START_DELAY_15S || (m_Events & BG_STARTING_EVENT_3) || p->IsSpectator())
|
||||
return;
|
||||
readyMarkerClickedSet.insert(p->GetGUIDLow());
|
||||
readyMarkerClickedSet.insert(p->GetGUID());
|
||||
uint32 count = readyMarkerClickedSet.size();
|
||||
uint32 req = ArenaTeam::GetReqPlayersForType(GetArenaType());
|
||||
p->GetSession()->SendNotification("You are marked as ready %u/%u", count, req);
|
||||
@@ -1453,7 +1454,7 @@ void Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value,
|
||||
}
|
||||
}
|
||||
|
||||
void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid)
|
||||
void Battleground::AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid)
|
||||
{
|
||||
m_ReviveQueue[npc_guid].push_back(player_guid);
|
||||
|
||||
@@ -1466,26 +1467,26 @@ void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid
|
||||
|
||||
void Battleground::RemovePlayerFromResurrectQueue(Player* player)
|
||||
{
|
||||
for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
|
||||
for (std::vector<uint64>::iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
|
||||
for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
|
||||
for (GuidVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
|
||||
if (*itr2 == player->GetGUID())
|
||||
{
|
||||
(itr->second).erase(itr2);
|
||||
itr->second.erase(itr2);
|
||||
player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Battleground::RelocateDeadPlayers(uint64 queueIndex)
|
||||
void Battleground::RelocateDeadPlayers(ObjectGuid queueIndex)
|
||||
{
|
||||
// Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
|
||||
std::vector<uint64>& ghostList = m_ReviveQueue[queueIndex];
|
||||
GuidVector& ghostList = m_ReviveQueue[queueIndex];
|
||||
if (!ghostList.empty())
|
||||
{
|
||||
GraveyardStruct const* closestGrave = nullptr;
|
||||
for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr)
|
||||
for (ObjectGuid const guid : ghostList)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(*itr);
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -1495,6 +1496,7 @@ void Battleground::RelocateDeadPlayers(uint64 queueIndex)
|
||||
if (closestGrave)
|
||||
player->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
|
||||
}
|
||||
|
||||
ghostList.clear();
|
||||
}
|
||||
}
|
||||
@@ -1511,7 +1513,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
|
||||
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
|
||||
// So we must create it specific for this instance
|
||||
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
|
||||
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, GetBgMap(),
|
||||
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(),
|
||||
PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, goState))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
|
||||
@@ -1522,11 +1524,11 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
uint32 guid = go->GetGUIDLow();
|
||||
ObjectGuid::LowType spawnId = go->GetSpawnId();
|
||||
|
||||
// without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
|
||||
// iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
|
||||
GameObjectData& data = sObjectMgr->NewGOData(guid);
|
||||
GameObjectData& data = sObjectMgr->NewGOData(spawnId);
|
||||
|
||||
data.id = entry;
|
||||
data.mapid = GetMapId();
|
||||
@@ -1567,8 +1569,8 @@ void Battleground::DoorClose(uint32 type)
|
||||
}
|
||||
}
|
||||
else
|
||||
LOG_ERROR("server", "Battleground::DoorClose: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
|
||||
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
|
||||
LOG_ERROR("server", "Battleground::DoorClose: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
|
||||
type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
|
||||
}
|
||||
|
||||
void Battleground::DoorOpen(uint32 type)
|
||||
@@ -1579,16 +1581,16 @@ void Battleground::DoorOpen(uint32 type)
|
||||
obj->SetGoState(GO_STATE_ACTIVE);
|
||||
}
|
||||
else
|
||||
LOG_ERROR("server", "Battleground::DoorOpen: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
|
||||
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
|
||||
LOG_ERROR("server", "Battleground::DoorOpen: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
|
||||
type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
|
||||
}
|
||||
|
||||
GameObject* Battleground::GetBGObject(uint32 type)
|
||||
{
|
||||
GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]);
|
||||
if (!obj)
|
||||
LOG_ERROR("server", "Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
|
||||
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
|
||||
LOG_ERROR("server", "Battleground::GetBGObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
|
||||
type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1596,8 +1598,8 @@ Creature* Battleground::GetBGCreature(uint32 type)
|
||||
{
|
||||
Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]);
|
||||
if (!creature)
|
||||
LOG_ERROR("server", "Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
|
||||
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
|
||||
LOG_ERROR("server", "Battleground::GetBGCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
|
||||
type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID);
|
||||
return creature;
|
||||
}
|
||||
|
||||
@@ -1639,7 +1641,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y,
|
||||
}
|
||||
|
||||
Creature* creature = new Creature();
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
|
||||
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
|
||||
{
|
||||
LOG_ERROR("server", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!",
|
||||
entry, m_MapId, m_InstanceID);
|
||||
@@ -1687,13 +1689,14 @@ bool Battleground::DelCreature(uint32 type)
|
||||
if (Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]))
|
||||
{
|
||||
creature->AddObjectToRemoveList();
|
||||
BgCreatures[type] = 0;
|
||||
BgCreatures[type].Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_ERROR("server", "Battleground::DelCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
|
||||
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
|
||||
BgCreatures[type] = 0;
|
||||
LOG_ERROR("server", "Battleground::DelCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
|
||||
type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID);
|
||||
|
||||
BgCreatures[type].Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1706,12 +1709,14 @@ bool Battleground::DelObject(uint32 type)
|
||||
{
|
||||
obj->SetRespawnTime(0); // not save respawn time
|
||||
obj->Delete();
|
||||
BgObjects[type] = 0;
|
||||
BgObjects[type].Clear();
|
||||
return true;
|
||||
}
|
||||
LOG_ERROR("server", "Battleground::DelObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
|
||||
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
|
||||
BgObjects[type] = 0;
|
||||
|
||||
LOG_ERROR("server", "Battleground::DelObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
|
||||
type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
|
||||
|
||||
BgObjects[type].Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1722,7 +1727,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float
|
||||
if (Creature* creature = AddCreature(entry, type, x, y, z, o))
|
||||
{
|
||||
creature->setDeathState(DEAD);
|
||||
creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID());
|
||||
creature->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID());
|
||||
// aura
|
||||
// TODO: Fix display here
|
||||
// creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
|
||||
@@ -1878,7 +1883,7 @@ TeamId Battleground::GetOtherTeamId(TeamId teamId)
|
||||
return teamId != TEAM_NEUTRAL ? (teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE) : TEAM_NEUTRAL;
|
||||
}
|
||||
|
||||
bool Battleground::IsPlayerInBattleground(uint64 guid) const
|
||||
bool Battleground::IsPlayerInBattleground(ObjectGuid guid) const
|
||||
{
|
||||
BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
|
||||
if (itr != m_Players.end())
|
||||
@@ -1916,13 +1921,15 @@ void Battleground::SetHoliday(bool is_holiday)
|
||||
m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL;
|
||||
}
|
||||
|
||||
int32 Battleground::GetObjectType(uint64 guid)
|
||||
int32 Battleground::GetObjectType(ObjectGuid guid)
|
||||
{
|
||||
for (uint32 i = 0; i < BgObjects.size(); ++i)
|
||||
if (BgObjects[i] == guid)
|
||||
return i;
|
||||
LOG_ERROR("server", "Battleground::GetObjectType: player used gameobject (GUID: %u) which is not in internal data for BG (map: %u, instance id: %u), cheating?",
|
||||
GUID_LOPART(guid), m_MapId, m_InstanceID);
|
||||
|
||||
LOG_ERROR("server", "Battleground::GetObjectType: player used gameobject (%s) which is not in internal data for BG (map: %u, instance id: %u), cheating?",
|
||||
guid.ToString().c_str(), m_MapId, m_InstanceID);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ class ArenaLogEntryData
|
||||
{
|
||||
public:
|
||||
ArenaLogEntryData() {}
|
||||
void Fill(const char* name, uint32 guid, uint32 acc, uint32 arenaTeamId, std::string ip)
|
||||
void Fill(const char* name, ObjectGuid::LowType guid, uint32 acc, uint32 arenaTeamId, std::string ip)
|
||||
{
|
||||
Name = std::string(name);
|
||||
Guid = guid;
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
}
|
||||
|
||||
std::string Name;
|
||||
uint32 Guid{0};
|
||||
ObjectGuid::LowType Guid{0};
|
||||
uint32 Acc;
|
||||
uint32 ArenaTeamId{0};
|
||||
std::string IP;
|
||||
@@ -400,28 +400,28 @@ public:
|
||||
[[nodiscard]] uint32 GetMaxFreeSlots() const;
|
||||
|
||||
typedef std::set<Player*> SpectatorList;
|
||||
typedef std::map<uint64, uint64> ToBeTeleportedMap;
|
||||
typedef std::map<ObjectGuid, ObjectGuid> ToBeTeleportedMap;
|
||||
void AddSpectator(Player* p) { m_Spectators.insert(p); }
|
||||
void RemoveSpectator(Player* p) { m_Spectators.erase(p); }
|
||||
bool HaveSpectators() { return !m_Spectators.empty(); }
|
||||
[[nodiscard]] const SpectatorList& GetSpectators() const { return m_Spectators; }
|
||||
void AddToBeTeleported(uint64 spectator, uint64 participant) { m_ToBeTeleported[spectator] = participant; }
|
||||
void RemoveToBeTeleported(uint64 spectator) { ToBeTeleportedMap::iterator itr = m_ToBeTeleported.find(spectator); if (itr != m_ToBeTeleported.end()) m_ToBeTeleported.erase(itr); }
|
||||
void AddToBeTeleported(ObjectGuid spectator, ObjectGuid participant) { m_ToBeTeleported[spectator] = participant; }
|
||||
void RemoveToBeTeleported(ObjectGuid spectator) { ToBeTeleportedMap::iterator itr = m_ToBeTeleported.find(spectator); if (itr != m_ToBeTeleported.end()) m_ToBeTeleported.erase(itr); }
|
||||
void SpectatorsSendPacket(WorldPacket& data);
|
||||
|
||||
[[nodiscard]] bool isArena() const { return m_IsArena; }
|
||||
[[nodiscard]] bool isBattleground() const { return !m_IsArena; }
|
||||
[[nodiscard]] bool isRated() const { return m_IsRated; }
|
||||
|
||||
typedef std::map<uint64, Player*> BattlegroundPlayerMap;
|
||||
typedef std::map<ObjectGuid, Player*> BattlegroundPlayerMap;
|
||||
[[nodiscard]] BattlegroundPlayerMap const& GetPlayers() const { return m_Players; }
|
||||
[[nodiscard]] uint32 GetPlayersSize() const { return m_Players.size(); }
|
||||
|
||||
void ReadyMarkerClicked(Player* p); // pussywizard
|
||||
std::set<uint32> readyMarkerClickedSet; // pussywizard
|
||||
GuidSet readyMarkerClickedSet; // pussywizard
|
||||
|
||||
typedef std::map<uint64, BattlegroundScore*> BattlegroundScoreMap;
|
||||
typedef std::map<uint64, ArenaLogEntryData> ArenaLogEntryDataMap;// pussywizard
|
||||
typedef std::map<ObjectGuid, BattlegroundScore*> BattlegroundScoreMap;
|
||||
typedef std::map<ObjectGuid, ArenaLogEntryData> ArenaLogEntryDataMap;// pussywizard
|
||||
ArenaLogEntryDataMap ArenaLogEntries; // pussywizard
|
||||
[[nodiscard]] BattlegroundScoreMap::const_iterator GetPlayerScoresBegin() const { return PlayerScores.begin(); }
|
||||
[[nodiscard]] BattlegroundScoreMap::const_iterator GetPlayerScoresEnd() const { return PlayerScores.end(); }
|
||||
@@ -429,11 +429,11 @@ public:
|
||||
|
||||
[[nodiscard]] uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); }
|
||||
|
||||
void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
|
||||
void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid);
|
||||
void RemovePlayerFromResurrectQueue(Player* player);
|
||||
|
||||
/// Relocate all players in ReviveQueue to the closest graveyard
|
||||
void RelocateDeadPlayers(uint64 queueIndex);
|
||||
void RelocateDeadPlayers(ObjectGuid queueIndex);
|
||||
|
||||
void StartBattleground();
|
||||
|
||||
@@ -532,7 +532,7 @@ public:
|
||||
virtual void EventPlayerUsedGO(Player* /*player*/, GameObject* /*go*/) {}
|
||||
|
||||
// this function can be used by spell to interact with the BG map
|
||||
virtual void DoAction(uint32 /*action*/, uint64 /*var*/) {}
|
||||
virtual void DoAction(uint32 /*action*/, ObjectGuid /*var*/) {}
|
||||
|
||||
virtual void HandlePlayerResurrect(Player* /*player*/) {}
|
||||
|
||||
@@ -550,8 +550,8 @@ public:
|
||||
void SetHoliday(bool is_holiday);
|
||||
|
||||
// TODO: make this protected:
|
||||
typedef std::vector<uint64> BGObjects;
|
||||
typedef std::vector<uint64> BGCreatures;
|
||||
typedef GuidVector BGObjects;
|
||||
typedef GuidVector BGCreatures;
|
||||
BGObjects BgObjects;
|
||||
BGCreatures BgCreatures;
|
||||
void SpawnBGObject(uint32 type, uint32 respawntime);
|
||||
@@ -560,7 +560,7 @@ public:
|
||||
bool DelCreature(uint32 type);
|
||||
bool DelObject(uint32 type);
|
||||
bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, TeamId teamId);
|
||||
int32 GetObjectType(uint64 guid);
|
||||
int32 GetObjectType(ObjectGuid guid);
|
||||
|
||||
void DoorOpen(uint32 type);
|
||||
void DoorClose(uint32 type);
|
||||
@@ -571,15 +571,15 @@ public:
|
||||
|
||||
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
|
||||
static TeamId GetOtherTeamId(TeamId teamId);
|
||||
[[nodiscard]] bool IsPlayerInBattleground(uint64 guid) const;
|
||||
[[nodiscard]] bool IsPlayerInBattleground(ObjectGuid guid) const;
|
||||
|
||||
[[nodiscard]] bool ToBeDeleted() const { return m_SetDeleteThis; }
|
||||
//void SetDeleteThis() { m_SetDeleteThis = true; }
|
||||
|
||||
void RewardXPAtKill(Player* killer, Player* victim);
|
||||
|
||||
[[nodiscard]] virtual uint64 GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const { return 0; }
|
||||
virtual void SetDroppedFlagGUID(uint64 /*guid*/, TeamId /*teamId*/ = TEAM_NEUTRAL) {}
|
||||
[[nodiscard]] virtual ObjectGuid GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const { return ObjectGuid::Empty; }
|
||||
virtual void SetDroppedFlagGUID(ObjectGuid /*guid*/, TeamId /*teamId*/ = TEAM_NEUTRAL) {}
|
||||
[[nodiscard]] uint32 GetTeamScore(TeamId teamId) const;
|
||||
|
||||
virtual TeamId GetPrematureWinner();
|
||||
@@ -637,9 +637,9 @@ protected:
|
||||
virtual void RemovePlayer(Player* /*player*/) {}
|
||||
|
||||
// Player lists, those need to be accessible by inherited classes
|
||||
BattlegroundPlayerMap m_Players;
|
||||
BattlegroundPlayerMap m_Players;
|
||||
// Spirit Guide guid + Player list GUIDS
|
||||
std::map<uint64, std::vector<uint64> > m_ReviveQueue;
|
||||
std::map<ObjectGuid, GuidVector> m_ReviveQueue;
|
||||
|
||||
// these are important variables used for starting messages
|
||||
uint8 m_Events;
|
||||
@@ -708,8 +708,8 @@ private:
|
||||
virtual void PostUpdateImpl(uint32 /* diff */) { }
|
||||
|
||||
// Player lists
|
||||
std::vector<uint64> m_ResurrectQueue; // Player GUID
|
||||
std::deque<uint64> m_OfflineQueue; // Player GUID
|
||||
GuidVector m_ResurrectQueue; // Player GUID
|
||||
GuidDeque m_OfflineQueue; // Player GUID
|
||||
|
||||
// Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction
|
||||
// Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG
|
||||
|
||||
@@ -248,11 +248,11 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
itr2 = itr++;
|
||||
if (!bg->IsPlayerInBattleground(itr2->first))
|
||||
{
|
||||
LOG_ERROR("server", "Player " UI64FMTD " has scoreboard entry for battleground %u but is not in battleground!", itr->first, bg->GetBgTypeID());
|
||||
LOG_ERROR("server", "Player %s has scoreboard entry for battleground %u but is not in battleground!", itr->first.ToString().c_str(), bg->GetBgTypeID());
|
||||
continue;
|
||||
}
|
||||
|
||||
*data << uint64(itr2->first);
|
||||
*data << itr2->first;
|
||||
*data << uint32(itr2->second->KillingBlows);
|
||||
if (type == 0)
|
||||
{
|
||||
@@ -392,16 +392,16 @@ void BattlegroundMgr::BuildPlaySoundPacket(WorldPacket* data, uint32 soundid)
|
||||
*data << uint32(soundid);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid)
|
||||
void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid)
|
||||
{
|
||||
data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8);
|
||||
*data << uint64(guid);
|
||||
*data << guid;
|
||||
}
|
||||
|
||||
void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player)
|
||||
{
|
||||
data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8);
|
||||
*data << uint64(player->GetGUID());
|
||||
*data << player->GetGUID();
|
||||
}
|
||||
|
||||
Battleground* BattlegroundMgr::GetBattleground(uint32 instanceId)
|
||||
@@ -646,7 +646,7 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution()
|
||||
LOG_INFO("server", "AzerothCore Battleground: Automatic Arena Point Distribution initialized.");
|
||||
}
|
||||
|
||||
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
|
||||
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
|
||||
{
|
||||
if (!player)
|
||||
return;
|
||||
@@ -659,7 +659,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
|
||||
loser_kills = acore::Honor::hk_honor_at_level(player->getLevel(), float(loser_kills));
|
||||
|
||||
data->Initialize(SMSG_BATTLEFIELD_LIST);
|
||||
*data << uint64(guid); // battlemaster guid
|
||||
*data << guid; // battlemaster guid
|
||||
*data << uint8(fromWhere); // from where you joined
|
||||
*data << uint32(bgTypeId); // battleground id
|
||||
*data << uint8(0); // unk
|
||||
@@ -714,7 +714,7 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid)
|
||||
void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid)
|
||||
{
|
||||
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
|
||||
uint32 time_ = RESURRECTION_INTERVAL - bg->GetLastResurrectTime(); // resurrect every X seconds
|
||||
@@ -1021,7 +1021,7 @@ void BattlegroundMgr::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, T
|
||||
for (auto itr : ginfo->Players)
|
||||
{
|
||||
// get the player
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(itr);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(itr);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -1049,7 +1049,7 @@ void BattlegroundMgr::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, T
|
||||
|
||||
// pussywizard:
|
||||
if (bg->isArena() && bg->isRated())
|
||||
bg->ArenaLogEntries[player->GetGUID()].Fill(player->GetName().c_str(), player->GetGUIDLow(), player->GetSession()->GetAccountId(), ginfo->ArenaTeamId, player->GetSession()->GetRemoteAddress());
|
||||
bg->ArenaLogEntries[player->GetGUID()].Fill(player->GetName().c_str(), player->GetGUID().GetCounter(), player->GetSession()->GetAccountId(), ginfo->ArenaTeamId, player->GetSession()->GetRemoteAddress());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ public:
|
||||
|
||||
/* Packet Building */
|
||||
void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player);
|
||||
void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid);
|
||||
void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
|
||||
void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid);
|
||||
void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
|
||||
void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result);
|
||||
void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
|
||||
void BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg);
|
||||
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType, TeamId teamId, bool isRated = false, BattlegroundTypeId forceBgTypeId = BATTLEGROUND_TYPE_NONE);
|
||||
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid);
|
||||
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid);
|
||||
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
|
||||
|
||||
/* Battlegrounds */
|
||||
Battleground* GetBattleground(uint32 InstanceID);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include <unordered_map>
|
||||
|
||||
std::unordered_map<uint64, uint32> BGSpamProtection;
|
||||
std::unordered_map<ObjectGuid, uint32> BGSpamProtection;
|
||||
|
||||
/*********************************************************/
|
||||
/*** BATTLEGROUND QUEUE SYSTEM ***/
|
||||
@@ -240,11 +240,11 @@ uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo) const
|
||||
}
|
||||
|
||||
//remove player from queue and from group info, if group info is empty then remove it too
|
||||
void BattlegroundQueue::RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQueueSlot)
|
||||
void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot)
|
||||
{
|
||||
// pussywizard: leave queue packet
|
||||
if (playerQueueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
|
||||
if (Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld(guid))
|
||||
if (Player* p = ObjectAccessor::FindConnectedPlayer(guid))
|
||||
{
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, nullptr, playerQueueSlot, STATUS_NONE, 0, 0, 0, TEAM_NEUTRAL);
|
||||
@@ -302,7 +302,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQu
|
||||
if (groupInfo->IsInvitedToBGInstanceGUID && groupInfo->IsRated && !sentToBg)
|
||||
if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(groupInfo->ArenaTeamId))
|
||||
{
|
||||
if (Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid))
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
|
||||
at->MemberLost(player, groupInfo->OpponentsMatchmakerRating);
|
||||
at->SaveToDB();
|
||||
}
|
||||
@@ -321,7 +321,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQu
|
||||
{
|
||||
uint32 queueSlot = PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
|
||||
if (Player* plr = ObjectAccessor::FindPlayerInOrOutOfWorld(*(groupInfo->Players.begin())))
|
||||
if (Player* plr = ObjectAccessor::FindConnectedPlayer(*(groupInfo->Players.begin())))
|
||||
{
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(groupInfo->BgTypeId, groupInfo->ArenaType);
|
||||
queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId);
|
||||
@@ -338,20 +338,20 @@ void BattlegroundQueue::AddEvent(BasicEvent* Event, uint64 e_time)
|
||||
m_events.AddEvent(Event, m_events.CalculateTime(e_time));
|
||||
}
|
||||
|
||||
bool BattlegroundQueue::IsPlayerInvitedToRatedArena(uint64 pl_guid)
|
||||
bool BattlegroundQueue::IsPlayerInvitedToRatedArena(ObjectGuid pl_guid)
|
||||
{
|
||||
auto qItr = m_QueuedPlayers.find(pl_guid);
|
||||
return qItr != m_QueuedPlayers.end() && qItr->second->IsRated && qItr->second->IsInvitedToBGInstanceGUID;
|
||||
}
|
||||
|
||||
//returns true when player pl_guid is in queue and is invited to bgInstanceGuid
|
||||
bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
|
||||
bool BattlegroundQueue::IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
|
||||
{
|
||||
auto qItr = m_QueuedPlayers.find(pl_guid);
|
||||
return qItr != m_QueuedPlayers.end() && qItr->second->IsInvitedToBGInstanceGUID == bgInstanceGuid && qItr->second->RemoveInviteTime == removeTime;
|
||||
}
|
||||
|
||||
bool BattlegroundQueue::GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo)
|
||||
bool BattlegroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo)
|
||||
{
|
||||
auto qItr = m_QueuedPlayers.find(guid);
|
||||
if (qItr == m_QueuedPlayers.end())
|
||||
@@ -1034,7 +1034,7 @@ void BattlegroundQueue::SendMessageArenaQueue(GroupQueueInfo* ginfo, bool IsJoin
|
||||
|
||||
bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(m_PlayerGuid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(m_PlayerGuid);
|
||||
|
||||
// player logged off, so he is no longer in queue
|
||||
if (!player)
|
||||
@@ -1072,7 +1072,7 @@ void BGQueueInviteEvent::Abort(uint64 /*e_time*/)
|
||||
|
||||
bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(m_PlayerGuid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(m_PlayerGuid);
|
||||
|
||||
// player logged off, so he is no longer in queue
|
||||
if (!player)
|
||||
@@ -1096,7 +1096,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, player->GetGUIDLow());
|
||||
stmt->setUInt32(0, player->GetGUID().GetCounter());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!)
|
||||
{
|
||||
std::set<uint64> Players; // player guid set
|
||||
GuidSet Players; // player guid set
|
||||
TeamId teamId; // Player team (TEAM_ALLIANCE/TEAM_HORDE)
|
||||
TeamId RealTeamID; // Realm player team (TEAM_ALLIANCE/TEAM_HORDE)
|
||||
BattlegroundTypeId BgTypeId; // battleground type id
|
||||
@@ -63,10 +63,10 @@ public:
|
||||
bool CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
|
||||
bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam);
|
||||
GroupQueueInfo* AddGroup(Player* leader, Group* group, PvPDifficultyEntry const* bracketEntry, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId);
|
||||
void RemovePlayer(uint64 guid, bool sentToBg, uint32 playerQueueSlot);
|
||||
bool IsPlayerInvitedToRatedArena(uint64 pl_guid);
|
||||
bool IsPlayerInvited(uint64 pl_guid, uint32 bgInstanceGuid, uint32 removeTime);
|
||||
bool GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo);
|
||||
void RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot);
|
||||
bool IsPlayerInvitedToRatedArena(ObjectGuid pl_guid);
|
||||
bool IsPlayerInvited(ObjectGuid pl_guid, uint32 bgInstanceGuid, uint32 removeTime);
|
||||
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo);
|
||||
void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo);
|
||||
uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo) const;
|
||||
uint32 GetPlayersCountInGroupsQueue(BattlegroundBracketId bracketId, BattlegroundQueueGroupTypes bgqueue);
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
void SetBgTypeIdAndArenaType(BattlegroundTypeId b, uint8 a) { m_bgTypeId = b; m_arenaType = ArenaType(a); } // pussywizard
|
||||
void AddEvent(BasicEvent* Event, uint64 e_time);
|
||||
|
||||
typedef std::map<uint64, GroupQueueInfo*> QueuedPlayersMap;
|
||||
typedef std::map<ObjectGuid, GroupQueueInfo*> QueuedPlayersMap;
|
||||
QueuedPlayersMap m_QueuedPlayers;
|
||||
|
||||
//do NOT use deque because deque.erase() invalidates ALL iterators
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
class BGQueueInviteEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
BGQueueInviteEvent(uint64 pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) :
|
||||
BGQueueInviteEvent(ObjectGuid pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) :
|
||||
m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime)
|
||||
{ }
|
||||
~BGQueueInviteEvent() override = default;
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
bool Execute(uint64 e_time, uint32 p_time) override;
|
||||
void Abort(uint64 e_time) override;
|
||||
private:
|
||||
uint64 m_PlayerGuid;
|
||||
ObjectGuid m_PlayerGuid;
|
||||
uint32 m_BgInstanceGUID;
|
||||
BattlegroundTypeId m_BgTypeId;
|
||||
uint8 m_ArenaType;
|
||||
@@ -154,7 +154,7 @@ private:
|
||||
class BGQueueRemoveEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
BGQueueRemoveEvent(uint64 pl_guid, uint32 bgInstanceGUID, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime)
|
||||
BGQueueRemoveEvent(ObjectGuid pl_guid, uint32 bgInstanceGUID, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime)
|
||||
: m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgQueueTypeId(bgQueueTypeId)
|
||||
{}
|
||||
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
bool Execute(uint64 e_time, uint32 p_time) override;
|
||||
void Abort(uint64 e_time) override;
|
||||
private:
|
||||
uint64 m_PlayerGuid;
|
||||
ObjectGuid m_PlayerGuid;
|
||||
uint32 m_BgInstanceGUID;
|
||||
uint32 m_RemoveTime;
|
||||
BattlegroundQueueTypeId m_BgQueueTypeId;
|
||||
|
||||
@@ -294,7 +294,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
|
||||
|
||||
if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
{
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node);
|
||||
UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
@@ -307,7 +307,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
|
||||
{
|
||||
if (!_capturePointInfo[node]._captured)
|
||||
{
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node);
|
||||
UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1);
|
||||
_capturePointInfo[node]._state = BG_AB_NODE_STATE_ALLY_CONTESTED + player->GetTeamId();
|
||||
_capturePointInfo[node]._ownerTeamId = TEAM_NEUTRAL;
|
||||
@@ -327,7 +327,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
|
||||
}
|
||||
else
|
||||
{
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node, 0);
|
||||
player->KilledMonsterCredit(BG_AB_QUEST_CREDIT_BASE + node);
|
||||
UpdatePlayerScore(player, SCORE_BASES_ASSAULTED, 1);
|
||||
NodeDeoccupied(node); // before setting team owner to neutral
|
||||
|
||||
@@ -379,14 +379,14 @@ bool BattlegroundAB::SetupBattleground()
|
||||
AddSpiritGuide(BG_AB_SPIRIT_HORDE, BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][0], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][1], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][2], BG_AB_SpiritGuidePos[BG_AB_SPIRIT_HORDE][3], TEAM_HORDE);
|
||||
|
||||
for (uint32 i = BG_AB_OBJECT_BANNER_NEUTRAL; i < BG_AB_OBJECT_MAX; ++i)
|
||||
if (BgObjects[i] == 0)
|
||||
if (!BgObjects[i])
|
||||
{
|
||||
LOG_ERROR("sql.sql", "BatteGroundAB: Failed to spawn some object Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32 i = BG_AB_SPIRIT_ALIANCE; i <= BG_AB_SPIRIT_HORDE; ++i)
|
||||
if (BgCreatures[i] == 0)
|
||||
if (!BgCreatures[i])
|
||||
{
|
||||
LOG_ERROR("sql.sql", "BatteGroundAB: Failed to spawn spirit guides Battleground not created!");
|
||||
return false;
|
||||
|
||||
@@ -325,7 +325,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
|
||||
if (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid <= AV_NPC_A_GRAVEDEFENSE3)
|
||||
|| (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))
|
||||
{
|
||||
CreatureData& data = sObjectMgr->NewOrExistCreatureData(creature->GetDBTableGUIDLow());
|
||||
CreatureData& data = sObjectMgr->NewOrExistCreatureData(creature->GetSpawnId());
|
||||
data.wander_distance = 5;
|
||||
}
|
||||
//else wander_distance will be 15, so creatures move maximum=10
|
||||
|
||||
@@ -28,8 +28,6 @@ BattlegroundEY::BattlegroundEY()
|
||||
_honorTics = 0;
|
||||
_ownedPointsCount[TEAM_ALLIANCE] = 0;
|
||||
_ownedPointsCount[TEAM_HORDE] = 0;
|
||||
_flagKeeperGUID = 0;
|
||||
_droppedFlagGUID = 0;
|
||||
_flagState = BG_EY_FLAG_STATE_ON_BASE;
|
||||
_flagCapturedObject = 0;
|
||||
|
||||
@@ -318,14 +316,14 @@ bool BattlegroundEY::SetupBattleground()
|
||||
AddSpiritGuide(BG_EY_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, TEAM_HORDE);
|
||||
|
||||
for (uint32 i = BG_EY_OBJECT_DOOR_A; i < BG_EY_OBJECT_MAX; ++i)
|
||||
if (BgObjects[i] == 0)
|
||||
if (!BgObjects[i])
|
||||
{
|
||||
LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn some object Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32 i = BG_EY_SPIRIT_MAIN_ALLIANCE; i <= BG_EY_SPIRIT_MAIN_HORDE; ++i)
|
||||
if (BgCreatures[i] == 0)
|
||||
if (!BgCreatures[i])
|
||||
{
|
||||
LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn spirit guides Battleground not created!");
|
||||
return false;
|
||||
@@ -343,8 +341,8 @@ void BattlegroundEY::Init()
|
||||
_honorTics = BattlegroundMgr::IsBGWeekend(GetBgTypeID(true)) ? BG_EY_HONOR_TICK_WEEKEND : BG_EY_HONOR_TICK_NORMAL;
|
||||
_ownedPointsCount[TEAM_ALLIANCE] = 0;
|
||||
_ownedPointsCount[TEAM_HORDE] = 0;
|
||||
_flagKeeperGUID = 0;
|
||||
_droppedFlagGUID = 0;
|
||||
_flagKeeperGUID.Clear();
|
||||
_droppedFlagGUID.Clear();
|
||||
_flagState = BG_EY_FLAG_STATE_ON_BASE;
|
||||
_flagCapturedObject = 0;
|
||||
}
|
||||
@@ -372,9 +370,9 @@ void BattlegroundEY::RespawnFlagAfterDrop()
|
||||
|
||||
_flagState = BG_EY_FLAG_STATE_ON_BASE;
|
||||
RespawnFlag();
|
||||
if (GameObject* flag = ObjectAccessor::GetObjectInMap(GetDroppedFlagGUID(), FindBgMap(), (GameObject*)nullptr))
|
||||
if (GameObject* flag = FindBgMap()->GetGameObject(GetDroppedFlagGUID()))
|
||||
flag->Delete();
|
||||
SetDroppedFlagGUID(0);
|
||||
SetDroppedFlagGUID(ObjectGuid::Empty);
|
||||
}
|
||||
|
||||
void BattlegroundEY::HandleKillPlayer(Player* player, Player* killer)
|
||||
@@ -391,7 +389,7 @@ void BattlegroundEY::EventPlayerDroppedFlag(Player* player)
|
||||
if (GetFlagPickerGUID() != player->GetGUID())
|
||||
return;
|
||||
|
||||
SetFlagPicker(0);
|
||||
SetFlagPicker(ObjectGuid::Empty);
|
||||
player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
return;
|
||||
@@ -413,7 +411,7 @@ void BattlegroundEY::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
|
||||
_flagState = BG_EY_FLAG_STATE_ON_PLAYER;
|
||||
SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY);
|
||||
SetFlagPicker(player->GetGUID());
|
||||
SetDroppedFlagGUID(0);
|
||||
SetDroppedFlagGUID(ObjectGuid::Empty);
|
||||
|
||||
player->CastSpell(player, BG_EY_NETHERSTORM_FLAG_SPELL, true);
|
||||
player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
|
||||
@@ -501,7 +499,7 @@ void BattlegroundEY::EventTeamCapturedPoint(TeamId teamId, uint32 point)
|
||||
|
||||
void BattlegroundEY::EventPlayerCapturedFlag(Player* player, uint32 BgObjectType)
|
||||
{
|
||||
SetFlagPicker(0);
|
||||
SetFlagPicker(ObjectGuid::Empty);
|
||||
_flagState = BG_EY_FLAG_STATE_ON_BASE;
|
||||
player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
|
||||
player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
|
||||
|
||||
@@ -326,14 +326,14 @@ public:
|
||||
void StartingEventOpenDoors() override;
|
||||
|
||||
/* BG Flags */
|
||||
uint64 GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const override { return _flagKeeperGUID; }
|
||||
void SetFlagPicker(uint64 guid) { _flagKeeperGUID = guid; }
|
||||
ObjectGuid GetFlagPickerGUID(TeamId /*teamId*/ = TEAM_NEUTRAL) const override { return _flagKeeperGUID; }
|
||||
void SetFlagPicker(ObjectGuid guid) { _flagKeeperGUID = guid; }
|
||||
uint8 GetFlagState() const { return _flagState; }
|
||||
void RespawnFlag();
|
||||
void RespawnFlagAfterDrop();
|
||||
|
||||
void RemovePlayer(Player* player) override;
|
||||
void HandleBuffUse(uint64 buff_guid);
|
||||
void HandleBuffUse(ObjectGuid buff_guid);
|
||||
void HandleAreaTrigger(Player* player, uint32 trigger) override;
|
||||
void HandleKillPlayer(Player* player, Player* killer) override;
|
||||
GraveyardStruct const* GetClosestGraveyard(Player* player) override;
|
||||
@@ -342,8 +342,8 @@ public:
|
||||
void EndBattleground(TeamId winnerTeamId) override;
|
||||
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
|
||||
void FillInitialWorldStates(WorldPacket& data) override;
|
||||
void SetDroppedFlagGUID(uint64 guid, TeamId /*teamId*/ = TEAM_NEUTRAL) override { _droppedFlagGUID = guid; }
|
||||
uint64 GetDroppedFlagGUID() const { return _droppedFlagGUID; }
|
||||
void SetDroppedFlagGUID(ObjectGuid guid, TeamId /*teamId*/ = TEAM_NEUTRAL) override { _droppedFlagGUID = guid; }
|
||||
ObjectGuid GetDroppedFlagGUID() const { return _droppedFlagGUID; }
|
||||
|
||||
/* Battleground Events */
|
||||
void EventPlayerClickedOnFlag(Player* player, GameObject* gameObject) override;
|
||||
@@ -390,8 +390,8 @@ private:
|
||||
EventMap _bgEvents;
|
||||
uint32 _honorTics;
|
||||
uint8 _ownedPointsCount[BG_TEAMS_COUNT];
|
||||
uint64 _flagKeeperGUID;
|
||||
uint64 _droppedFlagGUID;
|
||||
ObjectGuid _flagKeeperGUID;
|
||||
ObjectGuid _droppedFlagGUID;
|
||||
uint8 _flagState;
|
||||
uint32 _flagCapturedObject;
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ BattlegroundIC::~BattlegroundIC()
|
||||
{
|
||||
}
|
||||
|
||||
void BattlegroundIC::DoAction(uint32 action, uint64 guid)
|
||||
void BattlegroundIC::DoAction(uint32 action, ObjectGuid guid)
|
||||
{
|
||||
if (action != ACTION_TELEPORT_PLAYER_TO_TRANSPORT)
|
||||
return;
|
||||
@@ -127,7 +127,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
|
||||
if (!catapult->IsAlive())
|
||||
{
|
||||
// Check if creature respawn time is properly saved
|
||||
RespawnMap::iterator itr = respawnMap.find(catapult->GetGUIDLow());
|
||||
RespawnMap::iterator itr = respawnMap.find(catapult->GetGUID());
|
||||
if (itr == respawnMap.end() || time(nullptr) < itr->second)
|
||||
continue;
|
||||
|
||||
@@ -145,7 +145,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
|
||||
if (!glaiveThrower->IsAlive())
|
||||
{
|
||||
// Check if creature respawn time is properly saved
|
||||
RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUIDLow());
|
||||
RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUID());
|
||||
if (itr == respawnMap.end() || time(nullptr) < itr->second)
|
||||
continue;
|
||||
|
||||
@@ -174,7 +174,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
|
||||
if (!siege->IsAlive())
|
||||
{
|
||||
// Check if creature respawn time is properly saved
|
||||
RespawnMap::iterator itr = respawnMap.find(siege->GetGUIDLow());
|
||||
RespawnMap::iterator itr = respawnMap.find(siege->GetGUID());
|
||||
if (itr == respawnMap.end() || time(nullptr) < itr->second)
|
||||
continue;
|
||||
|
||||
@@ -191,7 +191,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
|
||||
if (!demolisher->IsAlive())
|
||||
{
|
||||
// Check if creature respawn time is properly saved
|
||||
RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUIDLow());
|
||||
RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUID());
|
||||
if (itr == respawnMap.end() || time(nullptr) < itr->second)
|
||||
continue;
|
||||
|
||||
@@ -521,7 +521,7 @@ void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer)
|
||||
// Xinef: Add to respawn list
|
||||
if (entry == NPC_DEMOLISHER || entry == NPC_SIEGE_ENGINE_H || entry == NPC_SIEGE_ENGINE_A ||
|
||||
entry == NPC_GLAIVE_THROWER_A || entry == NPC_GLAIVE_THROWER_H || entry == NPC_CATAPULT)
|
||||
respawnMap[unit->GetGUIDLow()] = time(nullptr) + VEHICLE_RESPAWN_TIME;
|
||||
respawnMap[unit->GetGUID()] = time(nullptr) + VEHICLE_RESPAWN_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -868,7 +868,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture)
|
||||
if (!siegeVehicle->IsVehicleInUse())
|
||||
Unit::Kill(siegeEngine, siegeEngine);
|
||||
|
||||
respawnMap[siegeEngine->GetGUIDLow()] = time(nullptr) + VEHICLE_RESPAWN_TIME;
|
||||
respawnMap[siegeEngine->GetGUID()] = time(nullptr) + VEHICLE_RESPAWN_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -924,7 +924,7 @@ public:
|
||||
|
||||
bool AllNodesConrolledByTeam(TeamId teamId) const override; // overwrited
|
||||
bool IsResourceGlutAllowed(TeamId teamId) const;
|
||||
void DoAction(uint32 action, uint64 guid) override;
|
||||
void DoAction(uint32 action, ObjectGuid guid) override;
|
||||
private:
|
||||
uint32 closeFortressDoorsTimer;
|
||||
bool doorsClosed;
|
||||
@@ -935,7 +935,7 @@ private:
|
||||
BG_IC_GateState GateStatus[6];
|
||||
ICNodePoint nodePoint[7];
|
||||
|
||||
typedef std::map<uint32, uint32> RespawnMap;
|
||||
typedef std::map<ObjectGuid, uint32> RespawnMap;
|
||||
RespawnMap respawnMap;
|
||||
|
||||
MotionTransport* gunshipAlliance;
|
||||
|
||||
@@ -886,13 +886,13 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
|
||||
|
||||
GraveyardStatus[i] = Source->GetTeamId();
|
||||
// Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
|
||||
std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]];
|
||||
GuidVector& ghost_list = m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]];
|
||||
if (!ghost_list.empty())
|
||||
{
|
||||
GraveyardStruct const* ClosestGrave = nullptr;
|
||||
for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
|
||||
for (ObjectGuid const guid : ghost_list)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(*itr);
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
@@ -902,8 +902,9 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
|
||||
if (ClosestGrave)
|
||||
player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
|
||||
}
|
||||
|
||||
// xinef: clear resurrect queue for this creature
|
||||
m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]].clear();
|
||||
ghost_list.clear();
|
||||
}
|
||||
|
||||
DelCreature(BG_SA_MAXNPC + i);
|
||||
|
||||
@@ -24,10 +24,6 @@ BattlegroundWS::BattlegroundWS()
|
||||
StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_WS_START_HALF_MINUTE;
|
||||
StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN;
|
||||
|
||||
_flagKeepers[TEAM_ALLIANCE] = 0;
|
||||
_flagKeepers[TEAM_HORDE] = 0;
|
||||
_droppedFlagGUID[TEAM_ALLIANCE] = 0;
|
||||
_droppedFlagGUID[TEAM_HORDE] = 0;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_lastFlagCaptureTeam = TEAM_NEUTRAL;
|
||||
@@ -70,18 +66,18 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff)
|
||||
RespawnFlagAfterDrop(TEAM_HORDE);
|
||||
break;
|
||||
case BG_WS_EVENT_BOTH_FLAGS_KEPT10:
|
||||
if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_ALLIANCE), this->FindBgMap(), (Player*)nullptr))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_ALLIANCE)))
|
||||
player->CastSpell(player, BG_WS_SPELL_FOCUSED_ASSAULT, true);
|
||||
if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_HORDE), this->FindBgMap(), (Player*)nullptr))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_HORDE)))
|
||||
player->CastSpell(player, BG_WS_SPELL_FOCUSED_ASSAULT, true);
|
||||
break;
|
||||
case BG_WS_EVENT_BOTH_FLAGS_KEPT15:
|
||||
if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_ALLIANCE), this->FindBgMap(), (Player*)nullptr))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_ALLIANCE)))
|
||||
{
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT);
|
||||
player->CastSpell(player, BG_WS_SPELL_BRUTAL_ASSAULT, true);
|
||||
}
|
||||
if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_HORDE), this->FindBgMap(), (Player*)nullptr))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_HORDE)))
|
||||
{
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT);
|
||||
player->CastSpell(player, BG_WS_SPELL_BRUTAL_ASSAULT, true);
|
||||
@@ -142,7 +138,7 @@ void BattlegroundWS::RespawnFlagAfterDrop(TeamId teamId)
|
||||
if (GameObject* flag = GetBgMap()->GetGameObject(GetDroppedFlagGUID(teamId)))
|
||||
flag->Delete();
|
||||
|
||||
SetDroppedFlagGUID(0, teamId);
|
||||
SetDroppedFlagGUID(ObjectGuid::Empty, teamId);
|
||||
_bgEvents.CancelEvent(BG_WS_EVENT_BOTH_FLAGS_KEPT10);
|
||||
_bgEvents.CancelEvent(BG_WS_EVENT_BOTH_FLAGS_KEPT15);
|
||||
RemoveAssaultAuras();
|
||||
@@ -157,7 +153,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
|
||||
RemoveAssaultAuras();
|
||||
|
||||
AddPoints(player->GetTeamId(), 1);
|
||||
SetFlagPicker(0, GetOtherTeamId(player->GetTeamId()));
|
||||
SetFlagPicker(ObjectGuid::Empty, GetOtherTeamId(player->GetTeamId()));
|
||||
UpdateFlagState(GetOtherTeamId(player->GetTeamId()), BG_WS_FLAG_STATE_ON_BASE);
|
||||
if (player->GetTeamId() == TEAM_ALLIANCE)
|
||||
{
|
||||
@@ -200,7 +196,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* player)
|
||||
if (GetFlagPickerGUID(TEAM_HORDE) != player->GetGUID() && GetFlagPickerGUID(TEAM_ALLIANCE) != player->GetGUID())
|
||||
return;
|
||||
|
||||
SetFlagPicker(0, GetOtherTeamId(player->GetTeamId()));
|
||||
SetFlagPicker(ObjectGuid::Empty, GetOtherTeamId(player->GetTeamId()));
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT);
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_BRUTAL_ASSAULT);
|
||||
@@ -279,7 +275,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
|
||||
// Alliance Flag on ground
|
||||
if (GetFlagState(TEAM_ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && player->IsWithinDistInMap(gameObject, 10.0f) && gameObject->GetEntry() == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY)
|
||||
{
|
||||
SetDroppedFlagGUID(0, TEAM_ALLIANCE);
|
||||
SetDroppedFlagGUID(ObjectGuid::Empty, TEAM_ALLIANCE);
|
||||
if (player->GetTeamId() == TEAM_ALLIANCE)
|
||||
{
|
||||
UpdateFlagState(TEAM_ALLIANCE, BG_WS_FLAG_STATE_ON_BASE);
|
||||
@@ -310,7 +306,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
|
||||
// Horde Flag on ground
|
||||
if (GetFlagState(TEAM_HORDE) == BG_WS_FLAG_STATE_ON_GROUND && player->IsWithinDistInMap(gameObject, 10.0f) && gameObject->GetEntry() == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY)
|
||||
{
|
||||
SetDroppedFlagGUID(0, TEAM_HORDE);
|
||||
SetDroppedFlagGUID(ObjectGuid::Empty, TEAM_HORDE);
|
||||
if (player->GetTeamId() == TEAM_HORDE)
|
||||
{
|
||||
UpdateFlagState(TEAM_HORDE, BG_WS_FLAG_STATE_ON_BASE);
|
||||
@@ -412,14 +408,14 @@ bool BattlegroundWS::SetupBattleground()
|
||||
AddSpiritGuide(WS_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, TEAM_HORDE);
|
||||
|
||||
for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i < BG_WS_OBJECT_MAX; ++i)
|
||||
if (BgObjects[i] == 0)
|
||||
if (!BgObjects[i])
|
||||
{
|
||||
LOG_ERROR("sql.sql", "BatteGroundWS: Failed to spawn some object Battleground not created!");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32 i = WS_SPIRIT_MAIN_ALLIANCE; i < BG_CREATURES_MAX_WS; ++i)
|
||||
if (BgCreatures[i] == 0)
|
||||
if (!BgCreatures[i])
|
||||
{
|
||||
LOG_ERROR("sql.sql", "BatteGroundWS: Failed to spawn spirit guides Battleground not created!");
|
||||
return false;
|
||||
@@ -434,10 +430,10 @@ void BattlegroundWS::Init()
|
||||
Battleground::Init();
|
||||
|
||||
_bgEvents.Reset();
|
||||
_flagKeepers[TEAM_ALLIANCE] = 0;
|
||||
_flagKeepers[TEAM_HORDE] = 0;
|
||||
_droppedFlagGUID[TEAM_ALLIANCE] = 0;
|
||||
_droppedFlagGUID[TEAM_HORDE] = 0;
|
||||
_flagKeepers[TEAM_ALLIANCE].Clear();
|
||||
_flagKeepers[TEAM_HORDE].Clear();
|
||||
_droppedFlagGUID[TEAM_ALLIANCE].Clear();
|
||||
_droppedFlagGUID[TEAM_HORDE].Clear();
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_lastFlagCaptureTeam = TEAM_NEUTRAL;
|
||||
@@ -530,8 +526,8 @@ TeamId BattlegroundWS::GetPrematureWinner()
|
||||
|
||||
uint32 BattlegroundWS::GetAssaultSpellId() const
|
||||
{
|
||||
if ((GetFlagPickerGUID(TEAM_ALLIANCE) == 0 && GetFlagState(TEAM_ALLIANCE) != BG_WS_FLAG_STATE_ON_GROUND) ||
|
||||
(GetFlagPickerGUID(TEAM_HORDE) == 0 && GetFlagState(TEAM_HORDE) != BG_WS_FLAG_STATE_ON_GROUND) ||
|
||||
if ((!GetFlagPickerGUID(TEAM_ALLIANCE) && GetFlagState(TEAM_ALLIANCE) != BG_WS_FLAG_STATE_ON_GROUND) ||
|
||||
(!GetFlagPickerGUID(TEAM_HORDE) && GetFlagState(TEAM_HORDE) != BG_WS_FLAG_STATE_ON_GROUND) ||
|
||||
_bgEvents.GetNextEventTime(BG_WS_EVENT_BOTH_FLAGS_KEPT10) > 0)
|
||||
return 0;
|
||||
|
||||
@@ -540,12 +536,12 @@ uint32 BattlegroundWS::GetAssaultSpellId() const
|
||||
|
||||
void BattlegroundWS::RemoveAssaultAuras()
|
||||
{
|
||||
if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_ALLIANCE), this->FindBgMap(), (Player*)nullptr))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_ALLIANCE)))
|
||||
{
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT);
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_BRUTAL_ASSAULT);
|
||||
}
|
||||
if (Player* player = ObjectAccessor::GetObjectInMap(GetFlagPickerGUID(TEAM_HORDE), this->FindBgMap(), (Player*)nullptr))
|
||||
if (Player* player = ObjectAccessor::GetPlayer(FindBgMap(), GetFlagPickerGUID(TEAM_HORDE)))
|
||||
{
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_FOCUSED_ASSAULT);
|
||||
player->RemoveAurasDueToSpell(BG_WS_SPELL_BRUTAL_ASSAULT);
|
||||
|
||||
@@ -159,8 +159,8 @@ public:
|
||||
void StartingEventOpenDoors() override;
|
||||
|
||||
/* BG Flags */
|
||||
uint64 GetFlagPickerGUID(TeamId teamId) const override { return _flagKeepers[teamId]; }
|
||||
void SetFlagPicker(uint64 guid, TeamId teamId) { _flagKeepers[teamId] = guid; }
|
||||
ObjectGuid GetFlagPickerGUID(TeamId teamId) const override { return _flagKeepers[teamId]; }
|
||||
void SetFlagPicker(ObjectGuid guid, TeamId teamId) { _flagKeepers[teamId] = guid; }
|
||||
void RespawnFlagAfterDrop(TeamId teamId);
|
||||
uint8 GetFlagState(TeamId teamId) const { return _flagState[teamId]; }
|
||||
|
||||
@@ -179,8 +179,8 @@ public:
|
||||
|
||||
void UpdateFlagState(TeamId teamId, uint32 value);
|
||||
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
|
||||
void SetDroppedFlagGUID(uint64 guid, TeamId teamId) override { _droppedFlagGUID[teamId] = guid; }
|
||||
uint64 GetDroppedFlagGUID(TeamId teamId) const { return _droppedFlagGUID[teamId];}
|
||||
void SetDroppedFlagGUID(ObjectGuid guid, TeamId teamId) override { _droppedFlagGUID[teamId] = guid; }
|
||||
ObjectGuid GetDroppedFlagGUID(TeamId teamId) const { return _droppedFlagGUID[teamId];}
|
||||
void FillInitialWorldStates(WorldPacket& data) override;
|
||||
|
||||
/* Scorekeeping */
|
||||
@@ -194,8 +194,8 @@ public:
|
||||
private:
|
||||
EventMap _bgEvents;
|
||||
|
||||
uint64 _flagKeepers[2];
|
||||
uint64 _droppedFlagGUID[2];
|
||||
ObjectGuid _flagKeepers[2];
|
||||
ObjectGuid _droppedFlagGUID[2];
|
||||
uint8 _flagState[2];
|
||||
TeamId _lastFlagCaptureTeam;
|
||||
uint32 _reputationCapture;
|
||||
|
||||
Reference in New Issue
Block a user