feat(Core/Script): Hooks for custom arena teams/types (#3508)

This commit is contained in:
Petric
2020-11-29 21:04:38 +00:00
committed by GitHub
parent d503ba0d71
commit 5984e82f22
9 changed files with 225 additions and 29 deletions

View File

@@ -7546,10 +7546,25 @@ uint32 Player::GetGroupIdFromStorage(uint32 guid)
uint32 Player::GetArenaTeamIdFromStorage(uint32 guid, uint8 slot)
{
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guid))
return playerData->arenaTeamId[slot];
{
auto itr = playerData->arenaTeamId.find(slot);
if (itr != playerData->arenaTeamId.end())
{
return itr->second;
}
}
return 0;
}
void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
{
if (slot < MAX_ARENA_SLOT)
{
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value);
}
}
uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENA_TEAM_ID_BY_PLAYER_GUID);
@@ -17710,7 +17725,7 @@ void Player::_LoadArenaTeamInfo()
{
memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END);
for (uint8 slot = 0; slot <= 2; ++slot)
for (uint8 slot = 0; slot < MAX_ARENA_SLOT; ++slot)
if (uint32 arenaTeamId = Player::GetArenaTeamIdFromStorage(GetGUIDLow(), slot))
{
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
@@ -21627,6 +21642,38 @@ void Player::LeaveAllArenaTeams(uint64 guid)
} while (result->NextRow());
}
uint32 Player::GetArenaTeamId(uint8 slot) const
{
uint32 rtVal = 0;
if (slot >= MAX_ARENA_SLOT)
{
sScriptMgr->GetCustomGetArenaTeamId(this, slot, rtVal);
}
else
{
rtVal = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID);
}
return rtVal;
}
uint32 Player::GetArenaPersonalRating(uint8 slot) const
{
uint32 rtVal = 0;
if (slot >= MAX_ARENA_SLOT)
{
sScriptMgr->GetCustomGetArenaTeamId(this, slot, rtVal);
}
else
{
rtVal = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING);
}
return rtVal;
}
void Player::SetRestBonus(float rest_bonus_new)
{
// Prevent resting on max level
@@ -22287,6 +22334,9 @@ uint32 Player::GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const
max_personal_rating = p_rating;
}
}
sScriptMgr->OnGetMaxPersonalArenaRatingRequirement(this, minarenaslot, max_personal_rating);
return max_personal_rating;
}