mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
refactor(Core/WorldSession): Make SendNotification use fmt and parse acore_string (#19489)
* refactor(Core/WorldSession): Make SendNotification use `fmt` * Make SendNotification use `fmt` * Make SendNotification parse acore_string entries
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "QueryHolder.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "Tokenize.h"
|
||||
#include "Transport.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WardenMac.h"
|
||||
@@ -785,37 +786,12 @@ bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string_view str)
|
||||
return false;
|
||||
}
|
||||
|
||||
void WorldSession::SendNotification(const char* format, ...)
|
||||
void WorldSession::SendNotification(std::string_view str)
|
||||
{
|
||||
if (format)
|
||||
WorldPacket data(SMSG_NOTIFICATION, str.size() + 1);
|
||||
for (std::string_view line : Acore::Tokenize(str, '\n', true))
|
||||
{
|
||||
va_list ap;
|
||||
char szStr[1024];
|
||||
szStr[0] = '\0';
|
||||
va_start(ap, format);
|
||||
vsnprintf(szStr, 1024, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr) + 1));
|
||||
data << szStr;
|
||||
SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::SendNotification(uint32 string_id, ...)
|
||||
{
|
||||
char const* format = GetAcoreString(string_id);
|
||||
if (format)
|
||||
{
|
||||
va_list ap;
|
||||
char szStr[1024];
|
||||
szStr[0] = '\0';
|
||||
va_start(ap, string_id);
|
||||
vsnprintf(szStr, 1024, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr) + 1));
|
||||
data << szStr;
|
||||
data << line.data();
|
||||
SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,9 +345,19 @@ 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 SendNotification(const char* format, ...) ATTR_PRINTF(2, 3);
|
||||
void SendNotification(uint32 string_id, ...);
|
||||
void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName* declinedName);
|
||||
void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0);
|
||||
void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3);
|
||||
|
||||
Reference in New Issue
Block a user