diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 62662718d..a95ae5db7 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -138,11 +138,11 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid) { pl->SetInArenaTeam(Id, GetSlot()); pl->SetArenaTeamIdInvited(0); - pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 7) + 5, newmember.personal_rating ); + pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating ); // hide promote/remove buttons if(CaptainGuid != PlayerGuid) - pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 7) + 1, 1); + pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 1); } return true; } @@ -238,7 +238,7 @@ void ArenaTeam::SetCaptain(const uint64& guid) // disable remove/promote buttons Player *oldcaptain = objmgr.GetPlayer(GetCaptain()); if(oldcaptain) - oldcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 7), 1); + oldcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 1); // set new captain CaptainGuid = guid; @@ -249,7 +249,7 @@ void ArenaTeam::SetCaptain(const uint64& guid) // enable remove/promote buttons Player *newcaptain = objmgr.GetPlayer(guid); if(newcaptain) - newcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 7), 0); + newcaptain->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_MEMBER, 0); } void ArenaTeam::DelMember(uint64 guid) @@ -270,9 +270,9 @@ void ArenaTeam::DelMember(uint64 guid) player->SetInArenaTeam(0, GetSlot()); player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0); // delete all info regarding this team - for(int i = 0; i < 6; ++i) + for(int i = 0; i < ARENA_TEAM_END; ++i) { - player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 7) + i, 0); + player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + i, 0); } } @@ -565,11 +565,11 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating) int32 mod = (int32)ceil(32.0f * (0.0f - chance)); itr->ModifyPersonalRating(plr, mod, GetSlot()); // update personal played stats - itr->games_week +=1; - itr->games_season +=1; + itr->games_week += 1; + itr->games_season += 1; // update the unit fields - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 7 * GetSlot() + 2, itr->games_week); - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 7 * GetSlot() + 3, itr->games_season); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK, itr->games_week); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON, itr->games_season); return; } } @@ -590,8 +590,8 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating) else itr->personal_rating += mod; // update personal played stats - itr->games_week +=1; - itr->games_season +=1; + itr->games_week += 1; + itr->games_season += 1; return; } } @@ -609,13 +609,13 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating) int32 mod = (int32)floor(32.0f * (1.0f - chance)); itr->ModifyPersonalRating(plr, mod, GetSlot()); // update personal stats - itr->games_week +=1; - itr->games_season +=1; + itr->games_week += 1; + itr->games_season += 1; itr->wins_season += 1; itr->wins_week += 1; // update unit fields - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 7 * GetSlot() + 2, itr->games_week); - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 7 * GetSlot() + 3, itr->games_season); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK, itr->games_week); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON, itr->games_season); return; } } diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h index 775dc9b07..629b89d99 100644 --- a/src/game/ArenaTeam.h +++ b/src/game/ArenaTeam.h @@ -101,7 +101,7 @@ struct ArenaTeamMember else personal_rating += mod; if(plr) - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot*7) + 5, personal_rating); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING, personal_rating); } }; diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index d37a38572..cedf18a3c 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -726,7 +726,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) Player *member = itr->getSource(); // calc avg personal rating - avg_pers_rating += member->GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaslot * 7) + 5); + avg_pers_rating += member->GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaslot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); } if (arenatype) diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 0f395144a..d9eae3a94 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -78,7 +78,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = '%u'",GUID_LOPART(m_guid)); // in other case still be dummy query res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT guildid,rank FROM guild_member WHERE guid = '%u'", GUID_LOPART(m_guid)); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADARENAINFO, "SELECT arenateamid, played_week, played_season, personal_rating FROM arena_team_member WHERE guid='%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADARENAINFO, "SELECT arenateamid, played_week, played_season, wons_season, personal_rating FROM arena_team_member WHERE guid='%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS,"SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid)); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c962deca1..d5059f863 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13869,7 +13869,7 @@ void Player::_LoadDeclinedNames(QueryResult* result) void Player::_LoadArenaTeamInfo(QueryResult *result) { // arenateamid, played_week, played_season, personal_rating - memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32)*21); + memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END); if (!result) return; @@ -13880,7 +13880,8 @@ void Player::_LoadArenaTeamInfo(QueryResult *result) uint32 arenateamid = fields[0].GetUInt32(); uint32 played_week = fields[1].GetUInt32(); uint32 played_season = fields[2].GetUInt32(); - uint32 personal_rating = fields[3].GetUInt32(); + uint32 wons_season = fields[3].GetUInt32(); + uint32 personal_rating = fields[4].GetUInt32(); ArenaTeam* aTeam = objmgr.GetArenaTeamById(arenateamid); if(!aTeam) @@ -13890,15 +13891,15 @@ void Player::_LoadArenaTeamInfo(QueryResult *result) } uint8 arenaSlot = aTeam->GetSlot(); - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 0] = arenateamid; // TeamID - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 1] = ((aTeam->GetCaptain() == GetGUID()) ? (uint32)0 : (uint32)1); // Captain 0, member 1 - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 2] = played_week; // Played Week - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 3] = played_season; // Played Season - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 4] = 0; // Unk - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 5] = personal_rating; // Personal Rating - m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 7 + 6] = 0; // unk + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_ID] = arenateamid; // TeamID + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_MEMBER] = ((aTeam->GetCaptain() == GetGUID()) ? (uint32)0 : (uint32)1); // Captain 0, member 1 + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK] = played_week; // Played Week + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON] = played_season; // Played Season + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_WINS_SEASON] = wons_season; // wins season + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING] = personal_rating; // Personal Rating + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_UNK2] = 0; // unk 3.2 - }while (result->NextRow()); + } while (result->NextRow()); delete result; } @@ -14130,8 +14131,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) continue; // arena team not exist or not member, cleanup fields - for(int j = 0; j < 7; ++j) - SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arena_slot * 7 + j, 0); + for(int j = 0; j < ARENA_TEAM_END; ++j) + SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arena_slot * ARENA_TEAM_END) + j, 0); } _LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES)); @@ -17321,10 +17322,10 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count); WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); - data << pCreature->GetGUID(); - data << (uint32)(vendor_slot+1); // numbered from 1 at client - data << (uint32)(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); - data << (uint32)count; + data << uint64(pCreature->GetGUID()); + data << uint32(vendor_slot+1); // numbered from 1 at client + data << uint32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); + data << uint32(count); GetSession()->SendPacket(&data); SendNewItem(it, pProto->BuyCount*count, true, false, false); @@ -17366,10 +17367,10 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count); WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); - data << pCreature->GetGUID(); - data << (uint32)(vendor_slot+1); // numbered from 1 at client - data << (uint32)(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); - data << (uint32)count; + data << uint64(pCreature->GetGUID()); + data << uint32(vendor_slot + 1); // numbered from 1 at client + data << uint32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); + data << uint32(count); GetSession()->SendPacket(&data); SendNewItem(it, pProto->BuyCount*count, true, false, false); @@ -17396,9 +17397,9 @@ uint32 Player::GetMaxPersonalArenaRatingRequirement() { if(ArenaTeam * at = objmgr.GetArenaTeamById(GetArenaTeamId(i))) { - uint32 p_rating = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (i * 7) + 5); + uint32 p_rating = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (i * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); uint32 t_rating = at->GetRating(); - p_rating = p_ratingSendPacket(&data); sLog.outDebug("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(),GetGUIDLow()); @@ -17568,12 +17569,12 @@ void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) void Player::SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId, Spell* spell) { // start cooldowns at server side, if any - AddSpellAndCategoryCooldowns(spellInfo,itemId,spell); + AddSpellAndCategoryCooldowns(spellInfo, itemId, spell); // Send activate cooldown timer (possible 0) at client side WorldPacket data(SMSG_COOLDOWN_EVENT, (4+8)); - data << spellInfo->Id; - data << GetGUID(); + data << uint32(spellInfo->Id); + data << uint64(GetGUID()); SendDirectMessage(&data); } @@ -17719,7 +17720,7 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) { // ignore item gem conditions //if state changed, (dis)apply enchant - ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot),!wasactive,true,true); + ApplyEnchantment(pItem, EnchantmentSlot(enchant_slot), !wasactive, true, true); } } } @@ -17810,7 +17811,7 @@ void Player::ReportedAfkBy(Player* reporter) return; // check if player has 'Idle' or 'Inactive' debuff - if(m_bgAfkReporter.find(reporter->GetGUIDLow())==m_bgAfkReporter.end() && !HasAura(43680,0) && !HasAura(43681,0) && reporter->CanReportAfkDueToLimit()) + if(m_bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgAfkReporter.end() && !HasAura(43680,0) && !HasAura(43681,0) && reporter->CanReportAfkDueToLimit()) { m_bgAfkReporter.insert(reporter->GetGUIDLow()); // 3 players have to complain to apply debuff diff --git a/src/game/Player.h b/src/game/Player.h index 5ffb8323d..b3ec48982 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -510,8 +510,6 @@ enum ActivateTaxiReplies ERR_TAXINOTSTANDING = 12 }; - - enum MirrorTimerType { FATIGUE_TIMER = 0, @@ -719,6 +717,19 @@ enum InstanceResetWarningType RAID_INSTANCE_EXPIRED = 5 }; +// PLAYER_FIELD_ARENA_TEAM_INFO_1_1 offsets +enum ArenaTeamInfoType +{ + ARENA_TEAM_ID = 0, + ARENA_TEAM_MEMBER = 1, // 0 - captain, 1 - member + ARENA_TEAM_GAMES_WEEK = 2, + ARENA_TEAM_GAMES_SEASON = 3, + ARENA_TEAM_WINS_SEASON = 4, + ARENA_TEAM_PERSONAL_RATING = 5, + ARENA_TEAM_UNK2 = 6, // new in 3.2 + ARENA_TEAM_END = 7 +}; + // used in most movement packets (send and received) enum MovementFlags { @@ -1609,9 +1620,9 @@ class MANGOS_DLL_SPEC Player : public Unit // Arena Team void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot) { - SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 7), ArenaTeamId); + SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END), ArenaTeamId); } - uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 7)); } + uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END)); } static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }