Core/Player: Extend action button value to uint64 to be able to hold battle pet guids
Port From (https://github.com/TrinityCore/TrinityCore/commit/f67cd38312014b13624dcb5fe1d117dac4892b7d)
This commit is contained in:
@@ -676,7 +676,7 @@ namespace Game.Entities
|
||||
do
|
||||
{
|
||||
byte button = result.Read<byte>(0);
|
||||
uint action = result.Read<uint>(1);
|
||||
ulong action = result.Read<ulong>(1);
|
||||
byte type = result.Read<byte>(2);
|
||||
|
||||
ActionButton ab = AddActionButton(button, action, type);
|
||||
@@ -684,7 +684,7 @@ namespace Game.Entities
|
||||
ab.uState = ActionButtonUpdateState.UnChanged;
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Player, " ...at loading, and will deleted in DB also");
|
||||
Log.outError(LogFilter.Player, $"Player::_LoadActions: Player '{GetName()}' ({GetGUID()}) has an invalid action button (Button: {button}, Action: {action}, Type: {type}). It will be deleted at next save. This can be due to a player changing their talents.");
|
||||
|
||||
// Will deleted in DB at next save (it can create data until save but marked as deleted)
|
||||
m_actionButtons[button] = new ActionButton();
|
||||
|
||||
@@ -413,8 +413,10 @@ namespace Game.Entities
|
||||
uState = ActionButtonUpdateState.New;
|
||||
}
|
||||
|
||||
public ActionButtonType GetButtonType() { return (ActionButtonType)((packedData & 0xFFFFFFFF00000000) >> 56); }
|
||||
public uint GetAction() { return (uint)(packedData & 0x00000000FFFFFFFF); }
|
||||
public ActionButtonType GetButtonType() { return (ActionButtonType)((packedData & 0xFF00000000000000) >> 56); }
|
||||
|
||||
public ulong GetAction() { return (packedData & 0x00FFFFFFFFFFFFFF); }
|
||||
|
||||
public void SetActionAndType(ulong action, ActionButtonType type)
|
||||
{
|
||||
ulong newData = action | ((ulong)type << 56);
|
||||
|
||||
@@ -1327,39 +1327,39 @@ namespace Game.Entities
|
||||
return (byte)_CUFProfiles.Count(p => p != null);
|
||||
}
|
||||
|
||||
bool IsActionButtonDataValid(byte button, uint action, uint type)
|
||||
bool IsActionButtonDataValid(byte button, ulong action, uint type)
|
||||
{
|
||||
if (button >= PlayerConst.MaxActionButtons)
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Action {0} not added into button {1} for player {2} (GUID: {3}): button must be < {4}", action, button, GetName(), GetGUID(), PlayerConst.MaxActionButtons);
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Action {action} not added into button {button} for player {GetName()} ({GetGUID()}): button must be < {PlayerConst.MaxActionButtons}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action >= PlayerConst.MaxActionButtonActionValue)
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Action {0} not added into button {1} for player {2} (GUID: {3}): action must be < {4}", action, button, GetName(), GetGUID(), PlayerConst.MaxActionButtonActionValue);
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Action {action} not added into button {button} for player {GetName()} ({GetGUID()}): action must be < {PlayerConst.MaxActionButtonActionValue}");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ((ActionButtonType)type)
|
||||
{
|
||||
case ActionButtonType.Spell:
|
||||
if (!Global.SpellMgr.HasSpellInfo(action, Difficulty.None))
|
||||
if (!Global.SpellMgr.HasSpellInfo((uint)action, Difficulty.None))
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Spell action {0} not added into button {1} for player {2} (GUID: {3}): spell not exist", action, button, GetName(), GetGUID());
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Spell action {action} not added into button {button} for player {GetName()} ({GetGUID()}): spell not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasSpell(action))
|
||||
if (!HasSpell((uint)action))
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Spell action {0} not added into button {1} for player {2} (GUID: {3}): player don't known this spell", action, button, GetName(), GetGUID());
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Spell action {action} not added into button {button} for player {GetName()} ({GetGUID()}): player don't known this spell");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ActionButtonType.Item:
|
||||
if (Global.ObjectMgr.GetItemTemplate(action) == null)
|
||||
if (Global.ObjectMgr.GetItemTemplate((uint)action) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Item action {0} not added into button {1} for player {2} (GUID: {3}): item not exist", action, button, GetName(), GetGUID());
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Item action {action} not added into button {button} for player {GetName()} ({GetGUID()}): item not exist");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -1376,13 +1376,13 @@ namespace Game.Entities
|
||||
var mount = CliDB.MountStorage.LookupByKey(action);
|
||||
if (mount == null)
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Mount action {0} not added into button {1} for player {2} ({3}): mount does not exist", action, button, GetName(), GetGUID().ToString());
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Mount action {action} not added into button {button} for player {GetName()} ({GetGUID()}): mount does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasSpell(mount.SourceSpellID))
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Mount action {0} not added into button {1} for player {2} ({3}): Player does not know this mount", action, button, GetName(), GetGUID().ToString());
|
||||
Log.outError(LogFilter.Player, $"Player::IsActionButtonDataValid: Mount action {action} not added into button {button} for player {GetName()} ({GetGUID()}): Player does not know this mount");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -1392,14 +1392,16 @@ namespace Game.Entities
|
||||
case ActionButtonType.Eqset:
|
||||
break;
|
||||
default:
|
||||
Log.outError(LogFilter.Player, "Unknown action type {0}", type);
|
||||
Log.outError(LogFilter.Player, $"Unknown action type {type}");
|
||||
return false; // other cases not checked at this moment
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetMultiActionBars(byte mask) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.MultiActionBars), mask); }
|
||||
public ActionButton AddActionButton(byte button, uint action, uint type)
|
||||
|
||||
public ActionButton AddActionButton(byte button, ulong action, uint type)
|
||||
{
|
||||
if (!IsActionButtonDataValid(button, action, type))
|
||||
return null;
|
||||
@@ -1413,7 +1415,7 @@ namespace Game.Entities
|
||||
// set data and update to CHANGED if not NEW
|
||||
ab.SetActionAndType(action, (ActionButtonType)type);
|
||||
|
||||
Log.outDebug(LogFilter.Player, "Player '{0}' Added Action '{1}' (type {2}) to Button '{3}'", GetGUID().ToString(), action, type, button);
|
||||
Log.outDebug(LogFilter.Player, $"Player::AddActionButton: Player '{GetName()}' ({GetGUID()}) added action '{action}' (type {type}) to button '{button}'");
|
||||
return ab;
|
||||
}
|
||||
public void RemoveActionButton(byte _button)
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Game
|
||||
[WorldPacketHandler(ClientOpcodes.SetActionButton)]
|
||||
void HandleSetActionButton(SetActionButton packet)
|
||||
{
|
||||
uint action = packet.GetButtonAction();
|
||||
ulong action = packet.GetButtonAction();
|
||||
uint type = packet.GetButtonType();
|
||||
|
||||
if (packet.Action == 0)
|
||||
|
||||
@@ -160,10 +160,10 @@ namespace Game.Networking.Packets
|
||||
Index = _worldPacket.ReadUInt8();
|
||||
}
|
||||
|
||||
public uint GetButtonAction() { return (uint)(Action & 0x00000000FFFFFFFF); }
|
||||
public uint GetButtonType() { return (uint)((Action & 0xFFFFFFFF00000000) >> 56); }
|
||||
public uint GetButtonAction() { return (uint)(Action & 0x00FFFFFFFFFFFFFF); }
|
||||
public uint GetButtonType() { return (uint)((Action & 0xFF00000000000000) >> 56); }
|
||||
|
||||
public ulong Action; // two packed public uint (action and type)
|
||||
public ulong Action; // two packed values (action and type)
|
||||
public byte Index;
|
||||
}
|
||||
|
||||
|
||||
@@ -4909,7 +4909,7 @@ namespace Game.Spells
|
||||
|
||||
//! Action button data is unverified when it's set so it can be "hacked"
|
||||
//! to contain invalid spells, so filter here.
|
||||
uint spell_id = ab.GetAction();
|
||||
uint spell_id = (uint)ab.GetAction();
|
||||
if (spell_id == 0)
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user