mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[11814] Use the same variable to store the message for AFK and DND
Also make code in this area easier to read Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
e89d5db5e3
commit
5b0c0c9fa4
4 changed files with 42 additions and 40 deletions
|
|
@ -454,41 +454,48 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
|
||||||
|
|
||||||
if (!_player->isInCombat())
|
if (!_player->isInCombat())
|
||||||
{
|
{
|
||||||
if (!msg.empty() || !_player->isAFK())
|
if (_player->isAFK()) // Already AFK
|
||||||
{
|
{
|
||||||
if (msg.empty())
|
if (msg.empty())
|
||||||
_player->afkMsg = GetMangosString(LANG_PLAYER_AFK_DEFAULT);
|
_player->ToggleAFK(); // Remove AFK
|
||||||
else
|
else
|
||||||
_player->afkMsg = msg;
|
_player->autoReplyMsg = msg; // Update message
|
||||||
}
|
}
|
||||||
if (msg.empty() || !_player->isAFK())
|
else // New AFK mode
|
||||||
{
|
{
|
||||||
_player->ToggleAFK();
|
_player->autoReplyMsg = msg.empty() ? GetMangosString(LANG_PLAYER_AFK_DEFAULT) : msg;
|
||||||
if (_player->isAFK() && _player->isDND())
|
|
||||||
_player->ToggleDND();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
|
if (_player->isDND())
|
||||||
|
_player->ToggleDND();
|
||||||
|
|
||||||
|
_player->ToggleAFK();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CHAT_MSG_DND:
|
case CHAT_MSG_DND:
|
||||||
{
|
{
|
||||||
std::string msg;
|
std::string msg;
|
||||||
recv_data >> msg;
|
recv_data >> msg;
|
||||||
|
|
||||||
if (!msg.empty() || !_player->isDND())
|
if (_player->isDND()) // Already DND
|
||||||
{
|
{
|
||||||
if (msg.empty())
|
if (msg.empty())
|
||||||
_player->dndMsg = GetMangosString(LANG_PLAYER_DND_DEFAULT);
|
_player->ToggleDND(); // Remove DND
|
||||||
else
|
else
|
||||||
_player->dndMsg = msg;
|
_player->autoReplyMsg = msg; // Update message
|
||||||
}
|
}
|
||||||
if (msg.empty() || !_player->isDND())
|
else // New DND mode
|
||||||
{
|
{
|
||||||
_player->ToggleDND();
|
_player->autoReplyMsg = msg.empty() ? GetMangosString(LANG_PLAYER_DND_DEFAULT) : msg;
|
||||||
if (_player->isDND() && _player->isAFK())
|
|
||||||
|
if (_player->isAFK())
|
||||||
_player->ToggleAFK();
|
_player->ToggleAFK();
|
||||||
|
|
||||||
|
_player->ToggleDND();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sLog.outError("CHAT: unknown message type %u, lang: %u", type, lang);
|
sLog.outError("CHAT: unknown message type %u, lang: %u", type, lang);
|
||||||
|
|
|
||||||
|
|
@ -1649,40 +1649,36 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::ToggleAFK()
|
void Player::ToggleAFK()
|
||||||
{
|
{
|
||||||
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
|
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
|
||||||
|
|
||||||
bool state = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
|
|
||||||
|
|
||||||
// afk player not allowed in battleground
|
// afk player not allowed in battleground
|
||||||
if (state && InBattleGround() && !InArena())
|
if (isAFK() && InBattleGround() && !InArena())
|
||||||
LeaveBattleground();
|
LeaveBattleground();
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::ToggleDND()
|
void Player::ToggleDND()
|
||||||
{
|
{
|
||||||
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
|
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
|
||||||
|
|
||||||
return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 Player::chatTag() const
|
uint8 Player::chatTag() const
|
||||||
{
|
{
|
||||||
// it's bitmask
|
// it's bitmask
|
||||||
// 0x8 - ??
|
|
||||||
// 0x4 - gm
|
|
||||||
// 0x2 - dnd
|
|
||||||
// 0x1 - afk
|
// 0x1 - afk
|
||||||
if(isGMChat())
|
// 0x2 - dnd
|
||||||
|
// 0x4 - gm
|
||||||
|
// 0x8 - ??
|
||||||
|
|
||||||
|
if (isGMChat()) // Always show GM icons if activated
|
||||||
return 4;
|
return 4;
|
||||||
else if(isDND())
|
|
||||||
return 3;
|
|
||||||
if (isAFK())
|
if (isAFK())
|
||||||
return 1;
|
return 1;
|
||||||
else
|
if (isDND())
|
||||||
|
return 3;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18390,9 +18386,9 @@ void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiv
|
||||||
|
|
||||||
// announce afk or dnd message
|
// announce afk or dnd message
|
||||||
if (rPlayer->isAFK())
|
if (rPlayer->isAFK())
|
||||||
ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->afkMsg.c_str());
|
ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->autoReplyMsg.c_str());
|
||||||
else if (rPlayer->isDND())
|
else if (rPlayer->isDND())
|
||||||
ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str());
|
ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->autoReplyMsg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::PetSpellInitialize()
|
void Player::PetSpellInitialize()
|
||||||
|
|
|
||||||
|
|
@ -1060,13 +1060,12 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask);
|
Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask);
|
||||||
GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameobject_type = MAX_GAMEOBJECT_TYPE) const;
|
GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameobject_type = MAX_GAMEOBJECT_TYPE) const;
|
||||||
|
|
||||||
bool ToggleAFK();
|
void ToggleAFK();
|
||||||
bool ToggleDND();
|
void ToggleDND();
|
||||||
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
|
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
|
||||||
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
|
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
|
||||||
uint8 chatTag() const;
|
uint8 chatTag() const;
|
||||||
std::string afkMsg;
|
std::string autoReplyMsg;
|
||||||
std::string dndMsg;
|
|
||||||
|
|
||||||
uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
|
uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11813"
|
#define REVISION_NR "11814"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue