Skip to content

Commit

Permalink
[10857] Complete set Byte/ShortFlag value functions and use it for PL…
Browse files Browse the repository at this point in the history
…AYER_FIELD_BYTES proper access.

Not expected any changes in work.
  • Loading branch information
VladimirMangos committed Dec 11, 2010
1 parent 62ecfd3 commit 7a674eb
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
54 changes: 45 additions & 9 deletions src/game/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
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
{
if(apply) SetFlag(index,flag); else RemoveFlag(index,flag);
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 )
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*/)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10856"
#define REVISION_NR "10857"
#endif // __REVISION_NR_H__

0 comments on commit 7a674eb

Please sign in to comment.