aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2023-01-09 19:54:56 +0100
committerShauren <shauren.trinity@gmail.com>2023-01-12 22:55:19 +0100
commit4119f69b214d6199b7ab508e305b2958eeffb332 (patch)
tree9e0219ec4a54b7c2cff3e9664b10630ec4031404 /src/server/game/Entities
parentd675ed79c51ec64260f751d9d7f3c920da94eed2 (diff)
Core/Creatures: Split creature_addon and creature_template_addon's byte columns into seperate ones (#28562)
* Instead of dumping raw byte values into these fields, we now only allow setting values which should be accessible to database devs. The remaining byte values should be handled by core internals and spells (pet talents and shapeshifting for example) (cherry picked from commit 6f835c233f7605d74926a2a3058634c9de478617)
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp74
-rw-r--r--src/server/game/Entities/Creature/CreatureData.h7
-rw-r--r--src/server/game/Entities/Unit/UnitDefines.h14
3 files changed, 44 insertions, 51 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 57ff7b1a0a7..aace76abc41 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -2630,64 +2630,50 @@ CreatureAddon const* Creature::GetCreatureAddon() const
//creature_addon table
bool Creature::LoadCreaturesAddon()
{
- CreatureAddon const* cainfo = GetCreatureAddon();
- if (!cainfo)
+ CreatureAddon const* creatureAddon = GetCreatureAddon();
+ if (!creatureAddon)
return false;
- if (cainfo->mount != 0)
- Mount(cainfo->mount);
+ if (creatureAddon->mount != 0)
+ Mount(creatureAddon->mount);
- if (cainfo->bytes1 != 0)
- {
- // 0 StandState
- // 1 FreeTalentPoints Pet only, so always 0 for default creature
- // 2 StandFlags
- // 3 StandMiscFlags
+ SetStandState(UnitStandStateType(creatureAddon->standState));
+ ReplaceAllVisFlags(UnitVisFlags(creatureAddon->visFlags));
+ SetAnimTier(AnimTier(creatureAddon->animTier), false);
- SetStandState(UnitStandStateType(cainfo->bytes1 & 0xFF));
- ReplaceAllVisFlags(UnitVisFlags((cainfo->bytes1 >> 16) & 0xFF));
- SetAnimTier(AnimTier((cainfo->bytes1 >> 24) & 0xFF), false);
+ //! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2:
+ //! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs)
+ //! Check using InhabitType as movement flags are assigned dynamically
+ //! basing on whether the creature is in air or not
+ //! Set MovementFlag_Hover. Otherwise do nothing.
+ if (CanHover())
+ AddUnitMovementFlag(MOVEMENTFLAG_HOVER);
- //! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2:
- //! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs)
- //! Check using InhabitType as movement flags are assigned dynamically
- //! basing on whether the creature is in air or not
- //! Set MovementFlag_Hover. Otherwise do nothing.
- if (CanHover())
- AddUnitMovementFlag(MOVEMENTFLAG_HOVER);
- }
+ SetSheath(SheathState(creatureAddon->sheathState));
+ ReplaceAllPvpFlags(UnitPVPStateFlags(creatureAddon->pvpFlags));
- if (cainfo->bytes2 != 0)
- {
- // 0 SheathState
- // 1 PvpFlags
- // 2 PetFlags Pet only, so always 0 for default creature
- // 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura
-
- SetSheath(SheathState(cainfo->bytes2 & 0xFF));
- ReplaceAllPvpFlags(UnitPVPStateFlags((cainfo->bytes2 >> 8) & 0xFF));
- ReplaceAllPetFlags(UNIT_PET_FLAG_NONE);
- SetShapeshiftForm(FORM_NONE);
- }
+ // These fields must only be handled by core internals and must not be modified via scripts/DB dat
+ ReplaceAllPetFlags(UNIT_PET_FLAG_NONE);
+ SetShapeshiftForm(FORM_NONE);
- if (cainfo->emote != 0)
- SetEmoteState(Emote(cainfo->emote));
+ if (creatureAddon->emote != 0)
+ SetEmoteState(Emote(creatureAddon->emote));
- SetAIAnimKitId(cainfo->aiAnimKit);
- SetMovementAnimKitId(cainfo->movementAnimKit);
- SetMeleeAnimKitId(cainfo->meleeAnimKit);
+ SetAIAnimKitId(creatureAddon->aiAnimKit);
+ SetMovementAnimKitId(creatureAddon->movementAnimKit);
+ SetMeleeAnimKitId(creatureAddon->meleeAnimKit);
// Check if visibility distance different
- if (cainfo->visibilityDistanceType != VisibilityDistanceType::Normal)
- SetVisibilityDistanceOverride(cainfo->visibilityDistanceType);
+ if (creatureAddon->visibilityDistanceType != VisibilityDistanceType::Normal)
+ SetVisibilityDistanceOverride(creatureAddon->visibilityDistanceType);
// Load Path
- if (cainfo->path_id != 0)
- _waypointPathId = cainfo->path_id;
+ if (creatureAddon->path_id != 0)
+ _waypointPathId = creatureAddon->path_id;
- if (!cainfo->auras.empty())
+ if (!creatureAddon->auras.empty())
{
- for (std::vector<uint32>::const_iterator itr = cainfo->auras.begin(); itr != cainfo->auras.end(); ++itr)
+ for (std::vector<uint32>::const_iterator itr = creatureAddon->auras.begin(); itr != creatureAddon->auras.end(); ++itr)
{
SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(*itr, GetMap()->GetDifficultyID());
if (!AdditionalSpellInfo)
diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h
index 45ded7b5011..09b758d7af3 100644
--- a/src/server/game/Entities/Creature/CreatureData.h
+++ b/src/server/game/Entities/Creature/CreatureData.h
@@ -645,8 +645,11 @@ struct CreatureAddon
{
uint32 path_id;
uint32 mount;
- uint32 bytes1;
- uint32 bytes2;
+ uint8 standState;
+ uint8 animTier;
+ uint8 sheathState;
+ uint8 pvpFlags;
+ uint8 visFlags;
uint32 emote;
uint16 aiAnimKit;
uint16 movementAnimKit;
diff --git a/src/server/game/Entities/Unit/UnitDefines.h b/src/server/game/Entities/Unit/UnitDefines.h
index 93adec7dd4b..759f3070458 100644
--- a/src/server/game/Entities/Unit/UnitDefines.h
+++ b/src/server/game/Entities/Unit/UnitDefines.h
@@ -43,7 +43,9 @@ enum UnitStandStateType : uint8
UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6,
UNIT_STAND_STATE_DEAD = 7,
UNIT_STAND_STATE_KNEEL = 8,
- UNIT_STAND_STATE_SUBMERGED = 9
+ UNIT_STAND_STATE_SUBMERGED = 9,
+
+ MAX_UNIT_STAND_STATE
};
// byte flag value (UNIT_FIELD_BYTES_1, 2)
@@ -64,7 +66,9 @@ enum class AnimTier : uint8
Swim = 1, // falls back to ground tier animations, not handled by the client, should never appear in sniffs, will prevent tier change animations from playing correctly if used
Hover = 2, // plays flying tier animations or falls back to ground tier animations, automatically enables hover clientside when entering visibility with this value
Fly = 3, // plays flying tier animations
- Submerged = 4
+ Submerged = 4,
+
+ Max
};
// low byte (0 from 0..3) of UNIT_FIELD_BYTES_2
@@ -72,10 +76,10 @@ enum SheathState : uint8
{
SHEATH_STATE_UNARMED = 0, // non prepared weapon
SHEATH_STATE_MELEE = 1, // prepared melee weapon
- SHEATH_STATE_RANGED = 2 // prepared ranged weapon
-};
+ SHEATH_STATE_RANGED = 2, // prepared ranged weapon
-#define MAX_SHEATH_STATE 3
+ MAX_SHEATH_STATE
+};
// byte (1 from 0..3) of UNIT_FIELD_BYTES_2
enum UnitPVPStateFlags : uint8