Skip to content

Commit

Permalink
[12038] Use bitmask for chat tag.
Browse files Browse the repository at this point in the history
Thanks to stfx for porting

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
  • Loading branch information
kaelima authored and Schmoozerd committed Jul 13, 2012
1 parent fc9052f commit 6a4215b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/game/BattleGround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace MaNGOS
data << ObjectGuid(targetGuid);
data << uint32(strlen(text)+1);
data << text;
data << uint8(i_source ? i_source->chatTag() : uint8(0));
data << uint8(i_source ? i_source->GetChatTag() : CHAT_TAG_NONE);
}

ChatMsg i_msgtype;
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace MaNGOS
data << ObjectGuid(targetGuid);
data << uint32(strlen(str)+1);
data << str;
data << uint8(i_source ? i_source->chatTag() : uint8(0));
data << uint8(i_source ? i_source->GetChatTag() : CHAT_TAG_NONE);
}
private:

Expand Down
2 changes: 1 addition & 1 deletion src/game/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ void Channel::Say(ObjectGuid p, const char *what, uint32 lang)
data << ObjectGuid(p);
data << uint32(messageLength);
data << what;
data << uint8(plr ? plr->chatTag() : 0);
data << uint8(plr ? plr->GetChatTag() : CHAT_TAG_NONE);

SendToAll(&data, !m_players[p].IsModerator() ? p : ObjectGuid());
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin
*data << uint32(messageLength);
*data << message;
if(session != 0 && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK)
*data << uint8(session->GetPlayer()->chatTag());
*data << uint8(session->GetPlayer()->GetChatTag());
else
*data << uint8(0);
}
Expand Down
25 changes: 12 additions & 13 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,23 +1606,22 @@ void Player::ToggleDND()
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
}

uint8 Player::chatTag() const
uint8 Player::GetChatTag() const
{
// it's bitmask
// 0x1 - afk
// 0x2 - dnd
// 0x4 - gm
// 0x8 - ??

if (isGMChat()) // Always show GM icons if activated
return 4;
uint8 tag = CHAT_TAG_NONE;

if (isAFK())
return 1;
tag |= CHAT_TAG_AFK;
if (isDND())
return 3;
tag |= CHAT_TAG_DND;
if (isGMChat())
tag |= CHAT_TAG_GM;
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_COMMENTATOR))
tag |= CHAT_TAG_COM;
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
tag |= CHAT_TAG_DEV;

return 0;
return tag;
}

bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options)
Expand Down Expand Up @@ -18431,7 +18430,7 @@ void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string
*data << ObjectGuid(GetObjectGuid());
*data << uint32(text.length()+1);
*data << text;
*data << uint8(chatTag());
*data << uint8(GetChatTag());
}

void Player::Say(const std::string& text, const uint32 language)
Expand Down
12 changes: 11 additions & 1 deletion src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,16 @@ enum EnviromentalDamage
DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
};

enum PlayerChatTag
{
CHAT_TAG_NONE = 0x00,
CHAT_TAG_AFK = 0x01,
CHAT_TAG_DND = 0x02,
CHAT_TAG_GM = 0x04,
CHAT_TAG_COM = 0x08, // Commentator
CHAT_TAG_DEV = 0x10, // Developer
};

enum PlayedTimeIndex
{
PLAYED_TIME_TOTAL = 0,
Expand Down Expand Up @@ -1071,7 +1081,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void ToggleDND();
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
uint8 chatTag() const;
uint8 GetChatTag() const;
std::string autoReplyMsg;

uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint32 newskintone);
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 "12037"
#define REVISION_NR "12038"
#endif // __REVISION_NR_H__

1 comment on commit 6a4215b

@rsa
Copy link
Contributor

@rsa rsa commented on 6a4215b Jul 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, good catch.

Please sign in to comment.