diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 94119d0d5..b7f1d6acb 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -454,41 +454,48 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) if (!_player->isInCombat()) { - if (!msg.empty() || !_player->isAFK()) + if (_player->isAFK()) // Already AFK { if (msg.empty()) - _player->afkMsg = GetMangosString(LANG_PLAYER_AFK_DEFAULT); + _player->ToggleAFK(); // Remove AFK else - _player->afkMsg = msg; + _player->autoReplyMsg = msg; // Update message } - if (msg.empty() || !_player->isAFK()) + else // New AFK mode { - _player->ToggleAFK(); - if (_player->isAFK() && _player->isDND()) + _player->autoReplyMsg = msg.empty() ? GetMangosString(LANG_PLAYER_AFK_DEFAULT) : msg; + + if (_player->isDND()) _player->ToggleDND(); + + _player->ToggleAFK(); } } - } break; - + break; + } case CHAT_MSG_DND: { std::string msg; recv_data >> msg; - if (!msg.empty() || !_player->isDND()) + if (_player->isDND()) // Already DND { if (msg.empty()) - _player->dndMsg = GetMangosString(LANG_PLAYER_DND_DEFAULT); + _player->ToggleDND(); // Remove DND else - _player->dndMsg = msg; + _player->autoReplyMsg = msg; // Update message } - if (msg.empty() || !_player->isDND()) + else // New DND mode { - _player->ToggleDND(); - if (_player->isDND() && _player->isAFK()) + _player->autoReplyMsg = msg.empty() ? GetMangosString(LANG_PLAYER_DND_DEFAULT) : msg; + + if (_player->isAFK()) _player->ToggleAFK(); + + _player->ToggleDND(); } - } break; + break; + } default: sLog.outError("CHAT: unknown message type %u, lang: %u", type, lang); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index fc7f17217..7731dc944 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1649,41 +1649,37 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) return true; } -bool Player::ToggleAFK() +void Player::ToggleAFK() { ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); - bool state = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); - // afk player not allowed in battleground - if (state && InBattleGround() && !InArena()) + if (isAFK() && InBattleGround() && !InArena()) LeaveBattleground(); - - return state; } -bool Player::ToggleDND() +void Player::ToggleDND() { ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); - - return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } uint8 Player::chatTag() const { // it's bitmask - // 0x8 - ?? - // 0x4 - gm - // 0x2 - dnd // 0x1 - afk - if(isGMChat()) + // 0x2 - dnd + // 0x4 - gm + // 0x8 - ?? + + if (isGMChat()) // Always show GM icons if activated return 4; - else if(isDND()) - return 3; - if(isAFK()) + + if (isAFK()) return 1; - else - return 0; + if (isDND()) + return 3; + + return 0; } bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options) @@ -18390,9 +18386,9 @@ void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiv // announce afk or dnd message 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()) - 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() diff --git a/src/game/Player.h b/src/game/Player.h index fa8901b65..d0724510f 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1060,13 +1060,12 @@ class MANGOS_DLL_SPEC Player : public Unit Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask); GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameobject_type = MAX_GAMEOBJECT_TYPE) const; - bool ToggleAFK(); - bool ToggleDND(); + void ToggleAFK(); + 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; - std::string afkMsg; - std::string dndMsg; + std::string autoReplyMsg; uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 628e0c3f9..c1a5bd931 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 "11813" + #define REVISION_NR "11814" #endif // __REVISION_NR_H__