diff options
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 3 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 24 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 4 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_reset.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 2 |
7 files changed, 32 insertions, 28 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ad2bc43e4a9..c8c55690b7f 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -518,7 +518,7 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/) m_creatureInfo = cinfo; // map mode related always // equal to player Race field, but creature does not have race - SetRace(0); + SetRace(RACE_NONE); // known valid are: CLASS_WARRIOR, CLASS_PALADIN, CLASS_ROGUE, CLASS_MAGE SetClass(uint8(cinfo->unit_class)); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 152e86370b5..ea41877c2c7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -471,7 +471,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac SetObjectScale(1.0f); - setFactionForRace(createInfo->Race); + SetFactionForRace(createInfo->Race); if (!IsValidGender(createInfo->Sex)) { @@ -483,7 +483,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac SetRace(createInfo->Race); SetClass(createInfo->Class); SetGender(Gender(createInfo->Sex)); - SetPowerType(Powers(powertype)); + SetPowerType(Powers(powertype), false); InitDisplayIds(); UpdatePositionData(); if (sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP) @@ -2157,7 +2157,7 @@ void Player::SetGameMaster(bool on) PhasingHandler::SetAlwaysVisible(this, HasAuraType(SPELL_AURA_PHASE_ALWAYS_VISIBLE), false); m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON; - setFactionForRace(GetRace()); + SetFactionForRace(GetRace()); RemovePlayerFlag(PLAYER_FLAGS_GM); RemoveUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS); @@ -2311,9 +2311,8 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate) packet.ReferAFriendBonusType = recruitAFriend ? 1 : 0; SendDirectMessage(packet.Write()); - uint32 curXP = m_activePlayerData->XP; - uint32 nextLvlXP = m_activePlayerData->NextLevelXP; - uint32 newXP = curXP + xp + bonus_xp; + uint32 nextLvlXP = GetXPForNextLevel(); + uint32 newXP = GetXP() + xp + bonus_xp; while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { @@ -2323,7 +2322,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate) GiveLevel(level + 1); level = GetLevel(); - nextLvlXP = m_activePlayerData->NextLevelXP; + nextLvlXP = GetXPForNextLevel(); } SetXP(newXP); @@ -6306,7 +6305,7 @@ TeamId Player::TeamIdForRace(uint8 race) return TEAM_NEUTRAL; } -void Player::setFactionForRace(uint8 race) +void Player::SetFactionForRace(uint8 race) { m_team = TeamForRace(race); @@ -17980,7 +17979,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder* holder) return false; } - SetLevel(fields.level); + SetLevel(fields.level, false); SetXP(fields.xp); Tokenizer exploredZones(fields.exploredZones, ' '); @@ -18059,7 +18058,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder* holder) //Need to call it to initialize m_team (m_team can be calculated from race) //Other way is to saves m_team into characters table. - setFactionForRace(GetRace()); + SetFactionForRace(GetRace()); // load home bind and check in same time class/race pair, it used later for restore broken positions if (!_LoadHomeBind(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_HOME_BIND))) @@ -20441,7 +20440,7 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba stmt->setUInt8(index++, GetClass()); stmt->setUInt8(index++, GetNativeGender()); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect stmt->setUInt8(index++, GetLevel()); - stmt->setUInt32(index++, m_activePlayerData->XP); + stmt->setUInt32(index++, GetXP()); stmt->setUInt64(index++, GetMoney()); stmt->setUInt8(index++, GetInventorySlotCount()); stmt->setUInt8(index++, GetBankBagSlotCount()); @@ -20569,7 +20568,7 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba stmt->setUInt8(index++, GetClass()); stmt->setUInt8(index++, GetNativeGender()); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect stmt->setUInt8(index++, GetLevel()); - stmt->setUInt32(index++, m_activePlayerData->XP); + stmt->setUInt32(index++, GetXP()); stmt->setUInt64(index++, GetMoney()); stmt->setUInt8(index++, GetInventorySlotCount()); stmt->setUInt8(index++, GetBankBagSlotCount()); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index e87777a042a..7cecd210ce8 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2152,7 +2152,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> static TeamId TeamIdForRace(uint8 race); uint32 GetTeam() const { return m_team; } TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } - void setFactionForRace(uint8 race); + void SetFactionForRace(uint8 race); void InitDisplayIds(); @@ -2178,7 +2178,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> /*********************************************************/ /*** PVP SYSTEM ***/ /*********************************************************/ - // TODO: Properly implement correncies as of Cataclysm void UpdateHonorFields(); bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false); void ResetHonorStats(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 8d6ec5c493f..a54f2db3fae 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5218,13 +5218,16 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType SendAttackStateUpdate(&dmgInfo); } -void Unit::SetPowerType(Powers new_powertype) +void Unit::SetPowerType(Powers new_powertype, bool sendUpdate/* = true*/) { if (GetPowerType() == new_powertype) return; SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DisplayPower), new_powertype); + if (!sendUpdate) + return; + if (Player* thisPlayer = ToPlayer()) { if (thisPlayer->GetGroup()) @@ -8813,10 +8816,13 @@ bool Unit::CanFreeMove() const UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerGUID().IsEmpty(); } -void Unit::SetLevel(uint8 lvl) +void Unit::SetLevel(uint8 lvl, bool sendUpdate/* = true*/) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Level), lvl); + if (!sendUpdate) + return; + if (Player* player = ToPlayer()) { // group update @@ -11073,7 +11079,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) void Unit::RestoreFaction() { if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->setFactionForRace(GetRace()); + ToPlayer()->SetFactionForRace(GetRace()); else { if (HasUnitTypeMask(UNIT_MASK_MINION)) @@ -11491,15 +11497,15 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const break; } - if (Player const* thisPlayer = ToPlayer()) + if (Player const* player = ToPlayer()) { if (Aura* artifactAura = GetAura(ARTIFACTS_ALL_WEAPONS_GENERAL_WEAPON_EQUIPPED_PASSIVE)) - if (Item* artifact = ToPlayer()->GetItemByGuid(artifactAura->GetCastItemGUID())) + if (Item* artifact = player->GetItemByGuid(artifactAura->GetCastItemGUID())) if (ArtifactAppearanceEntry const* artifactAppearance = sArtifactAppearanceStore.LookupEntry(artifact->GetModifier(ITEM_MODIFIER_ARTIFACT_APPEARANCE_ID))) if (ShapeshiftForm(artifactAppearance->OverrideShapeshiftFormID) == form) return artifactAppearance->OverrideShapeshiftDisplayID; - if (ShapeshiftFormModelData const* formModelData = sDB2Manager.GetShapeshiftFormModelData(GetRace(), thisPlayer->GetNativeGender(), form)) + if (ShapeshiftFormModelData const* formModelData = sDB2Manager.GetShapeshiftFormModelData(GetRace(), player->GetNativeGender(), form)) { bool useRandom = false; switch (form) @@ -11524,8 +11530,8 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const if (ChrCustomizationDisplayInfoEntry const* displayInfo = formModelData->Displays[i]) { ChrCustomizationReqEntry const* choiceReq = sChrCustomizationReqStore.LookupEntry((*formModelData->Choices)[i]->ChrCustomizationReqID); - if (!choiceReq || thisPlayer->GetSession()->MeetsChrCustomizationReq(choiceReq, Classes(GetClass()), false, - MakeChrCustomizationChoiceRange(thisPlayer->m_playerData->Customizations))) + if (!choiceReq || player->GetSession()->MeetsChrCustomizationReq(choiceReq, Classes(GetClass()), false, + MakeChrCustomizationChoiceRange(player->m_playerData->Customizations))) displayIds.push_back(displayInfo->DisplayID); } } @@ -11535,7 +11541,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const } else { - if (uint32 formChoice = thisPlayer->GetCustomizationChoice(formModelData->OptionID)) + if (uint32 formChoice = player->GetCustomizationChoice(formModelData->OptionID)) { auto choiceItr = std::find_if(formModelData->Choices->begin(), formModelData->Choices->end(), [formChoice](ChrCustomizationChoiceEntry const* choice) { diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 641db7d7d17..d5dd44c836b 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -852,7 +852,7 @@ class TC_GAME_API Unit : public WorldObject uint8 GetLevel() const { return uint8(m_unitData->Level); } uint8 GetLevelForTarget(WorldObject const* /*target*/) const override { return GetLevel(); } - void SetLevel(uint8 lvl); + void SetLevel(uint8 lvl, bool sendUpdate = true); uint8 GetRace() const { return m_unitData->Race; } void SetRace(uint8 race) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Race), race); } uint64 GetRaceMask() const { return UI64LIT(1) << (GetRace() - 1); } @@ -903,7 +903,7 @@ class TC_GAME_API Unit : public WorldObject virtual float GetArmorMultiplierForTarget(WorldObject const* /*target*/) const { return 1.0f; } Powers GetPowerType() const { return Powers(*m_unitData->DisplayPower); } - void SetPowerType(Powers power); + void SetPowerType(Powers power, bool sendUpdate = true); void SetOverrideDisplayPowerId(uint32 powerDisplayId) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::OverrideDisplayPowerID), powerDisplayId); } void UpdateDisplayPower(); int32 GetPower(Powers power) const; diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index a3f6dda4870..94f63070002 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -104,7 +104,7 @@ public: if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) player->SetShapeshiftForm(FORM_NONE); - player->setFactionForRace(player->GetRace()); + player->SetFactionForRace(player->GetRace()); player->SetPowerType(Powers(powerType)); // reset only if player not in some form; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index f3945a64a43..190f32b044f 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3690,7 +3690,7 @@ class spell_gen_gm_freeze : public AuraScript if (Player* player = GetTarget()->ToPlayer()) { // Reset player faction + allow combat + allow duels - player->setFactionForRace(player->GetRace()); + player->SetFactionForRace(player->GetRace()); player->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE); // save player player->SaveToDB(); |