From a2e74f182fedbe100681f3e59852bec2ef654fb0 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 11 Dec 2010 13:55:47 +0300 Subject: [PATCH] [10857] Complete set Byte/ShortFlag value functions and use it for PLAYER_FIELD_BYTES proper access. Not expected any changes in work. --- src/game/Object.h | 54 +++++++++++++++++++++++++++++++++------- src/game/Player.cpp | 4 +-- src/game/Player.h | 8 +++--- src/game/SpellAuras.cpp | 2 +- src/shared/revision_nr.h | 2 +- 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/game/Object.h b/src/game/Object.h index 72a140856..0d7750d01 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -222,15 +222,20 @@ class MANGOS_DLL_SPEC Object return (m_uint32Values[ index ] & flag) != 0; } + void ApplyModFlag( uint16 index, uint32 flag, bool apply) + { + if (apply) + SetFlag(index, flag); + else + RemoveFlag(index, flag); + } + void SetByteFlag( uint16 index, uint8 offset, uint8 newFlag ); void RemoveByteFlag( uint16 index, uint8 offset, uint8 newFlag ); - void SetShortFlag(uint16 index, bool highpart, uint16 newFlag); - void RemoveShortFlag(uint16 index, bool highpart, uint16 oldFlag); - - void ToggleFlag( uint16 index, uint8 offset, uint8 flag ) + void ToggleByteFlag( uint16 index, uint8 offset, uint8 flag ) { - if(HasByteFlag(index, offset, flag)) + if (HasByteFlag(index, offset, flag)) RemoveByteFlag(index, offset, flag); else SetByteFlag(index, offset, flag); @@ -243,9 +248,37 @@ class MANGOS_DLL_SPEC Object return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0; } - void ApplyModFlag( uint16 index, uint32 flag, bool apply) + void ApplyModByteFlag( uint16 index, uint8 offset, uint32 flag, bool apply) { - if(apply) SetFlag(index,flag); else RemoveFlag(index,flag); + if (apply) + SetByteFlag(index, offset, flag); + else + RemoveByteFlag(index, offset, flag); + } + + void SetShortFlag(uint16 index, bool highpart, uint16 newFlag); + void RemoveShortFlag(uint16 index, bool highpart, uint16 oldFlag); + + void ToggleShortFlag( uint16 index, bool highpart, uint8 flag ) + { + if (HasShortFlag(index, highpart, flag)) + RemoveShortFlag(index, highpart, flag); + else + SetShortFlag(index, highpart, flag); + } + + bool HasShortFlag( uint16 index, bool highpart, uint8 flag ) const + { + MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false ) ); + return (((uint16*)&m_uint32Values[index])[highpart ? 1 : 0] & flag) != 0; + } + + void ApplyModShortFlag( uint16 index, bool highpart, uint32 flag, bool apply) + { + if (apply) + SetShortFlag(index, highpart, flag); + else + RemoveShortFlag(index, highpart, flag); } void SetFlag64( uint16 index, uint64 newFlag ) @@ -264,7 +297,7 @@ class MANGOS_DLL_SPEC Object void ToggleFlag64( uint16 index, uint64 flag) { - if(HasFlag64(index, flag)) + if (HasFlag64(index, flag)) RemoveFlag64(index, flag); else SetFlag64(index, flag); @@ -278,7 +311,10 @@ class MANGOS_DLL_SPEC Object void ApplyModFlag64( uint16 index, uint64 flag, bool apply) { - if(apply) SetFlag64(index,flag); else RemoveFlag64(index, flag); + if (apply) + SetFlag64(index, flag); + else + RemoveFlag64(index, flag); } void ClearUpdateMask(bool remove); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 981257839..32c760bfe 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -4543,7 +4543,7 @@ void Player::KillPlayer() //SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP ); SetFlag(UNIT_DYNAMIC_FLAGS, 0x00); - ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable()); + ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable()); // 6 minutes until repop at graveyard m_deathTimer = 6*MINUTE*IN_MILLISECONDS; @@ -15904,7 +15904,7 @@ void Player::LoadCorpse() { if(Corpse *corpse = GetCorpse()) { - ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable() ); + ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable() ); } else { diff --git a/src/game/Player.h b/src/game/Player.h index 11cfb40c7..b17d60b07 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -570,12 +570,12 @@ enum PlayerFlags #define KNOWN_TITLES_SIZE 3 #define MAX_TITLE_INDEX (KNOWN_TITLES_SIZE*64) // 3 uint64 fields -// used in PLAYER_FIELD_BYTES values +// used in (PLAYER_FIELD_BYTES, 0) byte values enum PlayerFieldByteFlags { - PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x00000002, - PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x00000008, // Display time till auto release spirit - PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x00000010 // Display no "release spirit" window at all + PLAYER_FIELD_BYTE_TRACK_STEALTHED = 0x02, + PLAYER_FIELD_BYTE_RELEASE_TIMER = 0x08, // Display time till auto release spirit + PLAYER_FIELD_BYTE_NO_RELEASE_WINDOW = 0x10 // Display no "release spirit" window at all }; // used in byte (PLAYER_FIELD_BYTES2,3) values diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 985399f01..e82514708 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3438,7 +3438,7 @@ void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/) if(apply) GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); - GetTarget()->ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply); + GetTarget()->ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply); } void Aura::HandleAuraModScale(bool apply, bool /*Real*/) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bb3e2c7e2..f4ebde977 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10856" + #define REVISION_NR "10857" #endif // __REVISION_NR_H__