diff options
Diffstat (limited to 'src/server/game/Handlers/CharacterHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 9ecb11140ce..6e9136a952f 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -738,7 +738,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Create Character: %s %s", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().ToString().c_str()); sScriptMgr->OnPlayerCreate(&newChar); - sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER), newChar.getRace(), newChar.getClass(), newChar.getLevel(), false); + sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.m_playerData->NativeSex, newChar.getRace(), newChar.getClass(), newChar.getLevel(), false); newChar.CleanupsBeforeDelete(); }; @@ -902,7 +902,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) return; } - pCurrChar->SetUInt32Value(PLAYER_FIELD_VIRTUAL_PLAYER_REALM, GetVirtualRealmAddress()); + pCurrChar->SetVirtualPlayerRealm(GetVirtualRealmAddress()); SendTutorialsData(); @@ -1078,10 +1078,10 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) pCurrChar->LoadPet(); // Set FFA PvP for non GM in non-rest mode - if (sWorld->IsFFAPvPRealm() && !pCurrChar->IsGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) - pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP); + if (sWorld->IsFFAPvPRealm() && !pCurrChar->IsGameMaster() && !pCurrChar->HasPlayerFlag(PLAYER_FLAGS_RESTING)) + pCurrChar->AddPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP); - if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) + if (pCurrChar->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP)) pCurrChar->SetContestedPvP(); // Apply at_login requests @@ -1225,7 +1225,7 @@ void WorldSession::HandleTutorialFlag(WorldPackets::Misc::TutorialSetFlag& packe void WorldSession::HandleSetWatchedFactionOpcode(WorldPackets::Character::SetWatchedFaction& packet) { - GetPlayer()->SetUInt32Value(ACTIVE_PLAYER_FIELD_WATCHED_FACTION_INDEX, packet.FactionIndex); + GetPlayer()->SetWatchedFactionIndex(packet.FactionIndex); } void WorldSession::HandleSetFactionInactiveOpcode(WorldPackets::Character::SetFactionInactive& packet) @@ -1389,19 +1389,19 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPackets::Character::SetPlay void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance& packet) { BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(packet.NewHairStyle); - if (!bs_hair || bs_hair->Type != 0 || bs_hair->Race != _player->getRace() || bs_hair->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)) + if (!bs_hair || bs_hair->Type != 0 || bs_hair->Race != _player->getRace() || bs_hair->Sex != _player->m_playerData->NativeSex) return; BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(packet.NewFacialHair); - if (!bs_facialHair || bs_facialHair->Type != 2 || bs_facialHair->Race != _player->getRace() || bs_facialHair->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)) + if (!bs_facialHair || bs_facialHair->Type != 2 || bs_facialHair->Race != _player->getRace() || bs_facialHair->Sex != _player->m_playerData->NativeSex) return; BarberShopStyleEntry const* bs_skinColor = sBarberShopStyleStore.LookupEntry(packet.NewSkinColor); - if (bs_skinColor && (bs_skinColor->Type != 3 || bs_skinColor->Race != _player->getRace() || bs_skinColor->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER))) + if (bs_skinColor && (bs_skinColor->Type != 3 || bs_skinColor->Race != _player->getRace() || bs_skinColor->Sex != _player->m_playerData->NativeSex)) return; BarberShopStyleEntry const* bs_face = sBarberShopStyleStore.LookupEntry(packet.NewFace); - if (bs_face && (bs_face->Type != 4 || bs_face->Race != _player->getRace() || bs_face->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER))) + if (bs_face && (bs_face->Type != 4 || bs_face->Race != _player->getRace() || bs_face->Sex != _player->m_playerData->NativeSex)) return; std::array<BarberShopStyleEntry const*, PLAYER_CUSTOM_DISPLAY_SIZE> customDisplayEntries; @@ -1409,19 +1409,19 @@ void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance for (std::size_t i = 0; i < PLAYER_CUSTOM_DISPLAY_SIZE; ++i) { BarberShopStyleEntry const* bs_customDisplay = sBarberShopStyleStore.LookupEntry(packet.NewCustomDisplay[i]); - if (bs_customDisplay && (bs_customDisplay->Type != 5 + i || bs_customDisplay->Race != _player->getRace() || bs_customDisplay->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER))) + if (bs_customDisplay && (bs_customDisplay->Type != 5 + i || bs_customDisplay->Race != _player->getRace() || bs_customDisplay->Sex != _player->m_playerData->NativeSex)) return; customDisplayEntries[i] = bs_customDisplay; customDisplay[i] = bs_customDisplay ? bs_customDisplay->Data : 0; } - if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER), + if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->m_playerData->NativeSex, bs_hair->Data, packet.NewHairColor, - bs_face ? bs_face->Data : _player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID), + bs_face ? bs_face->Data : _player->m_playerData->FaceID, bs_facialHair->Data, - bs_skinColor ? bs_skinColor->Data : _player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID), + bs_skinColor ? bs_skinColor->Data : _player->m_playerData->SkinID, customDisplay)) return; @@ -1454,16 +1454,16 @@ void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance _player->ModifyMoney(-int64(cost)); // it isn't free _player->UpdateCriteria(CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, cost); - _player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID, uint8(bs_hair->Data)); - _player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID, uint8(packet.NewHairColor)); - _player->SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, uint8(bs_facialHair->Data)); + _player->SetHairStyleId(bs_hair->Data); + _player->SetHairColorId(packet.NewHairColor); + _player->SetFacialHairStyleId(bs_facialHair->Data); if (bs_skinColor) - _player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID, uint8(bs_skinColor->Data)); + _player->SetSkinId(bs_skinColor->Data); if (bs_face) - _player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID, uint8(bs_face->Data)); + _player->SetFaceId(bs_face->Data); for (uint32 i = 0; i < PLAYER_CUSTOM_DISPLAY_SIZE; ++i) - _player->SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_CUSTOM_DISPLAY_OPTION + i, customDisplay[i]); + _player->SetCustomDisplayOption(i, customDisplay[i]); _player->UpdateCriteria(CRITERIA_TYPE_VISIT_BARBER_SHOP, 1); @@ -2230,18 +2230,11 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa // Title conversion if (!knownTitlesStr.empty()) { - uint32 const ktcount = KNOWN_TITLES_SIZE * 2; - uint32 knownTitles[ktcount]; - Tokenizer tokens(knownTitlesStr, ' ', ktcount); + std::vector<uint32> knownTitles; + Tokenizer tokens(knownTitlesStr, ' '); - if (tokens.size() != ktcount) - { - SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo.get()); - return; - } - - for (uint32 index = 0; index < ktcount; ++index) - knownTitles[index] = atoul(tokens[index]); + for (uint32 index = 0; index < tokens.size(); ++index) + knownTitles.push_back(atoul(tokens[index])); for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeTitles.begin(); it != sObjectMgr->FactionChangeTitles.end(); ++it) { @@ -2255,6 +2248,9 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa { uint32 maskID = htitleInfo->MaskID; uint32 index = maskID / 32; + if (index >= knownTitles.size()) + continue; + uint32 old_flag = 1 << (maskID % 32); uint32 new_flag = 1 << (atitleInfo->MaskID % 32); if (knownTitles[index] & old_flag) @@ -2268,6 +2264,9 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa { uint32 maskID = atitleInfo->MaskID; uint32 index = maskID / 32; + if (index >= knownTitles.size()) + continue; + uint32 old_flag = 1 << (maskID % 32); uint32 new_flag = 1 << (htitleInfo->MaskID % 32); if (knownTitles[index] & old_flag) @@ -2279,7 +2278,7 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa } std::ostringstream ss; - for (uint32 index = 0; index < ktcount; ++index) + for (uint32 index = 0; index < knownTitles.size(); ++index) ss << knownTitles[index] << ' '; stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); @@ -2343,7 +2342,7 @@ void WorldSession::HandleReorderCharacters(WorldPackets::Character::ReorderChara void WorldSession::HandleOpeningCinematic(WorldPackets::Misc::OpeningCinematic& /*packet*/) { // Only players that has not yet gained any experience can use this - if (_player->GetUInt32Value(ACTIVE_PLAYER_FIELD_XP)) + if (*_player->m_activePlayerData->XP) return; if (ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(_player->getClass())) |