Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2024-08-12 01:07:20 +08:00
44 changed files with 433 additions and 305 deletions

View File

@@ -392,9 +392,6 @@ int main(int argc, char** argv)
if (MySQL::GetLibraryVersion() < 80000)
LOG_WARN("server", "WARNING: You are using MySQL version 5.7 which is soon EOL!\nThis version will be deprecated. Consider upgrading to MySQL 8.0 or 8.1!");
#endif
#if OPENSSL_VERSION_NUMBER < 0x30000000L
LOG_WARN("server", "WARNING: You are using OpenSSL version 1.1 which is soon EOL!\nThis version will be deprecated. Consider upgrading to OpenSSL 3.0 or 3.1!");
#endif
// Launch CliRunnable thread
std::shared_ptr<std::thread> cliThread;

View File

@@ -1306,7 +1306,7 @@ void Battleground::ReadyMarkerClicked(Player* p)
readyMarkerClickedSet.insert(p->GetGUID());
uint32 count = readyMarkerClickedSet.size();
uint32 req = ArenaTeam::GetReqPlayersForType(GetArenaType());
p->GetSession()->SendNotification("You are marked as ready %u/%u", count, req);
ChatHandler(p->GetSession()).SendNotification("You are marked as ready {}/{}", count, req);
if (count == req)
{
m_Events |= BG_STARTING_EVENT_2;

View File

@@ -99,19 +99,41 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
return false;
}
void ChatHandler::SendWorldText(std::string_view str)
void ChatHandler::SendNotification(std::string_view str)
{
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
for (std::string_view line : lines)
{
WorldPacket data(SMSG_NOTIFICATION, line.size() + 1);
data << line.data();
m_session->SendPacket(&data);
}
}
Player* player = m_session->GetPlayer();
if (!player || !player->IsInWorld())
void ChatHandler::SendGMText(std::string_view str)
{
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
// Session should have permissions to receive global gm messages
if (AccountMgr::IsPlayerAccount(m_session->GetSecurity()))
return;
for (std::string_view line : lines)
{
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
player->SendDirectMessage(&data);
m_session->SendPacket(&data);
}
}
void ChatHandler::SendWorldText(std::string_view str)
{
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
for (std::string_view line : lines)
{
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
m_session->SendPacket(&data);
}
}
@@ -120,9 +142,6 @@ void ChatHandler::SendWorldTextOptional(std::string_view str, uint32 flag)
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
Player* player = m_session->GetPlayer();
if (!player || !player->IsInWorld())
return;
if (sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED))
if (player->GetPlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS).HasFlag(flag))
return;
@@ -483,6 +502,23 @@ Player* ChatHandler::getSelectedPlayerOrSelf() const
return targetPlayer;
}
bool ChatHandler::HasSession() const
{
if (!m_session)
return false;
return true;
}
void ChatHandler::DoForAllValidSessions(std::function<void(Player*)> exec)
{
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
if (Player* player = itr->second->GetPlayer())
if (player->IsInWorld())
exec(player);
}
char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
{
// skip empty
@@ -1003,6 +1039,11 @@ int CliHandler::GetSessionDbLocaleIndex() const
return sObjectMgr->GetDBCLocaleIndex();
}
bool CliHandler::HasSession() const
{
return true;
}
bool AddonChannelCommandHandler::ParseCommands(std::string_view str)
{
if (memcmp(str.data(), "AzerothCore\t", 12))

View File

@@ -69,36 +69,62 @@ public:
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
void SendNotification(std::string_view str);
template<typename... Args>
void SendNotification(uint32 strId, Args&&... args)
{
if (HasSession())
SendNotification(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
}
template<typename... Args>
void SendNotification(char const* fmt, Args&&... args)
{
if (HasSession())
SendNotification(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
void SendGMText(std::string_view str);
template<typename... Args>
void SendGMText(uint32 strId, Args&&... args)
{
// GMText should be sent to all sessions
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendGMText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
});
}
template<typename... Args>
void SendGMText(char const* fmt, Args&&... args)
{
// GMText should be sent to all sessions
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendGMText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
});
}
void SendWorldText(std::string_view str);
template<typename... Args>
void SendWorldText(uint32 strId, Args&&... args)
{
// WorldText should be sent to all sessions
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
{
Player* player = itr->second->GetPlayer();
if (player && player->IsInWorld())
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
}
}
});
}
template<typename... Args>
void SendWorldText(char const* fmt, Args&&... args)
{
// WorldTextOptional should be sent to all sessions
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
{
Player* player = itr->second->GetPlayer();
if (player && player->IsInWorld())
// WorldText should be sent to all sessions
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
}
});
}
void SendWorldTextOptional(std::string_view str, uint32 flag);
@@ -106,31 +132,21 @@ public:
void SendWorldTextOptional(uint32 strId, uint32 flag, Args&&... args)
{
// WorldTextOptional should be sent to all sessions
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
{
Player* player = itr->second->GetPlayer();
if (player && player->IsInWorld())
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldTextOptional(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...), flag);
}
}
});
}
template<typename... Args>
void SendWorldTextOptional(char const* fmt, uint32 flag, Args&&... args)
{
// WorldTextOptional should be sent to all sessions
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
{
Player* player = itr->second->GetPlayer();
if (player && player->IsInWorld())
DoForAllValidSessions([&](Player* player)
{
m_session = player->GetSession();
SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), flag);
}
}
});
}
// function with different implementation for chat/console
@@ -143,13 +159,15 @@ public:
template<typename... Args>
void PSendSysMessage(char const* fmt, Args&&... args)
{
SendSysMessage(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
if (HasSession())
SendSysMessage(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
void PSendSysMessage(uint32 entry, Args&&... args)
{
SendSysMessage(PGetParseString(entry, std::forward<Args>(args)...));
if (HasSession())
SendSysMessage(PGetParseString(entry, std::forward<Args>(args)...));
}
template<typename... Args>
@@ -198,6 +216,12 @@ public:
// Returns either the selected player or self if there is no selected player
Player* getSelectedPlayerOrSelf() const;
// Has different implementation for console
virtual bool HasSession() const;
// Do whatever you want to all the players with a valid session [including GameMasters], i.e.: param exec = [&](Player* p) { p->Whatever(); }
// A "valid" session requires player->IsInWorld() to be true
void DoForAllValidSessions(std::function<void(Player*)> exec);
char* extractKeyFromLink(char* text, char const* linkType, char** something1 = nullptr);
char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = nullptr);
char* extractQuotedArg(char* args);
@@ -247,6 +271,9 @@ public:
LocaleConstant GetSessionDbcLocale() const override;
int GetSessionDbLocaleIndex() const override;
// CLI does not have a session, so we override it to always be true to output SendNotification and PSendSysMessage to console
bool HasSession() const override;
private:
void* m_callbackArg;
Print* m_print;

View File

@@ -16,6 +16,7 @@
*/
#include "BattlegroundMgr.h"
#include "Chat.h"
#include "GossipDef.h"
#include "Language.h"
#include "ObjectMgr.h"
@@ -262,9 +263,9 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
ToggleInstantFlight();
if (m_isInstantFlightOn)
GetSession()->SendNotification(LANG_INSTANT_FLIGHT_ON);
ChatHandler(GetSession()).SendNotification(LANG_INSTANT_FLIGHT_ON);
else
GetSession()->SendNotification(LANG_INSTANT_FLIGHT_OFF);
ChatHandler(GetSession()).SendNotification(LANG_INSTANT_FLIGHT_OFF);
PlayerTalkClass->SendCloseGossip();
return;

View File

@@ -55,7 +55,7 @@ void WorldSession::SendAuctionHello(ObjectGuid guid, Creature* unit)
{
if (GetPlayer()->GetLevel() < sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ))
{
SendNotification(LANG_AUCTION_REQ, sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_AUCTION_REQ, sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ));
return;
}

View File

@@ -55,7 +55,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recvData)
if (!_player->GetBGAccessByLevel(bgTypeId))
{
// temp, must be gossip message...
SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR);
ChatHandler(this).SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR);
return;
}
@@ -414,7 +414,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
if (_player->GetCharmGUID() || _player->IsInCombat())
{
_player->GetSession()->SendNotification(LANG_YOU_IN_COMBAT);
ChatHandler(_player->GetSession()).SendNotification(LANG_YOU_IN_COMBAT);
return;
}

View File

@@ -966,14 +966,14 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder)
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
{
pCurrChar->resetSpells();
SendNotification(LANG_RESET_SPELLS);
ChatHandler(this).SendNotification(LANG_RESET_SPELLS);
}
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
{
pCurrChar->resetTalents(true);
pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
SendNotification(LANG_RESET_TALENTS);
ChatHandler(this).SendNotification(LANG_RESET_TALENTS);
}
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_CHECK_ACHIEVS))
@@ -1039,7 +1039,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder)
pCurrChar->SetTaxiCheater(true);
if (pCurrChar->IsGameMaster())
SendNotification(LANG_GM_ON);
ChatHandler(this).SendNotification(LANG_GM_ON);
std::string IP_str = GetRemoteAddress();
LOG_INFO("entities.player", "Account: {} (IP: {}) Login Character:[{}] ({}) Level: {}",
@@ -1234,7 +1234,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar)
sWorld->ShutdownMsg(true, pCurrChar);
if (pCurrChar->IsGameMaster())
SendNotification(LANG_GM_ON);
ChatHandler(pCurrChar->GetSession()).SendNotification(LANG_GM_ON);
m_playerLoading = false;
}

View File

@@ -74,7 +74,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (lang == LANG_UNIVERSAL && type != CHAT_MSG_AFK && type != CHAT_MSG_DND)
{
LOG_ERROR("entities.player.cheat", "CMSG_MESSAGECHAT: Possible hacking-attempt: {} tried to send a message in universal language", GetPlayerInfo());
SendNotification(LANG_UNKNOWN_LANGUAGE);
ChatHandler(this).SendNotification(LANG_UNKNOWN_LANGUAGE);
recvData.rfinish();
return;
}
@@ -85,7 +85,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
LanguageDesc const* langDesc = GetLanguageDescByID(lang);
if (!langDesc)
{
SendNotification(LANG_UNKNOWN_LANGUAGE);
ChatHandler(this).SendNotification(LANG_UNKNOWN_LANGUAGE);
recvData.rfinish();
return;
}
@@ -105,7 +105,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (!foundAura)
{
SendNotification(LANG_NOT_LEARNED_LANGUAGE);
ChatHandler(this).SendNotification(LANG_NOT_LEARNED_LANGUAGE);
recvData.rfinish();
return;
}
@@ -137,7 +137,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (sender->GetTotalPlayedTime() < minutes * MINUTE)
{
SendNotification(LANG_MUTED_PLAYER, minutes);
ChatHandler(this).SendNotification(LANG_MUTED_PLAYER, minutes);
recvData.rfinish();
return;
}
@@ -164,7 +164,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (sender->HasAura(1852) && type != CHAT_MSG_WHISPER)
{
SendNotification(LANG_GM_SILENCE, sender->GetName());
ChatHandler(this).SendNotification(LANG_GM_SILENCE, sender->GetName());
recvData.rfinish();
return;
}
@@ -296,7 +296,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (!_player->CanSpeak())
{
std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime().count());
SendNotification(LANG_WAIT_BEFORE_SPEAKING, timeStr);
ChatHandler(this).SendNotification(LANG_WAIT_BEFORE_SPEAKING, timeStr);
return;
}
}
@@ -361,7 +361,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (sender->GetLevel() < sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ))
{
SendNotification(LANG_SAY_REQ, sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_SAY_REQ, sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ));
return;
}
@@ -387,7 +387,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (sender->GetLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ) && receiver != sender)
{
SendNotification(LANG_WHISPER_REQ, sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_WHISPER_REQ, sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ));
return;
}
@@ -407,7 +407,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
// pussywizard: optimization
if (GetPlayer()->HasAura(1852) && !receiver->IsGameMaster())
{
SendNotification(LANG_GM_SILENCE, GetPlayer()->GetName());
ChatHandler(this).SendNotification(LANG_GM_SILENCE, GetPlayer()->GetName());
return;
}
@@ -601,7 +601,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
{
if (sender->GetLevel() < sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
{
SendNotification(LANG_CHANNEL_REQ, sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_CHANNEL_REQ, sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ));
return;
}
}
@@ -746,7 +746,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData)
if (!GetPlayer()->CanSpeak())
{
std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime().count());
SendNotification(LANG_WAIT_BEFORE_SPEAKING, timeStr);
ChatHandler(this).SendNotification(LANG_WAIT_BEFORE_SPEAKING, timeStr);
return;
}

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Chat.h"
#include "DatabaseEnv.h"
#include "Group.h"
#include "GroupMgr.h"
@@ -725,7 +726,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData)
// Check if player is in BG
if (_player->InBattleground())
{
_player->GetSession()->SendNotification(LANG_BG_READY_CHECK_ERROR);
ChatHandler(_player->GetSession()).SendNotification(LANG_BG_READY_CHECK_ERROR);
return;
}
}

View File

@@ -16,6 +16,7 @@
*/
#include "AccountMgr.h"
#include "Chat.h"
#include "CharacterCache.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
@@ -117,7 +118,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
if (player->GetLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
{
SendNotification(LANG_MAIL_SENDER_REQ, sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_MAIL_SENDER_REQ, sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ));
return;
}

View File

@@ -1118,7 +1118,7 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data)
if (AccountMgr::IsAdminAccount(GetSecurity()))
GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation);
else
SendNotification(LANG_PERMISSION_DENIED);
ChatHandler(this).SendNotification(LANG_PERMISSION_DENIED);
}
void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
@@ -1129,13 +1129,13 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
if (!AccountMgr::IsAdminAccount(GetSecurity()))
{
SendNotification(LANG_PERMISSION_DENIED);
ChatHandler(this).SendNotification(LANG_PERMISSION_DENIED);
return;
}
if (charname.empty() || !normalizePlayerName (charname))
{
SendNotification(LANG_NEED_CHARACTER_NAME);
ChatHandler(this).SendNotification(LANG_NEED_CHARACTER_NAME);
return;
}
@@ -1143,7 +1143,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
if (!player)
{
SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str());
ChatHandler(this).SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str());
return;
}
@@ -1157,7 +1157,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
if (!result)
{
SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str());
ChatHandler(this).SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str());
return;
}

View File

@@ -17,6 +17,7 @@
#include "Battleground.h"
#include "BattlegroundAV.h"
#include "Chat.h"
#include "GameObjectAI.h"
#include "Group.h"
#include "Language.h"
@@ -586,7 +587,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
// Check if player is in BG
if (_player->InBattleground())
{
_player->GetSession()->SendNotification(LANG_BG_SHARE_QUEST_ERROR);
ChatHandler(_player->GetSession()).SendNotification(LANG_BG_SHARE_QUEST_ERROR);
continue;
}
}

View File

@@ -35,7 +35,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData)
if (GetPlayer()->GetLevel() < sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ))
{
SendNotification(LANG_TICKET_REQ, sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_TICKET_REQ, sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ));
return;
}
@@ -118,7 +118,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData)
sTicketMgr->AddTicket(ticket);
sTicketMgr->UpdateLastChange();
sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName().c_str(), ticket->GetId());
ChatHandler(nullptr).SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId());
response = GMTICKET_RESPONSE_CREATE_SUCCESS;
}
@@ -145,7 +145,7 @@ void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket& recv_data)
ticket->SetMessage(message);
ticket->SaveToDB(trans);
sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName().c_str(), ticket->GetId());
ChatHandler(nullptr).SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->GetId());
response = GMTICKET_RESPONSE_UPDATE_SUCCESS;
}
@@ -163,7 +163,7 @@ void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket& /*recv_data*/)
data << uint32(GMTICKET_RESPONSE_TICKET_DELETED);
SendPacket(&data);
sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName().c_str(), ticket->GetId());
ChatHandler(nullptr).SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->GetId());
sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID());
sTicketMgr->SendTicket(this, nullptr);

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Chat.h"
#include "Item.h"
#include "Language.h"
#include "Log.h"
@@ -264,7 +265,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
// not accept case incorrect money amount
if (!_player->HasEnoughMoney(my_trade->GetMoney()))
{
SendNotification(LANG_NOT_ENOUGH_GOLD);
ChatHandler(this).SendNotification(LANG_NOT_ENOUGH_GOLD);
my_trade->SetAccepted(false, true);
return;
}
@@ -272,7 +273,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
// not accept case incorrect money amount
if (!trader->HasEnoughMoney(his_trade->GetMoney()))
{
trader->GetSession()->SendNotification(LANG_NOT_ENOUGH_GOLD);
ChatHandler(trader->GetSession()).SendNotification(LANG_NOT_ENOUGH_GOLD);
his_trade->SetAccepted(false, true);
return;
}
@@ -422,8 +423,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
{
clearAcceptTradeMode(my_trade, his_trade);
SendNotification(LANG_NOT_FREE_TRADE_SLOTS);
trader->GetSession()->SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS);
ChatHandler(this).SendNotification(LANG_NOT_FREE_TRADE_SLOTS);
ChatHandler(trader->GetSession()).SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS);
my_trade->SetAccepted(false);
his_trade->SetAccepted(false);
delete my_spell;
@@ -434,8 +435,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
{
clearAcceptTradeMode(my_trade, his_trade);
SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS);
trader->GetSession()->SendNotification(LANG_NOT_FREE_TRADE_SLOTS);
ChatHandler(this).SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS);
ChatHandler(trader->GetSession()).SendNotification(LANG_NOT_FREE_TRADE_SLOTS);
my_trade->SetAccepted(false);
his_trade->SetAccepted(false);
delete my_spell;
@@ -574,7 +575,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
if (GetPlayer()->GetLevel() < sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ))
{
SendNotification(LANG_TRADE_REQ, sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_TRADE_REQ, sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ));
return;
}
@@ -639,7 +640,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
if (pOther->GetLevel() < sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ))
{
SendNotification(LANG_TRADE_OTHER_REQ, sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ));
ChatHandler(this).SendNotification(LANG_TRADE_OTHER_REQ, sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ));
return;
}

View File

@@ -16,6 +16,7 @@
*/
#include "InstanceScript.h"
#include "Chat.h"
#include "Creature.h"
#include "DatabaseEnv.h"
#include "GameObject.h"
@@ -602,7 +603,7 @@ void InstanceScript::DoSendNotifyToInstance(char const* format, ...)
instance->DoForAllPlayers([&, buff](Player* player)
{
player->GetSession()->SendNotification("%s", buff);
ChatHandler(player->GetSession()).SendNotification("{}", buff);
});
}
}

View File

@@ -815,16 +815,6 @@ bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string_view str)
return false;
}
void WorldSession::SendNotification(std::string_view str)
{
WorldPacket data(SMSG_NOTIFICATION, str.size() + 1);
for (std::string_view line : Acore::Tokenize(str, '\n', true))
{
data << line.data();
SendPacket(&data);
}
}
char const* WorldSession::GetAcoreString(uint32 entry) const
{
return sObjectMgr->GetAcoreString(entry, GetSessionDbLocaleIndex());

View File

@@ -365,18 +365,6 @@ public:
void ReadMovementInfo(WorldPacket& data, MovementInfo* mi);
void WriteMovementInfo(WorldPacket* data, MovementInfo* mi);
void SendNotification(std::string_view str);
template<typename... Args>
void SendNotification(uint32 strId, Args&&... args)
{
SendNotification(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
}
template<typename... Args>
void SendNotification(char const* fmt, Args&&... args)
{
SendNotification(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
void SendPacket(WorldPacket const* packet);
void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName* declinedName);
void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0);

View File

@@ -22,6 +22,7 @@
#include "BattlegroundSA.h"
#include "BattlegroundWS.h"
#include "CellImpl.h"
#include "Chat.h"
#include "Common.h"
#include "Creature.h"
#include "DynamicObject.h"
@@ -6168,7 +6169,7 @@ void Spell::EffectPlaySound(SpellEffIndex effIndex)
{
case 58730: // Restricted Flight Area
case 58600: // Restricted Flight Area
player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE);
ChatHandler(player->GetSession()).SendNotification(LANG_ZONE_NOFLYZONE);
break;
default:
break;

View File

@@ -4792,12 +4792,6 @@ void SpellMgr::LoadSpellInfoCorrections()
spellInfo->Effects[EFFECT_0].RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_20_YARDS);
});
// Random Periodic
ApplySpellFix({ 40867 }, [](SpellInfo* spellInfo)
{
spellInfo->Effects[EFFECT_0].Amplitude = 9000;
});
// Flame Wave
ApplySpellFix({ 33800 }, [](SpellInfo* spellInfo)
{

View File

@@ -566,7 +566,6 @@ public:
[[nodiscard]] virtual uint16 GetConfigMaxSkillValue() const = 0;
virtual void SetInitialWorldSettings() = 0;
virtual void LoadConfigSettings(bool reload = false) = 0;
virtual void SendGMText(uint32 string_id, ...) = 0;
virtual void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
virtual void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
virtual bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;

View File

@@ -2582,32 +2582,6 @@ namespace Acore
};
} // namespace Acore
/// Send a System Message to all GMs (except self if mentioned)
void World::SendGMText(uint32 string_id, ...)
{
va_list ap;
va_start(ap, string_id);
Acore::WorldWorldTextBuilder wt_builder(string_id, &ap);
Acore::LocalizedPacketListDo<Acore::WorldWorldTextBuilder> wt_do(wt_builder);
for (SessionMap::iterator itr = _sessions.begin(); itr != _sessions.end(); ++itr)
{
// Session should have permissions to receive global gm messages
WorldSession* session = itr->second;
if (!session || AccountMgr::IsPlayerAccount(session->GetSecurity()))
continue;
// Player should be in world
Player* player = session->GetPlayer();
if (!player || !player->IsInWorld())
continue;
wt_do(session->GetPlayer());
}
va_end(ap);
}
/// Send a packet to all players (or players selected team) in the zone (except self if mentioned)
bool World::SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession* self, TeamId teamId)
{

View File

@@ -238,7 +238,6 @@ public:
void SetInitialWorldSettings() override;
void LoadConfigSettings(bool reload = false) override;
void SendGMText(uint32 string_id, ...) override;
void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;

View File

@@ -68,22 +68,22 @@ public:
if (!enableArg)
{
if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->isGMChat())
session->SendNotification(LANG_GM_CHAT_ON);
handler->SendNotification(LANG_GM_CHAT_ON);
else
session->SendNotification(LANG_GM_CHAT_OFF);
handler->SendNotification(LANG_GM_CHAT_OFF);
return true;
}
if (*enableArg)
{
session->GetPlayer()->SetGMChat(true);
session->SendNotification(LANG_GM_CHAT_ON);
handler->SendNotification(LANG_GM_CHAT_ON);
return true;
}
else
{
session->GetPlayer()->SetGMChat(false);
session->SendNotification(LANG_GM_CHAT_OFF);
handler->SendNotification(LANG_GM_CHAT_OFF);
return true;
}
}
@@ -206,14 +206,14 @@ public:
_player->SetGMVisible(true);
_player->UpdateObjectVisibility();
handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE);
handler->SendNotification(LANG_INVISIBLE_VISIBLE);
}
else
{
_player->AddAura(VISUAL_AURA, _player);
_player->SetGMVisible(false);
_player->UpdateObjectVisibility();
handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE);
handler->SendNotification(LANG_INVISIBLE_INVISIBLE);
}
return true;
@@ -223,7 +223,7 @@ public:
{
handler->GetPlayer()->SetGameMaster(true);
handler->GetPlayer()->UpdateTriggerVisibility();
handler->GetSession()->SendNotification(LANG_GM_ON);
handler->SendNotification(LANG_GM_ON);
return true;
}
@@ -231,7 +231,7 @@ public:
{
handler->GetPlayer()->SetGameMaster(false);
handler->GetPlayer()->UpdateTriggerVisibility();
handler->GetSession()->SendNotification(LANG_GM_OFF);
handler->SendNotification(LANG_GM_OFF);
return true;
}
};

View File

@@ -77,7 +77,7 @@ public:
if (WorldSession* session = handler->GetSession())
name = session->GetPlayer()->GetName();
sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, name.c_str(), message.data());
handler->SendGMText(LANG_GM_ANNOUNCE_COLOR, name, message.data());
return true;
}
@@ -92,12 +92,12 @@ public:
}
// announce to logged in GMs
static bool HandleGMAnnounceCommand(ChatHandler* /*handler*/, Tail message)
static bool HandleGMAnnounceCommand(ChatHandler* handler, Tail message)
{
if (message.empty())
return false;
sWorld->SendGMText(LANG_GM_BROADCAST, message.data());
handler->SendGMText(LANG_GM_BROADCAST, message.data());
return true;
}

View File

@@ -464,7 +464,7 @@ public:
auto SetCommentatorMod = [&](bool enable)
{
session->SendNotification(enable ? "Commentator mode on" : "Commentator mode off");
handler->SendNotification(enable ? "Commentator mode on" : "Commentator mode off");
session->GetPlayer()->SetCommentator(enable);
};
@@ -508,7 +508,7 @@ public:
auto SetDevMod = [&](bool enable)
{
session->SendNotification(enable ? LANG_DEV_ON : LANG_DEV_OFF);
handler->SendNotification(enable ? LANG_DEV_ON : LANG_DEV_OFF);
session->GetPlayer()->SetDeveloper(enable);
sScriptMgr->OnHandleDevCommand(handler->GetSession()->GetPlayer(), enable);
};

View File

@@ -77,7 +77,8 @@ public:
static ChatCommandTable morphCommandTable =
{
{ "reset", HandleMorphResetCommand, SEC_MODERATOR, Console::No },
{ "target", HandleMorphTargetCommand, SEC_MODERATOR, Console::No }
{ "target", HandleMorphTargetCommand, SEC_MODERATOR, Console::No },
{ "mount", HandleMorphMountCommand, SEC_MODERATOR, Console::No }
};
static ChatCommandTable commandTable =
@@ -868,6 +869,21 @@ public:
return true;
}
static bool HandleMorphMountCommand(ChatHandler* handler, uint32 displayID)
{
Player* target = handler->getSelectedPlayerOrSelf();
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) // check online security
return false;
if (!target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).empty())
target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
else
return false;
return true;
}
//set temporary phase mask for player
static bool HandleModifyPhaseCommand(ChatHandler* handler, uint32 phaseMask)
{

View File

@@ -16,6 +16,7 @@
*/
#include "CreatureScript.h"
#include "GridNotifiers.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
@@ -145,7 +146,12 @@ class spell_anetheron_sleep : public SpellScript
void FilterTargets(std::list<WorldObject*>& targets)
{
if (!targets.empty())
{
if (Unit* victim = GetCaster()->GetVictim())
targets.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true));
Acore::Containers::RandomResize(targets, 3);
}
}
void Register() override

View File

@@ -143,10 +143,10 @@ class spell_mother_shahraz_random_periodic_aura : public AuraScript
return ValidateSpellInfo({ SPELL_SINFUL_PERIODIC, SPELL_SINISTER_PERIODIC, SPELL_VILE_PERIODIC, SPELL_WICKED_PERIODIC });
}
void Update(AuraEffect const* /*effect*/)
void Update(AuraEffect const* effect)
{
PreventDefaultAction();
if (GetUnitOwner())
if (GetUnitOwner() && (effect->GetTickNumber() % 6 == 1 || effect->GetTickNumber() == 1)) // Reapplies 12-18s after the third beam
GetUnitOwner()->CastSpell(GetUnitOwner(), RAND(SPELL_SINFUL_PERIODIC, SPELL_SINISTER_PERIODIC, SPELL_VILE_PERIODIC, SPELL_WICKED_PERIODIC), true);
}

View File

@@ -2221,6 +2221,11 @@ struct dragonmaw_race_npc : public ScriptedAI
}
}
void PathEndReached(uint32 /*pathId*/) override
{
Reset();
}
void UpdateAI(uint32 diff) override
{
scheduler.Update(diff);

View File

@@ -16,6 +16,7 @@
*/
#include "CellImpl.h"
#include "Chat.h"
#include "CreatureScript.h"
#include "GameEventMgr.h"
#include "GameObjectAI.h"
@@ -1081,7 +1082,7 @@ public:
if (player->GetQuestRewardStatus(QUEST_TELE_CRYSTAL_FLAG))
return false;
player->GetSession()->SendNotification(GO_TELE_TO_DALARAN_CRYSTAL_FAILED);
ChatHandler(player->GetSession()).SendNotification(GO_TELE_TO_DALARAN_CRYSTAL_FAILED);
return true;
}
@@ -1599,7 +1600,7 @@ public:
else
{
CloseGossipMenuFor(player);
player->GetSession()->SendNotification(GO_ANDERHOLS_SLIDER_CIDER_NOT_FOUND);
ChatHandler(player->GetSession()).SendNotification(GO_ANDERHOLS_SLIDER_CIDER_NOT_FOUND);
return false;
}
}