revert(Core): ChrRace.dbc full implementation (#16114)

* revert (core): ChrRace.dbc full implementation

we revert this due to several issues arrising. Although the dbc reading is done in full and correctly. Azerothcore relied on the original handling (althought not propper) for so long that  there is

* revert

* Update remove_charrace_dbc.sql

* Update remove_charrace_dbc.sql

* Update remove_charrace_dbc.sql
This commit is contained in:
M'Dic
2023-04-29 07:23:11 -04:00
committed by GitHub
parent 43103b6145
commit 7e58650cf5
26 changed files with 225 additions and 165 deletions

View File

@@ -9974,15 +9974,9 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit* victim, uint32 /*damage*/, Au
return true;
}
void Unit::setPowerType(Powers new_powertype, bool sendUpdate/* = true*/)
void Unit::setPowerType(Powers new_powertype)
{
if (getPowerType() == new_powertype)
return;
SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, new_powertype);
if (!sendUpdate)
return;
SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype);
if (GetTypeId() == TYPEID_PLAYER)
{
@@ -15185,10 +15179,7 @@ uint32 Unit::GetCreatureType() const
if (ssEntry && ssEntry->creatureType > 0)
return ssEntry->creatureType;
else
{
ChrRacesEntry const* raceEntry = sChrRacesStore.AssertEntry(getRace());
return raceEntry->CreatureType;
}
return CREATURE_TYPE_HUMANOID;
}
else
return ToCreature()->GetCreatureTemplate()->type;
@@ -21292,6 +21283,25 @@ void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns c
}
}
uint8 Unit::getRace(bool original) const
{
if (GetTypeId() == TYPEID_PLAYER)
{
if (original)
return m_realRace;
else
return m_race;
}
return GetByteValue(UNIT_FIELD_BYTES_0, 0);
}
void Unit::setRace(uint8 race)
{
if (GetTypeId() == TYPEID_PLAYER)
m_race = race;
}
// Check if unit in combat with specific unit
bool Unit::IsInCombatWith(Unit const* who) const
{

View File

@@ -39,14 +39,6 @@
#define BASE_MAXDAMAGE 2.0f
#define BASE_ATTACK_TIME 2000
enum UnitBytes0Offsets : uint8
{
UNIT_BYTES_0_OFFSET_RACE = 0,
UNIT_BYTES_0_OFFSET_CLASS = 1,
UNIT_BYTES_0_OFFSET_GENDER = 2,
UNIT_BYTES_0_OFFSET_POWER_TYPE = 3
};
enum UnitBytes1Offsets : uint8
{
UNIT_BYTES_1_OFFSET_STAND_STATE = 0,
@@ -1452,21 +1444,12 @@ public:
[[nodiscard]] uint8 GetLevel() const { return getLevel(); }
uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return GetLevel(); }
void SetLevel(uint8 lvl, bool showLevelChange = true);
[[nodiscard]] uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
void setRace(uint8 race) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, race); }
[[nodiscard]] uint32 getRaceMask() const { return 1 << (getRace() - 1); }
[[nodiscard]] uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
void setClass(uint8 classId) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, classId); }
[[nodiscard]] uint8 GetRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
void SetRace(uint8 race) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, race); }
[[nodiscard]] uint32 GetRaceMask() const { return 1 << (getRace() - 1); }
[[nodiscard]] uint8 GetClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
void SetClass(uint8 classId) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, classId); }
[[nodiscard]] uint8 getRace(bool original = false) const;
void setRace(uint8 race);
[[nodiscard]] uint32 getRaceMask() const { return 1 << (getRace(true) - 1); }
[[nodiscard]] uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
[[nodiscard]] uint32 getClassMask() const { return 1 << (getClass() - 1); }
Gender getGender() const { return Gender(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER)); }
void setGender(Gender gender) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender); }
virtual Gender GetNativeGender() const { return getGender(); }
virtual void SetNativeGender(Gender gender) { setGender(gender); }
[[nodiscard]] uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
[[nodiscard]] float GetStat(Stats stat) const { return float(GetUInt32Value(static_cast<uint16>(UNIT_FIELD_STAT0) + stat)); }
void SetStat(Stats stat, int32 val) { SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_STAT0) + stat, val); }
@@ -1497,8 +1480,8 @@ public:
int32 ModifyHealth(int32 val);
int32 GetHealthGain(int32 dVal);
[[nodiscard]] Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); }
void setPowerType(Powers power, bool sendUpdate = true);
[[nodiscard]] Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); }
void setPowerType(Powers power);
[[nodiscard]] uint32 GetPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power); }
[[nodiscard]] uint32 GetMaxPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_MAXPOWER1) + power); }
void SetPower(Powers power, uint32 val, bool withPowerUpdate = true, bool fromRegenerate = false);