Core/Units: update action button macros for Cataclysm

This commit is contained in:
funjoker
2024-09-17 10:05:33 +02:00
parent bf0e2fc469
commit 657d433ede
3 changed files with 12 additions and 12 deletions

View File

@@ -30,13 +30,13 @@ constexpr uint8 MAX_SPELL_VEHICLE = 6;
constexpr uint8 MAX_SPELL_POSSESS = 8;
constexpr uint8 MAX_SPELL_CONTROL_BAR = 10;
#define UNIT_ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF)
#define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24)
#define MAKE_UNIT_ACTION_BUTTON(A, T) (uint32(A) | (uint32(T) << 24))
#define UNIT_ACTION_BUTTON_ACTION(X) (uint32(X) & 0x007FFFFF)
#define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF800000) >> 23)
#define MAKE_UNIT_ACTION_BUTTON(A, T) (uint32(A) | (uint32(T) << 23))
struct UnitActionBarEntry
{
UnitActionBarEntry() : packedData(uint32(ACT_DISABLED) << 24) { }
UnitActionBarEntry() : packedData(uint32(ACT_DISABLED) << 23) { }
uint32 packedData;
@@ -61,7 +61,7 @@ struct UnitActionBarEntry
void SetAction(uint32 action)
{
packedData = (packedData & 0xFF000000) | UNIT_ACTION_BUTTON_ACTION(action);
packedData = (packedData & 0xFF800000) | UNIT_ACTION_BUTTON_ACTION(action);
}
};

View File

@@ -496,11 +496,11 @@ struct TC_GAME_API DeclinedName
std::string name[MAX_DECLINED_NAME_CASES];
};
enum ActiveStates : uint8
enum ActiveStates : uint16
{
ACT_PASSIVE = 0x01, // 0x01 - passive
ACT_DISABLED = 0x81, // 0x80 - castable
ACT_ENABLED = 0xC1, // 0x40 | 0x80 - auto cast + castable
ACT_DISABLED = 0x101, // 0x100 - castable
ACT_ENABLED = 0x181, // 0x80 | 0x100 - auto cast + castable
ACT_COMMAND = 0x07, // 0x01 | 0x02 | 0x04
ACT_REACTION = 0x06, // 0x02 | 0x04
ACT_DECIDE = 0x00 // custom

View File

@@ -70,7 +70,7 @@ void WorldSession::HandlePetAction(WorldPackets::Pet::PetAction& packet)
ObjectGuid guid2 = packet.TargetGUID; //tag guid
uint32 spellid = UNIT_ACTION_BUTTON_ACTION(packet.Action);
uint8 flag = UNIT_ACTION_BUTTON_TYPE(packet.Action); //delete = 0x07 CastSpell = C1
uint16 flag = UNIT_ACTION_BUTTON_TYPE(packet.Action); //delete = 0x07 CastSpell = C1
// used also for charmed creature
Unit* pet = ObjectAccessor::GetUnit(*_player, guid1);
@@ -289,9 +289,9 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
break;
}
break;
case ACT_DISABLED: // 0x81 spell (disabled), ignore
case ACT_DISABLED: // 0x101 spell (disabled), ignore
case ACT_PASSIVE: // 0x01
case ACT_ENABLED: // 0xC1 spell
case ACT_ENABLED: // 0x181 spell
{
Unit* unit_target = nullptr;
@@ -489,7 +489,7 @@ void WorldSession::HandlePetSetAction(WorldPackets::Pet::PetSetAction& packet)
uint32 actionData = packet.Action;
uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(actionData);
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(actionData);
uint16 act_state = UNIT_ACTION_BUTTON_TYPE(actionData);
TC_LOG_DEBUG("entities.pet", "Player {} has changed pet spell action. Position: {}, Spell: {}, State: 0x{:X}",
_player->GetName(), position, spell_id, uint32(act_state));