diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-09-18 22:15:46 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-09-18 23:52:17 +0200 |
commit | f67cd38312014b13624dcb5fe1d117dac4892b7d (patch) | |
tree | 3bf01a8798005e8017b672867edb5c8379f76087 | |
parent | e15898bf560fc8159777a2a29a29d6a91ffdb590 (diff) |
Core/Player: Extend action button value to uint64 to be able to hold battle pet guids
-rw-r--r-- | sql/base/characters_database.sql | 5 | ||||
-rw-r--r-- | sql/updates/characters/master/2022_09_18_00_characters.sql | 1 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 30 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 14 | ||||
-rw-r--r-- | src/server/game/Handlers/MiscHandler.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Server/Packets/SpellPackets.h | 2 |
6 files changed, 30 insertions, 28 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index 822e9bcb0e0..743da3345dc 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -459,7 +459,7 @@ CREATE TABLE `character_action` ( `guid` bigint unsigned NOT NULL DEFAULT '0', `spec` tinyint unsigned NOT NULL DEFAULT '0', `button` tinyint unsigned NOT NULL DEFAULT '0', - `action` int unsigned NOT NULL DEFAULT '0', + `action` bigint unsigned NOT NULL DEFAULT '0', `type` tinyint unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`guid`,`spec`,`button`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -3676,7 +3676,8 @@ INSERT INTO `updates` VALUES ('2022_07_14_00_characters.sql','2EAD57D77FC39F6678F2D2A7D9C24046E6B836D8','ARCHIVED','2022-07-14 21:44:35',0), ('2022_07_25_00_characters.sql','3159BB2F3C346A7881920AB2B1F8108247CF13EE','ARCHIVED','2022-07-25 18:44:10',0), ('2022_08_19_00_characters.sql','1C076A24F2B48F32E8EF835C01F8907CA9E86491','ARCHIVED','2022-08-19 23:43:01',0), -('2022_08_21_00_characters.sql','1D75688392FBDA18CD8494F32CF682DCB49642EC','ARCHIVED','2022-08-21 00:02:03',0); +('2022_08_21_00_characters.sql','1D75688392FBDA18CD8494F32CF682DCB49642EC','ARCHIVED','2022-08-21 00:02:03',0), +('2022_09_18_00_characters.sql','A7DF0C1F0E074F3E63A6CDD0AF873A1F3DC33B29','RELEASED','2022-09-18 21:48:42',0); /*!40000 ALTER TABLE `updates` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/characters/master/2022_09_18_00_characters.sql b/sql/updates/characters/master/2022_09_18_00_characters.sql new file mode 100644 index 00000000000..c87d83fa1f6 --- /dev/null +++ b/sql/updates/characters/master/2022_09_18_00_characters.sql @@ -0,0 +1 @@ +ALTER TABLE `character_action` MODIFY `action` bigint unsigned NOT NULL DEFAULT 0; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9103ac5561b..0bd26e72847 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6013,18 +6013,18 @@ void Player::SendActionButtons(uint32 state) const SendDirectMessage(packet.Write()); } -bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const +bool Player::IsActionButtonDataValid(uint8 button, uint64 action, uint8 type) const { if (button >= MAX_ACTION_BUTTONS) { - TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): button must be < %u", + TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action " UI64FMTD " not added into button %u for player %s (%s): button must be < %u", action, button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTONS); return false; } if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { - TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): action must be < %u", + TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action " UI64FMTD " not added into button %u for player %s (%s): action must be < " UI64FMTD, action, button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); return false; } @@ -6034,14 +6034,14 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co case ACTION_BUTTON_SPELL: if (!sSpellMgr->GetSpellInfo(action, DIFFICULTY_NONE)) { - TC_LOG_DEBUG("entities.player", "Player::IsActionButtonDataValid: Spell action %u not added into button %u for player %s (%s): spell does not exist. This can be due to a character imported from a different expansion", + TC_LOG_DEBUG("entities.player", "Player::IsActionButtonDataValid: Spell action " UI64FMTD " not added into button %u for player %s (%s): spell does not exist. This can be due to a character imported from a different expansion", action, button, GetName().c_str(), GetGUID().ToString().c_str()); return false; } if (!HasSpell(action)) { - TC_LOG_DEBUG("entities.player", "Player::IsActionButtonDataValid: Spell action %u not added into button %u for player %s (%s): player does not known this spell, this can be due to a player changing their talents", + TC_LOG_DEBUG("entities.player", "Player::IsActionButtonDataValid: Spell action " UI64FMTD " not added into button %u for player %s (%s): player does not known this spell, this can be due to a player changing their talents", action, button, GetName().c_str(), GetGUID().ToString().c_str()); return false; } @@ -6049,7 +6049,7 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co case ACTION_BUTTON_ITEM: if (!sObjectMgr->GetItemTemplate(action)) { - TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Item action %u not added into button %u for player %s (%s): item not exist", + TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Item action " UI64FMTD " not added into button %u for player %s (%s): item not exist", action, button, GetName().c_str(), GetGUID().ToString().c_str()); return false; } @@ -6058,7 +6058,7 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co { if (!GetSession()->GetBattlePetMgr()->GetPet(ObjectGuid::Create<HighGuid::BattlePet>(action))) { - TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Companion action %u not added into button %u for player %s (%s): companion does not exist", + TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Companion action " UI64FMTD " not added into button %u for player %s (%s): companion does not exist", action, button, GetName().c_str(), GetGUID().ToString().c_str()); return false; } @@ -6069,14 +6069,14 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co auto mount = sDB2Manager.GetMountById(action); if (!mount) { - TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Mount action %u not added into button %u for player %s (%s): mount does not exist", + TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Mount action " UI64FMTD " not added into button %u for player %s (%s): mount does not exist", action, button, GetName().c_str(), GetGUID().ToString().c_str()); return false; } if (!HasSpell(mount->SourceSpellID)) { - TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Mount action %u not added into button %u for player %s (%s): Player does not know this mount", + TC_LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Mount action " UI64FMTD " not added into button %u for player %s (%s): Player does not know this mount", action, button, GetName().c_str(), GetGUID().ToString().c_str()); return false; } @@ -6096,7 +6096,7 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co return true; } -ActionButton* Player::AddActionButton(uint8 button, uint32 action, uint8 type) +ActionButton* Player::AddActionButton(uint8 button, uint64 action, uint8 type) { if (!IsActionButtonDataValid(button, action, type)) return nullptr; @@ -6107,7 +6107,7 @@ ActionButton* Player::AddActionButton(uint8 button, uint32 action, uint8 type) // set data and update to CHANGED if not NEW ab.SetActionAndType(action, ActionButtonType(type)); - TC_LOG_DEBUG("entities.player", "Player::AddActionButton: Player '%s' (%s) added action '%u' (type %u) to button '%u'", + TC_LOG_DEBUG("entities.player", "Player::AddActionButton: Player '%s' (%s) added action '" UI64FMTD "' (type %u) to button '%u'", GetName().c_str(), GetGUID().ToString().c_str(), action, type, button); return &ab; } @@ -17932,14 +17932,14 @@ void Player::_LoadActions(PreparedQueryResult result) { Field* fields = result->Fetch(); uint8 button = fields[0].GetUInt8(); - uint32 action = fields[1].GetUInt32(); + uint64 action = fields[1].GetUInt64(); uint8 type = fields[2].GetUInt8(); if (ActionButton* ab = AddActionButton(button, action, type)) ab->uState = ACTIONBUTTON_UNCHANGED; else { - TC_LOG_DEBUG("entities.player", "Player::_LoadActions: Player '%s' (%s) has an invalid action button (Button: %u, Action: %u, Type: %u). It will be deleted at next save. This can be due to a player changing their talents.", + TC_LOG_DEBUG("entities.player", "Player::_LoadActions: Player '%s' (%s) has an invalid action button (Button: %u, Action: " UI64FMTD ", Type: %u). It will be deleted at next save. This can be due to a player changing their talents.", GetName().c_str(), GetGUID().ToString().c_str(), button, action, type); // Will be deleted in DB at next save (it can create data until save but marked as deleted). @@ -19974,7 +19974,7 @@ void Player::_SaveActions(CharacterDatabaseTransaction trans) stmt->setUInt64(0, GetGUID().GetCounter()); stmt->setUInt8(1, GetActiveTalentGroup()); stmt->setUInt8(2, itr->first); - stmt->setUInt32(3, itr->second.GetAction()); + stmt->setUInt64(3, itr->second.GetAction()); stmt->setUInt8(4, uint8(itr->second.GetType())); trans->Append(stmt); @@ -19983,7 +19983,7 @@ void Player::_SaveActions(CharacterDatabaseTransaction trans) break; case ACTIONBUTTON_CHANGED: stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACTION); - stmt->setUInt32(0, itr->second.GetAction()); + stmt->setUInt64(0, itr->second.GetAction()); stmt->setUInt8(1, uint8(itr->second.GetType())); stmt->setUInt64(2, GetGUID().GetCounter()); stmt->setUInt8(3, itr->first); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index f3b6e250726..a524674505a 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -328,9 +328,9 @@ enum ReputationSource REPUTATION_SOURCE_SPELL }; -#define ACTION_BUTTON_ACTION(X) (uint64(X) & 0x00000000FFFFFFFF) -#define ACTION_BUTTON_TYPE(X) ((uint64(X) & 0xFFFFFFFF00000000) >> 56) -#define MAX_ACTION_BUTTON_ACTION_VALUE (0xFFFFFFFF) +#define ACTION_BUTTON_ACTION(X) (uint64(X) & 0x00FFFFFFFFFFFFFF) +#define ACTION_BUTTON_TYPE(X) ((uint64(X) & 0xFF00000000000000) >> 56) +#define MAX_ACTION_BUTTON_ACTION_VALUE UI64LIT(0xFFFFFFFFFFFFFF) struct ActionButton { @@ -341,8 +341,8 @@ struct ActionButton // helpers ActionButtonType GetType() const { return ActionButtonType(ACTION_BUTTON_TYPE(packedData)); } - uint32 GetAction() const { return ACTION_BUTTON_ACTION(packedData); } - void SetActionAndType(uint32 action, ActionButtonType type) + uint64 GetAction() const { return ACTION_BUTTON_ACTION(packedData); } + void SetActionAndType(uint64 action, ActionButtonType type) { uint64 newData = uint64(action) | (uint64(type) << 56); if (newData != packedData || uState == ACTIONBUTTON_DELETED) @@ -1918,12 +1918,12 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> uint32 GetMovie() const { return m_movie; } void SetMovie(uint32 movie) { m_movie = movie; } - ActionButton* AddActionButton(uint8 button, uint32 action, uint8 type); + ActionButton* AddActionButton(uint8 button, uint64 action, uint8 type); void RemoveActionButton(uint8 button); ActionButton const* GetActionButton(uint8 button); void SendInitialActionButtons() const { SendActionButtons(0); } void SendActionButtons(uint32 state) const; - bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const; + bool IsActionButtonDataValid(uint8 button, uint64 action, uint8 type) const; void SetMultiActionBars(uint8 mask) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::MultiActionBars), mask); } PvPInfo pvpInfo; diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index b4b2ca8a98b..9cb0e65fed4 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -733,10 +733,10 @@ void WorldSession::HandleRequestAccountData(WorldPackets::ClientConfig::RequestA void WorldSession::HandleSetActionButtonOpcode(WorldPackets::Spells::SetActionButton& packet) { - uint32 action = ACTION_BUTTON_ACTION(packet.Action); - uint32 type = ACTION_BUTTON_TYPE(packet.Action); + uint64 action = ACTION_BUTTON_ACTION(packet.Action); + uint8 type = ACTION_BUTTON_TYPE(packet.Action); - TC_LOG_DEBUG("network", "CMSG_SET_ACTION_BUTTON Button: %u Action: %u Type: %u", packet.Index, action, type); + TC_LOG_DEBUG("network", "CMSG_SET_ACTION_BUTTON Button: %u Action: " UI64FMTD " Type: %u", packet.Index, action, uint32(type)); if (!packet.Action) GetPlayer()->RemoveActionButton(packet.Index); diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h index 86db415928d..b5c1bc3edbd 100644 --- a/src/server/game/Server/Packets/SpellPackets.h +++ b/src/server/game/Server/Packets/SpellPackets.h @@ -171,7 +171,7 @@ namespace WorldPackets void Read() override; - uint64 Action = 0; ///< two packed uint32 (action and type) + uint64 Action = 0; ///< two packed values (action and type) uint8 Index = 0; }; |